mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
Inject #UD into the guest when it executes either 'MONITOR' or 'MWAIT' on
an AMD/SVM host. MFC after: 1 week
This commit is contained in:
parent
12d7eaa009
commit
95474bc26a
2 changed files with 15 additions and 0 deletions
|
|
@ -461,6 +461,9 @@ vmcb_init(struct svm_softc *sc, int vcpu, uint64_t iopm_base_pa,
|
|||
svm_enable_intercept(sc, vcpu, VMCB_CTRL1_INTCPT,
|
||||
VMCB_INTCPT_FERR_FREEZE);
|
||||
|
||||
svm_enable_intercept(sc, vcpu, VMCB_CTRL2_INTCPT, VMCB_INTCPT_MONITOR);
|
||||
svm_enable_intercept(sc, vcpu, VMCB_CTRL2_INTCPT, VMCB_INTCPT_MWAIT);
|
||||
|
||||
/*
|
||||
* From section "Canonicalization and Consistency Checks" in APMv2
|
||||
* the VMRUN intercept bit must be set to pass the consistency check.
|
||||
|
|
@ -1140,6 +1143,10 @@ exit_reason_to_str(uint64_t reason)
|
|||
return ("msr");
|
||||
case VMCB_EXIT_IRET:
|
||||
return ("iret");
|
||||
case VMCB_EXIT_MONITOR:
|
||||
return ("monitor");
|
||||
case VMCB_EXIT_MWAIT:
|
||||
return ("mwait");
|
||||
default:
|
||||
snprintf(reasonbuf, sizeof(reasonbuf), "%#lx", reason);
|
||||
return (reasonbuf);
|
||||
|
|
@ -1406,6 +1413,12 @@ svm_vmexit(struct svm_softc *svm_sc, int vcpu, struct vm_exit *vmexit)
|
|||
info2, info1, state->rip);
|
||||
}
|
||||
break;
|
||||
case VMCB_EXIT_MONITOR:
|
||||
vmexit->exitcode = VM_EXITCODE_MONITOR;
|
||||
break;
|
||||
case VMCB_EXIT_MWAIT:
|
||||
vmexit->exitcode = VM_EXITCODE_MWAIT;
|
||||
break;
|
||||
default:
|
||||
vmm_stat_incr(svm_sc->vm, vcpu, VMEXIT_UNKNOWN, 1);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ struct svm_softc;
|
|||
#define VMCB_EXIT_MSR 0x7C
|
||||
#define VMCB_EXIT_SHUTDOWN 0x7F
|
||||
#define VMCB_EXIT_VMSAVE 0x83
|
||||
#define VMCB_EXIT_MONITOR 0x8A
|
||||
#define VMCB_EXIT_MWAIT 0x8B
|
||||
#define VMCB_EXIT_NPF 0x400
|
||||
#define VMCB_EXIT_INVALID -1
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue