Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752314AbdC2CDo (ORCPT ); Tue, 28 Mar 2017 22:03:44 -0400 Received: from mga06.intel.com ([134.134.136.31]:49916 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbdC2CDU (ORCPT ); Tue, 28 Mar 2017 22:03:20 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,239,1486454400"; d="scan'208";a="82117847" From: kan.liang@intel.com To: peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, linux-kernel@vger.kernel.org Cc: bp@alien8.de, acme@kernel.org, eranian@google.com, jolsa@kernel.org, ak@linux.intel.com, Kan Liang Subject: [PATCH V4 1/2] x86/msr: expose msr_flip_bit function Date: Tue, 28 Mar 2017 18:45:19 -0700 Message-Id: <1490751920-44720-2-git-send-email-kan.liang@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490751920-44720-1-git-send-email-kan.liang@intel.com> References: <1490751920-44720-1-git-send-email-kan.liang@intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1915 Lines: 68 From: Kan Liang There is no exported kernel interfaces which can flip a MSR bit. It has to do read-modify-write operation on the MSR through rd/wrmsr* interfaces. But the method is not atomic. There is already __flip_bit support. Just rename and expose it. Suggested-by: Thomas Gleixner Signed-off-by: Kan Liang --- arch/x86/include/asm/msr.h | 1 + arch/x86/lib/msr.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/msr.h b/arch/x86/include/asm/msr.h index 898dba2..c1e3026 100644 --- a/arch/x86/include/asm/msr.h +++ b/arch/x86/include/asm/msr.h @@ -312,6 +312,7 @@ struct msr *msrs_alloc(void); void msrs_free(struct msr *msrs); int msr_set_bit(u32 msr, u8 bit); int msr_clear_bit(u32 msr, u8 bit); +int msr_flip_bit(u32 msr, u8 bit, bool set); #ifdef CONFIG_SMP int rdmsr_on_cpu(unsigned int cpu, u32 msr_no, u32 *l, u32 *h); diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c index 0776425..9bda539 100644 --- a/arch/x86/lib/msr.c +++ b/arch/x86/lib/msr.c @@ -58,7 +58,7 @@ int msr_write(u32 msr, struct msr *m) return wrmsrl_safe(msr, m->q); } -static inline int __flip_bit(u32 msr, u8 bit, bool set) +int msr_flip_bit(u32 msr, u8 bit, bool set) { struct msr m, m1; int err = -EINVAL; @@ -85,6 +85,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set) return 1; } +EXPORT_SYMBOL_GPL(msr_flip_bit); /** * Set @bit in a MSR @msr. @@ -96,7 +97,7 @@ static inline int __flip_bit(u32 msr, u8 bit, bool set) */ int msr_set_bit(u32 msr, u8 bit) { - return __flip_bit(msr, bit, true); + return msr_flip_bit(msr, bit, true); } /** @@ -109,7 +110,7 @@ int msr_set_bit(u32 msr, u8 bit) */ int msr_clear_bit(u32 msr, u8 bit) { - return __flip_bit(msr, bit, false); + return msr_flip_bit(msr, bit, false); } #ifdef CONFIG_TRACEPOINTS -- 2.7.4