diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-11-17 23:30:09 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2020-11-17 23:30:09 +0100 |
commit | 972f95aa637ed70a65e0e90d2e589b58a81d8a59 (patch) | |
tree | 95950c9adcc3e910ba9f3954e9b668a6ab114e4d /sys/src/9/pc64/trap.c | |
parent | 8cb33f2f18d8383fd78368110b3a78c7732da6f9 (diff) |
pc, pc64: load idt early in trapinit0()
loading the interrupt vector table early allows
us to handle traps during bootup before mmuinit()
which gives better diagnostics for debugging.
we also can handle general protection fault on
rdmsr() and wrmsr() which helps during
cpuidentify() and archinit() when probing for
cpu features.
Diffstat (limited to 'sys/src/9/pc64/trap.c')
-rw-r--r-- | sys/src/9/pc64/trap.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/sys/src/9/pc64/trap.c b/sys/src/9/pc64/trap.c index b1078c560..b7e71a919 100644 --- a/sys/src/9/pc64/trap.c +++ b/sys/src/9/pc64/trap.c @@ -9,8 +9,6 @@ #include "../port/error.h" #include <trace.h> -static int trapinited; - void noted(Ureg*, ulong); static void debugexc(Ureg*, void*); @@ -194,13 +192,13 @@ trapinit0(void) u32int d1, v; uintptr vaddr; Segdesc *idt; + uintptr ptr[2]; idt = (Segdesc*)IDTADDR; vaddr = (uintptr)vectortable; for(v = 0; v < 256; v++){ d1 = (vaddr & 0xFFFF0000)|SEGP; switch(v){ - case VectorBPT: d1 |= SEGPL(3)|SEGIG; break; @@ -224,6 +222,9 @@ trapinit0(void) vaddr += 6; } + ((ushort*)&ptr[1])[-1] = sizeof(Segdesc)*512-1; + ptr[1] = IDTADDR; + lidt(&((ushort*)&ptr[1])[-1]); } void @@ -240,7 +241,6 @@ trapinit(void) trapenable(Vector15, unexpected, 0, "unexpected"); nmienable(); addarchfile("irqalloc", 0444, irqallocread, nil); - trapinited = 1; } static char* excname[32] = { @@ -324,13 +324,6 @@ trap(Ureg *ureg) Vctl *ctl, *v; Mach *mach; - if(!trapinited){ - /* faultamd64 can give a better error message */ - if(ureg->type == VectorPF) - faultamd64(ureg, nil); - panic("trap %llud: not ready", ureg->type); - } - m->perf.intrts = perfticks(); user = userureg(ureg); if(user){ @@ -447,11 +440,15 @@ trap(Ureg *ureg) return; } } else if(pc == _peekinst){ - if(vno == VectorGPF){ + if(vno == VectorGPF || vno == VectorPF){ ureg->pc += 2; return; } } + + /* early fault before trapinit() */ + if(vno == VectorPF) + faultamd64(ureg, 0); } dumpregs(ureg); |