WARN if ->set_dr() => kvm_set_dr() fails when emulating a MOV DR write, as the emulator _must_ pre-check for #GPs in order to get the event priority right when emulating MOV DR for L2 on SVM (all exceptions have higher priority than the instruction intercept). Opportunistically update the comment as the blurb about "#UD" being checked is incomplete and misleading. Signed-off-by: Sean Christopherson --- arch/x86/kvm/emulate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index b1799ed01939..e030ef9b9744 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3298,8 +3298,12 @@ static int em_dr_write(struct x86_emulate_ctxt *ctxt) else val = ctxt->src.val & ~0U; - /* #UD condition is already handled. */ - if (ctxt->ops->set_dr(ctxt, ctxt->modrm_reg, val)) + /* + * A #GP due to an illegal value should be impossible at this point, as + * such #GPs have priority over MOV DR intercepts on SVM, i.e. KVM must + * manually check the value *before* emulating the write. + */ + if (WARN_ON_ONCE(ctxt->ops->set_dr(ctxt, ctxt->modrm_reg, val))) return emulate_gp(ctxt, 0); /* Disable writeback. */ -- 2.54.0.1136.gdb2ca164c4-goog