From a1bcdcb74e17f93d66c94cd6ec537551dc7e142f Mon Sep 17 00:00:00 2001 From: Huy Vo Date: Thu, 3 Jan 2013 21:44:46 -0800 Subject: updated to handle exceptions and illegal instructions --- pk/entry.S | 8 ++++++-- pk/fp.c | 9 +++++---- pk/handlers.c | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pk/entry.S b/pk/entry.S index ee47b41..ef207b6 100644 --- a/pk/entry.S +++ b/pk/entry.S @@ -79,6 +79,10 @@ pop_tf: # write the trap frame onto the stack # restore gprs LOAD t0,32*REGBYTES(a0) # restore sr (should disable interrupts) mtpcr t0,ASM_CR(PCR_SR) + and t0,t0,SR_EV + beqz t0, 1f + vxcptkill +1: LOAD x1,1*REGBYTES(a0) mtpcr x1,ASM_CR(PCR_K0) @@ -133,10 +137,10 @@ trap_entry: mfpcr ra,ASM_CR(PCR_SR) and ra,ra,SR_PS add x2, sp, -320 - bnez ra, 1f + bnez ra, 2f la x2,stack_top-320 -1:jal save_tf +2:jal save_tf move sp,x2 move a0,x2 jal handle_trap diff --git a/pk/fp.c b/pk/fp.c index 5426c71..f6d4eaf 100644 --- a/pk/fp.c +++ b/pk/fp.c @@ -1,6 +1,7 @@ #include "pk.h" #include "pcr.h" #include "fp.h" +#include "config.h" static fp_state_t fp_state; @@ -211,10 +212,10 @@ int emulate_fp(trapframe_t* tf) #define STR(x) XSTR(x) #define XSTR(x) #x -#define PUT_FP_REG(which, type, val) asm("mxtf." STR(type) " $f" STR(which) ",%0" : : "r"(val)) -#define GET_FP_REG(which, type, val) asm("mftx." STR(type) " %0,$f" STR(which) : "=r"(val)) -#define LOAD_FP_REG(which, type, val) asm("fl" STR(type) " $f" STR(which) ",%0" : : "m"(val)) -#define STORE_FP_REG(which, type, val) asm("fs" STR(type) " $f" STR(which) ",%0" : "=m"(val) : : "memory") +#define PUT_FP_REG(which, type, val) asm("mxtf." STR(type) " f" STR(which) ",%0" : : "r"(val)) +#define GET_FP_REG(which, type, val) asm("mftx." STR(type) " %0,f" STR(which) : "=r"(val)) +#define LOAD_FP_REG(which, type, val) asm("fl" STR(type) " f" STR(which) ",%0" : : "m"(val)) +#define STORE_FP_REG(which, type, val) asm("fs" STR(type) " f" STR(which) ",%0" : "=m"(val) : : "memory") static void __attribute__((noinline)) set_fp_reg(unsigned int which, unsigned int dp, uint64_t val) diff --git a/pk/handlers.c b/pk/handlers.c index da2f915..1e440e6 100644 --- a/pk/handlers.c +++ b/pk/handlers.c @@ -1,5 +1,6 @@ #include "pcr.h" #include "pk.h" +#include "config.h" int have_fp = 1; // initialized to 1 because it can't be in the .bss section! int have_vector = 1; @@ -33,7 +34,7 @@ static void handle_privileged_instruction(trapframe_t* tf) static void handle_illegal_instruction(trapframe_t* tf) { #ifdef PK_ENABLE_FP_EMULATION - irq_enable(); + // irq_enable(); if(emulate_fp(tf) == 0) { -- cgit v1.1