1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21965aae3SH. Peter Anvin #ifndef _ASM_X86_SETUP_H 31965aae3SH. Peter Anvin #define _ASM_X86_SETUP_H 4bb898558SAl Viro 5af170c50SDavid Howells #include <uapi/asm/setup.h> 6af170c50SDavid Howells 7bb898558SAl Viro #define COMMAND_LINE_SIZE 2048 8bb898558SAl Viro 9a1ed4ddfSAndi Kleen #include <linux/linkage.h> 1035de5b06SAndy Lutomirski #include <asm/page_types.h> 112b6ff7deSPeter Zijlstra #include <asm/ibt.h> 12a1ed4ddfSAndi Kleen 13bb898558SAl Viro #ifdef __i386__ 14bb898558SAl Viro 15bb898558SAl Viro #include <linux/pfn.h> 16bb898558SAl Viro /* 17bb898558SAl Viro * Reserved space for vmalloc and iomap - defined in asm/page.h 18bb898558SAl Viro */ 19bb898558SAl Viro #define MAXMEM_PFN PFN_DOWN(MAXMEM) 20bb898558SAl Viro #define MAX_NONPAE_PFN (1 << 20) 21bb898558SAl Viro 22bb898558SAl Viro #endif /* __i386__ */ 23bb898558SAl Viro 24bb898558SAl Viro #define PARAM_SIZE 4096 /* sizeof(struct boot_params) */ 25bb898558SAl Viro 26bb898558SAl Viro #define OLD_CL_MAGIC 0xA33F 27bb898558SAl Viro #define OLD_CL_ADDRESS 0x020 /* Relative to real mode data */ 28bb898558SAl Viro #define NEW_CL_POINTER 0x228 /* Relative to real mode data */ 29bb898558SAl Viro 30bb898558SAl Viro #ifndef __ASSEMBLY__ 31bb898558SAl Viro #include <asm/bootparam.h> 32845b3944SThomas Gleixner #include <asm/x86_init.h> 33bb898558SAl Viro 345aa3d718SBorislav Petkov extern u64 relocated_ramdisk; 355aa3d718SBorislav Petkov 3615c55443SJaswinder Singh Rajput /* Interrupt control for vSMPowered x86_64 systems */ 3770511134SRavikiran G Thirumalai #ifdef CONFIG_X86_64 3815c55443SJaswinder Singh Rajput void vsmp_init(void); 39129d8bc8SYinghai Lu #else 40129d8bc8SYinghai Lu static inline void vsmp_init(void) { } 41129d8bc8SYinghai Lu #endif 4215c55443SJaswinder Singh Rajput 434b47cdbdSJoerg Roedel struct pt_regs; 444b47cdbdSJoerg Roedel 4515c55443SJaswinder Singh Rajput void setup_bios_corruption_check(void); 46630b3affSLukas Wunner void early_platform_quirks(void); 4715c55443SJaswinder Singh Rajput 4815c55443SJaswinder Singh Rajput extern unsigned long saved_video_mode; 4915c55443SJaswinder Singh Rajput 508fee697dSThomas Gleixner extern void reserve_standard_io_resources(void); 518fee697dSThomas Gleixner extern void i386_reserve_resources(void); 52ad3bc25aSBorislav Petkov extern unsigned long __startup_64(unsigned long physaddr, struct boot_params *bp); 53866b556eSJoerg Roedel extern void startup_64_setup_env(unsigned long physbase); 54f5963ba7SJoerg Roedel extern void early_setup_idt(void); 554b47cdbdSJoerg Roedel extern void __init do_early_exception(struct pt_regs *regs, int trapnr); 568fee697dSThomas Gleixner 57933b9463SAlan Cox #ifdef CONFIG_X86_INTEL_MID 58712b6aa8SKuppuswamy Sathyanarayanan extern void x86_intel_mid_early_setup(void); 593f4110a4SThomas Gleixner #else 60712b6aa8SKuppuswamy Sathyanarayanan static inline void x86_intel_mid_early_setup(void) { } 613f4110a4SThomas Gleixner #endif 623f4110a4SThomas Gleixner 63c751e17bSThomas Gleixner #ifdef CONFIG_X86_INTEL_CE 64c751e17bSThomas Gleixner extern void x86_ce4100_early_setup(void); 65c751e17bSThomas Gleixner #else 66c751e17bSThomas Gleixner static inline void x86_ce4100_early_setup(void) { } 67c751e17bSThomas Gleixner #endif 68c751e17bSThomas Gleixner 69bb898558SAl Viro #ifndef _SETUP 70bb898558SAl Viro 71e1fe9ed8SH. Peter Anvin #include <asm/espfix.h> 72535b3ddcSJiri Kosina #include <linux/kernel.h> 73e1fe9ed8SH. Peter Anvin 74bb898558SAl Viro /* 75bb898558SAl Viro * This is set up by the setup-routine at boot-time 76bb898558SAl Viro */ 77bb898558SAl Viro extern struct boot_params boot_params; 784545c898SJiri Kosina extern char _text[]; 79bb898558SAl Viro 8078cac48cSBorislav Petkov static inline bool kaslr_enabled(void) 8178cac48cSBorislav Petkov { 8288107d33SMike Rapoport return IS_ENABLED(CONFIG_RANDOMIZE_MEMORY) && 8388107d33SMike Rapoport !!(boot_params.hdr.loadflags & KASLR_FLAG); 8488107d33SMike Rapoport } 8588107d33SMike Rapoport 8688107d33SMike Rapoport /* 8788107d33SMike Rapoport * Apply no randomization if KASLR was disabled at boot or if KASAN 8888107d33SMike Rapoport * is enabled. KASAN shadow mappings rely on regions being PGD aligned. 8988107d33SMike Rapoport */ 9088107d33SMike Rapoport static inline bool kaslr_memory_enabled(void) 9188107d33SMike Rapoport { 9288107d33SMike Rapoport return kaslr_enabled() && !IS_ENABLED(CONFIG_KASAN); 9378cac48cSBorislav Petkov } 9478cac48cSBorislav Petkov 954545c898SJiri Kosina static inline unsigned long kaslr_offset(void) 964545c898SJiri Kosina { 974545c898SJiri Kosina return (unsigned long)&_text - __START_KERNEL; 984545c898SJiri Kosina } 994545c898SJiri Kosina 100bb898558SAl Viro /* 101bb898558SAl Viro * Do NOT EVER look at the BIOS memory size location. 102bb898558SAl Viro * It does not work on many machines. 103bb898558SAl Viro */ 104bb898558SAl Viro #define LOWMEMSIZE() (0x9f000) 105bb898558SAl Viro 10693dbda7cSJeremy Fitzhardinge /* exceedingly early brk-like allocator */ 10793dbda7cSJeremy Fitzhardinge extern unsigned long _brk_end; 10893dbda7cSJeremy Fitzhardinge void *extend_brk(size_t size, size_t align); 10993dbda7cSJeremy Fitzhardinge 110796216a5SJeremy Fitzhardinge /* 111e32683c6SJosh Poimboeuf * Reserve space in the .brk section, which is a block of memory from which the 112e32683c6SJosh Poimboeuf * caller is allowed to allocate very early (before even memblock is available) 113e32683c6SJosh Poimboeuf * by calling extend_brk(). All allocated memory will be eventually converted 114e32683c6SJosh Poimboeuf * to memblock. Any leftover unallocated memory will be freed. 115796216a5SJeremy Fitzhardinge * 116e32683c6SJosh Poimboeuf * The size is in bytes. 117796216a5SJeremy Fitzhardinge */ 118a1e2c031SJosh Poimboeuf #define RESERVE_BRK(name, size) \ 119e32683c6SJosh Poimboeuf __section(".bss..brk") __aligned(1) __used \ 120e32683c6SJosh Poimboeuf static char __brk_##name[size] 121796216a5SJeremy Fitzhardinge 1225d94e81fSDan Williams extern void probe_roms(void); 123*96e8fc58SJuergen Gross 124*96e8fc58SJuergen Gross void clear_bss(void); 125*96e8fc58SJuergen Gross 126bb898558SAl Viro #ifdef __i386__ 127bb898558SAl Viro 128a1ed4ddfSAndi Kleen asmlinkage void __init i386_start_kernel(void); 129bb898558SAl Viro 130bb898558SAl Viro #else 131a1ed4ddfSAndi Kleen asmlinkage void __init x86_64_start_kernel(char *real_mode); 132a1ed4ddfSAndi Kleen asmlinkage void __init x86_64_start_reservations(char *real_mode_data); 133bb898558SAl Viro 134bb898558SAl Viro #endif /* __i386__ */ 135bb898558SAl Viro #endif /* _SETUP */ 136e32683c6SJosh Poimboeuf 137e32683c6SJosh Poimboeuf #else /* __ASSEMBLY */ 138e32683c6SJosh Poimboeuf 139e32683c6SJosh Poimboeuf .macro __RESERVE_BRK name, size 140e32683c6SJosh Poimboeuf .pushsection .bss..brk, "aw" 141e32683c6SJosh Poimboeuf SYM_DATA_START(__brk_\name) 142e32683c6SJosh Poimboeuf .skip \size 143e32683c6SJosh Poimboeuf SYM_DATA_END(__brk_\name) 144796216a5SJeremy Fitzhardinge .popsection 145e32683c6SJosh Poimboeuf .endm 146e32683c6SJosh Poimboeuf 147e32683c6SJosh Poimboeuf #define RESERVE_BRK(name, size) __RESERVE_BRK name, size 148e32683c6SJosh Poimboeuf 149bb898558SAl Viro #endif /* __ASSEMBLY__ */ 150e32683c6SJosh Poimboeuf 1511965aae3SH. Peter Anvin #endif /* _ASM_X86_SETUP_H */ 152