lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAFULd4b=jUUPk3ZEzyfkeCZLOkQT9OXaM_Vx1Okw-00xwcU7bA@mail.gmail.com>
Date: Fri, 6 Sep 2024 21:31:06 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: Jacob Pan <jacob.pan@...ux.microsoft.com>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@....com>, linux-kernel@...r.kernel.org, 
	iommu@...ts.linux.dev, joro@...tes.org, robin.murphy@....com, 
	vasant.hegde@....com, jgg@...dia.com, jon.grimm@....com, 
	santosh.shukla@....com, pandoh@...gle.com, kumaranand@...gle.com
Subject: Re: [PATCH v3 2/5] iommu/amd: Introduce helper functions to access
 and update 256-bit DTE

On Fri, Sep 6, 2024 at 5:53 PM Jacob Pan <jacob.pan@...ux.microsoft.com> wrote:

> > +static void update_dte256(struct amd_iommu *iommu, struct
> > iommu_dev_data *dev_data,
> > +                       struct dev_table_entry *new)
> > +{
> > +     struct dev_table_entry *dev_table = get_dev_table(iommu);
> > +     struct dev_table_entry *ptr = &dev_table[dev_data->devid];
> > +     struct dev_table_entry old;
> > +     u128 tmp;
> > +
> > +     lockdep_assert_held(&dev_data->dte_lock);
> > +
> > +     old.data128[0] = ptr->data128[0];
> > +     old.data128[1] = ptr->data128[1];
> > +
> > +     tmp = cmpxchg128(&ptr->data128[1], old.data128[1], new->data128[1]);
> > +     if (tmp == old.data128[1]) {
> If you are able to deal with the failure, why not use try_cmpxchg128
> for the hi 128 bit also? It is more efficient.

Indeed, just write:

if (try_cmpxchg128(&ptr->data128[1], &old.data128[1], new->data128[1])) {

to substitute the last two lines above.

Please also note that try_cmpxchg128() updates its second argument on failure.

Uros.

Powered by blists - more mailing lists