summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShannon Zhao <shannon.zhao@linaro.org>2016-01-13 10:16:39 +0100
committerMarc Zyngier <marc.zyngier@arm.com>2016-01-24 22:55:59 +0100
commit9586a2ea6806599c819a9e800581c2a698ef7467 (patch)
tree27d104ccefa7cfde3f8c9d1c1d6e705432be77ac
parentarm64: KVM: Obey RES0/1 reserved bits when setting CPTR_EL2 (diff)
downloadlinux-9586a2ea6806599c819a9e800581c2a698ef7467.tar.xz
linux-9586a2ea6806599c819a9e800581c2a698ef7467.zip
arm64: KVM: Fix wrong use of the CPSR MODE mask for 32bit guests
The values of CPSR MODE mask are different between aarch32 and aarch64. It should use the right one according to the execution state. Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--arch/arm64/include/asm/kvm_emulate.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
index 3066328cd86b..779a5872a2c5 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;
}