mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
KVM: x86: Prioritize #UD on MOV DR over #GP due to non-zero CPL
Manually handle the CPL check for MOV DR instructions instead of using the
Priv flag, *after* checking for #UD scenarios, as #GP due to CPL>0 has
lower priority than all #UDs.
Fixes: 1e470be5a1 ("KVM: x86 emulator: fix mov dr to inject #UD when needed.")
Reviewed-by: Jim Mattson <jmattson@google.com>
Link: https://patch.msgid.link/20260612230113.684301-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
parent
e27ca3dfbb
commit
32a7188a66
|
|
@ -3844,6 +3844,9 @@ static int check_dr_read(struct x86_emulate_ctxt *ctxt)
|
|||
if ((cr4 & X86_CR4_DE) && (dr == 4 || dr == 5))
|
||||
return emulate_ud(ctxt);
|
||||
|
||||
if (ctxt->ops->cpl(ctxt))
|
||||
return emulate_gp(ctxt, 0);
|
||||
|
||||
if (ctxt->ops->get_effective_dr7(ctxt) & DR7_GD)
|
||||
return emulate_db(ctxt, DR6_BD);
|
||||
|
||||
|
|
@ -4380,11 +4383,10 @@ static const struct opcode twobyte_table[256] = {
|
|||
D(ImplicitOps | ModRM | SrcMem | NoAccess), /* NOP + 7 * reserved NOP */
|
||||
/* 0x20 - 0x2F */
|
||||
DIP(ModRM | DstMem | Priv | Op3264 | NoMod, cr_read, check_cr_access),
|
||||
DIP(ModRM | DstMem | Priv | Op3264 | NoMod, dr_read, check_dr_read),
|
||||
DIP(ModRM | DstMem | Op3264 | NoMod, dr_read, check_dr_read),
|
||||
IIP(ModRM | SrcMem | Priv | Op3264 | NoMod, em_cr_write, cr_write,
|
||||
check_cr_access),
|
||||
IIP(ModRM | SrcMem | Priv | Op3264 | NoMod, em_dr_write, dr_write,
|
||||
check_dr_write),
|
||||
IIP(ModRM | SrcMem | Op3264 | NoMod, em_dr_write, dr_write, check_dr_write),
|
||||
N, N, N, N,
|
||||
GP(ModRM | DstReg | SrcMem | Mov | Sse | Avx, &pfx_0f_28_0f_29),
|
||||
GP(ModRM | DstMem | SrcReg | Mov | Sse | Avx, &pfx_0f_28_0f_29),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user