diff options
author | Leandro Lupori <luporl@FreeBSD.org> | 2021-12-15 11:49:47 +0000 |
---|---|---|
committer | Leandro Lupori <luporl@FreeBSD.org> | 2021-12-15 11:49:47 +0000 |
commit | a076e2060c07307e7416759075db71f23de722c0 (patch) | |
tree | 09de696ca98df4247c3028eedb5dd81fdbce49fc | |
parent | 18679ab1c06575517df9df2509564dbf038d4720 (diff) | |
download | src-a076e2060c07307e7416759075db71f23de722c0.tar.gz src-a076e2060c07307e7416759075db71f23de722c0.zip |
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
-rw-r--r-- | sys/powerpc/aim/mmu_oea64.c | 2 | ||||
-rw-r--r-- | 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])); /* |