Merge branch 'xenfv-kvm-15' of git://git.infradead.org/users/dwmw2/qemu into HEAD

This adds support for emulating Xen under Linux/KVM, based on kernel
patches which have been present since Linux v5.12. As with the kernel
support, it's derived from work started by João Martins of Oracle in
2018.

This series just adds the basic platform support — CPUID, hypercalls,
event channels, a stub of XenStore.

A full single-tenant internal implementation of XenStore, and patches
to make QEMU's Xen PV drivers work with this Xen emulation, are waiting
in the wings to be submitted in a follow-on patch series.

As noted in the documentation, it's enabled by setting the xen-version
property on the KVM accelerator, e.g.:

 qemu-system-x86_64 -serial mon:stdio -M q35 -display none -m 1G -smp 2 \
    -accel kvm,xen-version=0x4000e,kernel-irqchip=split \
    -kernel vmlinuz-6.0.7-301.fc37.x86_64 \
    -append "console=ttyS0 root=/dev/sda1" \
    -drive file=/var/lib/libvirt/images/fedora28.qcow2,if=none,id=disk \
    -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0

Even before this was merged, we've already been using it to find and fix
bugs in the Linux kernel Xen guest support:

https://lore.kernel.org/all/4bffa69a949bfdc92c4a18e5a1c3cbb3b94a0d32.camel@infradead.org/
https://lore.kernel.org/all/871qnunycr.ffs@tglx/

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Paolo Bonzini 2023-03-01 15:02:13 +01:00
commit 526947e496
243 changed files with 15638 additions and 2170 deletions

View file

@ -380,3 +380,119 @@
#
##
{ 'command': 'query-sgx-capabilities', 'returns': 'SGXInfo', 'if': 'TARGET_I386' }
##
# @EvtchnPortType:
#
# An enumeration of Xen event channel port types.
#
# @closed: The port is unused.
#
# @unbound: The port is allocated and ready to be bound.
#
# @interdomain: The port is connected as an interdomain interrupt.
#
# @pirq: The port is bound to a physical IRQ (PIRQ).
#
# @virq: The port is bound to a virtual IRQ (VIRQ).
#
# @ipi: The post is an inter-processor interrupt (IPI).
#
# Since: 8.0
##
{ 'enum': 'EvtchnPortType',
'data': ['closed', 'unbound', 'interdomain', 'pirq', 'virq', 'ipi'],
'if': 'TARGET_I386' }
##
# @EvtchnInfo:
#
# Information about a Xen event channel port
#
# @port: the port number
#
# @vcpu: target vCPU for this port
#
# @type: the port type
#
# @remote-domain: remote domain for interdomain ports
#
# @target: remote port ID, or virq/pirq number
#
# @pending: port is currently active pending delivery
#
# @masked: port is masked
#
# Since: 8.0
##
{ 'struct': 'EvtchnInfo',
'data': {'port': 'uint16',
'vcpu': 'uint32',
'type': 'EvtchnPortType',
'remote-domain': 'str',
'target': 'uint16',
'pending': 'bool',
'masked': 'bool'},
'if': 'TARGET_I386' }
##
# @xen-event-list:
#
# Query the Xen event channels opened by the guest.
#
# Returns: list of open event channel ports.
#
# Since: 8.0
#
# Example:
#
# -> { "execute": "xen-event-list" }
# <- { "return": [
# {
# "pending": false,
# "port": 1,
# "vcpu": 1,
# "remote-domain": "qemu",
# "masked": false,
# "type": "interdomain",
# "target": 1
# },
# {
# "pending": false,
# "port": 2,
# "vcpu": 0,
# "remote-domain": "",
# "masked": false,
# "type": "virq",
# "target": 0
# }
# ]
# }
#
##
{ 'command': 'xen-event-list',
'returns': ['EvtchnInfo'],
'if': 'TARGET_I386' }
##
# @xen-event-inject:
#
# Inject a Xen event channel port (interrupt) to the guest.
#
# @port: The port number
#
# Returns: - Nothing on success.
#
# Since: 8.0
#
# Example:
#
# -> { "execute": "xen-event-inject", "arguments": { "port": 1 } }
# <- { "return": { } }
#
##
{ 'command': 'xen-event-inject',
'data': { 'port': 'uint32' },
'if': 'TARGET_I386' }