From d4b98bac3c304e3bed612c79680fc2226ddb7e9a Mon Sep 17 00:00:00 2001 From: Yunsup Lee Date: Thu, 6 Feb 2014 00:10:59 -0800 Subject: fix vector exceptions on rocket --- v/entry.S | 16 +++++++++++++++- v/vm.c | 23 ----------------------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/v/entry.S b/v/entry.S index 7b9230d..6933771 100644 --- a/v/entry.S +++ b/v/entry.S @@ -152,7 +152,21 @@ trap_entry: and ra,ra,SR_EA beqz ra, 2f addi x2,x2,38*REGBYTES - vxcptsave x2 + + # rocket currently doesn't support vxcptsave/vxcptrestore natively + csrr x3,impl + li x4,IMPL_ROCKET + bne x3,x4,3f + vgetcfg x4 + sd x4,0(x2) + vgetvl x4 + sd x4,8(x2) + addi x2,x2,16 + vxcptevac x2 + j 2f + + # native vxcptsave +3:vxcptsave x2 2:jal handle_trap # when coming from kernel, continue below its stack diff --git a/v/vm.c b/v/vm.c index 415c7e5..e28dd45 100644 --- a/v/vm.c +++ b/v/vm.c @@ -99,16 +99,6 @@ void handle_fault(unsigned long addr) __builtin___clear_cache(0,0); } -static void emulate_vxcptsave(trapframe_t* tf) -{ - long* where = (long*)tf->gpr[(tf->insn >> 15) & 0x1F]; - - where[0] = vgetcfg(); - where[1] = vgetvl(); - vxcptevac(&where[2]); - fence(); -} - static void do_vxcptrestore(long* where) { vsetcfg(where[0]); @@ -157,13 +147,6 @@ static void do_vxcptrestore(long* where) } } -static void emulate_vxcptrestore(trapframe_t* tf) -{ - long* where = (long*)tf->gpr[(tf->insn >> 15) & 0x1F]; - vxcptkill(); - do_vxcptrestore(where); -} - static void restore_vector(trapframe_t* tf) { if (read_csr(impl) == IMPL_ROCKET) @@ -192,12 +175,6 @@ void handle_trap(trapframe_t* tf) if (tf->insn == fssr) terminate(1); // FP test on non-FP hardware. "succeed." -#if 0 - else if ((tf->insn & 0xF83FFFFF) == 0x37B) - emulate_vxcptsave(tf); - else if ((tf->insn & 0xF83FFFFF) == 0x77B) - emulate_vxcptrestore(tf); -#endif else assert(0); tf->epc += 4; -- cgit v1.1