Skip to content

Commit

Permalink
Merge tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/m…
Browse files Browse the repository at this point in the history
…st/qemu into staging

virtio,pci: features, cleanups

vdpa:
      shadow vq vlan support
      net migration with cvq
cxl:
     dummy ACPI QTG DSM
     support emulating 4 HDM decoders
     serial number extended capability
virtio:
      hared dma-buf

Fixes, cleanups all over the place.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

* tag 'for_upstream' of https://git.kernel.org/pub/scm/virt/kvm/mst/qemu: (63 commits)
  libvhost-user: handle shared_object msg
  vhost-user: add shared_object msg
  hw/display: introduce virtio-dmabuf
  util/uuid: add a hash function
  virtio: remove unused next argument from virtqueue_split_read_next_desc()
  virtio: remove unnecessary thread fence while reading next descriptor
  virtio: use shadow_avail_idx while checking number of heads
  libvhost-user.c: add assertion to vu_message_read_default
  pcie_sriov: unregister_vfs(): fix error path
  hw/i386/pc: improve physical address space bound check for 32-bit x86 systems
  amd_iommu: Fix APIC address check
  vdpa net: follow VirtIO initialization properly at cvq isolation probing
  vdpa net: stop probing if cannot set features
  vdpa net: fix error message setting virtio status
  hw/pci-bridge/cxl-upstream: Add serial number extended capability support
  hw/cxl: Support 4 HDM decoders at all levels of topology
  hw/cxl: Fix and use same calculation for HDM decoder block size everywhere
  hw/cxl: Add utility functions decoder interleave ways and target count.
  hw/cxl: Push cxl_decoder_count_enc() and cxl_decode_ig() into .c
  vdpa net: zero vhost_vdpa iova_tree pointer at cleanup
  ...

