]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86: Move sysctls into arch/x86
authorJoel Granados <joel.granados@kernel.org>
Tue, 18 Feb 2025 09:56:24 +0000 (10:56 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 18 Feb 2025 10:08:36 +0000 (11:08 +0100)
Move the following sysctl tables into arch/x86/kernel/setup.c:

  panic_on_{unrecoverable_nmi,io_nmi}
  bootloader_{type,version}
  io_delay_type
  unknown_nmi_panic
  acpi_realmode_flags

Variables moved from include/linux/ to arch/x86/include/asm/ because there
is no longer need for them outside arch/x86/kernel:

  acpi_realmode_flags
  panic_on_{unrecoverable_nmi,io_nmi}

Include <asm/nmi.h> in arch/s86/kernel/setup.h in order to bring in
panic_on_{io_nmi,unrecovered_nmi}.

This is part of a greater effort to move ctl tables into their
respective subsystems which will reduce the merge conflicts in
kerenel/sysctl.c.

Signed-off-by: Joel Granados <joel.granados@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250218-jag-mv_ctltables-v1-8-cd3698ab8d29@kernel.org
arch/x86/include/asm/setup.h
arch/x86/include/asm/traps.h
arch/x86/kernel/setup.c
include/linux/acpi.h
kernel/sysctl.c

index 85f4fde3515c4338f68e4a053bfbaa7ed2db0e0e..a8d676bba5defb6fc6e0c8e923f4752d760f6e7f 100644 (file)
@@ -46,6 +46,7 @@ void setup_bios_corruption_check(void);
 void early_platform_quirks(void);
 
 extern unsigned long saved_video_mode;
+extern unsigned long acpi_realmode_flags;
 
 extern void reserve_standard_io_resources(void);
 extern void i386_reserve_resources(void);
index 1f1deaecd364b813e4ad42c3c7a634e95059388b..869b880618018411d709ab982538913ec8082057 100644 (file)
@@ -35,8 +35,6 @@ static inline int get_si_code(unsigned long condition)
                return TRAP_BRKPT;
 }
 
-extern int panic_on_unrecovered_nmi;
-
 void math_emulate(struct math_emu_info *);
 
 bool fault_in_kernel_space(unsigned long address);
index cebee310e2009efa7cbcb64f6f841995940166d7..9f8ff3aad4f4e621db7774fa6fe1097e539f444f 100644 (file)
@@ -56,6 +56,9 @@
 #include <asm/unwind.h>
 #include <asm/vsyscall.h>
 #include <linux/vmalloc.h>
+#if defined(CONFIG_X86_LOCAL_APIC)
+#include <asm/nmi.h>
+#endif
 
 /*
  * max_low_pfn_mapped: highest directly mapped pfn < 4 GB
@@ -146,6 +149,69 @@ static size_t ima_kexec_buffer_size;
 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
 int bootloader_type, bootloader_version;
 
+static const struct ctl_table x86_sysctl_table[] = {
+       {
+               .procname       = "panic_on_unrecovered_nmi",
+               .data           = &panic_on_unrecovered_nmi,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+       {
+               .procname       = "panic_on_io_nmi",
+               .data           = &panic_on_io_nmi,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+       {
+               .procname       = "bootloader_type",
+               .data           = &bootloader_type,
+               .maxlen         = sizeof(int),
+               .mode           = 0444,
+               .proc_handler   = proc_dointvec,
+       },
+       {
+               .procname       = "bootloader_version",
+               .data           = &bootloader_version,
+               .maxlen         = sizeof(int),
+               .mode           = 0444,
+               .proc_handler   = proc_dointvec,
+       },
+       {
+               .procname       = "io_delay_type",
+               .data           = &io_delay_type,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+#if defined(CONFIG_X86_LOCAL_APIC)
+       {
+               .procname       = "unknown_nmi_panic",
+               .data           = &unknown_nmi_panic,
+               .maxlen         = sizeof(int),
+               .mode           = 0644,
+               .proc_handler   = proc_dointvec,
+       },
+#endif
+#if defined(CONFIG_ACPI_SLEEP)
+       {
+               .procname       = "acpi_video_flags",
+               .data           = &acpi_realmode_flags,
+               .maxlen         = sizeof(unsigned long),
+               .mode           = 0644,
+               .proc_handler   = proc_doulongvec_minmax,
+       },
+#endif
+};
+
+static int __init init_x86_sysctl(void)
+{
+       register_sysctl_init("kernel", x86_sysctl_table);
+       return 0;
+}
+arch_initcall(init_x86_sysctl);
+
 /*
  * Setup options
  */
index 4e495b29c640f05eecba77942ad1dc53f1b87c4b..a70e62d69dc7966c3b0d1c845798358a85ff481e 100644 (file)
@@ -330,7 +330,6 @@ static inline bool acpi_sci_irq_valid(void)
 }
 
 extern int sbf_port;
-extern unsigned long acpi_realmode_flags;
 
 int acpi_register_gsi (struct device *dev, u32 gsi, int triggering, int polarity);
 int acpi_gsi_to_irq (u32 gsi, unsigned int *irq);
index cb57da499ebb1216cefb3705694ab62028fee03e..8a37d30f2aa60fee5086cf6716e6edb2502933bd 100644 (file)
@@ -1831,16 +1831,6 @@ static const struct ctl_table kern_table[] = {
                .mode           = 0444,
                .proc_handler   = proc_dointvec,
        },
-#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
-       {
-               .procname       = "unknown_nmi_panic",
-               .data           = &unknown_nmi_panic,
-               .maxlen         = sizeof (int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
-#endif
-
 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
        defined(CONFIG_DEBUG_STACKOVERFLOW)
        {
@@ -1851,43 +1841,6 @@ static const struct ctl_table kern_table[] = {
                .proc_handler   = proc_dointvec,
        },
 #endif
-#if defined(CONFIG_X86)
-       {
-               .procname       = "panic_on_unrecovered_nmi",
-               .data           = &panic_on_unrecovered_nmi,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
-       {
-               .procname       = "panic_on_io_nmi",
-               .data           = &panic_on_io_nmi,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
-       {
-               .procname       = "bootloader_type",
-               .data           = &bootloader_type,
-               .maxlen         = sizeof (int),
-               .mode           = 0444,
-               .proc_handler   = proc_dointvec,
-       },
-       {
-               .procname       = "bootloader_version",
-               .data           = &bootloader_version,
-               .maxlen         = sizeof (int),
-               .mode           = 0444,
-               .proc_handler   = proc_dointvec,
-       },
-       {
-               .procname       = "io_delay_type",
-               .data           = &io_delay_type,
-               .maxlen         = sizeof(int),
-               .mode           = 0644,
-               .proc_handler   = proc_dointvec,
-       },
-#endif
 #if defined(CONFIG_MMU)
        {
                .procname       = "randomize_va_space",
@@ -1906,15 +1859,6 @@ static const struct ctl_table kern_table[] = {
                .proc_handler   = proc_dointvec,
        },
 #endif
-#if    defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
-       {
-               .procname       = "acpi_video_flags",
-               .data           = &acpi_realmode_flags,
-               .maxlen         = sizeof (unsigned long),
-               .mode           = 0644,
-               .proc_handler   = proc_doulongvec_minmax,
-       },
-#endif
 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
        {
                .procname       = "ignore-unaligned-usertrap",