From 4e00cf6b1798fc95b3ccad8cb66a3e80c96b2786 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sat, 15 Nov 2014 11:43:05 +0100 Subject: pc64: get rid of fixed 8MB INIMAP and dynamically map KZERO-end in l.s traditionally, the pc kernel mapped the first 8MB of physical address space. when the kernel size grows beyond that memory mapping, it will crash on boot and theres no checking in the build process making sure it fits. with the pc64 kernel, it is not hard to always map the whole kernel memory image from KZERO to end[], so that the kernel will always fit into the initial mapping. --- sys/src/9/pc64/l.s | 13 ++++++++++--- sys/src/9/pc64/mem.h | 1 - sys/src/9/pc64/memory.c | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'sys') diff --git a/sys/src/9/pc64/l.s b/sys/src/9/pc64/l.s index 78171a114..94356a9fb 100644 --- a/sys/src/9/pc64/l.s +++ b/sys/src/9/pc64/l.s @@ -144,13 +144,20 @@ TEXT _warp64<>(SB), 1, $-4 MOVL $(PTESIZE|PTEGLOBAL|PTEWRITE|PTEVALID), DX MOVL DX, PDO(0)(AX) /* PDE for double-map */ + /* + * map from KZERO to end using 2MB pages + */ ADDL $PDO(KZERO), AX + MOVL $end-KZERO(SB), CX + ADDL $(PGLSZ(1)-1), CX + ANDL $~(PGLSZ(1)-1), CX + MOVL CX, MemMin-KZERO(SB) /* see memory.c */ + SHRL $(1*PTSHIFT+PGSHIFT), CX memloop: - MOVL DX, 0(AX) + MOVL DX, (AX) ADDL $PGLSZ(1), DX ADDL $8, AX - CMPL DX, $INIMAP - JLT memloop + LOOP memloop /* * Enable and activate Long Mode. From the manual: diff --git a/sys/src/9/pc64/mem.h b/sys/src/9/pc64/mem.h index acbbff43d..0a82a378d 100644 --- a/sys/src/9/pc64/mem.h +++ b/sys/src/9/pc64/mem.h @@ -79,7 +79,6 @@ #define CPU0END (CPU0MACH+MACHSIZE) #define MACHSIZE (2*KSTACK) -#define INIMAP (8*MiB) /* 4 pages; size of inital map in l.s */ /* * known x86 segments (in GDT) and their selectors diff --git a/sys/src/9/pc64/memory.c b/sys/src/9/pc64/memory.c index a4ff047d6..349133976 100644 --- a/sys/src/9/pc64/memory.c +++ b/sys/src/9/pc64/memory.c @@ -12,6 +12,8 @@ #include "io.h" #include "ureg.h" +u32int MemMin; /* set by l.s */ + #define MEMDEBUG 0 enum { @@ -22,8 +24,6 @@ enum { NMemType = 4, KB = 1024, - - MemMin = INIMAP, }; typedef struct Map Map; -- cgit v1.2.3