Re: [PATCH 3/6] x86/msr: minimize usage of native_*() msr access functions
From: Wei Liu
Date: Fri May 09 2025 - 17:49:51 EST
On Tue, May 06, 2025 at 11:20:12AM +0200, Juergen Gross wrote:
> In order to prepare for some MSR access function reorg work, switch
> most users of native_{read|write}_msr[_safe]() to the more generic
> rdmsr*()/wrmsr*() variants.
>
> For now this will have some intermediate performance impact with
> paravirtualization configured when running on bare metal, but this
> is a prereq change for the planned direct inlining of the rdmsr/wrmsr
> instructions with this configuration.
>
> The main reason for this switch is the planned move of the MSR trace
> function invocation from the native_*() functions to the generic
> rdmsr*()/wrmsr*() variants. Without this switch the users of the
> native_*() functions would lose the related tracing entries.
>
> Note that the Xen related MSR access functions will not be switched,
> as these will be handled after the move of the trace hooks.
>
> Signed-off-by: Juergen Gross <jgross@xxxxxxxx>
> ---
> arch/x86/hyperv/ivm.c | 2 +-
Acked-by: Wei Liu <wei.liu@xxxxxxxxxx>
>
> diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
> index 09a165a3c41e..fe177a6be581 100644
> --- a/arch/x86/hyperv/ivm.c
> +++ b/arch/x86/hyperv/ivm.c
> @@ -319,7 +319,7 @@ int hv_snp_boot_ap(u32 cpu, unsigned long start_ip)
> asm volatile("movl %%ds, %%eax;" : "=a" (vmsa->ds.selector));
> hv_populate_vmcb_seg(vmsa->ds, vmsa->gdtr.base);
>
> - vmsa->efer = native_read_msr(MSR_EFER);
> + rdmsrq(MSR_EFER, vmsa->efer);
>