diff options
author | Andrew Waterman <andrew@sifive.com> | 2019-07-17 16:36:51 -0700 |
---|---|---|
committer | Andrew Waterman <andrew@sifive.com> | 2019-07-17 16:36:51 -0700 |
commit | 31878c5e2f7a989977ef3f64da48e14387bbe0a2 (patch) | |
tree | 337da391ee1cfce345a34f7df0d16decb521bad6 /machine/emulation.c | |
parent | 3d681ed0d01df2fa65f15df86e06b63a7a696d1f (diff) | |
download | pk-31878c5e2f7a989977ef3f64da48e14387bbe0a2.zip pk-31878c5e2f7a989977ef3f64da48e14387bbe0a2.tar.gz pk-31878c5e2f7a989977ef3f64da48e14387bbe0a2.tar.bz2 |
Make illegal-instruction jump table entries relative to their base
This supports bbl living above 4 GiB.
Diffstat (limited to 'machine/emulation.c')
-rw-r--r-- | machine/emulation.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/machine/emulation.c b/machine/emulation.c index 132e977..c077a53 100644 --- a/machine/emulation.c +++ b/machine/emulation.c @@ -72,62 +72,62 @@ void illegal_insn_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) { asm (".pushsection .rodata\n" "illegal_insn_trap_table:\n" - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #if !defined(__riscv_flen) && defined(PK_ENABLE_FP_EMULATION) - " .word emulate_float_load\n" + " .word emulate_float_load - illegal_insn_trap_table\n" #else - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #endif - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #if !defined(__riscv_flen) && defined(PK_ENABLE_FP_EMULATION) - " .word emulate_float_store\n" + " .word emulate_float_store - illegal_insn_trap_table\n" #else - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #endif - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #if !defined(__riscv_muldiv) - " .word emulate_mul_div\n" + " .word emulate_mul_div - illegal_insn_trap_table\n" #else - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #endif - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #if !defined(__riscv_muldiv) && __riscv_xlen >= 64 - " .word emulate_mul_div32\n" + " .word emulate_mul_div32 - illegal_insn_trap_table\n" #else - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #endif - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #ifdef PK_ENABLE_FP_EMULATION - " .word emulate_fmadd\n" - " .word emulate_fmadd\n" - " .word emulate_fmadd\n" - " .word emulate_fmadd\n" - " .word emulate_fp\n" + " .word emulate_fmadd - illegal_insn_trap_table\n" + " .word emulate_fmadd - illegal_insn_trap_table\n" + " .word emulate_fmadd - illegal_insn_trap_table\n" + " .word emulate_fmadd - illegal_insn_trap_table\n" + " .word emulate_fp - illegal_insn_trap_table\n" #else - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" #endif - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word emulate_system_opcode\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" - " .word truly_illegal_insn\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word emulate_system_opcode - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" + " .word truly_illegal_insn - illegal_insn_trap_table\n" " .popsection"); uintptr_t mstatus = read_csr(mstatus); @@ -143,8 +143,8 @@ void illegal_insn_trap(uintptr_t* regs, uintptr_t mcause, uintptr_t mepc) write_csr(mepc, mepc + 4); extern uint32_t illegal_insn_trap_table[]; - uint32_t* pf = (void*)illegal_insn_trap_table + (insn & 0x7c); - emulation_func f = (emulation_func)(uintptr_t)*pf; + int32_t* pf = (void*)illegal_insn_trap_table + (insn & 0x7c); + emulation_func f = (emulation_func)((void*)illegal_insn_trap_table + *pf); f(regs, mcause, mepc, mstatus, insn); } |