summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMike Larkin <mlarkin@cvs.openbsd.org>2017-05-30 19:31:29 +0000
committerMike Larkin <mlarkin@cvs.openbsd.org>2017-05-30 19:31:29 +0000
commite11704b53fa56089bd20becbf309da945277d87c (patch)
tree420a108b6f68f4e218543871896dd8971d5a9317 /sys/arch
parent821870bd1cd6836e81163d6bf39b7ebb53d4aca2 (diff)
SVM: return EIO to vmd to stop the guest when it HLTs with interrupts
disabled (no NMI support yet)
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/vmm.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c
index 0b58bf85b7b..d1184e5cd7c 100644
--- a/sys/arch/amd64/amd64/vmm.c
+++ b/sys/arch/amd64/amd64/vmm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmm.c,v 1.150 2017/05/30 19:13:20 mlarkin Exp $ */
+/* $OpenBSD: vmm.c,v 1.151 2017/05/30 19:31:28 mlarkin Exp $ */
/*
* Copyright (c) 2014 Mike Larkin <mlarkin@openbsd.org>
*
@@ -3967,13 +3967,30 @@ vmx_handle_intr(struct vcpu *vcpu)
* svm_handle_hlt
*
* Handle HLT exits
+ *
+ * Parameters
+ * vcpu: The VCPU that executed the HLT instruction
+ *
+ * Return Values:
+ * EIO: The guest halted with interrupts disabled
+ * EAGAIN: Normal return to vmd - vmd should halt scheduling this VCPU
+ * until a virtual interrupt is ready to inject
*/
int
svm_handle_hlt(struct vcpu *vcpu)
{
+ struct vmcb *vmcb = (struct vmcb *)vcpu->vc_control_va;
+ uint64_t rflags = vmcb->v_rflags;
+
/* All HLT insns are 1 byte */
vcpu->vc_gueststate.vg_rip += 1;
+ if (!(rflags & PSL_I)) {
+ DPRINTF("%s: guest halted with interrupts disabled\n",
+ __func__);
+ return (EIO);
+ }
+
return (EAGAIN);
}
@@ -4012,7 +4029,8 @@ vmx_handle_hlt(struct vcpu *vcpu)
KASSERT(insn_length == 1);
if (!(rflags & PSL_I)) {
- DPRINTF("%s: guest halted with interrupts disabled\n", __func__);
+ DPRINTF("%s: guest halted with interrupts disabled\n",
+ __func__);
return (EIO);
}