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)
Thu, Nov 21, 6:49 AM
Unknown Object (File)
Thu, Nov 14, 6:51 PM
Unknown Object (File)
Thu, Nov 7, 10:53 AM
Unknown Object (File)
Mon, Nov 4, 7:27 AM
Unknown Object (File)
Oct 25 2024, 9:32 AM
Unknown Object (File)
Oct 25 2024, 9:31 AM
Unknown Object (File)
Oct 24 2024, 9:46 PM
Unknown Object (File)
Sep 30 2024, 6:06 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.