aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2015-11-11 09:21:18 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2015-11-18 06:25:35 -0500
commit002374f371bd02df864cce1fe85d90dc5b292837 (patch)
tree259c68277523eb556c185ff23bcac4a93a2fa256
parent8005c49d9aea74d382f474ce11afbbc7d7130bec (diff)
MIPS: KVM: Fix ASID restoration logic
ASID restoration on guest resume should determine the guest execution mode based on the guest Status register rather than bit 30 of the guest PC. Fix the two places in locore.S that do this, loading the guest status from the cop0 area. Note, this assembly is specific to the trap & emulate implementation of KVM, so it doesn't need to check the supervisor bit as that mode is not implemented in the guest. Fixes: b680f70fc111 ("KVM/MIPS32: Entry point for trampolining to...") Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: Gleb Natapov <gleb@kernel.org> Cc: linux-mips@linux-mips.org Cc: kvm@vger.kernel.org Cc: <stable@vger.kernel.org> # 3.10.x- Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/mips/kvm/locore.S16
1 files changed, 10 insertions, 6 deletions
diff --git a/arch/mips/kvm/locore.S b/arch/mips/kvm/locore.S
index 7bab3a4e8f7d..7e2210846b8b 100644
--- a/arch/mips/kvm/locore.S
+++ b/arch/mips/kvm/locore.S
@@ -157,9 +157,11 @@ FEXPORT(__kvm_mips_vcpu_run)
157 157
158FEXPORT(__kvm_mips_load_asid) 158FEXPORT(__kvm_mips_load_asid)
159 /* Set the ASID for the Guest Kernel */ 159 /* Set the ASID for the Guest Kernel */
160 INT_SLL t0, t0, 1 /* with kseg0 @ 0x40000000, kernel */ 160 PTR_L t0, VCPU_COP0(k1)
161 /* addresses shift to 0x80000000 */ 161 LONG_L t0, COP0_STATUS(t0)
162 bltz t0, 1f /* If kernel */ 162 andi t0, KSU_USER | ST0_ERL | ST0_EXL
163 xori t0, KSU_USER
164 bnez t0, 1f /* If kernel */
163 INT_ADDIU t1, k1, VCPU_GUEST_KERNEL_ASID /* (BD) */ 165 INT_ADDIU t1, k1, VCPU_GUEST_KERNEL_ASID /* (BD) */
164 INT_ADDIU t1, k1, VCPU_GUEST_USER_ASID /* else user */ 166 INT_ADDIU t1, k1, VCPU_GUEST_USER_ASID /* else user */
1651: 1671:
@@ -474,9 +476,11 @@ __kvm_mips_return_to_guest:
474 mtc0 t0, CP0_EPC 476 mtc0 t0, CP0_EPC
475 477
476 /* Set the ASID for the Guest Kernel */ 478 /* Set the ASID for the Guest Kernel */
477 INT_SLL t0, t0, 1 /* with kseg0 @ 0x40000000, kernel */ 479 PTR_L t0, VCPU_COP0(k1)
478 /* addresses shift to 0x80000000 */ 480 LONG_L t0, COP0_STATUS(t0)
479 bltz t0, 1f /* If kernel */ 481 andi t0, KSU_USER | ST0_ERL | ST0_EXL
482 xori t0, KSU_USER
483 bnez t0, 1f /* If kernel */
480 INT_ADDIU t1, k1, VCPU_GUEST_KERNEL_ASID /* (BD) */ 484 INT_ADDIU t1, k1, VCPU_GUEST_KERNEL_ASID /* (BD) */
481 INT_ADDIU t1, k1, VCPU_GUEST_USER_ASID /* else user */ 485 INT_ADDIU t1, k1, VCPU_GUEST_USER_ASID /* else user */
4821: 4861: