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

Re: [PATCH] xen/arm: traps: Fix sign extension logic in sign_extend()



On Wed, 18 Nov 2026, Michal Orzel wrote:
> At the moment, we always sign extend to the full register width, i.e.
> 64-bit on Arm64, even though for byte and half-word accesses the
> destination can also be a W (32-bit) register (LDRSB Wt, LDRSH Wt). In
> that case, the architecture requires bits [63:32] of Xt to be zero, but
> a subsequent use of Xt by the guest sees them set to ones. Fix it.
> 
> Fixes: ac0ca6895b65 ("xen/arm: io: Support sign-extension for every read 
> access")
> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>

Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>


> ---
>  xen/arch/arm/include/asm/traps.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/xen/arch/arm/include/asm/traps.h 
> b/xen/arch/arm/include/asm/traps.h
> index 3b40afe26259..c5b6ff5b788b 100644
> --- a/xen/arch/arm/include/asm/traps.h
> +++ b/xen/arch/arm/include/asm/traps.h
> @@ -111,6 +111,12 @@ static inline register_t sign_extend(const struct 
> hsr_dabt dabt, register_t r)
>           */
>          BUILD_BUG_ON(sizeof(register_t) != sizeof(unsigned long));
>          r |= (~0UL) << size;
> +
> +#ifdef CONFIG_ARM_64
> +        /* When loading to W register we should only sign extend to 32-bit */
> +        if ( !dabt.sf )
> +            r = (uint32_t)r;
> +#endif
>      }
>  
>      return r;
> -- 
> 2.43.0
> 



 


Rackspace

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