From 493ea92815e8180fcf396ee95a0552112e8b0472 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 22 Nov 2009 20:08:27 +0100 Subject: Do not assume that VM_MIN_KERNEL_ADDRESS is 0 * i386/i386/vm_param.h (VM_MAX_KERNEL_ADDRESS): Add VM_MIN_KERNEL_ADDRESS. (kvtolin): Subtract VM_MIN_KERNEL_ADDRESS. (lintokv): Add VM_MIN_KERNEL_ADDRESS. * i386/i386at/model_dep.c (mem_size_init): Subtract VM_MIN_KERNEL_ADDRESS in computation of phys_last_addr. (i386at_init): Use VM_MIN_KERNEL_ADDRESS instead of 0 as argument of lin2pdenum. --- i386/i386at/model_dep.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'i386/i386at') diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 3929293..7dfeb1c 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -236,8 +236,8 @@ mem_size_init(void) /* Reserve 1/6 of the memory address space for virtual mappings. * Yes, this loses memory. Blame i386. */ - if (phys_last_addr > (VM_MAX_KERNEL_ADDRESS / 6) * 5) { - phys_last_addr = (VM_MAX_KERNEL_ADDRESS / 6) * 5; + if (phys_last_addr > ((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 6) * 5) { + phys_last_addr = ((VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) / 6) * 5; printf("Truncating memory size to %dMiB\n", (phys_last_addr - phys_first_addr) / (1024 * 1024)); } @@ -321,10 +321,10 @@ i386at_init(void) * Also, set the WP bit so that on 486 or better processors * page-level write protection works in kernel mode. */ - kernel_page_dir[lin2pdenum(0)] = + kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS)] = kernel_page_dir[lin2pdenum(LINEAR_MIN_KERNEL_ADDRESS)]; #if PAE - kernel_page_dir[lin2pdenum(0) + 1] = + kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 1] = kernel_page_dir[lin2pdenum(LINEAR_MIN_KERNEL_ADDRESS) + 1]; set_cr3((unsigned)kernel_pmap->pdpbase); if (!CPU_HAS_FEATURE(CPU_FEATURE_PAE)) @@ -348,9 +348,9 @@ i386at_init(void) ktss_init(); /* Get rid of the temporary direct mapping and flush it out of the TLB. */ - kernel_page_dir[lin2pdenum(0)] = 0; + kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS)] = 0; #if PAE - kernel_page_dir[lin2pdenum(0) + 1] = 0; + kernel_page_dir[lin2pdenum(VM_MIN_KERNEL_ADDRESS) + 1] = 0; #endif /* PAE */ flush_tlb(); -- cgit v1.2.3