From 7d48ef45b6df0cf8985b84305e02b7440de8f50f Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Mon, 24 Mar 2025 23:25:59 +0000 Subject: [PATCH] x86/emul: Adjust handling of CR8_LEGACY The APM description of the AltMovCR8 feature bit is: "LOCK MOV CR0 means MOV CR8" Adjust the decode logic to behave like this. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Reviewed-by: Teddy Astie --- xen/arch/x86/x86_emulate/decode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/x86_emulate/decode.c b/xen/arch/x86/x86_emulate/decode.c index 2c13356c4d..57f6baffb0 100644 --- a/xen/arch/x86/x86_emulate/decode.c +++ b/xen/arch/x86/x86_emulate/decode.c @@ -780,12 +780,12 @@ decode_twobyte(struct x86_emulate_state *s, break; case 0x20: case 0x22: /* mov to/from cr */ - if ( s->lock_prefix && vcpu_has_cr8_legacy() ) + if ( s->lock_prefix && vcpu_has_cr8_legacy() && s->modrm_reg == 0 ) { - s->modrm_reg += 8; + s->modrm_reg = 8; s->lock_prefix = false; } - /* fall through */ + fallthrough; case 0x21: case 0x23: /* mov to/from dr */ ASSERT(s->ea.type == OP_REG); /* Early operand adjustment ensures this. */ generate_exception_if(s->lock_prefix, X86_EXC_UD);