All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger@xenproject.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Nicola Vetrini <nicola.vetrini@bugseng.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Teddy Astie <teddy.astie@vates.tech>
Subject: Re: [PATCH 1/4] x86/pagewalk: avoid ACCESS_ONCE() in compound literals
Date: Mon, 21 Sep 2026 11:42:49 +0200	[thread overview]
Message-ID: <arD8GNgbFKq3hjZN@macbook.local> (raw)
In-Reply-To: <d83a7e4e-38ff-47eb-97b8-8ea0553ba332@suse.com>

On Mon, Sep 21, 2026 at 10:59:09AM +0200, Jan Beulich wrote:
> On 21.09.2026 10:53, Roger Pau Monné wrote:
> > On Thu, Sep 03, 2026 at 01:51:28PM +0200, Jan Beulich wrote:
> >> Compound literals are also covered by Misra C:2012 rule 13.1
> >> ("Initializer lists shall not contain persistent side effects"), and
> >> (sadly?) that rule also applies to lists with just a single element, or
> >> more generally with just a single side effect. Use intermediate variables
> >> to overcome this as well as ACCESS_ONCE()'s restriction to be usable on
> >> scalar types only.
> >>
> >> No functional change intended.
> >>
> >> Fixes: 0345b835dc97 ("x86/pagewalk: Read guest PTEs with ACCESS_ONCE()")
> >> Signed-off-by: Jan Beulich <jbeulich@suse.com>
> >>
> >> --- a/xen/arch/x86/mm/guest_walk.c
> >> +++ b/xen/arch/x86/mm/guest_walk.c
> >> @@ -129,7 +129,9 @@ guest_walk_tables(const struct vcpu *v,
> >>              guest_l4_table_offset(va) * sizeof(gw->l4e);
> >>      if ( !hvmemul_read_cache(v, l4gpa, &gw->l4e, sizeof(gw->l4e)) )
> >>      {
> >> -        gw->l4e = (guest_l4e_t){ ACCESS_ONCE(l4p[guest_l4_table_offset(va)].l4) };
> >> +        guest_intpte_t l4e = ACCESS_ONCE(l4p[guest_l4_table_offset(va)].l4);
> >> +
> >> +        gw->l4e = (guest_l4e_t){ l4e };
> > 
> > Did you consider using the l4e_from_intpte() and similar helpers here
> > and below?
> 
> No, I didn't, as they aren't applicable to guest_l<N>e_t. guest_intpte_t
> aliases intpte_t only for GUEST_PAGING_LEVELS > 2.

Right, as otherwise it's a 32bit PTE.

Acked-by: Roger Pau Monné <roger@xenproject.org>

Thanks, Roger.


  reply	other threads:[~2026-09-21  9:43 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-03 11:50 [PATCH 0/4] address remaining rule 13.1 violations; mark clean Jan Beulich
2026-09-03 11:51 ` [PATCH 1/4] x86/pagewalk: avoid ACCESS_ONCE() in compound literals Jan Beulich
2026-09-21  8:53   ` Roger Pau Monné
2026-09-21  8:59     ` Jan Beulich
2026-09-21  9:42       ` Roger Pau Monné [this message]
2026-09-03 11:52 ` [PATCH 2/4] Arm/guestcopy: avoid use of "current" " Jan Beulich
2026-09-17  9:53   ` Orzel, Michal
2026-09-03 11:53 ` [PATCH 3/4] sched/core: avoid use of "current" in initializer lists Jan Beulich
2026-09-03 13:26   ` Jürgen Groß
2026-09-03 13:55     ` Jan Beulich
2026-09-03 13:57       ` Jürgen Groß
2026-09-03 11:54 ` [PATCH 4/4] automation/Eclair: tag rule 13.1 as clean Jan Beulich
2026-09-17 10:00   ` Nicola Vetrini
2026-09-08 12:21 ` [PATCH v1.1 3/4] sched/core: avoid use of "current" in initializer lists Jan Beulich
2026-09-10 12:07   ` Jürgen Groß
2026-09-30 14:03     ` Jan Beulich

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=arD8GNgbFKq3hjZN@macbook.local \
    --to=roger@xenproject.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=nicola.vetrini@bugseng.com \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.