Re: [PATCH v3 08/16] x86/extable: Add support for immediate form MSR instructions
From: Jürgen Groß
Date: Wed Feb 18 2026 - 11:28:55 EST
On 18.02.26 16:48, Andrew Cooper wrote:
Ideally please CC xen-devel on all patches if you've CC'd some, or at
least CC me on all patches that you partially send to xen-devel. Having
only 4 patches of the series is very awkward to reply to.
+ /* + * To maintain consistency with existing RDMSR and WRMSR(NS)
instructions, + * the register operand for immediate form MSR
instructions is ALWAYS + * encoded as RAX in <asm/msr.h> for reading
or writing the MSR value. + */ + u64 msr_val = regs->ax;
This is unsafe. It assumes that the only source of MSR $IMM
instructions anywhere are the wrappers.
While this might be the wish of the developers, that doesn't make it true.
You've already decoded the instruction and got the ModRM byte, so either
check that it really is encoding %rax, or select the proper GPR based on
ModRM.
I'll use the proper GPR.
Thanks,
Juergen
Attachment:
OpenPGP_0xB0DE9DD628BF132F.asc
Description: OpenPGP public key
Attachment:
OpenPGP_signature.asc
Description: OpenPGP digital signature