Skip to content

Commit d55d5bc

Browse files
ardbiesheuvelIngo Molnar
authored andcommitted
x86/boot: Rename conflicting 'boot_params' pointer to 'boot_params_ptr'
The x86 decompressor is built and linked as a separate executable, but it shares components with the kernel proper, which are either #include'd as C files, or linked into the decompresor as a static library (e.g, the EFI stub) Both the kernel itself and the decompressor define a global symbol 'boot_params' to refer to the boot_params struct, but in the former case, it refers to the struct directly, whereas in the decompressor, it refers to a global pointer variable referring to the struct boot_params passed by the bootloader or constructed from scratch. This ambiguity is unfortunate, and makes it impossible to assign this decompressor variable from the x86 EFI stub, given that declaring it as extern results in a clash. So rename the decompressor version (whose scope is limited) to boot_params_ptr. [ mingo: Renamed 'boot_params_p' to 'boot_params_ptr' for clarity ] Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: [email protected]
1 parent d2a285d commit d55d5bc

File tree

10 files changed

+48
-47
lines changed

10 files changed

+48
-47
lines changed

arch/x86/boot/compressed/acpi.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ __efi_get_rsdp_addr(unsigned long cfg_tbl_pa, unsigned int cfg_tbl_len)
3030
* Search EFI system tables for RSDP. Preferred is ACPI_20_TABLE_GUID to
3131
* ACPI_TABLE_GUID because it has more features.
3232
*/
33-
rsdp_addr = efi_find_vendor_table(boot_params, cfg_tbl_pa, cfg_tbl_len,
33+
rsdp_addr = efi_find_vendor_table(boot_params_ptr, cfg_tbl_pa, cfg_tbl_len,
3434
ACPI_20_TABLE_GUID);
3535
if (rsdp_addr)
3636
return (acpi_physical_address)rsdp_addr;
3737

3838
/* No ACPI_20_TABLE_GUID found, fallback to ACPI_TABLE_GUID. */
39-
rsdp_addr = efi_find_vendor_table(boot_params, cfg_tbl_pa, cfg_tbl_len,
39+
rsdp_addr = efi_find_vendor_table(boot_params_ptr, cfg_tbl_pa, cfg_tbl_len,
4040
ACPI_TABLE_GUID);
4141
if (rsdp_addr)
4242
return (acpi_physical_address)rsdp_addr;
@@ -56,15 +56,15 @@ static acpi_physical_address efi_get_rsdp_addr(void)
5656
enum efi_type et;
5757
int ret;
5858

59-
et = efi_get_type(boot_params);
59+
et = efi_get_type(boot_params_ptr);
6060
if (et == EFI_TYPE_NONE)
6161
return 0;
6262

63-
systab_pa = efi_get_system_table(boot_params);
63+
systab_pa = efi_get_system_table(boot_params_ptr);
6464
if (!systab_pa)
6565
error("EFI support advertised, but unable to locate system table.");
6666

67-
ret = efi_get_conf_table(boot_params, &cfg_tbl_pa, &cfg_tbl_len);
67+
ret = efi_get_conf_table(boot_params_ptr, &cfg_tbl_pa, &cfg_tbl_len);
6868
if (ret || !cfg_tbl_pa)
6969
error("EFI config table not found.");
7070

@@ -156,7 +156,7 @@ acpi_physical_address get_rsdp_addr(void)
156156
{
157157
acpi_physical_address pa;
158158

159-
pa = boot_params->acpi_rsdp_addr;
159+
pa = boot_params_ptr->acpi_rsdp_addr;
160160

161161
if (!pa)
162162
pa = efi_get_rsdp_addr();
@@ -210,7 +210,7 @@ static unsigned long get_acpi_srat_table(void)
210210
rsdp = (struct acpi_table_rsdp *)get_cmdline_acpi_rsdp();
211211
if (!rsdp)
212212
rsdp = (struct acpi_table_rsdp *)(long)
213-
boot_params->acpi_rsdp_addr;
213+
boot_params_ptr->acpi_rsdp_addr;
214214

215215
if (!rsdp)
216216
return 0;

arch/x86/boot/compressed/cmdline.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ static inline char rdfs8(addr_t addr)
1414
#include "../cmdline.c"
1515
unsigned long get_cmd_line_ptr(void)
1616
{
17-
unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
17+
unsigned long cmd_line_ptr = boot_params_ptr->hdr.cmd_line_ptr;
1818

19-
cmd_line_ptr |= (u64)boot_params->ext_cmd_line_ptr << 32;
19+
cmd_line_ptr |= (u64)boot_params_ptr->ext_cmd_line_ptr << 32;
2020

2121
return cmd_line_ptr;
2222
}

arch/x86/boot/compressed/ident_map_64.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,17 @@ void initialize_identity_maps(void *rmode)
151151
* or does not touch all the pages covering them.
152152
*/
153153
kernel_add_identity_map((unsigned long)_head, (unsigned long)_end);
154-
boot_params = rmode;
155-
kernel_add_identity_map((unsigned long)boot_params, (unsigned long)(boot_params + 1));
154+
boot_params_ptr = rmode;
155+
kernel_add_identity_map((unsigned long)boot_params_ptr,
156+
(unsigned long)(boot_params_ptr + 1));
156157
cmdline = get_cmd_line_ptr();
157158
kernel_add_identity_map(cmdline, cmdline + COMMAND_LINE_SIZE);
158159

159160
/*
160161
* Also map the setup_data entries passed via boot_params in case they
161162
* need to be accessed by uncompressed kernel via the identity mapping.
162163
*/
163-
sd = (struct setup_data *)boot_params->hdr.setup_data;
164+
sd = (struct setup_data *)boot_params_ptr->hdr.setup_data;
164165
while (sd) {
165166
unsigned long sd_addr = (unsigned long)sd;
166167

arch/x86/boot/compressed/kaslr.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static unsigned long get_boot_seed(void)
6363
unsigned long hash = 0;
6464

6565
hash = rotate_xor(hash, build_str, sizeof(build_str));
66-
hash = rotate_xor(hash, boot_params, sizeof(*boot_params));
66+
hash = rotate_xor(hash, boot_params_ptr, sizeof(*boot_params_ptr));
6767

6868
return hash;
6969
}
@@ -383,7 +383,7 @@ static void handle_mem_options(void)
383383
static void mem_avoid_init(unsigned long input, unsigned long input_size,
384384
unsigned long output)
385385
{
386-
unsigned long init_size = boot_params->hdr.init_size;
386+
unsigned long init_size = boot_params_ptr->hdr.init_size;
387387
u64 initrd_start, initrd_size;
388388
unsigned long cmd_line, cmd_line_size;
389389

@@ -395,10 +395,10 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
395395
mem_avoid[MEM_AVOID_ZO_RANGE].size = (output + init_size) - input;
396396

397397
/* Avoid initrd. */
398-
initrd_start = (u64)boot_params->ext_ramdisk_image << 32;
399-
initrd_start |= boot_params->hdr.ramdisk_image;
400-
initrd_size = (u64)boot_params->ext_ramdisk_size << 32;
401-
initrd_size |= boot_params->hdr.ramdisk_size;
398+
initrd_start = (u64)boot_params_ptr->ext_ramdisk_image << 32;
399+
initrd_start |= boot_params_ptr->hdr.ramdisk_image;
400+
initrd_size = (u64)boot_params_ptr->ext_ramdisk_size << 32;
401+
initrd_size |= boot_params_ptr->hdr.ramdisk_size;
402402
mem_avoid[MEM_AVOID_INITRD].start = initrd_start;
403403
mem_avoid[MEM_AVOID_INITRD].size = initrd_size;
404404
/* No need to set mapping for initrd, it will be handled in VO. */
@@ -413,8 +413,8 @@ static void mem_avoid_init(unsigned long input, unsigned long input_size,
413413
}
414414

415415
/* Avoid boot parameters. */
416-
mem_avoid[MEM_AVOID_BOOTPARAMS].start = (unsigned long)boot_params;
417-
mem_avoid[MEM_AVOID_BOOTPARAMS].size = sizeof(*boot_params);
416+
mem_avoid[MEM_AVOID_BOOTPARAMS].start = (unsigned long)boot_params_ptr;
417+
mem_avoid[MEM_AVOID_BOOTPARAMS].size = sizeof(*boot_params_ptr);
418418

419419
/* We don't need to set a mapping for setup_data. */
420420

@@ -447,7 +447,7 @@ static bool mem_avoid_overlap(struct mem_vector *img,
447447
}
448448

449449
/* Avoid all entries in the setup_data linked list. */
450-
ptr = (struct setup_data *)(unsigned long)boot_params->hdr.setup_data;
450+
ptr = (struct setup_data *)(unsigned long)boot_params_ptr->hdr.setup_data;
451451
while (ptr) {
452452
struct mem_vector avoid;
453453

@@ -706,7 +706,7 @@ static inline bool memory_type_is_free(efi_memory_desc_t *md)
706706
static bool
707707
process_efi_entries(unsigned long minimum, unsigned long image_size)
708708
{
709-
struct efi_info *e = &boot_params->efi_info;
709+
struct efi_info *e = &boot_params_ptr->efi_info;
710710
bool efi_mirror_found = false;
711711
struct mem_vector region;
712712
efi_memory_desc_t *md;
@@ -777,8 +777,8 @@ static void process_e820_entries(unsigned long minimum,
777777
struct boot_e820_entry *entry;
778778

779779
/* Verify potential e820 positions, appending to slots list. */
780-
for (i = 0; i < boot_params->e820_entries; i++) {
781-
entry = &boot_params->e820_table[i];
780+
for (i = 0; i < boot_params_ptr->e820_entries; i++) {
781+
entry = &boot_params_ptr->e820_table[i];
782782
/* Skip non-RAM entries. */
783783
if (entry->type != E820_TYPE_RAM)
784784
continue;
@@ -852,7 +852,7 @@ void choose_random_location(unsigned long input,
852852
return;
853853
}
854854

855-
boot_params->hdr.loadflags |= KASLR_FLAG;
855+
boot_params_ptr->hdr.loadflags |= KASLR_FLAG;
856856

857857
if (IS_ENABLED(CONFIG_X86_32))
858858
mem_limit = KERNEL_IMAGE_SIZE;

arch/x86/boot/compressed/mem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ bool init_unaccepted_memory(void)
5454
enum efi_type et;
5555
int ret;
5656

57-
et = efi_get_type(boot_params);
57+
et = efi_get_type(boot_params_ptr);
5858
if (et == EFI_TYPE_NONE)
5959
return false;
6060

61-
ret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len);
61+
ret = efi_get_conf_table(boot_params_ptr, &cfg_table_pa, &cfg_table_len);
6262
if (ret) {
6363
warn("EFI config table not found.");
6464
return false;
6565
}
6666

67-
table = (void *)efi_find_vendor_table(boot_params, cfg_table_pa,
67+
table = (void *)efi_find_vendor_table(boot_params_ptr, cfg_table_pa,
6868
cfg_table_len, guid);
6969
if (!table)
7070
return false;

arch/x86/boot/compressed/misc.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void *memmove(void *dest, const void *src, size_t n);
4646
/*
4747
* This is set up by the setup-routine at boot-time
4848
*/
49-
struct boot_params *boot_params;
49+
struct boot_params *boot_params_ptr;
5050

5151
struct port_io_ops pio_ops;
5252

@@ -132,8 +132,8 @@ void __putstr(const char *s)
132132
if (lines == 0 || cols == 0)
133133
return;
134134

135-
x = boot_params->screen_info.orig_x;
136-
y = boot_params->screen_info.orig_y;
135+
x = boot_params_ptr->screen_info.orig_x;
136+
y = boot_params_ptr->screen_info.orig_y;
137137

138138
while ((c = *s++) != '\0') {
139139
if (c == '\n') {
@@ -154,8 +154,8 @@ void __putstr(const char *s)
154154
}
155155
}
156156

157-
boot_params->screen_info.orig_x = x;
158-
boot_params->screen_info.orig_y = y;
157+
boot_params_ptr->screen_info.orig_x = x;
158+
boot_params_ptr->screen_info.orig_y = y;
159159

160160
pos = (x + cols * y) * 2; /* Update cursor position */
161161
outb(14, vidport);
@@ -382,23 +382,23 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)
382382
size_t entry_offset;
383383

384384
/* Retain x86 boot parameters pointer passed from startup_32/64. */
385-
boot_params = rmode;
385+
boot_params_ptr = rmode;
386386

387387
/* Clear flags intended for solely in-kernel use. */
388-
boot_params->hdr.loadflags &= ~KASLR_FLAG;
388+
boot_params_ptr->hdr.loadflags &= ~KASLR_FLAG;
389389

390-
sanitize_boot_params(boot_params);
390+
sanitize_boot_params(boot_params_ptr);
391391

392-
if (boot_params->screen_info.orig_video_mode == 7) {
392+
if (boot_params_ptr->screen_info.orig_video_mode == 7) {
393393
vidmem = (char *) 0xb0000;
394394
vidport = 0x3b4;
395395
} else {
396396
vidmem = (char *) 0xb8000;
397397
vidport = 0x3d4;
398398
}
399399

400-
lines = boot_params->screen_info.orig_video_lines;
401-
cols = boot_params->screen_info.orig_video_cols;
400+
lines = boot_params_ptr->screen_info.orig_video_lines;
401+
cols = boot_params_ptr->screen_info.orig_video_cols;
402402

403403
init_default_io_ops();
404404

@@ -417,7 +417,7 @@ asmlinkage __visible void *extract_kernel(void *rmode, unsigned char *output)
417417
* so that early debugging output from the RSDP parsing code can be
418418
* collected.
419419
*/
420-
boot_params->acpi_rsdp_addr = get_rsdp_addr();
420+
boot_params_ptr->acpi_rsdp_addr = get_rsdp_addr();
421421

422422
debug_putstr("early console in extract_kernel\n");
423423

arch/x86/boot/compressed/misc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ extern memptr free_mem_ptr;
6161
extern memptr free_mem_end_ptr;
6262
void *malloc(int size);
6363
void free(void *where);
64-
extern struct boot_params *boot_params;
6564
void __putstr(const char *s);
6665
void __puthex(unsigned long value);
6766
#define error_putstr(__x) __putstr(__x)

arch/x86/boot/compressed/pgtable_64.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ static char trampoline_save[TRAMPOLINE_32BIT_SIZE];
2828
*/
2929
unsigned long *trampoline_32bit __section(".data");
3030

31-
extern struct boot_params *boot_params;
3231
int cmdline_find_option_bool(const char *option);
3332

3433
static unsigned long find_trampoline_placement(void)
@@ -49,7 +48,7 @@ static unsigned long find_trampoline_placement(void)
4948
*
5049
* Only look for values in the legacy ROM for non-EFI system.
5150
*/
52-
signature = (char *)&boot_params->efi_info.efi_loader_signature;
51+
signature = (char *)&boot_params_ptr->efi_info.efi_loader_signature;
5352
if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) &&
5453
strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) {
5554
ebda_start = *(unsigned short *)0x40e << 4;
@@ -65,10 +64,10 @@ static unsigned long find_trampoline_placement(void)
6564
bios_start = round_down(bios_start, PAGE_SIZE);
6665

6766
/* Find the first usable memory region under bios_start. */
68-
for (i = boot_params->e820_entries - 1; i >= 0; i--) {
67+
for (i = boot_params_ptr->e820_entries - 1; i >= 0; i--) {
6968
unsigned long new = bios_start;
7069

71-
entry = &boot_params->e820_table[i];
70+
entry = &boot_params_ptr->e820_table[i];
7271

7372
/* Skip all entries above bios_start. */
7473
if (bios_start <= entry->addr)
@@ -107,7 +106,7 @@ asmlinkage void configure_5level_paging(struct boot_params *bp, void *pgtable)
107106
bool l5_required = false;
108107

109108
/* Initialize boot_params. Required for cmdline_find_option_bool(). */
110-
boot_params = bp;
109+
boot_params_ptr = bp;
111110

112111
/*
113112
* Check if LA57 is desired and supported.

arch/x86/boot/compressed/sev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ void sev_prep_identity_maps(unsigned long top_level_pgt)
605605
* accessed after switchover.
606606
*/
607607
if (sev_snp_enabled()) {
608-
unsigned long cc_info_pa = boot_params->cc_blob_address;
608+
unsigned long cc_info_pa = boot_params_ptr->cc_blob_address;
609609
struct cc_blob_sev_info *cc_info;
610610

611611
kernel_add_identity_map(cc_info_pa, cc_info_pa + sizeof(*cc_info));

arch/x86/include/asm/boot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ extern const unsigned long kernel_total_size;
6868

6969
unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr,
7070
void (*error)(char *x));
71+
72+
extern struct boot_params *boot_params_ptr;
7173
#endif
7274

7375
#endif /* _ASM_X86_BOOT_H */

0 commit comments

Comments
 (0)