kasan: Increase the size of the bootstrap PTP reservation

We were undercounting in the case where the boot stack crosses a 2MB
boundary, resulting in a panic during locore execution.

MFC after:	1 week
Fixes:	756bc3adc5 ("kasan: Create a shadow for the bootstack prior to hammer_time()")
This commit is contained in:
Mark Johnston 2024-06-16 13:33:13 -04:00
parent 4441dd4094
commit 46bb2dca53
1 changed files with 5 additions and 4 deletions

View File

@ -11671,15 +11671,16 @@ pmap_pkru_clear(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
* Reserve enough memory to:
* 1) allocate PDP pages for the shadow map(s),
* 2) shadow the boot stack of KSTACK_PAGES pages,
* so we need one PD page, one or two PT pages, and KSTACK_PAGES shadow pages
* per shadow map.
* 3) assuming that the kernel stack does not cross a 1GB boundary,
* so we need one or two PD pages, one or two PT pages, and KSTACK_PAGES shadow
* pages per shadow map.
*/
#ifdef KASAN
#define SAN_EARLY_PAGES \
(NKASANPML4E + 1 + 2 + howmany(KSTACK_PAGES, KASAN_SHADOW_SCALE))
(NKASANPML4E + 2 + 2 + howmany(KSTACK_PAGES, KASAN_SHADOW_SCALE))
#else
#define SAN_EARLY_PAGES \
(NKMSANSHADPML4E + NKMSANORIGPML4E + 2 * (1 + 2 + KSTACK_PAGES))
(NKMSANSHADPML4E + NKMSANORIGPML4E + 2 * (2 + 2 + KSTACK_PAGES))
#endif
static uint64_t __nosanitizeaddress __nosanitizememory