Page MenuHomeFreeBSD

Support 2GB of memory on Malta systems with FreeBSD/mips.
ClosedPublic

Authored by jhb on Jun 26 2018, 11:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, May 5, 10:09 AM
Unknown Object (File)
Wed, May 1, 9:36 AM
Unknown Object (File)
Mar 30 2024, 4:43 PM
Unknown Object (File)
Mar 1 2024, 9:56 PM
Unknown Object (File)
Dec 22 2023, 11:05 PM
Unknown Object (File)
Nov 21 2023, 9:41 PM
Unknown Object (File)
Nov 21 2023, 6:46 PM
Unknown Object (File)
Nov 15 2023, 11:00 AM
Subscribers

Details

Summary

When 2GB of memory is enabled for QEMU's Malta emulation, the physical
memory ends at an address of 2^32 - 1. This causes an integer overflow
to zero when computing the upper bound of the second phys_avail[] range.
As a result, FreeBSD/mips kernels were only using the first 256MB of
RAM and ignoring the remaining 1.75GB. To work around this, truncate
the extended memory size to 2GB minus one page for 32-bit mips kernels.

Review request is more if there is a cleaner way to detect/handle the
overflow. The rather complicated mapping of physical address to RAM
in Malta is perhaps best explained here:

https://lists.gnu.org/archive/html/qemu-devel/2013-08/msg04382.html

Test Plan
  • boot FreeBSD/mips under qemu-system-mips with -m 2048.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Where the overflow occurs ? In this line ?

		phys_avail[3] = 0x90000000 + (ememsize - memsize);

phys_avail[x + 1] convention is to point to the byte next after the last byte of the region. For i386 this seems to be not a problem in real life due to the conveniently located PCI hole.

I do not see anything wrong with explicitly capping the amount of supported memory. Perhaps it can be done more elegantly by adding to 2G+256M and checking for overflow, but the end result is same, so I am not sure it its important.

In D16027#339568, @kib wrote:

Where the overflow occurs ? In this line ?

		phys_avail[3] = 0x90000000 + (ememsize - memsize);

Yes.

phys_avail[x + 1] convention is to point to the byte next after the last byte of the region. For i386 this seems to be not a problem in real life due to the conveniently located PCI hole.

Right.

I do not see anything wrong with explicitly capping the amount of supported memory. Perhaps it can be done more elegantly by adding to 2G+256M and checking for overflow, but the end result is same, so I am not sure it its important.

Yeah, I looked at detecting the overflow closer to the line in question, but it seemed a bit messier code-wise (though I was trying to do it based on the math in question rather than just the value of ememsize. I could just move the current code perhaps). Also, in theory changing ememsize is more consistent as it affects 'realmem' and anything that uses that.

This revision was not accepted when it landed; it landed in state Needs Review.Jun 28 2018, 9:27 PM
This revision was automatically updated to reflect the committed changes.