[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] amd-vi: set the size flag in the IOTLB page invalidation command


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Wed, 14 Oct 2026 09:51:42 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=63JVV+iMj3kFDQfc/Papuas4qCGoPPdfcLCYLdJ7awI=; b=r4LkB8ci6jKKKMKNcf6BsdZFVbnzdUVVvPPnvoflyPC9nChgF7Wy/mEf3oJuIMIdNOzgh+SWdw/rk/zn1lUhYX5DMS2jWnXEYj5l0h0vxZ2wdqzacKGTFhaZokAa9TGCgS1NEZ5zMpluugzKkyFLDUYd6BjTyLURlh+Mb1G7lumXFwjOBaluMo5PBwA5GMG2Z79gZhFDv48zkqFa9Z2EN6A8urgf98T87LbTEhfFBgOdaDKmFvUA5zMVI3EALnNTS2UN0kCnBKyOHtWJRvm6xAuvyZun+ESHmyTz3hYR+J8xYBXo8cup7oZqERImmqEF7c3MgDuqOkwHjp3lKPLpPw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=poryjatiZUG+UBswC6xe/NFumxaJbjNRM91jIfZbWyuFvgfVhkfWlqmWKgMmGEl0IE4Kx2GF/aD0yqmSv/VhwTDxj/TqGqz9r5Qn6iIDfDZvYy1VB8ifZZRM0xDRtDWvmCQss22FdQOFUQcABSL7NyAknwjlHwH3EPZyYq4BhYmiJcmLYsFJ0mWTDXtKbVUEE7nN8Rc8mSzbqDg/jzwjveZ6m/OyFeghhVCO3r30LRhZYm1N2e0u++jzBVSLofkioLbIA33NxeuOqtNPwL/VTfD0zhLuQ5j6+hhpDatzLuTT9ZUsN407tAuZL8aVKCllIZA9TzUR+EsU1VWGE6YY7g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Stefano Stabellini <stefano.stabellini@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, "Xenia Ragiadakou" <xenia.ragiadakou@xxxxxxx>
  • Delivery-date: Wed, 14 Oct 2026 13:52:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Stefano Stabellini <stefano.stabellini@xxxxxxx>

The S bit of an INVALIDATE_IOTLB_PAGES command selects between the two
sizes the command can name: cleared, the invalidation covers 4 Kbytes;
set, it covers the range encoded by the first zero bit of the address,
counting from bit 12. invalidate_iotlb_pages() builds that encoding
whenever it is given a non-zero order or the all-pages address, and then
passes the field's mask where set_field_in_reg_u32() expects the shift.
The correct mask is 1 and the shift is 0.  When mask (1) is passed for
both, the value is shifted out of the field it was to occupy and the
bit is left clear.  i.e. (x << 1) & 1 is always 0.

An endpoint holding translations of its own is therefore told to drop one
page where it should have dropped a range.  The rest of the range is
kept in its cache after the page tables backing it have changed.

Pass the shift, as the sibling INVALIDATE_IOMMU_PAGES builder does.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
Reviewed-by: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>
[ Reword commit message. ]
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
This was submitted to the security list, but it is out of scope.  Xenia
reviewed internally and Jan reviewed from the security list.

 xen/drivers/passthrough/amd/iommu_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/amd/iommu_cmd.c 
b/xen/drivers/passthrough/amd/iommu_cmd.c
index 665e882a2d..abfbdf2b28 100644
--- a/xen/drivers/passthrough/amd/iommu_cmd.c
+++ b/xen/drivers/passthrough/amd/iommu_cmd.c
@@ -212,7 +212,7 @@ static void invalidate_iotlb_pages(struct amd_iommu *iommu,
 
     set_field_in_reg_u32(sflag, 0,
                          IOMMU_INV_IOTLB_PAGES_S_FLAG_MASK,
-                         IOMMU_INV_IOTLB_PAGES_S_FLAG_MASK, &entry);
+                         IOMMU_INV_IOTLB_PAGES_S_FLAG_SHIFT, &entry);
 
     set_field_in_reg_u32((u32)addr_lo >> PAGE_SHIFT, entry,
                          IOMMU_INV_IOTLB_PAGES_ADDR_LOW_MASK,
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.