From: Jason Gunthorpe <jgg@nvidia.com>
To: Vasant Hegde <vasant.hegde@amd.com>, Joerg Roedel <jroedel@suse.de>
Cc: 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>,
Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
Joao Martins <joao.m.martins@oracle.com>
Subject: Re: [PATCH v2 10/14] iommu/amd: Remove conditions from domain free paths
Date: Wed, 4 Sep 2024 13:55:37 -0300 [thread overview]
Message-ID: <20240904165537.GP3915968@nvidia.com> (raw)
In-Reply-To: <ff5cd6f8-4338-4174-81e0-9cd31442aa21@amd.com>
On Mon, Sep 02, 2024 at 05:33:50PM +0530, Vasant Hegde wrote:
> > 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.
Oh, I see, and ops isn't a pointer so it doesn't become NULL like
other drivers..
> This is causing NULL pointer dereference when I try to change domain
> type.
Yes
> 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.
tlb is always NULL now that is why I had to do this.
@@ -2259,7 +2259,8 @@ static void cleanup_domain(struct protection_domain *domain)
void protection_domain_free(struct protection_domain *domain)
{
WARN_ON(!list_empty(&domain->dev_list));
- free_io_pgtable_ops(&domain->iop.pgtbl.ops);
+ if (domain->domain.type & __IOMMU_DOMAIN_PAGING)
+ free_io_pgtable_ops(&domain->iop.pgtbl.ops);
domain_id_free(domain->id);
kfree(domain);
}
Is that OK?
Joerg can you squish it?
Jason
next prev parent reply other threads:[~2024-09-04 16:55 UTC|newest]
Thread overview: 22+ 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
2024-09-04 16:55 ` Jason Gunthorpe [this message]
2024-09-04 17:04 ` Vasant Hegde
2024-09-10 4:56 ` Vasant Hegde
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=20240904165537.GP3915968@nvidia.com \
--to=jgg@nvidia.com \
--cc=alejandro.j.jimenez@oracle.com \
--cc=iommu@lists.linux.dev \
--cc=joao.m.martins@oracle.com \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--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