1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef BOOT_COMPRESSED_MISC_H
3 #define BOOT_COMPRESSED_MISC_H
6 * Special hack: we have to be careful, because no indirections are allowed here,
7 * and paravirt_ops is a kind of one. As it will only run in baremetal anyway,
8 * we just keep it from happening. (This list needs to be extended when new
9 * paravirt and debugging variants are added.)
11 #undef CONFIG_PARAVIRT
12 #undef CONFIG_PARAVIRT_XXL
13 #undef CONFIG_PARAVIRT_SPINLOCKS
15 #undef CONFIG_KASAN_GENERIC
19 /* cpu_feature_enabled() cannot be used this early */
20 #define USE_EARLY_PGTABLE_L5
22 #include <linux/linkage.h>
23 #include <linux/screen_info.h>
24 #include <linux/elf.h>
28 #include <asm/bootparam.h>
29 #include <asm/desc_defs.h>
32 #include <linux/acpi.h>
40 #define memptr unsigned
43 /* boot/compressed/vmlinux start and end markers */
44 extern char _head[], _end[];
47 extern memptr free_mem_ptr;
48 extern memptr free_mem_end_ptr;
49 void *malloc(int size);
50 void free(void *where);
51 extern struct boot_params *boot_params;
52 void __putstr(const char *s);
53 void __puthex(unsigned long value);
54 #define error_putstr(__x) __putstr(__x)
55 #define error_puthex(__x) __puthex(__x)
57 #ifdef CONFIG_X86_VERBOSE_BOOTUP
59 #define debug_putstr(__x) __putstr(__x)
60 #define debug_puthex(__x) __puthex(__x)
61 #define debug_putaddr(__x) { \
62 debug_putstr(#__x ": 0x"); \
63 debug_puthex((unsigned long)(__x)); \
69 static inline void debug_putstr(const char *s)
71 static inline void debug_puthex(unsigned long value)
73 #define debug_putaddr(x) /* */
78 int cmdline_find_option(const char *option, char *buffer, int bufsize);
79 int cmdline_find_option_bool(const char *option);
86 #ifdef CONFIG_RANDOMIZE_BASE
88 void choose_random_location(unsigned long input,
89 unsigned long input_size,
90 unsigned long *output,
91 unsigned long output_size,
92 unsigned long *virt_addr);
94 static inline void choose_random_location(unsigned long input,
95 unsigned long input_size,
96 unsigned long *output,
97 unsigned long output_size,
98 unsigned long *virt_addr)
104 bool has_cpuflag(int flag);
107 extern int set_page_decrypted(unsigned long address);
108 extern int set_page_encrypted(unsigned long address);
109 extern int set_page_non_present(unsigned long address);
110 extern unsigned char _pgtable[];
113 #ifdef CONFIG_EARLY_PRINTK
114 /* early_serial_console.c */
115 extern int early_serial_base;
116 void console_init(void);
118 static const int early_serial_base;
119 static inline void console_init(void)
123 void set_sev_encryption_mask(void);
125 #ifdef CONFIG_AMD_MEM_ENCRYPT
126 void sev_es_shutdown_ghcb(void);
127 extern bool sev_es_check_ghcb_fault(unsigned long address);
129 static inline void sev_es_shutdown_ghcb(void) { }
130 static inline bool sev_es_check_ghcb_fault(unsigned long address)
138 acpi_physical_address get_rsdp_addr(void);
140 static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
143 #if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
144 extern struct mem_vector immovable_mem[MAX_NUMNODES*2];
145 int count_immovable_mem_regions(void);
147 static inline int count_immovable_mem_regions(void) { return 0; }
151 #ifdef CONFIG_X86_5LEVEL
152 extern unsigned int __pgtable_l5_enabled, pgdir_shift, ptrs_per_p4d;
155 /* Used by PAGE_KERN* macros: */
156 extern pteval_t __default_kernel_pte_mask;
159 extern gate_desc boot_idt[BOOT_IDT_ENTRIES];
160 extern struct desc_ptr boot_idt_desc;
163 void cleanup_exception_handling(void);
165 static inline void cleanup_exception_handling(void) { }
168 /* IDT Entry Points */
169 void boot_page_fault(void);
170 void boot_stage1_vc(void);
171 void boot_stage2_vc(void);
173 unsigned long sev_verify_cbit(unsigned long cr3);
175 #endif /* BOOT_COMPRESSED_MISC_H */