From: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
To: "Igor Mammedov" <imammedo@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org,
"Clément Mathieu--Drif" <clement.mathieu--drif@eviden.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Hanna Reitz" <hreitz@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
qemu-block@nongnu.org, "Jason Wang" <jasowang@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Ani Sinha" <anisinha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Kevin Wolf" <kwolf@redhat.com>, "Yi Liu" <yi.l.liu@intel.com>,
peterx@redhat.com
Subject: Re: [PATCH 18/18] hw/i386/x86-iommu: Remove X86IOMMUState::pt_supported field
Date: Thu, 12 Jun 2025 17:39:19 -0400 [thread overview]
Message-ID: <06a32bb9-087e-4508-881c-df26176ab71c@oracle.com> (raw)
In-Reply-To: <20250606154219.37957b34@imammedo.users.ipa.redhat.com>
On 6/6/25 9:42 AM, Igor Mammedov wrote:
> On Thu, 1 May 2025 23:04:56 +0200
> Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
>> @@ -1486,15 +1485,8 @@ static AddressSpace *amdvi_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
>> AMDVI_INT_ADDR_FIRST,
>> &amdvi_dev_as->iommu_ir, 1);
>>
>> - if (!x86_iommu->pt_supported) {
>> - memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false);
>> - memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu),
>> - true);
>> - } else {
>> - memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu),
>> - false);
>> - memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, true);
>> - }
>> + memory_region_set_enabled(&amdvi_dev_as->iommu_nodma, false);
>> + memory_region_set_enabled(MEMORY_REGION(&amdvi_dev_as->iommu), true);
>
> given default is 'true', this hunk seems to be backwards,
> shouldn't it be 'else' branch code
>
I believe this is trying to preserve the change recently introduced in:
31753d5a336f ("hw/i386/amd_iommu: Fix device setup failure when PT is on.")
However, that doesn't explain the logic of enabling those specific
memory regions, which I think is also prone to cause confusion. I tried
to explain the "trick" and argued against it here[0].
I am ultimately rewriting that code in a series to add DMA remap
support[1], which hopefully makes it easier to follow which memory
regions are active under specific configurations.
Thank you,
Alejandro
[0]
https://lore.kernel.org/qemu-devel/914314b3-611d-4da3-9050-3c8c1b881e40@oracle.com/
[1]
https://lore.kernel.org/qemu-devel/20250502021605.1795985-1-alejandro.j.jimenez@oracle.com/
>
>> }
>> return &iommu_as[devfn]->as;
>> }
>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>> index c980cecb4ee..cc08dc41441 100644
>> --- a/hw/i386/intel_iommu.c
>> +++ b/hw/i386/intel_iommu.c
>> @@ -1066,6 +1066,7 @@ static inline bool vtd_ce_type_check(X86IOMMUState *x86_iommu,
>> {
>> switch (vtd_ce_get_type(ce)) {
>> case VTD_CONTEXT_TT_MULTI_LEVEL:
>> + case VTD_CONTEXT_TT_PASS_THROUGH:
>> /* Always supported */
>> break;
>> case VTD_CONTEXT_TT_DEV_IOTLB:
>> @@ -1074,12 +1075,6 @@ static inline bool vtd_ce_type_check(X86IOMMUState *x86_iommu,
>> return false;
>> }
>> break;
>> - case VTD_CONTEXT_TT_PASS_THROUGH:
>> - if (!x86_iommu->pt_supported) {
>> - error_report_once("%s: PT specified but not supported", __func__);
>> - return false;
>> - }
>> - break;
>> default:
>> /* Unknown type */
>> error_report_once("%s: unknown ce type: %"PRIu32, __func__,
>> @@ -4520,7 +4515,7 @@ static void vtd_cap_init(IntelIOMMUState *s)
>> {
>> X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
>>
>> - s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND |
>> + s->cap = VTD_CAP_FRO | VTD_CAP_NFR | VTD_CAP_ND | VTD_ECAP_PT |
>> VTD_CAP_MAMV | VTD_CAP_PSI | VTD_CAP_SLLPS |
>> VTD_CAP_MGAW(s->aw_bits);
>> if (s->dma_drain) {
>> @@ -4548,10 +4543,6 @@ static void vtd_cap_init(IntelIOMMUState *s)
>> s->ecap |= VTD_ECAP_DT;
>> }
>>
>> - if (x86_iommu->pt_supported) {
>> - s->ecap |= VTD_ECAP_PT;
>> - }
>> -
>> if (s->caching_mode) {
>> s->cap |= VTD_CAP_CM;
>> }
>> diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
>> index d34a6849f4a..ca7cd953e98 100644
>> --- a/hw/i386/x86-iommu.c
>> +++ b/hw/i386/x86-iommu.c
>> @@ -129,7 +129,6 @@ static const Property x86_iommu_properties[] = {
>> DEFINE_PROP_ON_OFF_AUTO("intremap", X86IOMMUState,
>> intr_supported, ON_OFF_AUTO_AUTO),
>> DEFINE_PROP_BOOL("device-iotlb", X86IOMMUState, dt_supported, false),
>> - DEFINE_PROP_BOOL("pt", X86IOMMUState, pt_supported, true),
>> };
>>
>> static void x86_iommu_class_init(ObjectClass *klass, const void *data)
>
>
prev parent reply other threads:[~2025-06-12 21:40 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-01 21:04 [PATCH 00/18] hw/i386/pc: Remove deprecated 2.8 and 2.9 PC machines Philippe Mathieu-Daudé
2025-05-01 21:04 ` [PATCH 01/18] hw/i386/pc: Remove deprecated pc-q35-2.8 and pc-i440fx-2.8 machines Philippe Mathieu-Daudé
2025-06-03 15:21 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 02/18] hw/i386/pc: Remove pc_compat_2_8[] array Philippe Mathieu-Daudé
2025-06-03 15:21 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 03/18] hw/southbridge/ich9: Remove ICH9_LPC_SMI_F_BROADCAST_BIT definition Philippe Mathieu-Daudé
2025-06-03 15:25 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 04/18] hw/i386/kvm: Remove KVMClockState::mach_use_reliable_get_clock field Philippe Mathieu-Daudé
2025-06-03 15:27 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 05/18] hw/core/machine: Remove hw_compat_2_8[] array Philippe Mathieu-Daudé
2025-06-03 15:28 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 06/18] hw/block/pflash: Remove PFlashCFI01::old_multiple_chip_handling field Philippe Mathieu-Daudé
2025-06-05 15:06 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 07/18] hw/pci/pcie: Remove QEMU_PCIE_EXTCAP_INIT definition Philippe Mathieu-Daudé
2025-06-05 15:14 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 08/18] hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_DEVERR definition Philippe Mathieu-Daudé
2025-06-06 13:07 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 09/18] hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_LNKCTL definition Philippe Mathieu-Daudé
2025-06-06 13:10 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 10/18] hw/virtio/virtio-pci: Remove VIRTIO_PCI_FLAG_INIT_PM definition Philippe Mathieu-Daudé
2025-06-06 13:11 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 11/18] hw/nvram/fw_cfg: Remove FWCfgState::file_slots field Philippe Mathieu-Daudé
2025-06-06 13:24 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 12/18] hw/nvram/fw_cfg: Inline fw_cfg_file_slots() Philippe Mathieu-Daudé
2025-06-06 13:29 ` Igor Mammedov
2025-06-16 5:05 ` Philippe Mathieu-Daudé
2025-05-01 21:04 ` [PATCH 13/18] hw/i386/pc: Remove deprecated pc-q35-2.9 and pc-i440fx-2.9 machines Philippe Mathieu-Daudé
2025-06-06 13:30 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 14/18] hw/i386/pc: Remove pc_compat_2_9[] array Philippe Mathieu-Daudé
2025-06-06 13:31 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 15/18] hw/core/machine: Remove hw_compat_2_9[] array Philippe Mathieu-Daudé
2025-06-06 13:31 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 16/18] hw/net/virtio-net: Remove VirtIONet::mtu_bypass_backend field Philippe Mathieu-Daudé
2025-06-06 13:33 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 17/18] hw/pci-bridge/gen_pcie_rp: Remove GenPCIERootPort::migrate_msix field Philippe Mathieu-Daudé
2025-06-06 13:34 ` Igor Mammedov
2025-05-01 21:04 ` [PATCH 18/18] hw/i386/x86-iommu: Remove X86IOMMUState::pt_supported field Philippe Mathieu-Daudé
2025-06-06 13:42 ` Igor Mammedov
2025-06-12 21:39 ` Alejandro Jimenez [this message]
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=06a32bb9-087e-4508-881c-df26176ab71c@oracle.com \
--to=alejandro.j.jimenez@oracle.com \
--cc=anisinha@redhat.com \
--cc=clement.mathieu--drif@eviden.com \
--cc=eduardo@habkost.net \
--cc=hreitz@redhat.com \
--cc=imammedo@redhat.com \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.com \
--cc=yi.l.liu@intel.com \
--cc=zhao1.liu@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).