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

Re: [PATCH] xen/arm: smmuv3: invalidate TLB when freeing a VMID


  • To: Leonid Komarianskyi <Leonid_Komarianskyi@xxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Wed, 28 Oct 2026 01:55:48 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=8JEB4TcI6rY9PoEiqupKaYUkobSukx5mh2G5+XgiwyQ=; b=TVOygFARYnPs8xmAQT5f1M8Pe2cW4dM0VWRLPnEpeAsDLE1En6TEhu5bsAHCZ4LY0g/aXvwDywIMYECafqVbmIAmraRq1Qiycj4QwO9c/oKOJQiKQmA9iW0zWcCB1uFbKilC55/aVR/cesLxBzm4hs7LGmFJo3t8hsUZbspZYoBf9eEa7VkUAPSjjP4dGUQpaedbe9ZGRNCOamJkOz+J+Wf1RZyQA+qzgNVNkfnT8KDCqsY+dySC4GNY/BT8agJINxNDAGzXDMuHy0vTHKVwRdrAnA1euW4RP2zqjFZ4GeOhim58JVypgKz6o+nP7nGaDdRBm7R//LEVmboc8eW/RQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fhZlJNUqVCSP5sPpEhetILpxiUPuD7GG5drBfJ4mJvMBMySNCxfzK6YXqdAqlet8jDFRfwOhaFl+UGtaSRFk/U515F8JGPx/X1hVj3ULTUxjui20PlYK8AT7DvFL8V16+BI0JH9wDMHSOh0OW8cwY0zACcnn0guDvlcg+CNMOjsPQ9rL4UeNjILFfj0cDOR6xrgDaNwzNGMgTDsL8jh3U4uN5lWJQ+lxgr3UUjY5NTPJHw0/NnQdsxYtr7tEvjtyj0DYC+8j6HZ7x7NJLezdtwsLHvI1RAw4kQbw36ZFcnEaYzFYB9UAlmD19vO6XG2ZvsxOQ0m6HF6DypV+A9P13g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Wed, 28 Oct 2026 01:55:59 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdZU2CvV133olROUKhJSegs8l4mg==
  • Thread-topic: [PATCH] xen/arm: smmuv3: invalidate TLB when freeing a VMID

Hi Leonid,

Leonid Komarianskyi <Leonid_Komarianskyi@xxxxxxxx> writes:

> arm_smmu_domain_free() releases the VMID without invalidating the SMMU
> TLB entries tagged with it. The VMID allocator (arm_smmu_bitmap_alloc)
> always returns the first free VMID, so a new domain usually gets the
> same VMID as the domain that was just destroyed. As a result, DMA from
> a device assigned to the new domain can use stale TLB entries and access
> memory of the old domain, which may already be in use by Xen or by
> another domain.
>
> In Linux, this invalidation is done by free_io_pgtable_ops(), which
> calls the tlb_flush_all callback (arm_smmu_tlb_inv_context()) before
> the VMID is released. The call was dropped when the io-pgtable code
> was removed during the port to Xen, and nothing replaced it.
>
> Linux guests that modify their P2M early in boot (e.g. by mapping
> shared_info in the xen_guest_init initcall) hide the problem, because
> the resulting IOTLB flush clears the stale entries. However, guests
> without Xen support (e.g. Linux with CONFIG_XEN disabled) do not modify
> the P2M early in boot, so the device keeps using stale SMMU TLB entries.
> This was observed as GPU rendering corruption after "xl destroy" and "xl
> create" of the same guest with CONFIG_XEN disabled.
>
> To fix the problem, issue a TLB invalidation for the VMID before
> releasing it.
>
> Fixes: b3be6ffb009c ("xen/arm: smmuv3: Remove Linux specific code that is not 
> usable in XEN")
> Signed-off-by: Leonid Komarianskyi <leonid_komarianskyi@xxxxxxxx>

Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>

> ---
>  xen/drivers/passthrough/arm/smmu-v3.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/xen/drivers/passthrough/arm/smmu-v3.c 
> b/xen/drivers/passthrough/arm/smmu-v3.c
> index bf153227dbd..93176e2fb21 100644
> --- a/xen/drivers/passthrough/arm/smmu-v3.c
> +++ b/xen/drivers/passthrough/arm/smmu-v3.c
> @@ -1153,8 +1153,14 @@ static void arm_smmu_domain_free(struct iommu_domain 
> *domain)
>       struct arm_smmu_device *smmu = smmu_domain->smmu;
>       struct arm_smmu_s2_cfg *cfg = &smmu_domain->s2_cfg;
>  
> -     if (cfg->vmid)
> +     if (cfg->vmid) {
> +             /*
> +              * Invalidate all entries tagged with this VMID
> +              * before it can be handed to another domain.
> +              */
> +             arm_smmu_tlb_inv_context(smmu_domain);
>               arm_smmu_bitmap_free(smmu->vmid_map, cfg->vmid);
> +     }
>  
>       xfree(smmu_domain);
>  }

-- 
WBR, Volodymyr


 


Rackspace

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