From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com,
jean-philippe@linaro.org, imammedo@redhat.com,
peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com,
zhenzhong.duan@intel.com
Cc: alex.williamson@redhat.com, jasowang@redhat.com,
pbonzini@redhat.com, berrange@redhat.com
Subject: [PATCH v6 7/9] hw/i386/q35: Set virtio-iommu aw-bits default value to 39
Date: Tue, 5 Mar 2024 19:06:25 +0100 [thread overview]
Message-ID: <20240305180734.48515-8-eric.auger@redhat.com> (raw)
In-Reply-To: <20240305180734.48515-1-eric.auger@redhat.com>
Currently the default input range can extend to 64 bits. On x86,
when the virtio-iommu protects vfio devices, the physical iommu
may support only 39 bits. Let's set the default to 39, as done
for the intel-iommu.
We use hw_compat_8_2 to handle the compatibility for machines
before 9.0 which used to have a virtio-iommu default input range
of 64 bits.
Of course if aw-bits is set from the command line, the default
is overriden.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
v5 -> v6:
- split pc/arm settings
v3 -> v4:
- update the qos test to relax the check on the max input IOVA
v2 -> v3:
- collected Zhenzhong's R-b
- use &error_abort instead of NULL error handle
on object_property_get_uint() call (Cédric)
- use VTD_HOST_AW_39BIT (Cédric)
v1 -> v2:
- set aw-bits to 48b on ARM
- use hw_compat_8_2 to handle the compat for older machines
which used 64b as a default
---
include/hw/i386/pc.h | 3 +++
hw/core/machine.c | 1 +
hw/i386/pc.c | 6 ++++++
hw/i386/pc_q35.c | 2 ++
tests/qtest/virtio-iommu-test.c | 2 +-
5 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 5065590281..b3229f98de 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -198,6 +198,9 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, size_t flash_size);
/* sgx.c */
void pc_machine_init_sgx_epc(PCMachineState *pcms);
+extern GlobalProperty pc_compat_defaults[];
+extern const size_t pc_compat_defaults_len;
+
extern GlobalProperty pc_compat_8_2[];
extern const size_t pc_compat_8_2_len;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 6bd09d4592..4b89172d1c 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -35,6 +35,7 @@
GlobalProperty hw_compat_8_2[] = {
{ TYPE_VIRTIO_IOMMU_PCI, "granule", "4k" },
+ { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "64" },
};
const size_t hw_compat_8_2_len = G_N_ELEMENTS(hw_compat_8_2);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index f5ff970acf..9024483356 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -59,6 +59,7 @@
#include "hw/i386/kvm/xen_evtchn.h"
#include "hw/i386/kvm/xen_gnttab.h"
#include "hw/i386/kvm/xen_xenstore.h"
+#include "hw/i386/intel_iommu.h"
#include "hw/mem/memory-device.h"
#include "e820_memory_layout.h"
#include "trace.h"
@@ -78,6 +79,11 @@
{ "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },\
{ "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, },
+GlobalProperty pc_compat_defaults[] = {
+ { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "39" },
+};
+const size_t pc_compat_defaults_len = G_N_ELEMENTS(pc_compat_defaults);
+
GlobalProperty pc_compat_8_2[] = {};
const size_t pc_compat_8_2_len = G_N_ELEMENTS(pc_compat_8_2);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 45a4102e75..32421a0a5f 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -356,6 +356,8 @@ static void pc_q35_machine_options(MachineClass *m)
machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE);
machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE);
+ compat_props_add(m->compat_props,
+ pc_compat_defaults, pc_compat_defaults_len);
}
static void pc_q35_9_0_machine_options(MachineClass *m)
diff --git a/tests/qtest/virtio-iommu-test.c b/tests/qtest/virtio-iommu-test.c
index 068e7a9e6c..0f36381acb 100644
--- a/tests/qtest/virtio-iommu-test.c
+++ b/tests/qtest/virtio-iommu-test.c
@@ -34,7 +34,7 @@ static void pci_config(void *obj, void *data, QGuestAllocator *t_alloc)
uint8_t bypass = qvirtio_config_readb(dev, 36);
g_assert_cmpint(input_range_start, ==, 0);
- g_assert_cmphex(input_range_end, ==, UINT64_MAX);
+ g_assert_cmphex(input_range_end, >=, 32);
g_assert_cmpint(domain_range_start, ==, 0);
g_assert_cmpint(domain_range_end, ==, UINT32_MAX);
g_assert_cmpint(bypass, ==, 1);
--
2.41.0
next prev parent reply other threads:[~2024-03-05 18:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 18:06 [PATCH v6 0/9] VIRTIO-IOMMU: Introduce aw-bits and granule options Eric Auger
2024-03-05 18:06 ` [PATCH v6 1/9] qdev: Add a granule_mode property Eric Auger
2024-03-05 18:06 ` [PATCH v6 2/9] virtio-iommu: Add a granule property Eric Auger
2024-03-05 18:06 ` [PATCH v6 3/9] virtio-iommu: Change the default granule to the host page size Eric Auger
2024-03-05 18:06 ` [PATCH v6 4/9] qemu-options.hx: Document the virtio-iommu-pci granule option Eric Auger
2024-03-05 18:06 ` [PATCH v6 5/9] virtio-iommu: Trace domain range limits as unsigned int Eric Auger
2024-03-05 18:06 ` [PATCH v6 6/9] virtio-iommu: Add an option to define the input range width Eric Auger
2024-03-05 18:06 ` Eric Auger [this message]
2024-03-06 3:15 ` [PATCH v6 7/9] hw/i386/q35: Set virtio-iommu aw-bits default value to 39 Duan, Zhenzhong
2024-03-06 8:11 ` Eric Auger
2024-03-05 18:06 ` [PATCH v6 8/9] hw/arm/virt: Set virtio-iommu aw-bits default value to 48 Eric Auger
2024-03-06 3:25 ` Duan, Zhenzhong
2024-03-06 8:11 ` Eric Auger
2024-03-05 18:06 ` [PATCH v6 9/9] qemu-options.hx: Document the virtio-iommu-pci aw-bits option Eric Auger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240305180734.48515-8-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=imammedo@redhat.com \
--cc=jasowang@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=yanghliu@redhat.com \
--cc=zhenzhong.duan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).