]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
x86/msr: Prepare for including <linux/percpu.h> into <asm/msr.h>
authorThomas Gleixner <tglx@linutronix.de>
Mon, 4 Mar 2024 10:12:19 +0000 (11:12 +0100)
committerIngo Molnar <mingo@kernel.org>
Mon, 4 Mar 2024 11:01:39 +0000 (12:01 +0100)
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
arch/x86/events/intel/core.c
arch/x86/events/intel/ds.c
arch/x86/include/asm/debugreg.h
arch/x86/include/asm/fsgsbase.h
arch/x86/include/asm/processor.h
arch/x86/include/asm/special_insns.h
arch/x86/kernel/cpu/intel_pconfig.c
arch/x86/kernel/cpu/rdrand.c
arch/x86/kernel/fpu/bugs.c
arch/x86/kernel/step.c

index 3804f21ab0494f90effb7399210524ba17c73b43..768d1414897fb1de72a9cb9abad354add11828a4 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/kvm_host.h>
 
 #include <asm/cpufeature.h>
+#include <asm/debugreg.h>
 #include <asm/hardirq.h>
 #include <asm/intel-family.h>
 #include <asm/intel_pt.h>
index d49d661ec0a7d1b75d17d05b8c75a44e8d5122e7..2641ba620f12a51d4c5d71ceba3bd28557926bfb 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/sched/clock.h>
 
 #include <asm/cpu_entry_area.h>
+#include <asm/debugreg.h>
 #include <asm/perf_event.h>
 #include <asm/tlbflush.h>
 #include <asm/insn.h>
index 0cec92c430cc9d2fc24307c3e230a06e115c6fa8..fdbbbfec745aa58855641ae59e17a3a50fc2696a 100644 (file)
@@ -5,7 +5,9 @@
 #include <linux/bug.h>
 #include <linux/percpu.h>
 #include <uapi/asm/debugreg.h>
+
 #include <asm/cpufeature.h>
+#include <asm/msr.h>
 
 DECLARE_PER_CPU(unsigned long, cpu_dr7);
 
@@ -159,4 +161,26 @@ static inline unsigned long amd_get_dr_addr_mask(unsigned int dr)
 }
 #endif
 
+static inline unsigned long get_debugctlmsr(void)
+{
+       unsigned long debugctlmsr = 0;
+
+#ifndef CONFIG_X86_DEBUGCTLMSR
+       if (boot_cpu_data.x86 < 6)
+               return 0;
+#endif
+       rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
+
+       return debugctlmsr;
+}
+
+static inline void update_debugctlmsr(unsigned long debugctlmsr)
+{
+#ifndef CONFIG_X86_DEBUGCTLMSR
+       if (boot_cpu_data.x86 < 6)
+               return;
+#endif
+       wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
+}
+
 #endif /* _ASM_X86_DEBUGREG_H */
index 35cff5f2becf6bcbbdc34a890f29d3ba197e100d..9e7e8ca8e2997727d733cc5db3b64ac330e30bc8 100644 (file)
@@ -6,7 +6,7 @@
 
 #ifdef CONFIG_X86_64
 
-#include <asm/msr-index.h>
+#include <asm/msr.h>
 
 /*
  * Read/write a task's FSBASE or GSBASE. This returns the value that
index 26620d7642a9fcf9d4a822140a1dd009399ee16a..d2ef4f5e03f87bce11dbf4efa2c72aeb9529db47 100644 (file)
@@ -576,28 +576,6 @@ extern void cpu_init(void);
 extern void cpu_init_exception_handling(void);
 extern void cr4_init(void);
 
-static inline unsigned long get_debugctlmsr(void)
-{
-       unsigned long debugctlmsr = 0;
-
-#ifndef CONFIG_X86_DEBUGCTLMSR
-       if (boot_cpu_data.x86 < 6)
-               return 0;
-#endif
-       rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
-
-       return debugctlmsr;
-}
-
-static inline void update_debugctlmsr(unsigned long debugctlmsr)
-{
-#ifndef CONFIG_X86_DEBUGCTLMSR
-       if (boot_cpu_data.x86 < 6)
-               return;
-#endif
-       wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctlmsr);
-}
-
 extern void set_task_blockstep(struct task_struct *task, bool on);
 
 /* Boot loader type from the setup header: */
index 48f8dd47cf6882ac9e3920d6e7105c0eff430528..f13df37c006000fb8a4bedf54976e2975abcb113 100644 (file)
@@ -2,11 +2,11 @@
 #ifndef _ASM_X86_SPECIAL_INSNS_H
 #define _ASM_X86_SPECIAL_INSNS_H
 
-
 #ifdef __KERNEL__
-
 #include <asm/nops.h>
 #include <asm/processor-flags.h>
+
+#include <linux/errno.h>
 #include <linux/irqflags.h>
 #include <linux/jump_label.h>
 
index 0771a905b2868085028747572c066c2d99df36a3..5be2b1790282671fc1934c700ea111a524759f86 100644 (file)
@@ -7,6 +7,8 @@
  * Author:
  *     Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
  */
+#include <linux/bug.h>
+#include <linux/limits.h>
 
 #include <asm/cpufeature.h>
 #include <asm/intel_pconfig.h>
index 26a427fa84eab5f90d12e26ebe2bf0e8f013b735..eeac00d20926e78e97543c269e9f78a91d64fc2e 100644 (file)
@@ -6,6 +6,7 @@
  * Authors: Fenghua Yu <fenghua.yu@intel.com>,
  *          H. Peter Anvin <hpa@linux.intel.com>
  */
+#include <linux/printk.h>
 
 #include <asm/processor.h>
 #include <asm/archrandom.h>
index a06b876bbf2d11a33e6dfb3d781c292a70884fbf..edbafc5940e33bc8d5df2a020d91d1855100f06b 100644 (file)
@@ -2,6 +2,8 @@
 /*
  * x86 FPU bug checks:
  */
+#include <linux/printk.h>
+
 #include <asm/cpufeature.h>
 #include <asm/fpu/api.h>
 
index 8e2b2552b5eead37378e51c3a959c6756fc9ddc2..3e2952679b88591aa20b07976f14575292dfe489 100644 (file)
@@ -6,7 +6,9 @@
 #include <linux/sched/task_stack.h>
 #include <linux/mm.h>
 #include <linux/ptrace.h>
+
 #include <asm/desc.h>
+#include <asm/debugreg.h>
 #include <asm/mmu_context.h>
 
 unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs)