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

Re: [PATCH v12 3/3] xen/riscv: refactor decode_trap_cause()



On Mon, 2024-08-05 at 08:20 +0200, Jan Beulich wrote:
> On 02.08.2024 15:54, Oleksii Kurochko wrote:
> > Use array_access_nospec() to prevent guest speculation.
> > 
> > Avoid double access of trap_causes[cause].
> > 
> > Suggested-by: Jan Beulich <jbeulich@xxxxxxxx>
> > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
> 
> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
> with ...
> 
> > @@ -48,9 +49,10 @@ static const char *decode_trap_cause(unsigned
> > long cause)
> >          [CAUSE_STORE_GUEST_PAGE_FAULT] = "Guest Store/AMO Page
> > Fault",
> >      };
> >  
> > -    if ( cause < ARRAY_SIZE(trap_causes) && trap_causes[cause] )
> > -        return trap_causes[cause];
> > -    return "UNKNOWN";
> > +    const char *res = cause < ARRAY_SIZE(trap_causes) ?
> > array_access_nospec(trap_causes, cause)
> 
> ... the overly long line here suitably wrapped; commonly we'd do this
> as ...
> 
> > +                                                      : NULL;
> 
>     const char *res = cause < ARRAY_SIZE(trap_causes)
>                       ? array_access_nospec(trap_causes, cause)
>                       : NULL;
> 
> I guess I'll adjust this while committing.
I will be happy with that. Thanks!

~ Oleksii
> 
> Jan
> 
> > +    return res ?: "UNKNOWN";
> >  }
> >  
> >  static const char *decode_reserved_interrupt_cause(unsigned long
> > irq_cause)
> 


 


Rackspace

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