From: Nicolin Chen <nicolinc@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: <will@kernel.org>, <robin.murphy@arm.com>, <joro@8bytes.org>,
<linux-arm-kernel@lists.infradead.org>, <iommu@lists.linux.dev>,
<linux-kernel@vger.kernel.org>, <skolothumtho@nvidia.com>,
<praan@google.com>
Subject: Re: [PATCH rc v1 1/4] iommu/arm-smmu-v3: Add ignored bits to fix STE update sequence
Date: Sun, 7 Dec 2025 11:35:01 -0800 [thread overview]
Message-ID: <aTXW5X4fAiEHAy6V@nvidia.com> (raw)
In-Reply-To: <aTWmpijaV75aixNb@nvidia.com>
On Sun, Dec 07, 2025 at 12:09:10PM -0400, Jason Gunthorpe wrote:
> On Sat, Dec 06, 2025 at 08:37:30PM -0800, Nicolin Chen wrote:
> > > Then ignored should be adjusted by the used: Only if both used are 1
> > > should the bit become ignored. Otherwise we can rely on which ever
> > > used is 0 to generate the hitless update.
> >
> > Hmm, not sure why it has to be both used.
>
> Thats the only case that causes an issue, if only one is used then
> there is no need to perform a breaking update.
>
> If cur_used is 0 then the bit will be set in the first update, if
> target_used is 0 then the bit will be set during the last update.
Ah, I see.
> > > /* Bits can change because they are not currently being used */
> > > + cur_used[i] &= ~ignored[i];
> > > unused_update[i] = (entry[i] & cur_used[i]) |
> > > (target[i] & ~cur_used[i]);
> >
> > If one of ignored bits is set in entry[i] but unset in target[i],
> > the unused_update will first mask it away, resulting in an extra
> > unnecessary update (though it's still hitless).
>
> Yes, this is how it has always worked. The point is to leave the
> existing the same not try to optimize it using ignored.
OK. Let's leave it and ask the test case to expect 3 v.s. 2.
> > One more change that we need is at the last equation:
> > - if ((unused_update[i] & target_used[i]) != target[i])
> > + if ((unused_update[i] & target_used[i] & ~ignored[i]) !=
> > + (target[i] & ~ignored[i]))
> >
> > Either side might have the ignored bits, so we have to suppress
> > ignored on both sides, which is required in the similar routine
> > in arm_smmu_entry_differs_in_used_bits() of the kunit code.
>
> The only way ignored is set is if both sides have it set and then we
> update the bit in the firsy cycle meaning unused_update must have the
> final value. There is no need to mask target since it will match. Not
> changing this line is a big part of what makes this appealing because
> it keeps the logic straightforward, in case ignored is used we shift
> the update always to the first cycle then everything else is the same.
The reason that I changed this is because the kunit tests failed
in arm_smmu_entry_differs_in_used_bits() when running the nested
cases:
STE initial value:
f800f0f0f0f0f0ef 00001000180800d5
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE used bits:
f80fffffffffffff 00003000fa0800ff
065fffff0000ffff 000ffffffffffff0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE target value:
000000000000000d 0000100000000000
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE used bits:
000000000000000f 0000300032080000
065fffff0000ffff 000ffffffffffff0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE value is now set to:
f800f0f0f0f0f0ef 00001000080000d5
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
# arm_smmu_v3_write_ste_test_nested_s1dssbypass_to_s1bypass: EXPECTATION FAILED at drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c:92
Expected arm_smmu_entry_differs_in_used_bits( test_writer->entry, entry_used_bits, test_writer->init_entry, ignored, 8) && arm_smmu_entry_differs_in_used_bits( test_writer->entry, entry_used_bits, test_writer->target_entry, ignored, 8) to be false, but is true
STE value is now set to:
000000000000000d 00001000080000d5
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE value is now set to:
000000000000000d 0000100000000000
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
not ok 21 arm_smmu_v3_write_ste_test_nested_s1dssbypass_to_s1bypass
STE initial value:
000000000000000d 0000100000000000
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE used bits:
000000000000000f 0000300032080000
065fffff0000ffff 000ffffffffffff0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE target value:
f800f0f0f0f0f0ef 00001000180800d5
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE used bits:
f80fffffffffffff 00003000fa0800ff
065fffff0000ffff 000ffffffffffff0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
STE value is now set to:
000000000000000d 00001000180800d5
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
# arm_smmu_v3_write_ste_test_nested_s1bypass_to_s1dssbypass: EXPECTATION FAILED at drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-test.c:92
Expected arm_smmu_entry_differs_in_used_bits( test_writer->entry, entry_used_bits, test_writer->init_entry, ignored, 8) && arm_smmu_entry_differs_in_used_bits( test_writer->entry, entry_used_bits, test_writer->target_entry, ignored, 8) to be false, but is true
STE value is now set to:
f800f0f0f0f0f0ef 00001000180800d5
0449b6c400000000 000dbeefdeadbee0
0000000000000000 0000000000000000
0000000000000000 0000000000000000
not ok 22 arm_smmu_v3_write_ste_test_nested_s1bypass_to_s1dssbypass
Any thought?
Thanks
Nicolin
next prev parent reply other threads:[~2025-12-07 19:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-06 0:51 [PATCH rc v1 0/4] iommu/arm-smmu-v3: Fix hitless STE update in nesting cases Nicolin Chen
2025-12-06 0:52 ` [PATCH rc v1 1/4] iommu/arm-smmu-v3: Add ignored bits to fix STE update sequence Nicolin Chen
2025-12-06 14:19 ` Shuai Xue
2025-12-06 19:38 ` Jason Gunthorpe
2025-12-06 19:34 ` Jason Gunthorpe
2025-12-06 19:45 ` Nicolin Chen
2025-12-06 19:57 ` Jason Gunthorpe
2025-12-07 4:37 ` Nicolin Chen
2025-12-07 16:09 ` Jason Gunthorpe
2025-12-07 19:35 ` Nicolin Chen [this message]
2025-12-07 20:11 ` Nicolin Chen
2025-12-06 0:52 ` [PATCH rc v1 2/4] iommu/arm-smmu-v3: Ignore STE MEV when computing the " Nicolin Chen
2025-12-06 0:52 ` [PATCH rc v1 3/4] iommu/arm-smmu-v3: Ignore STE EATS " Nicolin Chen
2025-12-06 19:46 ` Jason Gunthorpe
2025-12-06 19:54 ` Nicolin Chen
2025-12-06 0:52 ` [PATCH rc v1 4/4] iommu/arm-smmu-v3-test: Add nested s1bypass coverage Nicolin Chen
2025-12-06 12:34 ` Shuai Xue
2025-12-06 19:42 ` Jason Gunthorpe
2025-12-06 19:50 ` Nicolin Chen
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=aTXW5X4fAiEHAy6V@nvidia.com \
--to=nicolinc@nvidia.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=praan@google.com \
--cc=robin.murphy@arm.com \
--cc=skolothumtho@nvidia.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;
as well as URLs for NNTP newsgroup(s).