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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFULd4a1PHREX6ws9Gyu=TaaZvdgLfh6peoE5Tt010uGyY9Hgw@mail.gmail.com>
Date: Wed, 13 Nov 2024 15:06:05 +0100
From: Uros Bizjak <ubizjak@...il.com>
To: Jason Gunthorpe <jgg@...dia.com>
Cc: Arnd Bergmann <arnd@...db.de>, Suravee Suthikulpanit <suravee.suthikulpanit@....com>, 
	linux-kernel@...r.kernel.org, iommu@...ts.linux.dev, 
	Joerg Roedel <joro@...tes.org>, Robin Murphy <robin.murphy@....com>, vasant.hegde@....com, 
	Linux-Arch <linux-arch@...r.kernel.org>, Kevin Tian <kevin.tian@...el.com>, jon.grimm@....com, 
	santosh.shukla@....com, pandoh@...gle.com, kumaranand@...gle.com
Subject: Re: [PATCH v10 05/10] iommu/amd: Introduce helper function to update
 256-bit DTE

On Wed, Nov 13, 2024 at 2:20 PM Jason Gunthorpe <jgg@...dia.com> wrote:
>
> On Wed, Nov 13, 2024 at 01:50:14PM +0100, Arnd Bergmann wrote:
> > On Wed, Nov 13, 2024, at 13:03, Suravee Suthikulpanit wrote:
> > >
> > > +static void write_dte_upper128(struct dev_table_entry *ptr, struct
> > > dev_table_entry *new)
> > > +{
> > > +   struct dev_table_entry old = {};
> > > +
> > > +   old.data128[1] = __READ_ONCE(ptr->data128[1]);
> >
> > The __READ_ONCE() in place of READ_ONCE() does make this a
> > lot simpler. After seeing how it is used though, I wonder if
> > this should just be an open-coded volatile pointer access
> > to avoid complicating __unqual_scalar_typeof() further.
>
> I've been skeptical we even need the READ_ONCE. This is all under a
> lock, what is READ_ONCE even protecting against? It is safe to double
> read.

Even without atomicity guarantee, __READ_ONCE() still prevents the
compiler from performing unwanted optimizations (please see the first
comment in include/asm-generic/rwonce.h) and unwanted reordering of
reads and writes when this function is inlined. This macro does cast
the read to volatile, but IMO it is much more readable to use
__READ_ONCE() than volatile qualifier.

Uros.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