Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: MIPS: Update exit handler for VZ

The general guest exit handler needs a few tweaks for VZ compared to
trap & emulate, which for now are made directly depending on
CONFIG_KVM_MIPS_VZ:

- There is no need to re-enable the hardware page table walker (HTW), as
it can be left enabled during guest mode operation with VZ.

- There is no need to perform a privilege check, as any guest privilege
violations should have already been detected by the hardware and
triggered the appropriate guest exception.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org

+18 -13
+18 -13
arch/mips/kvm/mips.c
··· 1230 1230 vcpu->mode = OUTSIDE_GUEST_MODE; 1231 1231 1232 1232 /* re-enable HTW before enabling interrupts */ 1233 - htw_start(); 1233 + if (!IS_ENABLED(CONFIG_KVM_MIPS_VZ)) 1234 + htw_start(); 1234 1235 1235 1236 /* Set a default exit reason */ 1236 1237 run->exit_reason = KVM_EXIT_UNKNOWN; ··· 1249 1248 cause, opc, run, vcpu); 1250 1249 trace_kvm_exit(vcpu, exccode); 1251 1250 1252 - /* 1253 - * Do a privilege check, if in UM most of these exit conditions end up 1254 - * causing an exception to be delivered to the Guest Kernel 1255 - */ 1256 - er = kvm_mips_check_privilege(cause, opc, run, vcpu); 1257 - if (er == EMULATE_PRIV_FAIL) { 1258 - goto skip_emul; 1259 - } else if (er == EMULATE_FAIL) { 1260 - run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 1261 - ret = RESUME_HOST; 1262 - goto skip_emul; 1251 + if (!IS_ENABLED(CONFIG_KVM_MIPS_VZ)) { 1252 + /* 1253 + * Do a privilege check, if in UM most of these exit conditions 1254 + * end up causing an exception to be delivered to the Guest 1255 + * Kernel 1256 + */ 1257 + er = kvm_mips_check_privilege(cause, opc, run, vcpu); 1258 + if (er == EMULATE_PRIV_FAIL) { 1259 + goto skip_emul; 1260 + } else if (er == EMULATE_FAIL) { 1261 + run->exit_reason = KVM_EXIT_INTERNAL_ERROR; 1262 + ret = RESUME_HOST; 1263 + goto skip_emul; 1264 + } 1263 1265 } 1264 1266 1265 1267 switch (exccode) { ··· 1422 1418 } 1423 1419 1424 1420 /* Disable HTW before returning to guest or host */ 1425 - htw_stop(); 1421 + if (!IS_ENABLED(CONFIG_KVM_MIPS_VZ)) 1422 + htw_stop(); 1426 1423 1427 1424 return ret; 1428 1425 }