Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1611506
| From | kan.liang@intel.com |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH V4 1/2] x86/msr: expose msr_flip_bit function |
| Date | 2017-03-29 04:10 +0200 |
| Message-ID | <tqbdE-8tJ-29@gated-at.bofh.it> (permalink) |
| References | <tqbdE-8tJ-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Kan Liang <Kan.liang@intel.com>
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 <tglx@linutronix.de>
Signed-off-by: Kan Liang <Kan.liang@intel.com>
---
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V4 0/2] measure SMI cost (kernel) kan.liang@intel.com - 2017-03-29 04:10 +0200
[PATCH V4 1/2] x86/msr: expose msr_flip_bit function kan.liang@intel.com - 2017-03-29 04:10 +0200
Re: [PATCH V4 1/2] x86/msr: expose msr_flip_bit function Thomas Gleixner <tglx@linutronix.de> - 2017-03-29 07:50 +0200
RE: [PATCH V4 1/2] x86/msr: expose msr_flip_bit function "Liang, Kan" <kan.liang@intel.com> - 2017-03-29 15:10 +0200
csiph-web