From: "Suthikulpanit, Suravee via iommu" <iommu@lists.linux-foundation.org>
To: Lennert Buytenhek <buytenh@wantstofly.org>
Cc: iommu@lists.linux-foundation.org
Subject: Re: [PATCH v2] iommu/amd: Use report_iommu_fault()
Date: Thu, 5 Aug 2021 11:26:25 -0500 [thread overview]
Message-ID: <0d353fc0-79d0-36b7-eeee-ba27249bb258@amd.com> (raw)
In-Reply-To: <YQNksD4G1SS/yGM2@wantstofly.org>
Lennert,
On 7/29/2021 9:32 PM, Lennert Buytenhek wrote:
> We have three cases to handle:
>
> - EVENT_FLAG_I set: IRQ remapping fault, don't call report_iommu_fault()
>
> - EVENT_FLAG_I unset, but the request was a translation request
> (EVENT_FLAG_TR set) or the target page was not present (EVENT_FLAG_PR
> unset): call report_iommu_fault(), but the RW bit will be invalid, so
> don't try to map it to a IOMMU_FAULT_{READ,WRITE} code
So, why do we need to call report_iommu_fault() for this case?
My understanding is we only have IOMMU_FAULT_[READ|WRITE].
So, if we can't identify whether the DMA is read / write,
we should not need to call report_iommu_fauilt(), is it?
> - EVENT_FLAG_I unset, the request is a transaction request (EVENT_FLAG_TR
> unset) and the target page was present (EVENT_FLAG_PR set): call
> report_iommu_fault(), and use the RW bit to set IOMMU_FAULT_{READ,WRITE}
>
> So I don't think we can merge the test for EVENT_FLAG_I with the
> test for EVENT_FLAG_TR/EVENT_FLAG_PR.
The only condition that we would report_iommu_fault is
I=0, TR=0, PR=1, isn't it. So we should be able to just check if PR=1.
> We could do something like this, if you'd prefer:
>
> #define IS_IOMMU_MEM_TRANSACTION(flags) \
> (((flags) & EVENT_FLAG_I) == 0)
>
> #define IS_RW_FLAG_VALID(flags) \
> (((flags) & (EVENT_FLAG_TR | EVENT_FLAG_PR)) == EVENT_FLAG_PR)
>
> #define IS_WRITE_REQUEST(flags) \
> (IS_RW_FLAG_VALID(flags) && (flags & EVENT_FLAG_RW))
>
> And then do something like:
>
> if (dev_data && IS_IOMMU_MEM_TRANSACTION(flags)) {
> if (!report_iommu_fault(&dev_data->domain->domain, &pdev->dev,
> address,
> IS_WRITE_REQUEST(flags) ?
> IOMMU_FAULT_WRITE : IOMMU_FAULT_READ))
Actually, IS_WRITE_REQUEST() == 0 could mean:
- I=0, TR=0, PR=1 and RW=0: This is fine.
- I=0, (TR=1 or PR=0), and we should not be calling report_iommu_fault() here
since we cannot specify READ/WRITE here.
Thanks,
Suravee
> goto out;
> }
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2021-08-05 16:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 16:31 [PATCH v2] iommu/amd: Use report_iommu_fault() Lennert Buytenhek
2021-07-28 21:51 ` Suthikulpanit, Suravee via iommu
2021-07-30 2:32 ` Lennert Buytenhek
2021-08-03 16:20 ` Lennert Buytenhek
2021-08-05 16:26 ` Suthikulpanit, Suravee via iommu [this message]
2021-08-21 15:44 ` Lennert Buytenhek
2021-09-25 14:09 ` Lennert Buytenhek
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=0d353fc0-79d0-36b7-eeee-ba27249bb258@amd.com \
--to=iommu@lists.linux-foundation.org \
--cc=buytenh@wantstofly.org \
--cc=suravee.suthikulpanit@amd.com \
/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