Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 15 Dec 2021 11:57:39 GMT
From:      Leandro Lupori <luporl@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a076e2060c07 - main - powerpc64: fix the calculation of Maxmem
Message-ID:  <202112151157.1BFBvdxs035494@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by luporl:

URL: https://cgit.FreeBSD.org/src/commit/?id=a076e2060c07307e7416759075db71f23de722c0

commit a076e2060c07307e7416759075db71f23de722c0
Author:     Leandro Lupori <luporl@FreeBSD.org>
AuthorDate: 2021-12-15 11:49:47 +0000
Commit:     Leandro Lupori <luporl@FreeBSD.org>
CommitDate: 2021-12-15 11:49:47 +0000

    powerpc64: fix the calculation of Maxmem
    
    The calculation of Maxmem was skipping the last phys_avail segment,
    because of a wrong stop condition.
    
    This was detected when using QEMU/PowerNV with Radix MMU and low
    memory (2G). In this case opal_pci would allocate a DMA window that
    was too small to cover all physical memory, resulting in reading all
    zeroes from disk when using memory that was not inside the allocated
    window.
    
    Reviewed by:            jhibbits
    Sponsored by:           Instituto de Pesquisas Eldorado (eldorado.org.br)
    Differential Revision:  https://reviews.freebsd.org/D33449
    MFC after:              2 weeks
---
 sys/powerpc/aim/mmu_oea64.c | 2 +-
 sys/powerpc/aim/mmu_radix.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index 728f388ffb08..b3a4a225126f 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -1162,7 +1162,7 @@ moea64_late_bootstrap(vm_offset_t kernelstart, vm_offset_t kernelend)
 	 * Calculate the last available physical address.
 	 */
 	Maxmem = 0;
-	for (i = 0; phys_avail[i + 2] != 0; i += 2)
+	for (i = 0; phys_avail[i + 1] != 0; i += 2)
 		Maxmem = MAX(Maxmem, powerpc_btop(phys_avail[i + 1]));
 
 	/*
diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c
index 420a7a227c10..788bd7f22a0a 100644
--- a/sys/powerpc/aim/mmu_radix.c
+++ b/sys/powerpc/aim/mmu_radix.c
@@ -2066,7 +2066,7 @@ mmu_radix_late_bootstrap(vm_offset_t start, vm_offset_t end)
 	 * vm_page_array (upper bound).
 	 */
 	Maxmem = 0;
-	for (i = 0; phys_avail[i + 2] != 0; i += 2)
+	for (i = 0; phys_avail[i + 1] != 0; i += 2)
 		Maxmem = MAX(Maxmem, powerpc_btop(phys_avail[i + 1]));
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112151157.1BFBvdxs035494>