mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 10:09:10 +02:00
KVM: x86: Drop superfluous caching of KVM_ASYNC_PF_SEND_ALWAYS
Drop kvm_vcpu_arch.apf.send_always and instead use msr_en_val as the source
of truth to reduce the probability of operating on stale data. This fixes
flaws where KVM fails to update send_always when APF is explicitly
disabled by the guest or implicitly disabled by KVM on INIT. Absent other
bugs, the flaws are benign as KVM *shouldn't* consume send_always when PV
APF support is disabled.
Simply delete the field, as there's zero benefit to maintaining a separate
"cache" of the state.
Opportunistically turn the enabled vs. disabled logic at the end of
kvm_pv_enable_async_pf() into an if-else instead of using an early return,
e.g. so that it's more obvious that both paths are "success" paths.
Fixes: 6adba52742 ("KVM: Let host know whether the guest can handle async PF in non-userspace context.")
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://patch.msgid.link/20260406225359.1245490-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
3c0bf11dd4
commit
7e985021ef
|
|
@ -1057,7 +1057,6 @@ struct kvm_vcpu_arch {
|
|||
u16 vec;
|
||||
u32 id;
|
||||
u32 host_apf_flags;
|
||||
bool send_always;
|
||||
bool pageready_pending;
|
||||
} apf;
|
||||
|
||||
|
|
|
|||
|
|
@ -3660,16 +3660,12 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
|
|||
|
||||
vcpu->arch.apf.msr_en_val = data;
|
||||
|
||||
if (!__kvm_pv_async_pf_enabled(data)) {
|
||||
if (__kvm_pv_async_pf_enabled(data)) {
|
||||
kvm_async_pf_wakeup_all(vcpu);
|
||||
} else {
|
||||
kvm_clear_async_pf_completion_queue(vcpu);
|
||||
kvm_async_pf_hash_reset(vcpu);
|
||||
return 0;
|
||||
}
|
||||
|
||||
vcpu->arch.apf.send_always = (data & KVM_ASYNC_PF_SEND_ALWAYS);
|
||||
|
||||
kvm_async_pf_wakeup_all(vcpu);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -14008,7 +14004,7 @@ static bool kvm_can_deliver_async_pf(struct kvm_vcpu *vcpu)
|
|||
if (!kvm_pv_async_pf_enabled(vcpu))
|
||||
return false;
|
||||
|
||||
if (!vcpu->arch.apf.send_always &&
|
||||
if (!(vcpu->arch.apf.msr_en_val & KVM_ASYNC_PF_SEND_ALWAYS) &&
|
||||
(vcpu->arch.guest_state_protected || !kvm_x86_call(get_cpl)(vcpu)))
|
||||
return false;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user