Conflicts:
  hw/core/machine.c
  Context conflict due to #include changes in commit
  314e0a8 ("hw/core: remove needless
  includes").
  • Loading branch information
stefanhaRH committed Oct 4, 2023
2 parents 7e4b79d + 603cf71 commit e6fe25c
Show file tree
Hide file tree
Showing 74 changed files with 2,186 additions and 552 deletions.
7 changes: 7 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2154,6 +2154,13 @@ T: git https://gitlab.com/cohuck/qemu.git s390-next
T: git https://github.com/borntraeger/qemu.git s390-next
L: qemu-s390x@nongnu.org

virtio-dmabuf
M: Albert Esteve <aesteve@redhat.com>
S: Supported
F: hw/display/virtio-dmabuf.c
F: include/hw/virtio/virtio-dmabuf.h
F: tests/unit/test-virtio-dmabuf.c

virtiofs
M: Stefan Hajnoczi <stefanha@redhat.com>
S: Supported
Expand Down
57 changes: 57 additions & 0 deletions docs/interop/vhost-user.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,18 @@ Front-end message types
query the back-end for its device status as defined in the Virtio
specification.

``VHOST_USER_GET_SHARED_OBJECT``
:id: 41
:equivalent ioctl: N/A
:request payload: ``struct VhostUserShared``
:reply payload: dmabuf fd

When the ``VHOST_USER_PROTOCOL_F_SHARED_OBJECT`` protocol
feature has been successfully negotiated, and the UUID is found
in the exporters cache, this message is submitted by the front-end
to retrieve a given dma-buf fd from a given back-end, determined by
the requested UUID. Back-end will reply passing the fd when the operation
is successful, or no fd otherwise.

Back-end message types
----------------------
Expand Down Expand Up @@ -1528,6 +1540,51 @@ is sent by the front-end.

The state.num field is currently reserved and must be set to 0.

``VHOST_USER_BACKEND_SHARED_OBJECT_ADD``
:id: 6
:equivalent ioctl: N/A
:request payload: ``struct VhostUserShared``
:reply payload: N/A

When the ``VHOST_USER_PROTOCOL_F_SHARED_OBJECT`` protocol
feature has been successfully negotiated, this message can be submitted
by the backends to add themselves as exporters to the virtio shared lookup
table. The back-end device gets associated with a UUID in the shared table.
The back-end is responsible of keeping its own table with exported dma-buf fds.
When another back-end tries to import the resource associated with the UUID,
it will send a message to the front-end, which will act as a proxy to the
exporter back-end. If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and
the back-end sets the ``VHOST_USER_NEED_REPLY`` flag, the front-end must
respond with zero when operation is successfully completed, or non-zero
otherwise.

``VHOST_USER_BACKEND_SHARED_OBJECT_REMOVE``
:id: 7
:equivalent ioctl: N/A
:request payload: ``struct VhostUserShared``
:reply payload: N/A

When the ``VHOST_USER_PROTOCOL_F_SHARED_OBJECT`` protocol
feature has been successfully negotiated, this message can be submitted
by the backend to remove themselves from to the virtio-dmabuf shared
table API. The shared table will remove the back-end device associated with
the UUID. If ``VHOST_USER_PROTOCOL_F_REPLY_ACK`` is negotiated, and the
back-end sets the ``VHOST_USER_NEED_REPLY`` flag, the front-end must respond
with zero when operation is successfully completed, or non-zero otherwise.

``VHOST_USER_BACKEND_SHARED_OBJECT_LOOKUP``
:id: 8
:equivalent ioctl: N/A
:request payload: ``struct VhostUserShared``
:reply payload: dmabuf fd and ``u64``

When the ``VHOST_USER_PROTOCOL_F_SHARED_OBJECT`` protocol
feature has been successfully negotiated, this message can be submitted
by the backends to retrieve a given dma-buf fd from the virtio-dmabuf
shared table given a UUID. Frontend will reply passing the fd and a zero
when the operation is successful, or non-zero otherwise. Note that if the
operation fails, no fd is sent to the backend.

.. _reply_ack:

VHOST_USER_PROTOCOL_F_REPLY_ACK
Expand Down
6 changes: 0 additions & 6 deletions hw/acpi/acpi-x86-stub.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#include "qemu/osdep.h"
#include "hw/i386/pc.h"
#include "hw/i386/acpi-build.h"

void pc_madt_cpu_entry(int uid, const CPUArchIdList *apic_ids,
GArray *entry, bool force_enabled)
{
}

Object *acpi_get_i386_pci_host(void)
{
return NULL;
Expand Down
9 changes: 9 additions & 0 deletions hw/acpi/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "qemu/module.h"
#include "qemu/option.h"
#include "sysemu/runstate.h"
#include "trace.h"

struct acpi_table_header {
uint16_t _length; /* our length, not actual part of the hdr */
Expand Down Expand Up @@ -688,9 +689,11 @@ void acpi_gpe_ioport_writeb(ACPIREGS *ar, uint32_t addr, uint32_t val)

cur = acpi_gpe_ioport_get_ptr(ar, addr);
if (addr < ar->gpe.len / 2) {
trace_acpi_gpe_sts_ioport_writeb(addr, val);
/* GPE_STS */
*cur = (*cur) & ~val;
} else if (addr < ar->gpe.len) {
trace_acpi_gpe_en_ioport_writeb(addr - (ar->gpe.len / 2), val);
/* GPE_EN */
*cur = val;
} else {
Expand All @@ -709,6 +712,12 @@ uint32_t acpi_gpe_ioport_readb(ACPIREGS *ar, uint32_t addr)
val = *cur;
}

if (addr < ar->gpe.len / 2) {
trace_acpi_gpe_sts_ioport_readb(addr, val);
} else {
trace_acpi_gpe_en_ioport_readb(addr - (ar->gpe.len / 2), val);
}

return val;
}

Expand Down
9 changes: 3 additions & 6 deletions hw/acpi/cpu.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "qemu/osdep.h"
#include "migration/vmstate.h"
#include "hw/acpi/cpu.h"
#include "hw/core/cpu.h"
#include "qapi/error.h"
#include "qapi/qapi-events-acpi.h"
#include "trace.h"
Expand Down Expand Up @@ -338,7 +339,7 @@ const VMStateDescription vmstate_cpu_hotplug = {
#define CPU_FW_EJECT_EVENT "CEJF"

void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
hwaddr io_base,
build_madt_cpu_fn build_madt_cpu, hwaddr io_base,
const char *res_root,
const char *event_handler_method)
{
Expand All @@ -353,8 +354,6 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
MachineClass *mc = MACHINE_GET_CLASS(machine);
const CPUArchIdList *arch_ids = mc->possible_cpu_arch_ids(machine);
char *cphp_res_path = g_strdup_printf("%s." CPUHP_RES_DEVICE, res_root);
Object *obj = object_resolve_path_type("", TYPE_ACPI_DEVICE_IF, NULL);
AcpiDeviceIfClass *adevc = ACPI_DEVICE_IF_GET_CLASS(obj);

cpu_ctrl_dev = aml_device("%s", cphp_res_path);
{
Expand Down Expand Up @@ -664,9 +663,7 @@ void build_cpus_aml(Aml *table, MachineState *machine, CPUHotplugFeatures opts,
aml_append(dev, method);

/* build _MAT object */
assert(adevc && adevc->madt_cpu);
adevc->madt_cpu(i, arch_ids, madt_buf,
true); /* set enabled flag */
build_madt_cpu(i, arch_ids, madt_buf, true); /* set enabled flag */
aml_append(dev, aml_name_decl("_MAT",
aml_buffer(madt_buf->len, (uint8_t *)madt_buf->data)));
g_array_free(madt_buf, true);
Expand Down
57 changes: 57 additions & 0 deletions hw/acpi/cxl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,63 @@
#include "qapi/error.h"
#include "qemu/uuid.h"

void build_cxl_dsm_method(Aml *dev)
{
Aml *method, *ifctx, *ifctx2;

method = aml_method("_DSM", 4, AML_SERIALIZED);
{
Aml *function, *uuid;

uuid = aml_arg(0);
function = aml_arg(2);
/* CXL spec v3.0 9.17.3.1 *, QTG ID _DSM */
ifctx = aml_if(aml_equal(
uuid, aml_touuid("F365F9A6-A7DE-4071-A66A-B40C0B4F8E52")));

/* Function 0, standard DSM query function */
ifctx2 = aml_if(aml_equal(function, aml_int(0)));
{
uint8_t byte_list[1] = { 0x01 }; /* functions 1 only */

aml_append(ifctx2,
aml_return(aml_buffer(sizeof(byte_list), byte_list)));
}
aml_append(ifctx, ifctx2);

/*
* Function 1
* A return value of {1, {0}} inciate that
* max supported QTG ID of 1 and recommended QTG is 0.
* The values here are faked to simplify emulation.
*/
ifctx2 = aml_if(aml_equal(function, aml_int(1)));
{
uint16_t word_list[1] = { 0x01 };
uint16_t word_list2[1] = { 0 };
uint8_t *byte_list = (uint8_t *)word_list;
uint8_t *byte_list2 = (uint8_t *)word_list2;
Aml *pak, *pak1;

/*
* The return package is a package of a WORD and another package.
* The embedded package contains 0 or more WORDs for the
* recommended QTG IDs.
*/
pak1 = aml_package(1);
aml_append(pak1, aml_buffer(sizeof(uint16_t), byte_list2));
pak = aml_package(2);
aml_append(pak, aml_buffer(sizeof(uint16_t), byte_list));
aml_append(pak, pak1);

aml_append(ifctx2, aml_return(pak));
}
aml_append(ifctx, ifctx2);
}
aml_append(method, ifctx);
aml_append(dev, method);
}

static void cedt_build_chbs(GArray *table_data, PXBCXLDev *cxl)
{
PXBDev *pxb = PXB_DEV(cxl);
Expand Down
1 change: 1 addition & 0 deletions hw/acpi/hmat.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "qemu/osdep.h"
#include "qemu/units.h"
#include "sysemu/numa.h"
#include "hw/acpi/aml-build.h"
#include "hw/acpi/hmat.h"

/*
Expand Down
3 changes: 2 additions & 1 deletion hw/acpi/hmat.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
#ifndef HMAT_H
#define HMAT_H

#include "hw/acpi/aml-build.h"
#include "hw/acpi/bios-linker-loader.h"
#include "sysemu/numa.h"

/*
* ACPI 6.3: 5.2.27.3 Memory Proximity Domain Attributes Structure,
Expand Down
1 change: 1 addition & 0 deletions hw/acpi/memory_hotplug.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "qemu/osdep.h"
#include "hw/acpi/memory_hotplug.h"
#include "hw/mem/pc-dimm.h"
#include "hw/boards.h"
#include "hw/qdev-core.h"
#include "migration/vmstate.h"
#include "trace.h"
Expand Down
5 changes: 0 additions & 5 deletions hw/acpi/piix4.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
*/

#include "qemu/osdep.h"
#include "hw/i386/pc.h"
#include "hw/irq.h"
#include "hw/isa/apm.h"
#include "hw/i2c/pm_smbus.h"
Expand All @@ -43,7 +42,6 @@
#include "hw/acpi/acpi_dev_interface.h"
#include "migration/vmstate.h"
#include "hw/core/cpu.h"
#include "trace.h"
#include "qom/object.h"

#define GPE_BASE 0xafe0
Expand Down Expand Up @@ -518,7 +516,6 @@ static uint64_t gpe_readb(void *opaque, hwaddr addr, unsigned width)
PIIX4PMState *s = opaque;
uint32_t val = acpi_gpe_ioport_readb(&s->ar, addr);

trace_piix4_gpe_readb(addr, width, val);
return val;
}

Expand All @@ -527,7 +524,6 @@ static void gpe_writeb(void *opaque, hwaddr addr, uint64_t val,
{
PIIX4PMState *s = opaque;

trace_piix4_gpe_writeb(addr, width, val);
acpi_gpe_ioport_writeb(&s->ar, addr, val);
acpi_update_sci(&s->ar, s->irq);
}
Expand Down Expand Up @@ -654,7 +650,6 @@ static void piix4_pm_class_init(ObjectClass *klass, void *data)
hc->is_hotpluggable_bus = piix4_is_hotpluggable_bus;
adevc->ospm_status = piix4_ospm_status;
adevc->send_event = piix4_send_gpe;
adevc->madt_cpu = pc_madt_cpu_entry;
}

static const TypeInfo piix4_pm_info = {
Expand Down
10 changes: 6 additions & 4 deletions hw/acpi/trace-events
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ mhp_acpi_clear_remove_evt(uint32_t slot) "slot[0x%"PRIx32"] clear remove event"
mhp_acpi_pc_dimm_deleted(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm deleted"
mhp_acpi_pc_dimm_delete_failed(uint32_t slot) "slot[0x%"PRIx32"] pc-dimm delete failed"

# core.c
acpi_gpe_en_ioport_readb(uint32_t addr, uint8_t val) "addr: 0x%" PRIx32 " ==> 0x%02" PRIx8
acpi_gpe_en_ioport_writeb(uint32_t addr, uint8_t val) "addr: 0x%" PRIx32 " <== 0x%02" PRIx8
acpi_gpe_sts_ioport_readb(uint32_t addr, uint8_t val) "addr: 0x%" PRIx32 " ==> 0x%02" PRIx8
acpi_gpe_sts_ioport_writeb(uint32_t addr, uint8_t val) "addr: 0x%" PRIx32 " <== 0x%02" PRIx8

# cpu.c
cpuhp_acpi_invalid_idx_selected(uint32_t idx) "0x%"PRIx32
cpuhp_acpi_read_flags(uint32_t idx, uint8_t flags) "idx[0x%"PRIx32"] flags: 0x%"PRIx8
Expand Down Expand Up @@ -48,10 +54,6 @@ acpi_pci_sel_read(uint32_t val) "%" PRIu32
acpi_pci_ej_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64
acpi_pci_sel_write(uint64_t addr, uint64_t data) "0x%" PRIx64 " <== %" PRIu64

# piix4.c
piix4_gpe_readb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d ==> 0x%" PRIx64
piix4_gpe_writeb(uint64_t addr, unsigned width, uint64_t val) "addr: 0x%" PRIx64 " width: %d <== 0x%" PRIx64

# tco.c
tco_timer_reload(int ticks, int msec) "ticks=%d (%d ms)"
tco_timer_expired(int timeouts_no, bool strap, bool no_reboot) "timeouts_no=%d no_reboot=%d/%d"
Expand Down
5 changes: 4 additions & 1 deletion hw/core/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@
#include "sysemu/runstate.h"
#include "sysemu/xen.h"
#include "sysemu/qtest.h"
#include "hw/pci/pci_bridge.h"
#include "hw/mem/nvdimm.h"
#include "migration/global_state.h"
#include "exec/confidential-guest-support.h"
#include "hw/virtio/virtio-pci.h"
#include "hw/virtio/virtio-net.h"
#include "audio/audio.h"

GlobalProperty hw_compat_8_1[] = {};
GlobalProperty hw_compat_8_1[] = {
{ TYPE_PCI_BRIDGE, "x-pci-express-writeable-slt-bug", "true" },
};
const size_t hw_compat_8_1_len = G_N_ELEMENTS(hw_compat_8_1);

GlobalProperty hw_compat_8_0[] = {
Expand Down

0 comments on commit e6fe25c

Please sign in to comment.