setup.h 3.9 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
H
H. Peter Anvin 已提交
2 3
#ifndef _ASM_X86_SETUP_H
#define _ASM_X86_SETUP_H
T
Thomas Gleixner 已提交
4

5 6
#include <uapi/asm/setup.h>

T
Thomas Gleixner 已提交
7 8
#define COMMAND_LINE_SIZE 2048

9
#include <linux/linkage.h>
10
#include <asm/page_types.h>
11
#include <asm/ibt.h>
12

T
Thomas Gleixner 已提交
13 14 15 16 17 18 19 20 21
#ifdef __i386__

#include <linux/pfn.h>
/*
 * Reserved space for vmalloc and iomap - defined in asm/page.h
 */
#define MAXMEM_PFN	PFN_DOWN(MAXMEM)
#define MAX_NONPAE_PFN	(1 << 20)

22 23 24
#endif /* __i386__ */

#define PARAM_SIZE 4096		/* sizeof(struct boot_params) */
T
Thomas Gleixner 已提交
25 26

#define OLD_CL_MAGIC		0xA33F
27
#define OLD_CL_ADDRESS		0x020	/* Relative to real mode data */
T
Thomas Gleixner 已提交
28 29 30 31
#define NEW_CL_POINTER		0x228	/* Relative to real mode data */

#ifndef __ASSEMBLY__
#include <asm/bootparam.h>
32
#include <asm/x86_init.h>
T
Thomas Gleixner 已提交
33

34 35
extern u64 relocated_ramdisk;

36
/* Interrupt control for vSMPowered x86_64 systems */
37
#ifdef CONFIG_X86_64
38
void vsmp_init(void);
39 40 41
#else
static inline void vsmp_init(void) { }
#endif
42

43 44
struct pt_regs;

45
void setup_bios_corruption_check(void);
46
void early_platform_quirks(void);
47 48 49

extern unsigned long saved_video_mode;

50 51
extern void reserve_standard_io_resources(void);
extern void i386_reserve_resources(void);
52 53
extern unsigned long __startup_64(unsigned long physaddr, struct boot_params *bp);
extern unsigned long __startup_secondary_64(void);
J
Joerg Roedel 已提交
54
extern void startup_64_setup_env(unsigned long physbase);
55
extern void early_setup_idt(void);
56
extern void __init do_early_exception(struct pt_regs *regs, int trapnr);
57

58
#ifdef CONFIG_X86_INTEL_MID
59
extern void x86_intel_mid_early_setup(void);
60
#else
61
static inline void x86_intel_mid_early_setup(void) { }
62 63
#endif

T
Thomas Gleixner 已提交
64 65 66 67 68 69
#ifdef CONFIG_X86_INTEL_CE
extern void x86_ce4100_early_setup(void);
#else
static inline void x86_ce4100_early_setup(void) { }
#endif

70 71
#ifndef _SETUP

72
#include <asm/espfix.h>
73
#include <linux/kernel.h>
74

T
Thomas Gleixner 已提交
75 76 77 78
/*
 * This is set up by the setup-routine at boot-time
 */
extern struct boot_params boot_params;
J
Jiri Kosina 已提交
79
extern char _text[];
T
Thomas Gleixner 已提交
80

81 82
static inline bool kaslr_enabled(void)
{
83 84 85 86 87 88 89 90 91 92 93
	return IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) &&
		!!(boot_params.hdr.loadflags & KASLR_FLAG);
}

/*
 * Apply no randomization if KASLR was disabled at boot or if KASAN
 * is enabled. KASAN shadow mappings rely on regions being PGD aligned.
 */
static inline bool kaslr_memory_enabled(void)
{
	return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN);
94 95
}

J
Jiri Kosina 已提交
96 97 98 99 100
static inline unsigned long kaslr_offset(void)
{
	return (unsigned long)&_text - __START_KERNEL;
}

T
Thomas Gleixner 已提交
101 102 103 104 105 106
/*
 * Do NOT EVER look at the BIOS memory size location.
 * It does not work on many machines.
 */
#define LOWMEMSIZE()	(0x9f000)

107 108 109 110
/* exceedingly early brk-like allocator */
extern unsigned long _brk_end;
void *extend_brk(size_t size, size_t align);

111 112 113 114 115 116 117 118 119 120 121 122
/*
 * Reserve space in the brk section.  The name must be unique within
 * the file, and somewhat descriptive.  The size is in bytes.  Must be
 * used at file scope.
 *
 * (This uses a temp function to wrap the asm so we can pass it the
 * size parameter; otherwise we wouldn't be able to.  We can't use a
 * "section" attribute on a normal variable because it always ends up
 * being @progbits, which ends up allocating space in the vmlinux
 * executable.)
 */
#define RESERVE_BRK(name,sz)						\
123
	static void __section(".discard.text") __noendbr __used notrace	\
124 125 126
	__brk_reservation_fn_##name##__(void) {				\
		asm volatile (						\
			".pushsection .brk_reservation,\"aw\",@nobits;" \
127
			".brk." #name ":"				\
128
			" 1:.skip %c0;"					\
129
			" .size .brk." #name ", . - 1b;"		\
130 131 132 133
			" .popsection"					\
			: : "i" (sz));					\
	}

D
Dan Williams 已提交
134
extern void probe_roms(void);
135 136
#ifdef __i386__

137
asmlinkage void __init i386_start_kernel(void);
138

139
#else
140 141
asmlinkage void __init x86_64_start_kernel(char *real_mode);
asmlinkage void __init x86_64_start_reservations(char *real_mode_data);
142

T
Thomas Gleixner 已提交
143
#endif /* __i386__ */
144
#endif /* _SETUP */
145 146 147
#else
#define RESERVE_BRK(name,sz)				\
	.pushsection .brk_reservation,"aw",@nobits;	\
148
.brk.name:						\
149
1:	.skip sz;					\
150
	.size .brk.name,.-1b;				\
151
	.popsection
T
Thomas Gleixner 已提交
152
#endif /* __ASSEMBLY__ */
H
H. Peter Anvin 已提交
153
#endif /* _ASM_X86_SETUP_H */