Skip to content

Commit 15aad3b

Browse files
Qiangcybonzini
authored andcommitted
KVM: X86: Reset the vcpu->run->flags at the beginning of vcpu_run
Reset the vcpu->run->flags at the beginning of kvm_arch_vcpu_ioctl_run. It can avoid every thunk of code that needs to set the flag clear it, which increases the odds of missing a case and ending up with a flag in an undefined state. Signed-off-by: Chenyi Qiang <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 8e53324 commit 15aad3b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

arch/x86/kvm/x86.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8205,12 +8205,14 @@ static void post_kvm_run_save(struct kvm_vcpu *vcpu)
82058205
kvm_run->if_flag = !vcpu->arch.guest_state_protected
82068206
&& (kvm_get_rflags(vcpu) & X86_EFLAGS_IF) != 0;
82078207

8208-
kvm_run->flags = is_smm(vcpu) ? KVM_RUN_X86_SMM : 0;
82098208
kvm_run->cr8 = kvm_get_cr8(vcpu);
82108209
kvm_run->apic_base = kvm_get_apic_base(vcpu);
82118210
kvm_run->ready_for_interrupt_injection =
82128211
pic_in_kernel(vcpu->kvm) ||
82138212
kvm_vcpu_ready_for_interrupt_injection(vcpu);
8213+
8214+
if (is_smm(vcpu))
8215+
kvm_run->flags |= KVM_RUN_X86_SMM;
82148216
}
82158217

82168218
static void update_cr8_intercept(struct kvm_vcpu *vcpu)
@@ -9320,6 +9322,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
93209322

93219323
vcpu_load(vcpu);
93229324
kvm_sigset_activate(vcpu);
9325+
kvm_run->flags = 0;
93239326
kvm_load_guest_fpu(vcpu);
93249327

93259328
if (unlikely(vcpu->arch.mp_state == KVM_MP_STATE_UNINITIALIZED)) {

0 commit comments

Comments
 (0)