From: Vasant Hegde <vasant.hegde@amd.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
Robin Murphy <robin.murphy@arm.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Will Deacon <will@kernel.org>
Cc: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
Joao Martins <joao.m.martins@oracle.com>,
Joerg Roedel <jroedel@suse.de>,
patches@lists.linux.dev
Subject: Re: [PATCH v2 10/14] iommu/amd: Remove conditions from domain free paths
Date: Mon, 2 Sep 2024 17:33:50 +0530 [thread overview]
Message-ID: <ff5cd6f8-4338-4174-81e0-9cd31442aa21@amd.com> (raw)
In-Reply-To: <10-v2-831cdc4d00f3+1a315-amd_iopgtbl_jgg@nvidia.com>
Jason,
On 8/30/2024 5:36 AM, Jason Gunthorpe wrote:
> Don't use tlb as some flag to indicate if protection_domain_alloc()
> completed. Have protection_domain_alloc() unwind itself in the normal
> kernel style and require protection_domain_free() only be called on
> successful results of protection_domain_alloc().
>
> Also, the amd_iommu_domain_free() op is never called by the core code with
> a NULL argument, so remove all the NULL tests as well.
>
> Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/amd/iommu.c | 29 ++++++++++-------------------
> 1 file changed, 10 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 806156632bf70a..e23b7f7bf5b65d 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2258,17 +2258,9 @@ static void cleanup_domain(struct protection_domain *domain)
>
> void protection_domain_free(struct protection_domain *domain)
> {
> - if (!domain)
> - return;
> -
> WARN_ON(!list_empty(&domain->dev_list));
> -
> - if (domain->iop.pgtbl.cfg.tlb)
> - free_io_pgtable_ops(&domain->iop.pgtbl.ops);
> -
> - if (domain->id)
> - domain_id_free(domain->id);
> -
> + free_io_pgtable_ops(&domain->iop.pgtbl.ops);
This is common path gets for all domain type including passthrough, SVA.
Hence its not yet ready for unconditional call. This is causing NULL pointer
dereference when I try to change domain type.
For now, can you keep abvoe check -OR- add PAGING_DOMAIN check? I will revisit
after implementing global static identity domain and fixing SVA code.
-Vasant
next prev parent reply other threads:[~2024-09-02 12:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 0:06 [PATCH v2 00/14] Minor fixups and refactorings for AMD's io-pgtable code Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 01/14] iommu/amd: Move allocation of the top table into v1_alloc_pgtable Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 02/14] iommu/amd: Allocate the page table root using GFP_KERNEL Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 03/14] iommu/amd: Set the pgsize_bitmap correctly Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 04/14] iommu/amd: Remove amd_iommu_domain_update() from page table freeing Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 05/14] iommu/amd: Remove the amd_iommu_domain_set_pt_root() and related Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 06/14] iommu/amd: Rename struct amd_io_pgtable iopt to pgtbl Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 07/14] iommu/amd: Remove amd_io_pgtable::pgtbl_cfg Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 08/14] iommu/amd: Store the nid in io_pgtable_cfg instead of the domain Jason Gunthorpe
2024-09-02 5:52 ` Vasant Hegde
2024-08-30 0:06 ` [PATCH v2 09/14] iommu/amd: Narrow the use of struct protection_domain to invalidation Jason Gunthorpe
2024-09-02 5:53 ` Vasant Hegde
2024-08-30 0:06 ` [PATCH v2 10/14] iommu/amd: Remove conditions from domain free paths Jason Gunthorpe
2024-09-02 12:03 ` Vasant Hegde [this message]
2024-08-30 0:06 ` [PATCH v2 11/14] iommu/amd: Fix typo of , instead of ; Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 12/14] iommu/amd: Remove the confusing dummy iommu_flush_ops tlb ops Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 13/14] iommu/amd: Correct the reported page sizes from the V1 table Jason Gunthorpe
2024-08-30 0:06 ` [PATCH v2 14/14] iommu/amd: Do not set the D bit on AMD v2 table entries Jason Gunthorpe
2024-09-04 9:39 ` [PATCH v2 00/14] Minor fixups and refactorings for AMD's io-pgtable code 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=ff5cd6f8-4338-4174-81e0-9cd31442aa21@amd.com \
--to=vasant.hegde@amd.com \
--cc=alejandro.j.jimenez@oracle.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joao.m.martins@oracle.com \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=patches@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@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