@@ -36,6 +36,7 @@ bool filter_reg(__u64 reg)
3636 case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_I :
3737 case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_M :
3838 case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_V :
39+ case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SMSTATEEN :
3940 case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SSAIA :
4041 case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SSTC :
4142 case KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SVINVAL :
@@ -186,6 +187,8 @@ static const char *core_id_to_str(const char *prefix, __u64 id)
186187 "KVM_REG_RISCV_CSR_GENERAL | KVM_REG_RISCV_CSR_REG(" #csr ")"
187188#define RISCV_CSR_AIA (csr ) \
188189 "KVM_REG_RISCV_CSR_AIA | KVM_REG_RISCV_CSR_REG(" #csr ")"
190+ #define RISCV_CSR_SMSTATEEN (csr ) \
191+ "KVM_REG_RISCV_CSR_SMSTATEEN | KVM_REG_RISCV_CSR_REG(" #csr ")"
189192
190193static const char * general_csr_id_to_str (__u64 reg_off )
191194{
@@ -243,6 +246,18 @@ static const char *aia_csr_id_to_str(__u64 reg_off)
243246 return NULL ;
244247}
245248
249+ static const char * smstateen_csr_id_to_str (__u64 reg_off )
250+ {
251+ /* reg_off is the offset into struct kvm_riscv_smstateen_csr */
252+ switch (reg_off ) {
253+ case KVM_REG_RISCV_CSR_SMSTATEEN_REG (sstateen0 ):
254+ return RISCV_CSR_SMSTATEEN (sstateen0 );
255+ }
256+
257+ TEST_FAIL ("Unknown smstateen csr reg: 0x%llx" , reg_off );
258+ return NULL ;
259+ }
260+
246261static const char * csr_id_to_str (const char * prefix , __u64 id )
247262{
248263 __u64 reg_off = id & ~(REG_MASK | KVM_REG_RISCV_CSR );
@@ -255,6 +270,8 @@ static const char *csr_id_to_str(const char *prefix, __u64 id)
255270 return general_csr_id_to_str (reg_off );
256271 case KVM_REG_RISCV_CSR_AIA :
257272 return aia_csr_id_to_str (reg_off );
273+ case KVM_REG_RISCV_CSR_SMSTATEEN :
274+ return smstateen_csr_id_to_str (reg_off );
258275 }
259276
260277 TEST_FAIL ("%s: Unknown csr subtype: 0x%llx" , prefix , reg_subtype );
@@ -332,6 +349,7 @@ static const char *isa_ext_id_to_str(__u64 id)
332349 KVM_ISA_EXT_ARR (I ),
333350 KVM_ISA_EXT_ARR (M ),
334351 KVM_ISA_EXT_ARR (V ),
352+ KVM_ISA_EXT_ARR (SMSTATEEN ),
335353 KVM_ISA_EXT_ARR (SSAIA ),
336354 KVM_ISA_EXT_ARR (SSTC ),
337355 KVM_ISA_EXT_ARR (SVINVAL ),
@@ -637,6 +655,11 @@ static __u64 aia_regs[] = {
637655 KVM_REG_RISCV | KVM_REG_SIZE_ULONG | KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SSAIA ,
638656};
639657
658+ static __u64 smstateen_regs [] = {
659+ KVM_REG_RISCV | KVM_REG_SIZE_ULONG | KVM_REG_RISCV_CSR | KVM_REG_RISCV_CSR_SMSTATEEN | KVM_REG_RISCV_CSR_SMSTATEEN_REG (sstateen0 ),
660+ KVM_REG_RISCV | KVM_REG_SIZE_ULONG | KVM_REG_RISCV_ISA_EXT | KVM_RISCV_ISA_EXT_SMSTATEEN ,
661+ };
662+
640663static __u64 fp_f_regs [] = {
641664 KVM_REG_RISCV | KVM_REG_SIZE_U32 | KVM_REG_RISCV_FP_F | KVM_REG_RISCV_FP_F_REG (f [0 ]),
642665 KVM_REG_RISCV | KVM_REG_SIZE_U32 | KVM_REG_RISCV_FP_F | KVM_REG_RISCV_FP_F_REG (f [1 ]),
@@ -744,6 +767,8 @@ static __u64 fp_d_regs[] = {
744767 {"zihpm", .feature = KVM_RISCV_ISA_EXT_ZIHPM, .regs = zihpm_regs, .regs_n = ARRAY_SIZE(zihpm_regs),}
745768#define AIA_REGS_SUBLIST \
746769 {"aia", .feature = KVM_RISCV_ISA_EXT_SSAIA, .regs = aia_regs, .regs_n = ARRAY_SIZE(aia_regs),}
770+ #define SMSTATEEN_REGS_SUBLIST \
771+ {"smstateen", .feature = KVM_RISCV_ISA_EXT_SMSTATEEN, .regs = smstateen_regs, .regs_n = ARRAY_SIZE(smstateen_regs),}
747772#define FP_F_REGS_SUBLIST \
748773 {"fp_f", .feature = KVM_RISCV_ISA_EXT_F, .regs = fp_f_regs, \
749774 .regs_n = ARRAY_SIZE(fp_f_regs),}
@@ -871,6 +896,14 @@ static struct vcpu_reg_list aia_config = {
871896 },
872897};
873898
899+ static struct vcpu_reg_list smstateen_config = {
900+ .sublists = {
901+ BASE_SUBLIST ,
902+ SMSTATEEN_REGS_SUBLIST ,
903+ {0 },
904+ },
905+ };
906+
874907static struct vcpu_reg_list fp_f_config = {
875908 .sublists = {
876909 BASE_SUBLIST ,
@@ -903,6 +936,7 @@ struct vcpu_reg_list *vcpu_configs[] = {
903936 & zifencei_config ,
904937 & zihpm_config ,
905938 & aia_config ,
939+ & smstateen_config ,
906940 & fp_f_config ,
907941 & fp_d_config ,
908942};
0 commit comments