Skip to content

Commit 6444b40

Browse files
Sean ChristophersonKAGA-KOKO
authored andcommitted
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]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 43931d3 commit 6444b40

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

arch/x86/kernel/apic/apic.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ unsigned int num_processors;
6565
unsigned disabled_cpus;
6666

6767
/* Processor that is doing the boot up */
68-
unsigned int boot_cpu_physical_apicid = -1U;
68+
unsigned int boot_cpu_physical_apicid __ro_after_init = -1U;
6969
EXPORT_SYMBOL_GPL(boot_cpu_physical_apicid);
7070

71-
u8 boot_cpu_apic_version;
71+
u8 boot_cpu_apic_version __ro_after_init;
7272

7373
/*
7474
* The highest APIC ID seen during enumeration.
@@ -85,13 +85,13 @@ physid_mask_t phys_cpu_present_map;
8585
* disable_cpu_apicid=<int>, mostly used for the kdump 2nd kernel to
8686
* avoid undefined behaviour caused by sending INIT from AP to BSP.
8787
*/
88-
static unsigned int disabled_cpu_apicid __read_mostly = BAD_APICID;
88+
static unsigned int disabled_cpu_apicid __ro_after_init = BAD_APICID;
8989

9090
/*
9191
* This variable controls which CPUs receive external NMIs. By default,
9292
* external NMIs are delivered only to the BSP.
9393
*/
94-
static int apic_extnmi = APIC_EXTNMI_BSP;
94+
static int apic_extnmi __ro_after_init = APIC_EXTNMI_BSP;
9595

9696
/*
9797
* Map cpu index to physical APIC ID
@@ -114,7 +114,7 @@ EXPORT_EARLY_PER_CPU_SYMBOL(x86_cpu_to_acpiid);
114114
DEFINE_EARLY_PER_CPU_READ_MOSTLY(int, x86_cpu_to_logical_apicid, BAD_APICID);
115115

116116
/* Local APIC was disabled by the BIOS and enabled by the kernel */
117-
static int enabled_via_apicbase;
117+
static int enabled_via_apicbase __ro_after_init;
118118

119119
/*
120120
* Handle interrupt mode configuration register (IMCR).
@@ -172,23 +172,23 @@ static __init int setup_apicpmtimer(char *s)
172172
__setup("apicpmtimer", setup_apicpmtimer);
173173
#endif
174174

175-
unsigned long mp_lapic_addr;
176-
int disable_apic;
175+
unsigned long mp_lapic_addr __ro_after_init;
176+
int disable_apic __ro_after_init;
177177
/* Disable local APIC timer from the kernel commandline or via dmi quirk */
178178
static int disable_apic_timer __initdata;
179179
/* Local APIC timer works in C2 */
180-
int local_apic_timer_c2_ok;
180+
int local_apic_timer_c2_ok __ro_after_init;
181181
EXPORT_SYMBOL_GPL(local_apic_timer_c2_ok);
182182

183183
/*
184184
* Debug level, exported for io_apic.c
185185
*/
186-
int apic_verbosity;
186+
int apic_verbosity __ro_after_init;
187187

188-
int pic_mode;
188+
int pic_mode __ro_after_init;
189189

190190
/* Have we found an MP table */
191-
int smp_found_config;
191+
int smp_found_config __ro_after_init;
192192

193193
static struct resource lapic_resource = {
194194
.name = "Local APIC",
@@ -199,7 +199,7 @@ unsigned int lapic_timer_period = 0;
199199

200200
static void apic_pm_activate(void);
201201

202-
static unsigned long apic_phys;
202+
static unsigned long apic_phys __ro_after_init;
203203

204204
/*
205205
* Get the LAPIC version
@@ -1278,7 +1278,7 @@ void __init sync_Arb_IDs(void)
12781278
APIC_INT_LEVELTRIG | APIC_DM_INIT);
12791279
}
12801280

1281-
enum apic_intr_mode_id apic_intr_mode;
1281+
enum apic_intr_mode_id apic_intr_mode __ro_after_init;
12821282

12831283
static int __init apic_intr_mode_select(void)
12841284
{

0 commit comments

Comments
 (0)