lkml.org 
[lkml]   [2025]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [RFC PATCH v1 10/15] KVM: VMX: Use WRMSRNS or its immediate form when available
From
On 4/10/2025 4:24 PM, Sean Christopherson wrote:
>> +/*
>> + * Write EAX to MSR_IA32_SPEC_CTRL.
>> + *
>> + * Choose the best WRMSR instruction based on availability.
>> + *
>> + * Replace with 'wrmsrns' and 'wrmsrns %rax, $MSR_IA32_SPEC_CTRL' once binutils support them.
>> + */
>> +.macro WRITE_EAX_TO_MSR_IA32_SPEC_CTRL
>> + ALTERNATIVE_2 __stringify(mov $MSR_IA32_SPEC_CTRL, %ecx; \
>> + xor %edx, %edx; \
>> + mov %edi, %eax; \
>> + ds wrmsr), \
>> + __stringify(mov $MSR_IA32_SPEC_CTRL, %ecx; \
>> + xor %edx, %edx; \
>> + mov %edi, %eax; \
>> + ASM_WRMSRNS), \
>> + X86_FEATURE_WRMSRNS, \
>> + __stringify(xor %_ASM_AX, %_ASM_AX; \
>> + mov %edi, %eax; \
>> + ASM_WRMSRNS_RAX; .long MSR_IA32_SPEC_CTRL), \
>> + X86_FEATURE_MSR_IMM
>> +.endm
> This is quite hideous. I have no objection to optimizing __vmx_vcpu_run(), but
> I would much prefer that a macro like this live in generic code, and that it be
> generic. It should be easy enough to provide an assembly friendly equivalent to
> __native_wrmsr_constant().

Will do.

\
 
 \ /
  Last update: 2025-04-11 18:20    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog