[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 31/35] target/riscv: Raise the new execptions when 2nd stage t
From: |
Alistair Francis |
Subject: |
[PATCH v2 31/35] target/riscv: Raise the new execptions when 2nd stage translation fails |
Date: |
Fri, 31 Jan 2020 17:02:59 -0800 |
Signed-off-by: Alistair Francis <address@hidden>
Reviewed-by: Palmer Dabbelt <address@hidden>
---
target/riscv/cpu_helper.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index 5f96631637..da994aba57 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -585,16 +585,28 @@ static void raise_mmu_exception(CPURISCVState *env,
target_ulong address,
}
switch (access_type) {
case MMU_INST_FETCH:
- cs->exception_index = page_fault_exceptions ?
- RISCV_EXCP_INST_PAGE_FAULT : RISCV_EXCP_INST_ACCESS_FAULT;
+ if (riscv_cpu_virt_enabled(env) && !first_stage) {
+ cs->exception_index = RISCV_EXCP_INST_GUEST_PAGE_FAULT;
+ } else {
+ cs->exception_index = page_fault_exceptions ?
+ RISCV_EXCP_INST_PAGE_FAULT : RISCV_EXCP_INST_ACCESS_FAULT;
+ }
break;
case MMU_DATA_LOAD:
- cs->exception_index = page_fault_exceptions ?
- RISCV_EXCP_LOAD_PAGE_FAULT : RISCV_EXCP_LOAD_ACCESS_FAULT;
+ if (riscv_cpu_virt_enabled(env) && !first_stage) {
+ cs->exception_index = RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT;
+ } else {
+ cs->exception_index = page_fault_exceptions ?
+ RISCV_EXCP_LOAD_PAGE_FAULT : RISCV_EXCP_LOAD_ACCESS_FAULT;
+ }
break;
case MMU_DATA_STORE:
- cs->exception_index = page_fault_exceptions ?
- RISCV_EXCP_STORE_PAGE_FAULT : RISCV_EXCP_STORE_AMO_ACCESS_FAULT;
+ if (riscv_cpu_virt_enabled(env) && !first_stage) {
+ cs->exception_index = RISCV_EXCP_STORE_GUEST_AMO_ACCESS_FAULT;
+ } else {
+ cs->exception_index = page_fault_exceptions ?
+ RISCV_EXCP_STORE_PAGE_FAULT :
RISCV_EXCP_STORE_AMO_ACCESS_FAULT;
+ }
break;
default:
g_assert_not_reached();
--
2.25.0
- [PATCH v2 25/35] target/riscv: Only set TB flags with FP status if enabled, (continued)
- [PATCH v2 25/35] target/riscv: Only set TB flags with FP status if enabled, Alistair Francis, 2020/01/31
- [PATCH v2 22/35] target/riscv: Add Hypervisor trap return support, Alistair Francis, 2020/01/31
- [PATCH v2 24/35] target/riscv: Remove the hret instruction, Alistair Francis, 2020/01/31
- [PATCH v2 23/35] target/riscv: Add hfence instructions, Alistair Francis, 2020/01/31
- [PATCH v2 26/35] target/riscv: Disable guest FP support based on virtual status, Alistair Francis, 2020/01/31
- [PATCH v2 28/35] target/riscv: Respect MPRV and SPRV for floating point ops, Alistair Francis, 2020/01/31
- [PATCH v2 27/35] target/riscv: Mark both sstatus and msstatus_hs as dirty, Alistair Francis, 2020/01/31
- [PATCH v2 32/35] target/riscv: Set htval and mtval2 on execptions, Alistair Francis, 2020/01/31
- [PATCH v2 29/35] target/riscv: Allow specifying MMU stage, Alistair Francis, 2020/01/31
- [PATCH v2 30/35] target/riscv: Implement second stage MMU, Alistair Francis, 2020/01/31
- [PATCH v2 31/35] target/riscv: Raise the new execptions when 2nd stage translation fails,
Alistair Francis <=
- [PATCH v2 33/35] target/riscv: Add support for the 32-bit MSTATUSH CSR, Alistair Francis, 2020/01/31
- [PATCH v2 34/35] target/riscv: Add the MSTATUS_MPV_ISSET helper macro, Alistair Francis, 2020/01/31
- [PATCH v2 35/35] target/riscv: Allow enabling the Hypervisor extension, Alistair Francis, 2020/01/31