Skip to content

Commit efd7def

Browse files
Thomas Zimmermannbp3tk0v
authored andcommitted
x86/setup: Move UAPI setup structures into setup_data.h
The type definition of struct pci_setup_rom in <asm/pci.h> requires struct setup_data from <asm/bootparam.h>. Many drivers include <linux/pci.h>, but do not use boot parameters. Changes to bootparam.h or its included header files could easily trigger a large, unnecessary rebuild of the kernel. Moving struct setup_data and related code into its own header file avoids including <asm/bootparam.h> in <asm/pci.h>. Instead include the new header <asm/screen_data.h> and remove the include statement for x86_init.h, which is unnecessary but pulls in bootparams.h. Suggested-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20240112095000.8952-2-tzimmermann@suse.de
1 parent 41bccc9 commit efd7def

File tree

3 files changed

+85
-72
lines changed

3 files changed

+85
-72
lines changed

arch/x86/include/asm/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <linux/numa.h>
1111
#include <asm/io.h>
1212
#include <asm/memtype.h>
13-
#include <asm/x86_init.h>
13+
#include <asm/setup_data.h>
1414

1515
struct pci_sysdata {
1616
int domain; /* PCI domain */

arch/x86/include/uapi/asm/bootparam.h

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,7 @@
22
#ifndef _ASM_X86_BOOTPARAM_H
33
#define _ASM_X86_BOOTPARAM_H
44

5-
/* setup_data/setup_indirect types */
6-
#define SETUP_NONE 0
7-
#define SETUP_E820_EXT 1
8-
#define SETUP_DTB 2
9-
#define SETUP_PCI 3
10-
#define SETUP_EFI 4
11-
#define SETUP_APPLE_PROPERTIES 5
12-
#define SETUP_JAILHOUSE 6
13-
#define SETUP_CC_BLOB 7
14-
#define SETUP_IMA 8
15-
#define SETUP_RNG_SEED 9
16-
#define SETUP_ENUM_MAX SETUP_RNG_SEED
17-
18-
#define SETUP_INDIRECT (1<<31)
19-
#define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT)
5+
#include <asm/setup_data.h>
206

217
/* ram_size flags */
228
#define RAMDISK_IMAGE_START_MASK 0x07FF
@@ -48,22 +34,6 @@
4834
#include <asm/ist.h>
4935
#include <video/edid.h>
5036

51-
/* extensible setup data list node */
52-
struct setup_data {
53-
__u64 next;
54-
__u32 type;
55-
__u32 len;
56-
__u8 data[];
57-
};
58-
59-
/* extensible setup indirect data node */
60-
struct setup_indirect {
61-
__u32 type;
62-
__u32 reserved; /* Reserved, must be set to zero. */
63-
__u64 len;
64-
__u64 addr;
65-
};
66-
6737
struct setup_header {
6838
__u8 setup_sects;
6939
__u16 root_flags;
@@ -136,51 +106,11 @@ struct efi_info {
136106
*/
137107
#define E820_MAX_ENTRIES_ZEROPAGE 128
138108

139-
/*
140-
* The E820 memory region entry of the boot protocol ABI:
141-
*/
142-
struct boot_e820_entry {
143-
__u64 addr;
144-
__u64 size;
145-
__u32 type;
146-
} __attribute__((packed));
147-
148109
/*
149110
* Smallest compatible version of jailhouse_setup_data required by this kernel.
150111
*/
151112
#define JAILHOUSE_SETUP_REQUIRED_VERSION 1
152113

153-
/*
154-
* The boot loader is passing platform information via this Jailhouse-specific
155-
* setup data structure.
156-
*/
157-
struct jailhouse_setup_data {
158-
struct {
159-
__u16 version;
160-
__u16 compatible_version;
161-
} __attribute__((packed)) hdr;
162-
struct {
163-
__u16 pm_timer_address;
164-
__u16 num_cpus;
165-
__u64 pci_mmconfig_base;
166-
__u32 tsc_khz;
167-
__u32 apic_khz;
168-
__u8 standard_ioapic;
169-
__u8 cpu_ids[255];
170-
} __attribute__((packed)) v1;
171-
struct {
172-
__u32 flags;
173-
} __attribute__((packed)) v2;
174-
} __attribute__((packed));
175-
176-
/*
177-
* IMA buffer setup data information from the previous kernel during kexec
178-
*/
179-
struct ima_setup_data {
180-
__u64 addr;
181-
__u64 size;
182-
} __attribute__((packed));
183-
184114
/* The so-called "zeropage" */
185115
struct boot_params {
186116
struct screen_info screen_info; /* 0x000 */
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+
#ifndef _UAPI_ASM_X86_SETUP_DATA_H
3+
#define _UAPI_ASM_X86_SETUP_DATA_H
4+
5+
/* setup_data/setup_indirect types */
6+
#define SETUP_NONE 0
7+
#define SETUP_E820_EXT 1
8+
#define SETUP_DTB 2
9+
#define SETUP_PCI 3
10+
#define SETUP_EFI 4
11+
#define SETUP_APPLE_PROPERTIES 5
12+
#define SETUP_JAILHOUSE 6
13+
#define SETUP_CC_BLOB 7
14+
#define SETUP_IMA 8
15+
#define SETUP_RNG_SEED 9
16+
#define SETUP_ENUM_MAX SETUP_RNG_SEED
17+
18+
#define SETUP_INDIRECT (1<<31)
19+
#define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT)
20+
21+
#ifndef __ASSEMBLY__
22+
23+
#include <linux/types.h>
24+
25+
/* extensible setup data list node */
26+
struct setup_data {
27+
__u64 next;
28+
__u32 type;
29+
__u32 len;
30+
__u8 data[];
31+
};
32+
33+
/* extensible setup indirect data node */
34+
struct setup_indirect {
35+
__u32 type;
36+
__u32 reserved; /* Reserved, must be set to zero. */
37+
__u64 len;
38+
__u64 addr;
39+
};
40+
41+
/*
42+
* The E820 memory region entry of the boot protocol ABI:
43+
*/
44+
struct boot_e820_entry {
45+
__u64 addr;
46+
__u64 size;
47+
__u32 type;
48+
} __attribute__((packed));
49+
50+
/*
51+
* The boot loader is passing platform information via this Jailhouse-specific
52+
* setup data structure.
53+
*/
54+
struct jailhouse_setup_data {
55+
struct {
56+
__u16 version;
57+
__u16 compatible_version;
58+
} __attribute__((packed)) hdr;
59+
struct {
60+
__u16 pm_timer_address;
61+
__u16 num_cpus;
62+
__u64 pci_mmconfig_base;
63+
__u32 tsc_khz;
64+
__u32 apic_khz;
65+
__u8 standard_ioapic;
66+
__u8 cpu_ids[255];
67+
} __attribute__((packed)) v1;
68+
struct {
69+
__u32 flags;
70+
} __attribute__((packed)) v2;
71+
} __attribute__((packed));
72+
73+
/*
74+
* IMA buffer setup data information from the previous kernel during kexec
75+
*/
76+
struct ima_setup_data {
77+
__u64 addr;
78+
__u64 size;
79+
} __attribute__((packed));
80+
81+
#endif /* __ASSEMBLY__ */
82+
83+
#endif /* _UAPI_ASM_X86_SETUP_DATA_H */

0 commit comments

Comments
 (0)