mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sairaj Kodilkar <sarunkod@amd.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
	<joro@8bytes.org>, <suravee.suthikulpanit@amd.com>,
	<vasant.hegde@amd.com>, <robin.murphy@arm.com>,
	<ashish.kalra@amd.com>, <will@kernel.org>
Subject: Re: [PATCH v2 1/2] amd/iommu: Preserve domain ids inside the kdump kernel
Date: Tue, 25 Nov 2025 12:02:56 +0530	[thread overview]
Message-ID: <175b697f-6e0b-43f8-86ec-82b0e550b88c@amd.com> (raw)
In-Reply-To: <20251124144458.GH153257@nvidia.com>



On 11/24/2025 8:14 PM, Jason Gunthorpe wrote:
> On Fri, Nov 21, 2025 at 02:41:15PM +0530, Sairaj Kodilkar wrote:
>> Currently AMD IOMMU driver does not reserve domain ids programmed in the
>> DTE while reusing the device table inside kdump kernel. This can cause
>> reallocation of these domain ids for newer domains that are created by
>> the kdump kernel, which can lead to potential IO_PAGE_FAULTs
>>
>> Hence reserve these ids inside pdom_ids.
>>
>> Fixes: 38e5f33ee359 ("iommu/amd: Reuse device table for kdump")
>> Signed-off-by: Sairaj Kodilkar <sarunkod@amd.com>
>> Reported-by: Jason Gunthorpe <jgg@nvidia.com>
>> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
>> ---
>>   drivers/iommu/amd/init.c | 23 ++++++++++++++++++++++-
>>   1 file changed, 22 insertions(+), 1 deletion(-)
> This seems OK
>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
>
> But the a point of this work was to remove this code:
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 48bca4dc8eb61f..1cd799913cbcd6 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2024,7 +2024,6 @@ static void set_dte_entry(struct amd_iommu *iommu,
>                            phys_addr_t top_paddr, unsigned int top_level)
>   {
>          u16 domid;
> -       u32 old_domid;
>          struct dev_table_entry *initial_dte;
>          struct dev_table_entry new = {};
>          struct protection_domain *domain = dev_data->domain;
> @@ -2080,7 +2079,6 @@ static void set_dte_entry(struct amd_iommu *iommu,
>          if (dev_data->ats_enabled)
>                  new.data[1] |= DTE_FLAG_IOTLB;
>   
> -       old_domid = READ_ONCE(dte->data[1]) & DEV_DOMID_MASK;
>          new.data[1] |= domid;
>   
>          /*
> @@ -2096,15 +2094,6 @@ static void set_dte_entry(struct amd_iommu *iommu,
>          set_dte_gcr3_table(iommu, dev_data, &new);
>   
>          update_dte256(iommu, dev_data, &new);
> -
> -       /*
> -        * A kdump kernel might be replacing a domain ID that was copied from
> -        * the previous kernel--if so, it needs to flush the translation cache
> -        * entries for the old domain ID that is being overwritten
> -        */
> -       if (old_domid) {
> -               amd_iommu_flush_tlb_domid(iommu, old_domid);
> -       }
>   }
>   
>   /*
>
> Under the reasoning that:
>   - domids in use by the prior kernel are reserved in the IDA and are
>     never used by this kernel
>   - domids in the IDA must be clean
>   - There is no reason to flush a domid until it is returned to the IDA
>   - detach_device() calls amd_iommu_domain_flush_all() before the
>     domain can be freed and the domid returned the IDA which clears the
>     IOTLB
>
> Please add a patch?

Thanks for the explaination
Will add the patch for it

Thanks
Sairaj


  reply	other threads:[~2025-11-25  6:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-21  9:11 [PATCH v2 0/2] " Sairaj Kodilkar
2025-11-21  9:11 ` [PATCH v2 1/2] " Sairaj Kodilkar
2025-11-24 14:44   ` Jason Gunthorpe
2025-11-25  6:32     ` Sairaj Kodilkar [this message]
2025-11-26  8:21     ` Vasant Hegde
2025-11-26 15:20       ` Jason Gunthorpe
2025-12-02  5:21         ` Vasant Hegde
2025-11-21  9:11 ` [PATCH v2 2/2] amd/iommu: Make protection domain ID functions non-static Sairaj Kodilkar
2025-12-02  5:23 ` [PATCH v2 0/2] amd/iommu: Preserve domain ids inside the kdump kernel Vasant Hegde
2025-12-19 10:29   ` Joerg Roedel

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=175b697f-6e0b-43f8-86ec-82b0e550b88c@amd.com \
    --to=sarunkod@amd.com \
    --cc=ashish.kalra@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    /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

all inboxes | Powered by JetHome®