qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Zhenzhong Duan" <zhenzhong.duan@intel.com>,
	"Clément Mathieu--Drif" <clement.mathieu--drif@eviden.com>,
	"Yi Liu" <yi.l.liu@intel.com>, "Jason Wang" <jasowang@redhat.com>,
	"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Eduardo Habkost" <eduardo@habkost.net>
Subject: [PULL 08/18] intel_iommu: Fix invalidation descriptor type field
Date: Wed, 11 Sep 2024 09:51:48 -0400	[thread overview]
Message-ID: <663168943d3db6d9b51d3dfa0998848a6e6eda71.1726062663.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1726062663.git.mst@redhat.com>

From: Zhenzhong Duan <zhenzhong.duan@intel.com>

According to spec, invalidation descriptor type is 7bits which is
concatenation of bits[11:9] and bits[3:0] of invalidation descriptor.

Currently we only pick bits[3:0] as the invalidation type and treat
bits[11:9] as reserved zero. This is not a problem for now as bits[11:9]
is zero for all current invalidation types. But it will break if newer
type occupies bits[11:9].

Fix it by taking bits[11:9] into type and make reserved bits check accurate.

Suggested-by: Clément Mathieu--Drif<clement.mathieu--drif@eviden.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Yi Liu <yi.l.liu@intel.com>
Reviewed-by: Clément Mathieu--Drif<clement.mathieu--drif@eviden.com>
Message-Id: <20240814071321.2621384-2-zhenzhong.duan@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/i386/intel_iommu_internal.h | 11 ++++++-----
 hw/i386/intel_iommu.c          |  2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h
index 5f32c36943..13d5d129ae 100644
--- a/hw/i386/intel_iommu_internal.h
+++ b/hw/i386/intel_iommu_internal.h
@@ -356,7 +356,8 @@ union VTDInvDesc {
 typedef union VTDInvDesc VTDInvDesc;
 
 /* Masks for struct VTDInvDesc */
-#define VTD_INV_DESC_TYPE               0xf
+#define VTD_INV_DESC_TYPE(val)          ((((val) >> 5) & 0x70ULL) | \
+                                         ((val) & 0xfULL))
 #define VTD_INV_DESC_CC                 0x1 /* Context-cache Invalidate Desc */
 #define VTD_INV_DESC_IOTLB              0x2
 #define VTD_INV_DESC_DEVICE             0x3
@@ -372,7 +373,7 @@ typedef union VTDInvDesc VTDInvDesc;
 #define VTD_INV_DESC_WAIT_IF            (1ULL << 4)
 #define VTD_INV_DESC_WAIT_FN            (1ULL << 6)
 #define VTD_INV_DESC_WAIT_DATA_SHIFT    32
-#define VTD_INV_DESC_WAIT_RSVD_LO       0Xffffff80ULL
+#define VTD_INV_DESC_WAIT_RSVD_LO       0Xfffff180ULL
 #define VTD_INV_DESC_WAIT_RSVD_HI       3ULL
 
 /* Masks for Context-cache Invalidation Descriptor */
@@ -383,7 +384,7 @@ typedef union VTDInvDesc VTDInvDesc;
 #define VTD_INV_DESC_CC_DID(val)        (((val) >> 16) & VTD_DOMAIN_ID_MASK)
 #define VTD_INV_DESC_CC_SID(val)        (((val) >> 32) & 0xffffUL)
 #define VTD_INV_DESC_CC_FM(val)         (((val) >> 48) & 3UL)
-#define VTD_INV_DESC_CC_RSVD            0xfffc00000000ffc0ULL
+#define VTD_INV_DESC_CC_RSVD            0xfffc00000000f1c0ULL
 
 /* Masks for IOTLB Invalidate Descriptor */
 #define VTD_INV_DESC_IOTLB_G            (3ULL << 4)
