Skip to content

Commit 154fcf3

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h>
To clean up the per CPU insanity of UP which causes sparse to be rightfully unhappy and prevents the usage of the generic per CPU accessors on cpu_info it is necessary to include <linux/percpu.h> into <asm/msr.h>. Including <linux/percpu.h> into <asm/msr.h> is impossible because it ends up in header dependency hell. The problem is that <asm/processor.h> includes <asm/msr.h>. The inclusion of <linux/percpu.h> results in a compile fail where the compiler cannot longer handle an include in <asm/cpufeature.h> which references boot_cpu_data which is defined in <asm/processor.h>. The only reason why <asm/msr.h> is included in <asm/processor.h> are the set/get_debugctlmsr() inlines. They are defined there because <asm/processor.h> is such a nice dump ground for everything. In fact they belong obviously into <asm/debugreg.h>. Move them to <asm/debugreg.h> and fix up the resulting damage which is just exposing the reliance on random include chains. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lore.kernel.org/r/20240304005104.454678686@linutronix.de
1 parent 9eae297 commit 154fcf3

File tree

10 files changed

+36
-25
lines changed

10 files changed

+36
-25
lines changed

arch/x86/events/intel/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/kvm_host.h>
1818

1919
#include <asm/cpufeature.h>
20+
#include <asm/debugreg.h>
2021
#include <asm/hardirq.h>
2122
#include <asm/intel-family.h>
2223
#include <asm/intel_pt.h>

arch/x86/events/intel/ds.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/sched/clock.h>
66

77
#include <asm/cpu_entry_area.h>
8+
#include <asm/debugreg.h>
89
#include <asm/perf_event.h>
910
#include <asm/tlbflush.h>
1011
#include <asm/insn.h>

arch/x86/include/asm/debugreg.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include <linux/bug.h>
66
#include <linux/percpu.h>
77
#include <uapi/asm/debugreg.h>
8+
89
#include <asm/cpufeature.h>
10+
#include <asm/msr.h>
911

1012
DECLARE_PER_CPU(unsigned long, cpu_dr7);
1113

@@ -159,4 +161,26 @@ static inline unsigned long amd_get_dr_addr_mask(unsigned int dr)
159161
}
160162
#endif
161163

164+
static inline unsigned long get_debugctlmsr(void)
165+
{
166+
unsigned long debugctlmsr = 0;
167+
168+
#ifndef CONFIG_X86_DEBUGCTLMSR
169+
if (boot_cpu_data.x86 < 6)
170+
return 0;
171+
#endif
172+
rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
173+
174+
return debugctlmsr;
175+
}
176+
177+
static inline void update_debugctlmsr(unsigned long debugctlmsr)
178+
{
179+
#ifndef CONFIG_X86_DEBUGCTLMSR
180+
if (boot_cpu_data.x86 < 6)
181+
return;
182+
#endif
183+
wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
184+
}
185+
162186
#endif /* _ASM_X86_DEBUGREG_H */

arch/x86/include/asm/fsgsbase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#ifdef CONFIG_X86_64
88

9-
#include <asm/msr-index.h>
9+
#include <asm/msr.h>
1010

1111
/*
1212
* Read/write a task's FSBASE or GSBASE. This returns the value that

arch/x86/include/asm/processor.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -576,28 +576,6 @@ extern void cpu_init(void);
576576
extern void cpu_init_exception_handling(void);
577577
extern void cr4_init(void);
578578

579-
static inline unsigned long get_debugctlmsr(void)
580-
{
581-
unsigned long debugctlmsr = 0;
582-
583-
#ifndef CONFIG_X86_DEBUGCTLMSR
584-
if (boot_cpu_data.x86 < 6)
585-
return 0;
586-
#endif
587-
rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
588-
589-
return debugctlmsr;
590-
}
591-
592-
static inline void update_debugctlmsr(unsigned long debugctlmsr)
593-
{
594-
#ifndef CONFIG_X86_DEBUGCTLMSR
595-
if (boot_cpu_data.x86 < 6)
596-
return;
597-
#endif
598-
wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
599-
}
600-
601579
extern void set_task_blockstep(struct task_struct *task, bool on);
602580

603581
/* Boot loader type from the setup header: */

arch/x86/include/asm/special_insns.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
#ifndef _ASM_X86_SPECIAL_INSNS_H
33
#define _ASM_X86_SPECIAL_INSNS_H
44

5-
65
#ifdef __KERNEL__
7-
86
#include <asm/nops.h>
97
#include <asm/processor-flags.h>
8+
9+
#include <linux/errno.h>
1010
#include <linux/irqflags.h>
1111
#include <linux/jump_label.h>
1212

arch/x86/kernel/cpu/intel_pconfig.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* Author:
88
* Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
99
*/
10+
#include <linux/bug.h>
11+
#include <linux/limits.h>
1012

1113
#include <asm/cpufeature.h>
1214
#include <asm/intel_pconfig.h>

arch/x86/kernel/cpu/rdrand.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* Authors: Fenghua Yu <fenghua.yu@intel.com>,
77
* H. Peter Anvin <hpa@linux.intel.com>
88
*/
9+
#include <linux/printk.h>
910

1011
#include <asm/processor.h>
1112
#include <asm/archrandom.h>

arch/x86/kernel/fpu/bugs.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/*
33
* x86 FPU bug checks:
44
*/
5+
#include <linux/printk.h>
6+
57
#include <asm/cpufeature.h>
68
#include <asm/fpu/api.h>
79

arch/x86/kernel/step.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#include <linux/sched/task_stack.h>
77
#include <linux/mm.h>
88
#include <linux/ptrace.h>
9+
910
#include <asm/desc.h>
11+
#include <asm/debugreg.h>
1012
#include <asm/mmu_context.h>
1113

1214
unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs)

0 commit comments

Comments
 (0)