[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/18] target/riscv: Add CPU options of WorldGuard CPU extensi
From: |
Jim Shu |
Subject: |
[PATCH v2 06/18] target/riscv: Add CPU options of WorldGuard CPU extension |
Date: |
Thu, 17 Apr 2025 18:52:37 +0800 |
We define CPU options for WG CSR support in RISC-V CPUs which
can be set by machine/device emulation. The RISC-V CSR emulation
will also check this feature for emulating WG CSRs.
Signed-off-by: Jim Shu <jim.shu@sifive.com>
---
target/riscv/cpu.c | 3 +++
target/riscv/cpu_cfg.h | 3 +++
target/riscv/tcg/tcg-cpu.c | 11 +++++++++++
3 files changed, 17 insertions(+)
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 09ded6829a..a182e8c61f 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -236,6 +236,9 @@ const RISCVIsaExtData isa_edata_arr[] = {
ISA_EXT_DATA_ENTRY(xtheadmempair, PRIV_VERSION_1_11_0, ext_xtheadmempair),
ISA_EXT_DATA_ENTRY(xtheadsync, PRIV_VERSION_1_11_0, ext_xtheadsync),
ISA_EXT_DATA_ENTRY(xventanacondops, PRIV_VERSION_1_12_0,
ext_XVentanaCondOps),
+ ISA_EXT_DATA_ENTRY(smwg, PRIV_VERSION_1_12_0, ext_smwg),
+ ISA_EXT_DATA_ENTRY(smwgd, PRIV_VERSION_1_12_0, ext_smwgd),
+ ISA_EXT_DATA_ENTRY(sswg, PRIV_VERSION_1_12_0, ext_sswg),
{ },
};
diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h
index 8a843482cc..a5b045aa2f 100644
--- a/target/riscv/cpu_cfg.h
+++ b/target/riscv/cpu_cfg.h
@@ -143,6 +143,9 @@ struct RISCVCPUConfig {
bool ext_smmpm;
bool ext_sspm;
bool ext_supm;
+ bool ext_smwg;
+ bool ext_smwgd;
+ bool ext_sswg;
bool rvv_ta_all_1s;
bool rvv_ma_all_1s;
bool rvv_vl_half_avl;
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 5aef9eef36..343e46e698 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -694,6 +694,17 @@ void riscv_cpu_validate_set_extensions(RISCVCPU *cpu,
Error **errp)
cpu->cfg.ext_ssctr = false;
}
+ /* RISC-V WorldGuard */
+ if (cpu->cfg.ext_sswg && !cpu->cfg.ext_smwg) {
+ error_setg(errp, "Sswg extension requires Smwg extension");
+ return;
+ }
+
+ if (cpu->cfg.ext_smwgd != cpu->cfg.ext_sswg) {
+ error_setg(errp, "Smwgd/Sswg extensions should be enabled together");
+ return;
+ }
+
/*
* Disable isa extensions based on priv spec after we
* validated and set everything we need.
--
2.17.1
- [PATCH v2 00/18] Implements RISC-V WorldGuard extension v0.4, Jim Shu, 2025/04/17
- [PATCH v2 01/18] accel/tcg: Store section pointer in CPUTLBEntryFull, Jim Shu, 2025/04/17
- [PATCH v2 02/18] system/physmem: Remove the assertion of page-aligned section number, Jim Shu, 2025/04/17
- [PATCH v2 03/18] accel/tcg: memory access from CPU will pass access_type to IOMMU, Jim Shu, 2025/04/17
- [PATCH v2 04/18] exec: Add RISC-V WorldGuard WID to MemTxAttrs, Jim Shu, 2025/04/17
- [PATCH v2 05/18] hw/misc: riscv_worldguard: Add RISC-V WorldGuard global config, Jim Shu, 2025/04/17
- [PATCH v2 06/18] target/riscv: Add CPU options of WorldGuard CPU extension,
Jim Shu <=
- [PATCH v2 07/18] target/riscv: Add hard-coded CPU state of WG extension, Jim Shu, 2025/04/17
- [PATCH v2 08/18] target/riscv: Add defines for WorldGuard CSRs, Jim Shu, 2025/04/17
- [PATCH v2 09/18] target/riscv: Allow global WG config to set WG CPU callbacks, Jim Shu, 2025/04/17
- [PATCH v2 11/18] target/riscv: Add WID to MemTxAttrs of CPU memory transactions, Jim Shu, 2025/04/17
- [PATCH v2 10/18] target/riscv: Implement WorldGuard CSRs, Jim Shu, 2025/04/17
- [PATCH v2 12/18] target/riscv: Expose CPU options of WorldGuard, Jim Shu, 2025/04/17
- [PATCH v2 13/18] hw/misc: riscv_worldguard: Add API to enable WG extension of CPU, Jim Shu, 2025/04/17
- [PATCH v2 14/18] hw/misc: riscv_wgchecker: Implement RISC-V WorldGuard Checker, Jim Shu, 2025/04/17
- [PATCH v2 15/18] hw/misc: riscv_wgchecker: Implement wgchecker slot registers, Jim Shu, 2025/04/17
- [PATCH v2 16/18] hw/misc: riscv_wgchecker: Implement correct block-access behavior, Jim Shu, 2025/04/17