Skip to content

Commit c3de19c

Browse files
danielhbalistair23
authored andcommitted
target/riscv: add ssstateen
ssstateen is defined in RVA22 as: "Supervisor-mode view of the state-enable extension. The supervisor-mode (sstateen0-3) and hypervisor-mode (hstateen0-3) state-enable registers must be provided." Add ssstateen as a named feature that is available if we also have smstateen. Signed-off-by: Daniel Henrique Barboza <[email protected]> Acked-by: Alistair Francis <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
1 parent 7e4f75c commit c3de19c

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

target/riscv/cpu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ const RISCVIsaExtData isa_edata_arr[] = {
191191
ISA_EXT_DATA_ENTRY(ssccptr, PRIV_VERSION_1_11_0, has_priv_1_11),
192192
ISA_EXT_DATA_ENTRY(sscofpmf, PRIV_VERSION_1_12_0, ext_sscofpmf),
193193
ISA_EXT_DATA_ENTRY(sscounterenw, PRIV_VERSION_1_12_0, has_priv_1_12),
194+
ISA_EXT_DATA_ENTRY(ssstateen, PRIV_VERSION_1_12_0, ext_ssstateen),
194195
ISA_EXT_DATA_ENTRY(sstc, PRIV_VERSION_1_12_0, ext_sstc),
195196
ISA_EXT_DATA_ENTRY(sstvala, PRIV_VERSION_1_12_0, has_priv_1_12),
196197
ISA_EXT_DATA_ENTRY(sstvecd, PRIV_VERSION_1_12_0, has_priv_1_12),
@@ -1677,6 +1678,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_experimental_exts[] = {
16771678
*/
16781679
const RISCVCPUMultiExtConfig riscv_cpu_named_features[] = {
16791680
MULTI_EXT_CFG_BOOL("zic64b", ext_zic64b, true),
1681+
MULTI_EXT_CFG_BOOL("ssstateen", ext_ssstateen, true),
16801682

16811683
DEFINE_PROP_END_OF_LIST(),
16821684
};

target/riscv/cpu_cfg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ struct RISCVCPUConfig {
140140
/* Named features */
141141
bool ext_svade;
142142
bool ext_zic64b;
143+
bool ext_ssstateen;
143144

144145
/*
145146
* Always 'true' booleans for named features

target/riscv/tcg/tcg-cpu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,15 @@ static void riscv_cpu_enable_named_feat(RISCVCPU *cpu, uint32_t feat_offset)
204204
* All other named features are already enabled
205205
* in riscv_tcg_cpu_instance_init().
206206
*/
207-
if (feat_offset == CPU_CFG_OFFSET(ext_zic64b)) {
207+
switch (feat_offset) {
208+
case CPU_CFG_OFFSET(ext_zic64b):
208209
cpu->cfg.cbom_blocksize = 64;
209210
cpu->cfg.cbop_blocksize = 64;
210211
cpu->cfg.cboz_blocksize = 64;
212+
break;
213+
case CPU_CFG_OFFSET(ext_ssstateen):
214+
cpu->cfg.ext_smstateen = true;
215+
break;
211216
}
212217
}
213218

@@ -343,6 +348,8 @@ static void riscv_cpu_update_named_features(RISCVCPU *cpu)
343348
cpu->cfg.ext_zic64b = cpu->cfg.cbom_blocksize == 64 &&
344349
cpu->cfg.cbop_blocksize == 64 &&
345350
cpu->cfg.cboz_blocksize == 64;
351+
352+
cpu->cfg.ext_ssstateen = cpu->cfg.ext_smstateen;
346353
}
347354

348355
static void riscv_cpu_validate_g(RISCVCPU *cpu)

0 commit comments

Comments
 (0)