18e83f28bf
A guest which has configured the per-vCPU upcall vector may set the
HVM_PARAM_CALLBACK_IRQ param to fairly much anything other than zero.
For example, Linux v6.0+ after commit b1c3497e604 ("x86/xen: Add support
for HVMOP_set_evtchn_upcall_vector") will just do this after setting the
vector:
/* Trick toolstack to think we are enlightened. */
if (!cpu)
rc = xen_set_callback_via(1);
That's explicitly setting the delivery to GSI#1, but it's supposed to be
overridden by the per-vCPU vector setting. This mostly works in Qemu
*except* for the logic to enable the in-kernel handling of event channels,
which falsely determines that the kernel cannot accelerate GSI delivery
in this case.
Add a kvm_xen_has_vcpu_callback_vector() to report whether vCPU#0 has
the vector set, and use that in xen_evtchn_set_callback_param() to
enable the kernel acceleration features even when the param *appears*
to be set to target a GSI.
Preserve the Xen behaviour that when HVM_PARAM_CALLBACK_IRQ is set to
*zero* the event channel delivery is disabled completely. (Which is
what that bizarre guest behaviour is working round in the first place.)
Cc: qemu-stable@nongnu.org
Fixes: 91cce75617
("hw/xen: Add xen_evtchn device for event channel emulation")
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
/*
|
|
* Xen HVM emulation support in KVM
|
|
*
|
|
* Copyright © 2019 Oracle and/or its affiliates. All rights reserved.
|
|
* Copyright © 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
* See the COPYING file in the top-level directory.
|
|
*
|
|
*/
|
|
|
|
#ifndef QEMU_SYSEMU_KVM_XEN_H
|
|
#define QEMU_SYSEMU_KVM_XEN_H
|
|
|
|
/* The KVM API uses these to indicate "no GPA" or "no GFN" */
|
|
#define INVALID_GPA UINT64_MAX
|
|
#define INVALID_GFN UINT64_MAX
|
|
|
|
/* QEMU plays the rôle of dom0 for "interdomain" communication. */
|
|
#define DOMID_QEMU 0
|
|
|
|
int kvm_xen_soft_reset(void);
|
|
uint32_t kvm_xen_get_caps(void);
|
|
void *kvm_xen_get_vcpu_info_hva(uint32_t vcpu_id);
|
|
bool kvm_xen_has_vcpu_callback_vector(void);
|
|
void kvm_xen_inject_vcpu_callback_vector(uint32_t vcpu_id, int type);
|
|
void kvm_xen_set_callback_asserted(void);
|
|
int kvm_xen_set_vcpu_virq(uint32_t vcpu_id, uint16_t virq, uint16_t port);
|
|
uint16_t kvm_xen_get_gnttab_max_frames(void);
|
|
uint16_t kvm_xen_get_evtchn_max_pirq(void);
|
|
|
|
#define kvm_xen_has_cap(cap) (!!(kvm_xen_get_caps() & \
|
|
KVM_XEN_HVM_CONFIG_ ## cap))
|
|
|
|
#define XEN_SPECIAL_AREA_ADDR 0xfeff8000UL
|
|
#define XEN_SPECIAL_AREA_SIZE 0x4000UL
|
|
|
|
#define XEN_SPECIALPAGE_CONSOLE 0
|
|
#define XEN_SPECIALPAGE_XENSTORE 1
|
|
|
|
#define XEN_SPECIAL_PFN(x) ((XEN_SPECIAL_AREA_ADDR >> TARGET_PAGE_BITS) + \
|
|
XEN_SPECIALPAGE_##x)
|
|
|
|
#endif /* QEMU_SYSEMU_KVM_XEN_H */
|