blob: d9a631c5973c7f6423299baae66167579a8bdcff [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef BOOT_COMPRESSED_MISC_H
3#define BOOT_COMPRESSED_MISC_H
4
5/*
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.)
10 */
11#undef CONFIG_PARAVIRT
David Brazdil0f672f62019-12-10 10:32:29 +000012#undef CONFIG_PARAVIRT_XXL
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000013#undef CONFIG_PARAVIRT_SPINLOCKS
14#undef CONFIG_KASAN
15
16/* cpu_feature_enabled() cannot be used this early */
17#define USE_EARLY_PGTABLE_L5
18
19#include <linux/linkage.h>
20#include <linux/screen_info.h>
21#include <linux/elf.h>
22#include <linux/io.h>
23#include <asm/page.h>
24#include <asm/boot.h>
25#include <asm/bootparam.h>
Olivier Deprez157378f2022-04-04 15:47:50 +020026#include <asm/desc_defs.h>
David Brazdil0f672f62019-12-10 10:32:29 +000027
28#define BOOT_CTYPE_H
29#include <linux/acpi.h>
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000030
31#define BOOT_BOOT_H
32#include "../ctype.h"
33
34#ifdef CONFIG_X86_64
35#define memptr long
36#else
37#define memptr unsigned
38#endif
39
Olivier Deprez157378f2022-04-04 15:47:50 +020040/* boot/compressed/vmlinux start and end markers */
41extern char _head[], _end[];
42
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000043/* misc.c */
44extern memptr free_mem_ptr;
45extern memptr free_mem_end_ptr;
46extern struct boot_params *boot_params;
47void __putstr(const char *s);
48void __puthex(unsigned long value);
49#define error_putstr(__x) __putstr(__x)
50#define error_puthex(__x) __puthex(__x)
51
52#ifdef CONFIG_X86_VERBOSE_BOOTUP
53
54#define debug_putstr(__x) __putstr(__x)
55#define debug_puthex(__x) __puthex(__x)
56#define debug_putaddr(__x) { \
57 debug_putstr(#__x ": 0x"); \
58 debug_puthex((unsigned long)(__x)); \
59 debug_putstr("\n"); \
60 }
61
62#else
63
64static inline void debug_putstr(const char *s)
65{ }
Olivier Deprez157378f2022-04-04 15:47:50 +020066static inline void debug_puthex(unsigned long value)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000067{ }
68#define debug_putaddr(x) /* */
69
70#endif
71
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000072/* cmdline.c */
73int cmdline_find_option(const char *option, char *buffer, int bufsize);
74int cmdline_find_option_bool(const char *option);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000075
David Brazdil0f672f62019-12-10 10:32:29 +000076struct mem_vector {
Olivier Deprez157378f2022-04-04 15:47:50 +020077 u64 start;
78 u64 size;
David Brazdil0f672f62019-12-10 10:32:29 +000079};
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000080
81#if CONFIG_RANDOMIZE_BASE
82/* kaslr.c */
83void choose_random_location(unsigned long input,
84 unsigned long input_size,
85 unsigned long *output,
86 unsigned long output_size,
87 unsigned long *virt_addr);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000088#else
89static inline void choose_random_location(unsigned long input,
90 unsigned long input_size,
91 unsigned long *output,
92 unsigned long output_size,
93 unsigned long *virt_addr)
94{
95}
96#endif
97
Olivier Deprez157378f2022-04-04 15:47:50 +020098/* cpuflags.c */
99bool has_cpuflag(int flag);
100
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000101#ifdef CONFIG_X86_64
Olivier Deprez157378f2022-04-04 15:47:50 +0200102extern int set_page_decrypted(unsigned long address);
103extern int set_page_encrypted(unsigned long address);
104extern int set_page_non_present(unsigned long address);
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000105extern unsigned char _pgtable[];
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000106#endif
107
108#ifdef CONFIG_EARLY_PRINTK
109/* early_serial_console.c */
110extern int early_serial_base;
111void console_init(void);
112#else
113static const int early_serial_base;
114static inline void console_init(void)
115{ }
116#endif
117
118void set_sev_encryption_mask(void);
119
Olivier Deprez157378f2022-04-04 15:47:50 +0200120#ifdef CONFIG_AMD_MEM_ENCRYPT
121void sev_es_shutdown_ghcb(void);
122extern bool sev_es_check_ghcb_fault(unsigned long address);
123#else
124static inline void sev_es_shutdown_ghcb(void) { }
125static inline bool sev_es_check_ghcb_fault(unsigned long address)
126{
127 return false;
128}
129#endif
130
David Brazdil0f672f62019-12-10 10:32:29 +0000131/* acpi.c */
132#ifdef CONFIG_ACPI
133acpi_physical_address get_rsdp_addr(void);
134#else
135static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
Andrew Scullb4b6d4a2019-01-02 15:54:55 +0000136#endif
David Brazdil0f672f62019-12-10 10:32:29 +0000137
138#if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
139extern struct mem_vector immovable_mem[MAX_NUMNODES*2];
140int count_immovable_mem_regions(void);
141#else
142static inline int count_immovable_mem_regions(void) { return 0; }
143#endif
144
Olivier Deprez157378f2022-04-04 15:47:50 +0200145/* ident_map_64.c */
146#ifdef CONFIG_X86_5LEVEL
147extern unsigned int __pgtable_l5_enabled, pgdir_shift, ptrs_per_p4d;
148#endif
149
150/* Used by PAGE_KERN* macros: */
151extern pteval_t __default_kernel_pte_mask;
152
153/* idt_64.c */
154extern gate_desc boot_idt[BOOT_IDT_ENTRIES];
155extern struct desc_ptr boot_idt_desc;
156
157/* IDT Entry Points */
158void boot_page_fault(void);
159void boot_stage1_vc(void);
160void boot_stage2_vc(void);
161
162unsigned long sev_verify_cbit(unsigned long cr3);
163
David Brazdil0f672f62019-12-10 10:32:29 +0000164#endif /* BOOT_COMPRESSED_MISC_H */