summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2011-08-28 18:32:30 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2011-08-28 18:32:30 +0200
commit3d4e83e3e22b16aeeab0c75c290a3846d1ea99f7 (patch)
treec4a83d2ff36118a58062f9efd7a5cfbd9df21f4f
parentce6698ce59c7524986324469c679d564a52099ba (diff)
Rework memory mapping reservation
* i386/i386/vm_param.h (VM_KERNEL_MAP_SIZE): Define to 192MiB. * i386/i386at/model_dep.c (mem_size_init): Use VM_KERNEL_MAP_SIZE instead of 1/6 factor. * i386/intel/pmap.c (morevm): Remove. (pmap_bootstrap): Use VM_KERNEL_MAP_SIZE instead of morevm.
-rw-r--r--i386/i386/vm_param.h5
-rw-r--r--i386/i386at/model_dep.c11
-rw-r--r--i386/intel/pmap.c6
3 files changed, 12 insertions, 10 deletions
diff --git a/i386/i386/vm_param.h b/i386/i386/vm_param.h
index 95df604..b515a9e 100644
--- a/i386/i386/vm_param.h
+++ b/i386/i386/vm_param.h
@@ -27,7 +27,7 @@
#include <mach/vm_param.h>
#include <xen/public/xen.h>
-/* The kernel address space is 1GB, starting at virtual address 0. */
+/* The kernel address space is usually 1GB, usually starting at virtual address 0. */
#ifdef MACH_XEN
#define VM_MIN_KERNEL_ADDRESS 0x20000000UL
#else /* MACH_XEN */
@@ -45,6 +45,9 @@
#define VM_MAX_KERNEL_ADDRESS (LINEAR_MAX_KERNEL_ADDRESS - LINEAR_MIN_KERNEL_ADDRESS + VM_MIN_KERNEL_ADDRESS)
#endif /* MACH_XEN */
+/* Reserve mapping room for kmem_suballoc calls. */
+#define VM_KERNEL_MAP_SIZE (192 * 1024 * 1024)
+
/* The kernel virtual address space is actually located
at high linear addresses.
This is the kernel address range in linear addresses. */
diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c
index 4e7093c..f6e797c 100644
--- a/i386/i386at/model_dep.c
+++ b/i386/i386at/model_dep.c
@@ -261,6 +261,8 @@ void db_reset_cpu(void)
void
mem_size_init(void)
{
+ vm_offset_t max_phys_size;
+
/* Physical memory on all PCs starts at physical address 0.
XX make it a constant. */
phys_first_addr = 0;
@@ -285,12 +287,13 @@ mem_size_init(void)
printf("AT386 boot: physical memory from 0x%x to 0x%x\n",
phys_first_addr, phys_last_addr);
- /* Reserve 1/6 of the memory address space for virtual mappings.
+ /* Reserve room for virtual mappings.
* Yes, this loses memory. Blame i386. */
- 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;
+ max_phys_size = VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS - VM_KERNEL_MAP_SIZE;
+ if (phys_last_addr - phys_first_addr > max_phys_size) {
+ phys_last_addr = phys_first_addr + max_phys_size;
printf("Truncating memory size to %dMiB\n", (phys_last_addr - phys_first_addr) / (1024 * 1024));
- /* TODO Xen: free lost memory */
+ /* TODO Xen: be nice, free lost memory */
}
phys_first_addr = round_page(phys_first_addr);
diff --git a/i386/intel/pmap.c b/i386/intel/pmap.c
index 0b8ae90..c15538f 100644
--- a/i386/intel/pmap.c
+++ b/i386/intel/pmap.c
@@ -155,9 +155,6 @@ boolean_t pmap_initialized = FALSE;
vm_offset_t kernel_virtual_start;
vm_offset_t kernel_virtual_end;
-/* XXX stupid fixed limit - get rid */
-vm_size_t morevm = 128 * 1024 * 1024; /* VM space for kernel map */
-
/*
* Index into pv_head table, its lock bits, and the modify/reference
* bits starting at phys_first_addr.
@@ -620,8 +617,7 @@ void pmap_bootstrap()
* and extends to a stupid arbitrary limit beyond that.
*/
kernel_virtual_start = phystokv(phys_last_addr);
- kernel_virtual_end = phystokv(phys_last_addr) + morevm
- + (phys_last_addr - phys_first_addr);
+ kernel_virtual_end = phystokv(phys_last_addr) + VM_KERNEL_MAP_SIZE;
if (kernel_virtual_end < kernel_virtual_start
|| kernel_virtual_end > VM_MAX_KERNEL_ADDRESS)