Re: [PATCH 1/3] KVM: ARM64: Fix wrong use of the CPSR MODE mask

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

 



On 13/01/16 09:16, Shannon Zhao wrote:
> From: Shannon Zhao <shannon.zhao@xxxxxxxxxx>
> 
> The values of CPSR MODE mask are different between aarch32 and aarch64.
> It should use the right one according to the execution state.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@xxxxxxxxxx>
> ---
>  arch/arm64/include/asm/kvm_emulate.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
> index 3066328..779a587 100644
> --- a/arch/arm64/include/asm/kvm_emulate.h
> +++ b/arch/arm64/include/asm/kvm_emulate.h
> @@ -127,10 +127,14 @@ static inline unsigned long *vcpu_spsr(const struct kvm_vcpu *vcpu)
>  
>  static inline bool vcpu_mode_priv(const struct kvm_vcpu *vcpu)
>  {
> -	u32 mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
> +	u32 mode;
>  
> -	if (vcpu_mode_is_32bit(vcpu))
> +	if (vcpu_mode_is_32bit(vcpu)) {
> +		mode = *vcpu_cpsr(vcpu) & COMPAT_PSR_MODE_MASK;
>  		return mode > COMPAT_PSR_MODE_USR;
> +	}
> +
> +	mode = *vcpu_cpsr(vcpu) & PSR_MODE_MASK;
>  
>  	return mode != PSR_MODE_EL0t;
>  }
> 

Nice catch. At the moment, it will only affect perf's is_user_mode()
with a 32bit guest (always reporting the guest as running in kernel
mode), so that's not a big deal with mainline (but it clearly has a much
bigger implication with the PMU support).

Reviewed-by: Marc Zyngier <marc.zyngier@xxxxxxx>

	M.
-- 
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux