summary refs log tree commit diff stats
path: root/hw/core/sysbus-fdt.c
diff options
context:
space:
mode:
authorAmit Machhiwal <amachhiw@linux.ibm.com>2025-04-08 18:10:42 +0530
committerCédric Le Goater <clg@redhat.com>2025-04-25 09:01:37 +0200
commitd5e8e6195bcd37292657b5f69d7633b51670caf1 (patch)
tree4d58ab8146fc5f87243d5597e553a0b96626488f /hw/core/sysbus-fdt.c
parent6a7abe1c96bf5fbaa546c710b147f594c9db562e (diff)
downloadfocaccia-qemu-d5e8e6195bcd37292657b5f69d7633b51670caf1.tar.gz
focaccia-qemu-d5e8e6195bcd37292657b5f69d7633b51670caf1.zip
vfio/spapr: Fix L2 crash with PCI device passthrough and memory > 128G
An L2 KVM guest fails to boot inside a pSeries LPAR when booted with a
memory more than 128 GB and PCI device passthrough. The L2 guest also
crashes when it is booted with a memory greater than 128 GB and a PCI
device is hotplugged later.

The issue arises from a conditional check for `levels > 1` in
`spapr_tce_create_table()` within L1 KVM. This check is meant to prevent
multi-level TCEs, which are not supported by the PowerVM hypervisor. As
a result, when QEMU makes a `VFIO_IOMMU_SPAPR_TCE_CREATE` ioctl call
with `levels > 1`, it triggers the conditional check and returns
`EINVAL`, causing the guest to crash with the following errors:

 2025-03-04T06:36:36.133117Z qemu-system-ppc64: Failed to create a window, ret = -1 (Invalid argument)
 2025-03-04T06:36:36.133176Z qemu-system-ppc64: Failed to create SPAPR window: Invalid argument
 qemu: hardware error: vfio: DMA mapping failed, unable to continue

Fix this by checking the supported DDW "levels" returned by the
VFIO_IOMMU_SPAPR_TCE_GET_INFO ioctl before attempting the TCE create
ioctl in KVM.

The patch has been tested on KVM guests with memory configurations of up
to 390GB, and 450GB on PowerVM and bare-metal environments respectively.

Signed-off-by: Amit Machhiwal <amachhiw@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250408124042.2695955-3-amachhiw@linux.ibm.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/core/sysbus-fdt.c')
0 files changed, 0 insertions, 0 deletions