3a7c8fafd1b42adea229fd204132f6a2fb3cd2d9 ("x86/kvm: Restrict ASYNC_PF to user space") stopped setting KVM_ASYNC_PF_SEND_ALWAYS in Linux guests. While the flag can still be used by legacy guests, the mechanism is best effort so KVM is not obliged to use it. Suggested-by: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx> Signed-off-by: Nikita Kalyazin <kalyazin@xxxxxxxxxx> --- Documentation/virt/kvm/x86/msr.rst | 11 +++++------ arch/x86/include/asm/kvm_host.h | 1 - arch/x86/include/uapi/asm/kvm_para.h | 2 +- arch/x86/kvm/x86.c | 4 +--- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Documentation/virt/kvm/x86/msr.rst b/Documentation/virt/kvm/x86/msr.rst index 3aecf2a70e7b..b3bbc12b5d03 100644 --- a/Documentation/virt/kvm/x86/msr.rst +++ b/Documentation/virt/kvm/x86/msr.rst @@ -208,12 +208,11 @@ data: Bits 5-4 of the MSR are reserved and should be zero. Bit 0 is set to 1 when asynchronous page faults are enabled on the vcpu, 0 when disabled. - Bit 1 is 1 if asynchronous page faults can be injected when vcpu is in - cpl == 0. Bit 2 is 1 if asynchronous page faults are delivered to L1 as - #PF vmexits. Bit 2 can be set only if KVM_FEATURE_ASYNC_PF_VMEXIT is - present in CPUID. Bit 3 enables interrupt based delivery of 'page ready' - events. Bit 3 can only be set if KVM_FEATURE_ASYNC_PF_INT is present in - CPUID. + Bit 1 is reserved and should be zero. Bit 2 is 1 if asynchronous page + faults are delivered to L1 as #PF vmexits. Bit 2 can be set only if + KVM_FEATURE_ASYNC_PF_VMEXIT is present in CPUID. Bit 3 enables + interrupt based delivery of 'page ready' events. Bit 3 can only be set + if KVM_FEATURE_ASYNC_PF_INT is present in CPUID. 'Page not present' events are currently always delivered as synthetic #PF exception. During delivery of these events APF CR2 register contains diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index e159e44a6a1b..8ce00b17316f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -975,7 +975,6 @@ struct kvm_vcpu_arch { u64 msr_int_val; /* MSR_KVM_ASYNC_PF_INT */ u16 vec; u32 id; - bool send_user_only; u32 host_apf_flags; bool delivery_as_pf_vmexit; bool pageready_pending; diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h index a1efa7907a0b..5558a1ec3dc9 100644 --- a/arch/x86/include/uapi/asm/kvm_para.h +++ b/arch/x86/include/uapi/asm/kvm_para.h @@ -87,7 +87,7 @@ struct kvm_clock_pairing { #define KVM_MAX_MMU_OP_BATCH 32 #define KVM_ASYNC_PF_ENABLED (1 << 0) -#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1) +#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1) /* deprecated */ #define KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT (1 << 2) #define KVM_ASYNC_PF_DELIVERY_AS_INT (1 << 3) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 2e713480933a..8f784f07d423 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3558,7 +3558,6 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) sizeof(u64))) return 1; - vcpu->arch.apf.send_user_only = !(data & KVM_ASYNC_PF_SEND_ALWAYS); vcpu->arch.apf.delivery_as_pf_vmexit = data & KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT; kvm_async_pf_wakeup_all(vcpu); @@ -13361,8 +13360,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_user_only && - kvm_x86_call(get_cpl)(vcpu) == 0) + if (kvm_x86_call(get_cpl)(vcpu) == 0) return false; if (is_guest_mode(vcpu)) { -- 2.40.1