From: "Suthikulpanit, Suravee" <suravee.suthikulpanit@amd.com>
To: Uros Bizjak <ubizjak@gmail.com>,
linux-kernel@vger.kernel.org, iommu@lists.linux.dev
Cc: joro@8bytes.org, robin.murphy@arm.com, vasant.hegde@amd.com,
jgg@nvidia.com, kevin.tian@intel.com, jon.grimm@amd.com,
santosh.shukla@amd.com, pandoh@google.com, kumaranand@google.com
Subject: Re: [PATCH] iommu/amd: Modify set_dte_entry() to use 128-bit cmpxchg operation
Date: Fri, 30 Aug 2024 01:18:29 +0700 [thread overview]
Message-ID: <de6d9fa7-abc1-47a1-9935-b544a7ecd537@amd.com> (raw)
In-Reply-To: <e937e26f-038a-6d01-76a9-76c86760ca4a@gmail.com>
On 8/20/2024 1:15 AM, Uros Bizjak wrote:
>
>
> On 19. 08. 24 18:18, Suravee Suthikulpanit wrote:
>> The current implementation does not follow the 128-bit write
>> requirement to update DTE as specified in the AMD I/O Virtualization
>> Techonology (IOMMU) Specification.
>>
>> In addition, the function is used to program several DTE fields
>> (e.g. stage1 table, stage2 table, domain id, and etc.), which is
>> difficult to keep track with current implementation.
>>
>> Therefore, introduce new a new dte256_t data type and a helper function
>> update_dte_256(), which uses two try_cmpxchg128 operations to update
>> 256-bit DTE.
>>
>> Also, separate logic for setting up the GCR3 Table Root Pointer, GIOV,
>> GV,
>> GLX, and GuestPagingMode into another helper function
>> set_dte_gcr3_table().
>>
>> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
>
> [...]
>
>> +static void update_dte256(struct amd_iommu *iommu, u16 devid, struct
>> dte256 *new)
>> +{
>> + struct dev_table_entry *dev_table = get_dev_table(iommu);
>> + struct dte256 *ptr = (struct dte256 *)&dev_table[devid];
>> + struct dte256 old = {
>> + .qw_lo.data = ptr->qw_lo.data,
>> + .qw_hi.data = ptr->qw_hi.data,
>> + };
>> +
>> + /* Update qw_lo */
>> + if (!try_cmpxchg128(&ptr->qw_lo.data, &old.qw_lo.data,
>> new->qw_lo.data))
>> + goto err_out;
>> +
>> + /* Update qw_hi */
>> + if (!try_cmpxchg128(&ptr->qw_hi.data, &old.qw_hi.data,
>> new->qw_hi.data)) {
>> + /* Restore qw_lo */
>> + try_cmpxchg128(&ptr->qw_lo.data, &new->qw_lo.data,
>> old.qw_lo.data);
>
> You should use plain cmpxchg128() when the result is unused.
>
> Uros.
I will update in v2.
Thanks,
Suravee
prev parent reply other threads:[~2024-08-29 18:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 16:18 [PATCH] iommu/amd: Modify set_dte_entry() to use 128-bit cmpxchg operation Suravee Suthikulpanit
2024-08-19 17:09 ` Jason Gunthorpe
2024-08-29 18:15 ` Suthikulpanit, Suravee
2024-08-19 18:15 ` Uros Bizjak
2024-08-29 18:18 ` Suthikulpanit, Suravee [this message]
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=de6d9fa7-abc1-47a1-9935-b544a7ecd537@amd.com \
--to=suravee.suthikulpanit@amd.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=jon.grimm@amd.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kumaranand@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pandoh@google.com \
--cc=robin.murphy@arm.com \
--cc=santosh.shukla@amd.com \
--cc=ubizjak@gmail.com \
--cc=vasant.hegde@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