@@ -393,7 +394,7 @@ typedef union VTDInvDesc VTDInvDesc;
 #define VTD_INV_DESC_IOTLB_DID(val)     (((val) >> 16) & VTD_DOMAIN_ID_MASK)
 #define VTD_INV_DESC_IOTLB_ADDR(val)    ((val) & ~0xfffULL)
 #define VTD_INV_DESC_IOTLB_AM(val)      ((val) & 0x3fULL)
-#define VTD_INV_DESC_IOTLB_RSVD_LO      0xffffffff0000ff00ULL
+#define VTD_INV_DESC_IOTLB_RSVD_LO      0xffffffff0000f100ULL
 #define VTD_INV_DESC_IOTLB_RSVD_HI      0xf80ULL
 #define VTD_INV_DESC_IOTLB_PASID_PASID  (2ULL << 4)
 #define VTD_INV_DESC_IOTLB_PASID_PAGE   (3ULL << 4)
@@ -406,7 +407,7 @@ typedef union VTDInvDesc VTDInvDesc;
 #define VTD_INV_DESC_DEVICE_IOTLB_SIZE(val) ((val) & 0x1)
 #define VTD_INV_DESC_DEVICE_IOTLB_SID(val) (((val) >> 32) & 0xFFFFULL)
 #define VTD_INV_DESC_DEVICE_IOTLB_RSVD_HI 0xffeULL
-#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0fff8
+#define VTD_INV_DESC_DEVICE_IOTLB_RSVD_LO 0xffff0000ffe0f1f0
 
 /* Rsvd field masks for spte */
 #define VTD_SPTE_SNP 0x800ULL
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 16d2885fcc..68cb72a481 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2744,7 +2744,7 @@ static bool vtd_process_inv_desc(IntelIOMMUState *s)
         return false;
     }
 
-    desc_type = inv_desc.lo & VTD_INV_DESC_TYPE;
+    desc_type = VTD_INV_DESC_TYPE(inv_desc.lo);
     /* FIXME: should update at first or at last? */
     s->iq_last_desc_type = desc_type;
 
-- 
MST



  parent reply	other threads:[~2024-09-11 15:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11 13:51 [PULL 00/18] virtio,pc,pci: features, fixes, cleanups Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 01/18] virtio: Allow .get_vhost() without vhost_started Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 02/18] virtio: Always reset vhost devices Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 03/18] hw: Move declaration of IRQState to header and add init function Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 04/18] hw/isa/vt82c686.c: Embed i8259 irq in device state instead of allocating Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 05/18] pci: don't skip function 0 occupancy verification for devfn auto assign Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 06/18] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 07/18] virtio: rename virtio_split_packed_update_used_idx Michael S. Tsirkin
2024-09-11 13:51 ` Michael S. Tsirkin [this message]
2024-09-11 13:51 ` [PULL 09/18] intel_iommu: Make PASID-cache and PIOTLB type invalid in legacy mode Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 10/18] tests/acpi: pc: allow DSDT acpi table changes Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 11/18] hw/i386/acpi-build: Return a pre-computed _PRT table Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 12/18] tests/acpi: pc: update golden masters for DSDT Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 13/18] vhost_net: configure all host notifiers in a single MR transaction Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 14/18] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR Michael S. Tsirkin
2024-09-17 20:19   ` Peter Xu
2024-09-11 13:52 ` [PULL 15/18] hw/cxl: fix physical address field in get scan media results output Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 16/18] hw/audio/virtio-sound: fix heap buffer overflow Michael S. Tsirkin
2024-09-13 18:47   ` Volker Rümelin
2024-09-11 13:52 ` [PULL 17/18] virtio-mem: don't warn about THP sizes on a kernel without THP support Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 18/18] hw/acpi/ich9: Add periodic and swsmi timer Michael S. Tsirkin
2024-09-13  9:24 ` [PULL 00/18] virtio,pc,pci: features, fixes, cleanups Peter Maydell

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=663168943d3db6d9b51d3dfa0998848a6e6eda71.1726062663.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=clement.mathieu--drif@eviden.com \
    --cc=eduardo@habkost.net \
    --cc=jasowang@redhat.com \
    --cc=marcel.apfelbaum@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=yi.l.liu@intel.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).