Skip to content

Commit a25a1d6

Browse files
committed
Merge branch 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 microcode updates from Ingo Molnar: "The main changes are further simplification and unification of the code between the AMD and Intel microcode loaders, plus other simplifications - by Borislav Petkov" * 'x86-microcode-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/microcode/AMD: Remove struct cont_desc.eq_id x86/microcode/AMD: Remove AP scanning optimization x86/microcode/AMD: Simplify saving from initrd x86/microcode/AMD: Unify load_ucode_amd_ap() x86/microcode/AMD: Check patch level only on the BSP x86/microcode: Remove local vendor variable x86/microcode/AMD: Use find_microcode_in_initrd() x86/microcode/AMD: Get rid of global this_equiv_id x86/microcode: Decrease CPUID use x86/microcode/AMD: Rework container parsing x86/microcode/AMD: Extend the container struct x86/microcode/AMD: Shorten function parameter's name x86/microcode/AMD: Clean up find_equiv_id() x86/microcode: Convert to bare minimum MSR accessors x86/MSR: Carve out bare minimum accessors
2 parents 280d7a1 + f26483e commit a25a1d6

File tree

6 files changed

+249
-397
lines changed

6 files changed

+249
-397
lines changed

arch/x86/include/asm/apic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static inline void native_apic_msr_write(u32 reg, u32 v)
195195

196196
static inline void native_apic_msr_eoi_write(u32 reg, u32 v)
197197
{
198-
wrmsr_notrace(APIC_BASE_MSR + (APIC_EOI >> 4), APIC_EOI_ACK, 0);
198+
__wrmsr(APIC_BASE_MSR + (APIC_EOI >> 4), APIC_EOI_ACK, 0);
199199
}
200200

201201
static inline u32 native_apic_msr_read(u32 reg)

arch/x86/include/asm/microcode.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77

88
#define native_rdmsr(msr, val1, val2) \
99
do { \
10-
u64 __val = native_read_msr((msr)); \
10+
u64 __val = __rdmsr((msr)); \
1111
(void)((val1) = (u32)__val); \
1212
(void)((val2) = (u32)(__val >> 32)); \
1313
} while (0)
1414

1515
#define native_wrmsr(msr, low, high) \
16-
native_write_msr(msr, low, high)
16+
__wrmsr(msr, low, high)
1717

1818
#define native_wrmsrl(msr, val) \
19-
native_write_msr((msr), \
20-
(u32)((u64)(val)), \
21-
(u32)((u64)(val) >> 32))
19+
__wrmsr((msr), (u32)((u64)(val)), \
20+
(u32)((u64)(val) >> 32))
2221

2322
struct ucode_patch {
2423
struct list_head plist;

arch/x86/include/asm/microcode_amd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,4 @@ static inline int __init
5454
save_microcode_in_initrd_amd(unsigned int family) { return -EINVAL; }
5555
void reload_ucode_amd(void) {}
5656
#endif
57-
58-
extern bool check_current_patch_level(u32 *rev, bool early);
5957
#endif /* _ASM_X86_MICROCODE_AMD_H */

arch/x86/include/asm/msr.h

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,45 @@ static inline void do_trace_read_msr(unsigned int msr, u64 val, int failed) {}
8080
static inline void do_trace_rdpmc(unsigned int msr, u64 val, int failed) {}
8181
#endif
8282

83-
static inline unsigned long long native_read_msr(unsigned int msr)
83+
/*
84+
* __rdmsr() and __wrmsr() are the two primitives which are the bare minimum MSR
85+
* accessors and should not have any tracing or other functionality piggybacking
86+
* on them - those are *purely* for accessing MSRs and nothing more. So don't even
87+
* think of extending them - you will be slapped with a stinking trout or a frozen
88+
* shark will reach you, wherever you are! You've been warned.
89+
*/
90+
static inline unsigned long long notrace __rdmsr(unsigned int msr)
8491
{
8592
DECLARE_ARGS(val, low, high);
8693

8794
asm volatile("1: rdmsr\n"
8895
"2:\n"
8996
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_rdmsr_unsafe)
9097
: EAX_EDX_RET(val, low, high) : "c" (msr));
91-
if (msr_tracepoint_active(__tracepoint_read_msr))
92-
do_trace_read_msr(msr, EAX_EDX_VAL(val, low, high), 0);
98+
9399
return EAX_EDX_VAL(val, low, high);
94100
}
95101

102+
static inline void notrace __wrmsr(unsigned int msr, u32 low, u32 high)
103+
{
104+
asm volatile("1: wrmsr\n"
105+
"2:\n"
106+
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_unsafe)
107+
: : "c" (msr), "a"(low), "d" (high) : "memory");
108+
}
109+
110+
static inline unsigned long long native_read_msr(unsigned int msr)
111+
{
112+
unsigned long long val;
113+
114+
val = __rdmsr(msr);
115+
116+
if (msr_tracepoint_active(__tracepoint_read_msr))
117+
do_trace_read_msr(msr, val, 0);
118+
119+
return val;
120+
}
121+
96122
static inline unsigned long long native_read_msr_safe(unsigned int msr,
97123
int *err)
98124
{
@@ -114,31 +140,16 @@ static inline unsigned long long native_read_msr_safe(unsigned int msr,
114140
return EAX_EDX_VAL(val, low, high);
115141
}
116142

117-
/* Can be uninlined because referenced by paravirt */
118-
static inline void notrace
119-
__native_write_msr_notrace(unsigned int msr, u32 low, u32 high)
120-
{
121-
asm volatile("1: wrmsr\n"
122-
"2:\n"
123-
_ASM_EXTABLE_HANDLE(1b, 2b, ex_handler_wrmsr_unsafe)
124-
: : "c" (msr), "a"(low), "d" (high) : "memory");
125-
}
126-
127143
/* Can be uninlined because referenced by paravirt */
128144
static inline void notrace
129145
native_write_msr(unsigned int msr, u32 low, u32 high)
130146
{
131-
__native_write_msr_notrace(msr, low, high);
147+
__wrmsr(msr, low, high);
148+
132149
if (msr_tracepoint_active(__tracepoint_write_msr))
133150
do_trace_write_msr(msr, ((u64)high << 32 | low), 0);
134151
}
135152

136-
static inline void
137-
wrmsr_notrace(unsigned int msr, u32 low, u32 high)
138-
{
139-
__native_write_msr_notrace(msr, low, high);
140-
}
141-
142153
/* Can be uninlined because referenced by paravirt */
143154
static inline int notrace
144155
native_write_msr_safe(unsigned int msr, u32 low, u32 high)

0 commit comments

Comments
 (0)