Fix emulator nested exception redirection privilege

This commit is contained in:
Dolu1990 2019-03-28 00:38:38 +01:00
parent ac06111163
commit 9ac4998478
4 changed files with 10 additions and 9 deletions

View File

@ -181,8 +181,8 @@ Disassembly of section .text:
8000026c: 000027b7 lui a5,0x2
80000270: 80078793 addi a5,a5,-2048 # 1800 <__stack_size+0x1000>
80000274: 3007b073 csrc mstatus,a5
80000278: 000087b7 lui a5,0x8
8000027c: 08078793 addi a5,a5,128 # 8080 <__stack_size+0x7880>
80000278: 000017b7 lui a5,0x1
8000027c: 88078793 addi a5,a5,-1920 # 880 <__stack_size+0x80>
80000280: 3007a073 csrs mstatus,a5
80000284: 00008067 ret
@ -396,8 +396,8 @@ Disassembly of section .text:
800005b0: 000027b7 lui a5,0x2
800005b4: 80078793 addi a5,a5,-2048 # 1800 <__stack_size+0x1000>
800005b8: 3007b073 csrc mstatus,a5
800005bc: 000087b7 lui a5,0x8
800005c0: 08078793 addi a5,a5,128 # 8080 <__stack_size+0x7880>
800005bc: 000017b7 lui a5,0x1
800005c0: 88078793 addi a5,a5,-1920 # 880 <__stack_size+0x80>
800005c4: 3007a073 csrs mstatus,a5
800005c8: e81ff06f j 80000448 <trap+0x15c>
800005cc: 00f45993 srli s3,s0,0xf

View File

@ -38,8 +38,8 @@
:10023C00F327303473903714F3272034739027143A
:10024C0073101514F3275010739017349307001084
:10025C0073B0071093D5350093F5051073A00510F6
:10026C00B72700009387078073B00730B78700006B
:10027C009387070873A007306780000037070200D8
:10026C00B72700009387078073B00730B7170000DB
:10027C009387078873A00730678000003707020058
:10028C0073200730170700001307870173105730CE
:10029C009306100083270500930600003707020021
:1002AC00733007301385060023A0F500678000002B
@ -91,7 +91,7 @@
:10058C007390271473901414F3275010739017342E
:10059C009307001073B0071093D5350093F5051031
:1005AC0073A00510B72700009387078073B007303E
:1005BC00B78700009387070873A007306FF01FE818
:1005BC00B71700009387078873A007306FF01FE808
:1005CC009359F40093F9F901B33930016FF01FDE40
:1005DC0033060601135454001374C407B306D40035
:1005EC0023A00601B707020073A00730970700008D

View File

@ -47,7 +47,7 @@ void emulationTrapToSupervisorTrap(uint32_t sepc, uint32_t mstatus){
csr_clear(sstatus, MSTATUS_SPP);
csr_set(sstatus, (mstatus >> 3) & MSTATUS_SPP);
csr_clear(mstatus, MSTATUS_MPP);
csr_set(mstatus, 0x8000 | MSTATUS_MPIE);
csr_set(mstatus, 0x0800 | MSTATUS_MPIE);
}
#define max(a,b) \

View File

@ -562,6 +562,7 @@ public:
}
#define maskedWrite(dst, src, mask) dst=(dst & ~mask)|(src & mask);
virtual bool csrWrite(int32_t csr, uint32_t value){
if(((csr >> 8) & 0x3) > privilege) return true;
switch(csr){