Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RISC-V: KVM: Introduce feature specific reset for SBI FWFT

The SBI FWFT feature values must be reset upon VCPU reset so
introduce feature specific reset callback for this purpose.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Link: https://lore.kernel.org/r/20250823155947.1354229-3-apatel@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>

authored by

Anup Patel and committed by
Anup Patel
a6250b18 83df1d64

+28 -2
+28 -2
arch/riscv/kvm/vcpu_sbi_fwft.c
··· 31 31 bool (*supported)(struct kvm_vcpu *vcpu); 32 32 33 33 /** 34 + * @reset: Reset the feature value irrespective whether feature is supported or not 35 + * 36 + * This callback is mandatory 37 + */ 38 + void (*reset)(struct kvm_vcpu *vcpu); 39 + 40 + /** 34 41 * @set: Set the feature value 35 42 * 36 43 * Return SBI_SUCCESS on success or an SBI error (SBI_ERR_*) ··· 80 73 static bool kvm_sbi_fwft_misaligned_delegation_supported(struct kvm_vcpu *vcpu) 81 74 { 82 75 return misaligned_traps_can_delegate(); 76 + } 77 + 78 + static void kvm_sbi_fwft_reset_misaligned_delegation(struct kvm_vcpu *vcpu) 79 + { 80 + struct kvm_vcpu_config *cfg = &vcpu->arch.cfg; 81 + 82 + cfg->hedeleg &= ~MIS_DELEG; 83 83 } 84 84 85 85 static long kvm_sbi_fwft_set_misaligned_delegation(struct kvm_vcpu *vcpu, ··· 136 122 fwft->have_vs_pmlen_16 = try_to_set_pmm(ENVCFG_PMM_PMLEN_16); 137 123 138 124 return fwft->have_vs_pmlen_7 || fwft->have_vs_pmlen_16; 125 + } 126 + 127 + static void kvm_sbi_fwft_reset_pointer_masking_pmlen(struct kvm_vcpu *vcpu) 128 + { 129 + vcpu->arch.cfg.henvcfg &= ~ENVCFG_PMM; 139 130 } 140 131 141 132 static long kvm_sbi_fwft_set_pointer_masking_pmlen(struct kvm_vcpu *vcpu, ··· 208 189 { 209 190 .id = SBI_FWFT_MISALIGNED_EXC_DELEG, 210 191 .supported = kvm_sbi_fwft_misaligned_delegation_supported, 192 + .reset = kvm_sbi_fwft_reset_misaligned_delegation, 211 193 .set = kvm_sbi_fwft_set_misaligned_delegation, 212 194 .get = kvm_sbi_fwft_get_misaligned_delegation, 213 195 }, ··· 216 196 { 217 197 .id = SBI_FWFT_POINTER_MASKING_PMLEN, 218 198 .supported = kvm_sbi_fwft_pointer_masking_pmlen_supported, 199 + .reset = kvm_sbi_fwft_reset_pointer_masking_pmlen, 219 200 .set = kvm_sbi_fwft_set_pointer_masking_pmlen, 220 201 .get = kvm_sbi_fwft_get_pointer_masking_pmlen, 221 202 }, ··· 351 330 352 331 static void kvm_sbi_ext_fwft_reset(struct kvm_vcpu *vcpu) 353 332 { 354 - int i; 355 333 struct kvm_sbi_fwft *fwft = vcpu_to_fwft(vcpu); 334 + const struct kvm_sbi_fwft_feature *feature; 335 + int i; 356 336 357 - for (i = 0; i < ARRAY_SIZE(features); i++) 337 + for (i = 0; i < ARRAY_SIZE(features); i++) { 358 338 fwft->configs[i].flags = 0; 339 + feature = &features[i]; 340 + if (feature->reset) 341 + feature->reset(vcpu); 342 + } 359 343 } 360 344 361 345 const struct kvm_vcpu_sbi_extension vcpu_sbi_ext_fwft = {