[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/4] x86/pagewalk: avoid ACCESS_ONCE() in compound literals



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@xxxxxxxx>
> 
> --- 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?

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.