]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Fix the undersupported option KERNLOAD, part 1: fix crashes in locore
authorbde <bde@FreeBSD.org>
Mon, 18 Dec 2017 09:32:56 +0000 (09:32 +0000)
committerbde <bde@FreeBSD.org>
Mon, 18 Dec 2017 09:32:56 +0000 (09:32 +0000)
commit622efbbef85725de691b2c8c3af8b30fdf025121
tree44e11d4c6397aa6142de9977e8626b70a5fe1166
parent1e07b95bcf5b4aa824248dd4ea00b2df6269a711
Fix the undersupported option KERNLOAD, part 1: fix crashes in locore
when KERNLOAD is not a multiple of NBPDR (not the default) and PSE is
enabled (the default if the CPU supports it).  Addresses in PDEs must
be a multiple of NBPDR in the PSE case, but were not so in the crashing
case.

KERNLOAD defaults to NBPDR.  NBPDR is 4 MB for !PAE and 2 MB for PAE.
The default can be changed by editing i386/include/vmparam.h or using
makeoptions.  It can be changed to less than NBPDR to save real and
virtual memory at a small cost in time, or to more than NBPDR to waste
real and virtual memory.  It must be larger than 1 MB and a multiple of
PAGE_SIZE.  When it is less than NBPDR, it is necessarily not a multiple
of NBPDR.  This case has much larger bugs which will be fixed in part 2.

The fix is to only use PSE for physical addresses above <KERNLOAD
rounded _up_ to an NBPDR boundary>.  When the rounding is non-null,
this leaves part of the kernel not using large pages.  Rounding down
would avoid this pessimization, but would break setting of PAT bits
on i/o pages if it goes below 1MB.  Since rounding down always goes
below 1MB when KERNLOAD < NBPDR and the KERNLOAD > NBPDR case is not
useful, never round down.

Fix related style bugs (e.g., wrong literal values for NBPDR in comments).

Reviewed by: kib
sys/i386/i386/locore.s
sys/i386/i386/pmap.c