x86/apic: Annotate global config variables as "read-only after init"
PATCH 1/1 x86/apic: Annotate global config variables as "read-only after init"
Mark the APIC's global config variables that are constant after boot as __ro_after_init to help document that the majority of the APIC config is not changed at runtime, and to harden the kernel a smidge.
Signed-off-by Sean Christopherson <[email protected]>
---
This applies on tip/x86/apic, which is currently:
43931d350f30 ("x86/apic/x2apic: Implement IPI shorthands support")
Let me know if this patch should be based on a different tree.
arch/x86/kernel/apic/apic.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
arch/x86/kernel/apic/apic.c +13 -13
@@ -65,10 +65,10 @@ unsigned int num_processors;unsigned disabled_cpus;/* Processor that is doing the boot up */ -unsigned int boot_cpu_physical_apicid =-1U ; +unsigned int boot_cpu_physical_apicid__ro_after_init =-1U ;EXPORT_SYMBOL_GPL (boot_cpu_physical_apicid); -u8 boot_cpu_apic_version; +u8 boot_cpu_apic_version__ro_after_init ;/* * The highest APIC ID seen during enumeration.
@@ -85,13 +85,13 @@ physid_mask_t phys_cpu_present_map;* disable_cpu_apicid=<int>, mostly used for the kdump 2nd kernel to * avoid undefined behaviour caused by sending INIT from AP to BSP. */ -static unsigned int disabled_cpu_apicid__read_mostly =BAD_APICID ; +static unsigned int disabled_cpu_apicid__ro_after_init =BAD_APICID ;/* * This variable controls which CPUs receive external NMIs. By default, * external NMIs are delivered only to the BSP. */ -static int apic_extnmi =APIC_EXTNMI_BSP ; +static int apic_extnmi__ro_after_init =APIC_EXTNMI_BSP ;/* * Map cpu index to physical APIC ID
@@ -114,7 +114,7 @@ EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_acpiid);DEFINE_EARLY_PER_CPU_READ_MOSTLY (int, x86_cpu_to_logical_apicid,BAD_APICID );/* Local APIC was disabled by the BIOS and enabled by the kernel */ -static int enabled_via_apicbase; +static int enabled_via_apicbase__ro_after_init ;/* * Handle interrupt mode configuration register (IMCR).
@@ -172,23 +172,23 @@ static __init int setup_apicpmtimer(char *s)__setup ("apicpmtimer" , setup_apicpmtimer);#endif -unsigned long mp_lapic_addr; -int disable_apic; +unsigned long mp_lapic_addr__ro_after_init ; +int disable_apic__ro_after_init ;/* Disable local APIC timer from the kernel commandline or via dmi quirk */ static int disable_apic_timer__initdata ;/* Local APIC timer works in C2 */ -int local_apic_timer_c2_ok; +int local_apic_timer_c2_ok__ro_after_init ;EXPORT_SYMBOL_GPL (local_apic_timer_c2_ok);/* * Debug level, exported for io_apic.c */ -int apic_verbosity; +int apic_verbosity__ro_after_init ; -int pic_mode; +int pic_mode__ro_after_init ;/* Have we found an MP table */ -int smp_found_config; +int smp_found_config__ro_after_init ;static struct resource lapic_resource = { .name ="Local APIC" ,
@@ -199,7 +199,7 @@ unsigned int lapic_timer_period = 0;static void apic_pm_activate (void ); -static unsigned long apic_phys; +static unsigned long apic_phys__ro_after_init ;/* * Get the LAPIC version
@@ -1278,7 +1278,7 @@ void __init sync_Arb_IDs(void) APIC_INT_LEVELTRIG | APIC_DM_INIT); } -enum apic_intr_mode_id apic_intr_mode; +enum apic_intr_mode_id apic_intr_mode__ro_after_init ;static int __init apic_intr_mode_select (void ) {
Signature · 1 line
2.22.0
tip-bot for Sean Christopherson
merge botx86/apic: Annotate global config variables as "read-only after init"
Commit-ID: 6444b40eeda4f78f57b255dd7ecb8d3e5936eea2 Gitweb: https://git.kernel.org/tip/6444b40eeda4f78f57b255dd7ecb8d3e5936eea2 Author: Sean Christopherson <[email protected]> AuthorDate: Mon, 5 Aug 2019 14:21:34 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Wed, 7 Aug 2019 15:24:21 +0200
x86/apic: Annotate global config variables as "read-only after init"
Mark the APIC's global config variables that are constant after boot as __ro_after_init to help document that the majority of the APIC config is not changed at runtime, and to harden the kernel a smidge.
Signed-off-by Sean Christopherson <[email protected]>
Signed-off-by Thomas Gleixner <[email protected]>
--- arch/x86/kernel/apic/apic.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
arch/x86/kernel/apic/apic.c +13 -13
@@ -65,10 +65,10 @@ unsigned int num_processors;unsigned disabled_cpus;/* Processor that is doing the boot up */ -unsigned int boot_cpu_physical_apicid =-1U ; +unsigned int boot_cpu_physical_apicid__ro_after_init =-1U ;EXPORT_SYMBOL_GPL (boot_cpu_physical_apicid); -u8 boot_cpu_apic_version; +u8 boot_cpu_apic_version__ro_after_init ;/* * The highest APIC ID seen during enumeration.
@@ -85,13 +85,13 @@ physid_mask_t phys_cpu_present_map;* disable_cpu_apicid=<int>, mostly used for the kdump 2nd kernel to * avoid undefined behaviour caused by sending INIT from AP to BSP. */ -static unsigned int disabled_cpu_apicid__read_mostly =BAD_APICID ; +static unsigned int disabled_cpu_apicid__ro_after_init =BAD_APICID ;/* * This variable controls which CPUs receive external NMIs. By default, * external NMIs are delivered only to the BSP. */ -static int apic_extnmi =APIC_EXTNMI_BSP ; +static int apic_extnmi__ro_after_init =APIC_EXTNMI_BSP ;/* * Map cpu index to physical APIC ID
@@ -114,7 +114,7 @@ EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_acpiid);DEFINE_EARLY_PER_CPU_READ_MOSTLY (int, x86_cpu_to_logical_apicid,BAD_APICID );/* Local APIC was disabled by the BIOS and enabled by the kernel */ -static int enabled_via_apicbase; +static int enabled_via_apicbase__ro_after_init ;/* * Handle interrupt mode configuration register (IMCR).
@@ -172,23 +172,23 @@ static __init int setup_apicpmtimer(char *s)__setup ("apicpmtimer" , setup_apicpmtimer);#endif -unsigned long mp_lapic_addr; -int disable_apic; +unsigned long mp_lapic_addr__ro_after_init ; +int disable_apic__ro_after_init ;/* Disable local APIC timer from the kernel commandline or via dmi quirk */ static int disable_apic_timer__initdata ;/* Local APIC timer works in C2 */ -int local_apic_timer_c2_ok; +int local_apic_timer_c2_ok__ro_after_init ;EXPORT_SYMBOL_GPL (local_apic_timer_c2_ok);/* * Debug level, exported for io_apic.c */ -int apic_verbosity; +int apic_verbosity__ro_after_init ; -int pic_mode; +int pic_mode__ro_after_init ;/* Have we found an MP table */ -int smp_found_config; +int smp_found_config__ro_after_init ;static struct resource lapic_resource = { .name ="Local APIC" ,
@@ -199,7 +199,7 @@ unsigned int lapic_timer_period = 0;static void apic_pm_activate (void ); -static unsigned long apic_phys; +static unsigned long apic_phys__ro_after_init ;/* * Get the LAPIC version
@@ -1278,7 +1278,7 @@ void __init sync_Arb_IDs(void) APIC_INT_LEVELTRIG | APIC_DM_INIT); } -enum apic_intr_mode_id apic_intr_mode; +enum apic_intr_mode_id apic_intr_mode__ro_after_init ;static int __init apic_intr_mode_select (void ) {