[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 4/8] target/riscv: Add support for IOPMP
From: |
Ethan Chen |
Subject: |
[PATCH v9 4/8] target/riscv: Add support for IOPMP |
Date: |
Thu, 9 Jan 2025 10:44:37 +0800 |
Signed-off-by: Ethan Chen <ethan84@andestech.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
---
target/riscv/cpu.c | 3 +++
target/riscv/cpu_cfg.h | 2 ++
target/riscv/cpu_helper.c | 18 +++++++++++++++---
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index b8d5120106..212e522ed7 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -2798,6 +2798,9 @@ static const Property riscv_cpu_properties[] = {
* it with -x and default to 'false'.
*/
DEFINE_PROP_BOOL("x-misa-w", RISCVCPU, cfg.misa_w, false),
+
+ DEFINE_PROP_BOOL("iopmp", RISCVCPU, cfg.iopmp, false),
+ DEFINE_PROP_UINT32("iopmp_rrid", RISCVCPU, cfg.iopmp_rrid, 0),
};
#if defined(TARGET_RISCV64)
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
index a1457ab4f4..c5d5e1a77d 100644
--- a/target/riscv/cpu_cfg.h
+++ b/target/riscv/cpu_cfg.h
@@ -175,6 +175,8 @@ struct RISCVCPUConfig {
bool pmp;
bool debug;
bool misa_w;
+ bool iopmp;
+ uint32_t iopmp_rrid;
bool short_isa_string;
diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
index f62b21e182..926ae38684 100644
--- a/target/riscv/cpu_helper.c
+++ b/target/riscv/cpu_helper.c
@@ -1599,9 +1599,21 @@ bool riscv_cpu_tlb_fill(CPUState *cs, vaddr address, int
size,
}
if (ret == TRANSLATE_SUCCESS) {
- tlb_set_page(cs, address & ~(tlb_size - 1), pa & ~(tlb_size - 1),
- prot, mmu_idx, tlb_size);
- return true;
+ if (cpu->cfg.iopmp) {
+ /*
+ * Do not align address on early stage because IOPMP needs origin
+ * address for permission check.
+ */
+ tlb_set_page_with_attrs(cs, address, pa,
+ (MemTxAttrs)
+ {
+ .requester_id = cpu->cfg.iopmp_rrid,
+ },
+ prot, mmu_idx, tlb_size);
+ } else {
+ tlb_set_page(cs, address & ~(tlb_size - 1), pa & ~(tlb_size - 1),
+ prot, mmu_idx, tlb_size);
+ }
} else if (probe) {
return false;
} else {
--
2.34.1
- [PATCH v9 0/8] Support RISC-V IOPMP, Ethan Chen, 2025/01/08
- [PATCH v9 1/8] hw/core: Add config stream, Ethan Chen, 2025/01/08
- [PATCH v9 2/8] memory: Introduce memory region fetch operation, Ethan Chen, 2025/01/08
- [PATCH v9 3/8] system/physmem: Support IOMMU granularity smaller than TARGET_PAGE size, Ethan Chen, 2025/01/08
- [PATCH v9 4/8] target/riscv: Add support for IOPMP,
Ethan Chen <=
- [PATCH v9 5/8] hw/misc/riscv_iopmp_txn_info: Add struct for transaction infomation, Ethan Chen, 2025/01/08
- [PATCH v9 6/8] hw/misc/riscv_iopmp: Add RISC-V IOPMP device, Ethan Chen, 2025/01/08
- [PATCH v9 8/8] hw/riscv/virt: Add IOPMP support, Ethan Chen, 2025/01/08
- [PATCH v9 7/8] hw/misc/riscv_iopmp_dispatcher: Device for redirect IOPMP transaction infomation, Ethan Chen, 2025/01/08