diff options
author | David Woodhouse <dwmw@amazon.co.uk> | 2020-12-09 20:08:30 +0000 |
---|---|---|
committer | David Woodhouse <dwmw@amazon.co.uk> | 2021-02-04 14:19:39 +0000 |
commit | 40da8ccd724f7ca2f08550a46268bc3a91cc8869 (patch) | |
tree | 7f9240ecbda4aa6a5b33cd2b75d408aed68df5d9 /arch/x86/kvm/xen.h | |
parent | f2340cd9e41dc463cb1189274f3db560c1dfa1f4 (diff) | |
download | linux-40da8ccd724f7ca2f08550a46268bc3a91cc8869.tar.bz2 |
KVM: x86/xen: Add event channel interrupt vector upcall
It turns out that we can't handle event channels *entirely* in userspace
by delivering them as ExtINT, because KVM is a bit picky about when it
accepts ExtINT interrupts from a legacy PIC. The in-kernel local APIC
has to have LVT0 configured in APIC_MODE_EXTINT and unmasked, which
isn't necessarily the case for Xen guests especially on secondary CPUs.
To cope with this, add kvm_xen_get_interrupt() which checks the
evtchn_pending_upcall field in the Xen vcpu_info, and delivers the Xen
upcall vector (configured by KVM_XEN_ATTR_TYPE_UPCALL_VECTOR) if it's
set regardless of LAPIC LVT0 configuration. This gives us the minimum
support we need for completely userspace-based implementation of event
channels.
This does mean that vcpu_enter_guest() needs to check for the
evtchn_pending_upcall flag being set, because it can't rely on someone
having set KVM_REQ_EVENT unless we were to add some way for userspace to
do so manually.
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Diffstat (limited to 'arch/x86/kvm/xen.h')
-rw-r--r-- | arch/x86/kvm/xen.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/kvm/xen.h b/arch/x86/kvm/xen.h index fb85377fdbdc..4b32489c0cec 100644 --- a/arch/x86/kvm/xen.h +++ b/arch/x86/kvm/xen.h @@ -13,6 +13,7 @@ extern struct static_key_false_deferred kvm_xen_enabled; +int __kvm_xen_has_interrupt(struct kvm_vcpu *vcpu); int kvm_xen_vcpu_set_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data); int kvm_xen_vcpu_get_attr(struct kvm_vcpu *vcpu, struct kvm_xen_vcpu_attr *data); int kvm_xen_hvm_set_attr(struct kvm *kvm, struct kvm_xen_hvm_attr *data); @@ -29,6 +30,14 @@ static inline bool kvm_xen_hypercall_enabled(struct kvm *kvm) KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL); } +static inline int kvm_xen_has_interrupt(struct kvm_vcpu *vcpu) +{ + if (static_branch_unlikely(&kvm_xen_enabled.key) && + vcpu->arch.xen.vcpu_info_set && vcpu->kvm->arch.xen.upcall_vector) + return __kvm_xen_has_interrupt(vcpu); + + return 0; +} /* 32-bit compatibility definitions, also used natively in 32-bit build */ #include <asm/pvclock-abi.h> |