]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
arm64: KVM: Fix decoding of Rt/Rt2 when trapping AArch32 CP accesses
authorMarc Zyngier <marc.zyngier@arm.com>
Thu, 27 Apr 2017 18:06:48 +0000 (19:06 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 20 Jun 2017 08:50:21 +0000 (10:50 +0200)
BugLink: http://bugs.launchpad.net/bugs/1692898
commit c667186f1c01ca8970c785888868b7ffd74e51ee upstream.

Our 32bit CP14/15 handling inherited some of the ARMv7 code for handling
the trapped system registers, completely missing the fact that the
fields for Rt and Rt2 are now 5 bit wide, and not 4...

Let's fix it, and provide an accessor for the most common Rt case.

Reviewed-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <cdall@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/sys_regs.c

index f5ea0ba70f077479ea9b2f4b1cb2fd077e9e20e3..fe39e6841326f01c9ae2d933b8048459c2e8ef6e 100644 (file)
@@ -240,6 +240,12 @@ static inline u8 kvm_vcpu_trap_get_fault_type(const struct kvm_vcpu *vcpu)
        return kvm_vcpu_get_hsr(vcpu) & ESR_ELx_FSC_TYPE;
 }
 
+static inline int kvm_vcpu_sys_get_rt(struct kvm_vcpu *vcpu)
+{
+       u32 esr = kvm_vcpu_get_hsr(vcpu);
+       return (esr & ESR_ELx_SYS64_ISS_RT_MASK) >> ESR_ELx_SYS64_ISS_RT_SHIFT;
+}
+
 static inline unsigned long kvm_vcpu_get_mpidr_aff(struct kvm_vcpu *vcpu)
 {
        return vcpu_sys_reg(vcpu, MPIDR_EL1) & MPIDR_HWID_BITMASK;
index 87e7e6608cd8a31e6913be8134b90e443df314cb..7cee552ce0bf025759fb75a4c13850fa641878c8 100644 (file)
@@ -1573,8 +1573,8 @@ static int kvm_handle_cp_64(struct kvm_vcpu *vcpu,
 {
        struct sys_reg_params params;
        u32 hsr = kvm_vcpu_get_hsr(vcpu);
-       int Rt = (hsr >> 5) & 0xf;
-       int Rt2 = (hsr >> 10) & 0xf;
+       int Rt = kvm_vcpu_sys_get_rt(vcpu);
+       int Rt2 = (hsr >> 10) & 0x1f;
 
        params.is_aarch32 = true;
        params.is_32bit = false;
@@ -1625,7 +1625,7 @@ static int kvm_handle_cp_32(struct kvm_vcpu *vcpu,
 {
        struct sys_reg_params params;
        u32 hsr = kvm_vcpu_get_hsr(vcpu);
-       int Rt  = (hsr >> 5) & 0xf;
+       int Rt  = kvm_vcpu_sys_get_rt(vcpu);
 
        params.is_aarch32 = true;
        params.is_32bit = true;
@@ -1740,7 +1740,7 @@ int kvm_handle_sys_reg(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
        struct sys_reg_params params;
        unsigned long esr = kvm_vcpu_get_hsr(vcpu);
-       int Rt = (esr >> 5) & 0x1f;
+       int Rt = kvm_vcpu_sys_get_rt(vcpu);
        int ret;
 
        trace_kvm_handle_sys_reg(esr);