]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RISC-V: KVM: Set initial value of hedeleg in kvm_arch_vcpu_create()
authorAnup Patel <apatel@ventanamicro.com>
Sat, 23 Aug 2025 15:59:42 +0000 (21:29 +0530)
committerAnup Patel <anup@brainfault.org>
Tue, 16 Sep 2025 05:24:08 +0000 (10:54 +0530)
The hedeleg may be updated by ONE_REG interface before the VCPU
is run at least once hence set the initial value of hedeleg in
kvm_arch_vcpu_create() instead of kvm_riscv_vcpu_setup_config().

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-2-apatel@ventanamicro.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu.c

index 3ebcfffaa978154157cafe976b532ad36e79f3a7..47bcf190ccc5bb48478dd21245008861c7475b5a 100644 (file)
@@ -133,6 +133,8 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
 
        /* Mark this VCPU never ran */
        vcpu->arch.ran_atleast_once = false;
+
+       vcpu->arch.cfg.hedeleg = KVM_HEDELEG_DEFAULT;
        vcpu->arch.mmu_page_cache.gfp_zero = __GFP_ZERO;
        bitmap_zero(vcpu->arch.isa, RISCV_ISA_EXT_MAX);
 
@@ -570,7 +572,6 @@ static void kvm_riscv_vcpu_setup_config(struct kvm_vcpu *vcpu)
                        cfg->hstateen0 |= SMSTATEEN0_SSTATEEN0;
        }
 
-       cfg->hedeleg = KVM_HEDELEG_DEFAULT;
        if (vcpu->guest_debug)
                cfg->hedeleg &= ~BIT(EXC_BREAKPOINT);
 }