From 859c342d11a2d018e7b220e955bbe1ba1940f02f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 6 Jul 2014 18:49:55 +0200 Subject: Do not unmap page 0 when not needed Since we need it to access some BIOS information, e.g. at ACPI shutdown. When the kernel VM is not starting at 0, there is already nothing mapped there in user tasks, anyway. * i386/i386at/model_dep.c (machine_init) [VM_MIN_KERNEL_ADDRESS != 0]: Do not call pmap_unmap_page_zero. * i386/intel/pmap.c (pmap_unmap_page_zero): Warn that unmapping page zero may break some BIOS functions. --- i386/i386at/acpi.c | 3 +++ i386/i386at/model_dep.c | 4 ++++ i386/intel/pmap.c | 1 + 3 files changed, 8 insertions(+) (limited to 'i386') diff --git a/i386/i386at/acpi.c b/i386/i386at/acpi.c index ec8aeb1..986b3a2 100644 --- a/i386/i386at/acpi.c +++ b/i386/i386at/acpi.c @@ -55,8 +55,11 @@ grub_machine_acpi_get_rsdpv2 (void) grub_uint8_t *ebda, *ptr; grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); + printf("ptr is %p\n", (* ((grub_uint16_t *) phystokv (0x40e))) << 4); + printf("len is %u\n", *( (grub_uint16_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4))); ebda = (grub_uint8_t *) phystokv ((* ((grub_uint16_t *) phystokv (0x40e))) << 4); ebda_len = * (grub_uint16_t *) ebda; + printf("EBDA len %d\n", ebda_len); if (! ebda_len) return 0; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 6093a66..209cfb1 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -180,10 +180,14 @@ void machine_init(void) *(unsigned short *)phystokv(0x472) = 0x1234; #endif /* MACH_HYP */ +#if VM_MIN_KERNEL_ADDRESS == 0 /* * Unmap page 0 to trap NULL references. + * + * Note that this breaks accessing some BIOS areas stored there. */ pmap_unmap_page_zero(); +#endif } /* Conserve power on processor CPU. */ diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c index 8a23a44..62b33cf 100644 --- a/i386/intel/pmap.c +++ b/i386/intel/pmap.c @@ -2835,6 +2835,7 @@ pmap_unmap_page_zero (void) { int *pte; + printf("Unmapping the zero page. Some BIOS functions may not be working any more.\n"); pte = (int *) pmap_pte (kernel_pmap, 0); if (!pte) return; -- cgit v1.2.3