Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1560884

Re: [PATCH 02/13] x86/microcode: Use own MSR accessors

From Thomas Gleixner <tglx@linutronix.de>
Newsgroups linux.kernel
Subject Re: [PATCH 02/13] x86/microcode: Use own MSR accessors
Date 2017-01-17 19:20 +0100
Message-ID <t0Gwp-1Z2-5@gated-at.bofh.it> (permalink)
References <t0FTI-1vq-27@gated-at.bofh.it> <t0G3o-1zz-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, 17 Jan 2017, Borislav Petkov wrote:
> diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h
> index 38711df3bcb5..fbecea6e46e2 100644
> --- a/arch/x86/include/asm/microcode.h
> +++ b/arch/x86/include/asm/microcode.h
> @@ -5,20 +5,33 @@
>  #include <linux/earlycpio.h>
>  #include <linux/initrd.h>
>  
> -#define native_rdmsr(msr, val1, val2)			\
> +static inline unsigned long long __rdmsr(unsigned int msr)
> +{
> +	DECLARE_ARGS(val, low, high);
> +
> +	asm volatile("1: rdmsr\n"
> +		     "2:\n"
> +		     : EAX_EDX_RET(val, low, high) : "c" (msr));
> +	return EAX_EDX_VAL(val, low, high);
> +}
> +
> +#define microcode_rdmsr(msr, val1, val2)		\
>  do {							\
> -	u64 __val = native_read_msr((msr));		\
> +	u64 __val = __rdmsr((msr));			\
>  	(void)((val1) = (u32)__val);			\
>  	(void)((val2) = (u32)(__val >> 32));		\
>  } while (0)
>  
> -#define native_wrmsr(msr, low, high)			\
> -	native_write_msr(msr, low, high)
> +static inline void microcode_wrmsr(unsigned int msr, u64 val)
> +{
> +	u32 low, high;
> +
> +	low  = (u32)val;
> +	high = (u32)(val >> 32);
>  
> -#define native_wrmsrl(msr, val)				\
> -	native_write_msr((msr),				\
> -			 (u32)((u64)(val)),		\
> -			 (u32)((u64)(val) >> 32))
> +	asm volatile("wrmsr\n"
> +		     :: "c" (msr), "a"(low), "d" (high) : "memory");
> +}

msr.h already has:

wrmsr_notrace() so adding wrmsrl_notrace() to it should be a nobrainer.

Providing rdmsr_notrace() in msr.h is a natural extension of the existing
interfaces.

That would get rid of all the extra microcode specific MSR accessors which
are just yet another copy of stuff in msr.h.

Thanks,

	tglx

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 02/13] x86/microcode: Use own MSR accessors Borislav Petkov <bp@alien8.de> - 2017-01-17 18:50 +0100
  Re: [PATCH 02/13] x86/microcode: Use own MSR accessors Thomas Gleixner <tglx@linutronix.de> - 2017-01-17 19:20 +0100
    Re: [PATCH 02/13] x86/microcode: Use own MSR accessors Borislav Petkov <bp@alien8.de> - 2017-01-17 19:30 +0100
      Re: [PATCH 02/13] x86/microcode: Use own MSR accessors Thomas Gleixner <tglx@linutronix.de> - 2017-01-17 20:20 +0100
        Re: [PATCH 02/13] x86/microcode: Use own MSR accessors Borislav Petkov <bp@alien8.de> - 2017-01-17 23:50 +0100
          Re: [PATCH 02/13] x86/microcode: Use own MSR accessors Thomas Gleixner <tglx@linutronix.de> - 2017-01-18 11:00 +0100

csiph-web