From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751258AbdAQSOb (ORCPT ); Tue, 17 Jan 2017 13:14:31 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:45955 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235AbdAQSO1 (ORCPT ); Tue, 17 Jan 2017 13:14:27 -0500 Date: Tue, 17 Jan 2017 18:51:06 +0100 (CET) From: Thomas Gleixner To: Borislav Petkov cc: X86 ML , LKML Subject: Re: [PATCH 02/13] x86/microcode: Use own MSR accessors In-Reply-To: <20170117173734.14251-3-bp@alien8.de> Message-ID: References: <20170117173734.14251-1-bp@alien8.de> <20170117173734.14251-3-bp@alien8.de> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > #include > > -#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