Linux Audio

Check our new training course

Loading...
v3.15
 
 1#ifndef BOOT_COMPRESSED_MISC_H
 2#define BOOT_COMPRESSED_MISC_H
 3
 4/*
 5 * we have to be careful, because no indirections are allowed here, and
 6 * paravirt_ops is a kind of one. As it will only run in baremetal anyway,
 7 * we just keep it from happening
 
 8 */
 9#undef CONFIG_PARAVIRT
10#ifdef CONFIG_X86_32
11#define _ASM_X86_DESC_H 1
12#endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14#include <linux/linkage.h>
15#include <linux/screen_info.h>
16#include <linux/elf.h>
17#include <linux/io.h>
18#include <asm/page.h>
19#include <asm/boot.h>
20#include <asm/bootparam.h>
21#include <asm/bootparam_utils.h>
 
 
 
 
 
22
23#define BOOT_BOOT_H
24#include "../ctype.h"
 
 
 
25
26#ifdef CONFIG_X86_64
27#define memptr long
28#else
29#define memptr unsigned
30#endif
31
 
 
 
32/* misc.c */
33extern memptr free_mem_ptr;
34extern memptr free_mem_end_ptr;
35extern struct boot_params *real_mode;		/* Pointer to real-mode data */
 
 
36void __putstr(const char *s);
 
 
37#define error_putstr(__x)  __putstr(__x)
 
 
38
39#ifdef CONFIG_X86_VERBOSE_BOOTUP
40
41#define debug_putstr(__x)  __putstr(__x)
 
 
 
 
 
 
42
43#else
44
45static inline void debug_putstr(const char *s)
46{ }
 
 
 
47
48#endif
49
50#if CONFIG_EARLY_PRINTK || CONFIG_RANDOMIZE_BASE
51/* cmdline.c */
52int cmdline_find_option(const char *option, char *buffer, int bufsize);
53int cmdline_find_option_bool(const char *option);
54#endif
55
56
57#if CONFIG_RANDOMIZE_BASE
58/* aslr.c */
59unsigned char *choose_kernel_location(unsigned char *input,
60				      unsigned long input_size,
61				      unsigned char *output,
62				      unsigned long output_size);
63/* cpuflags.c */
64bool has_cpuflag(int flag);
 
 
 
 
65#else
66static inline
67unsigned char *choose_kernel_location(unsigned char *input,
68				      unsigned long input_size,
69				      unsigned char *output,
70				      unsigned long output_size)
71{
72	return output;
73}
74#endif
75
 
 
 
 
 
 
 
 
 
 
76#ifdef CONFIG_EARLY_PRINTK
77/* early_serial_console.c */
78extern int early_serial_base;
79void console_init(void);
80#else
81static const int early_serial_base;
82static inline void console_init(void)
83{ }
84#endif
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86#endif
v6.9.4
  1/* 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
 12#undef CONFIG_PARAVIRT_XXL
 13#undef CONFIG_PARAVIRT_SPINLOCKS
 14#undef CONFIG_KASAN
 15#undef CONFIG_KASAN_GENERIC
 16
 17#define __NO_FORTIFY
 18
 19/* cpu_feature_enabled() cannot be used this early */
 20#define USE_EARLY_PGTABLE_L5
 21
 22/*
 23 * Boot stub deals with identity mappings, physical and virtual addresses are
 24 * the same, so override these defines.
 25 *
 26 * <asm/page.h> will not define them if they are already defined.
 27 */
 28#define __pa(x)  ((unsigned long)(x))
 29#define __va(x)  ((void *)((unsigned long)(x)))
 30
 31#include <linux/linkage.h>
 32#include <linux/screen_info.h>
 33#include <linux/elf.h>
 
 34#include <asm/page.h>
 35#include <asm/boot.h>
 36#include <asm/bootparam.h>
 37#include <asm/desc_defs.h>
 38
 39#include "tdx.h"
 40
 41#define BOOT_CTYPE_H
 42#include <linux/acpi.h>
 43
 44#define BOOT_BOOT_H
 45#include "../ctype.h"
 46#include "../io.h"
 47
 48#include "efi.h"
 49
 50#ifdef CONFIG_X86_64
 51#define memptr long
 52#else
 53#define memptr unsigned
 54#endif
 55
 56/* boot/compressed/vmlinux start and end markers */
 57extern char _head[], _end[];
 58
 59/* misc.c */
 60extern memptr free_mem_ptr;
 61extern memptr free_mem_end_ptr;
 62extern int spurious_nmi_count;
 63void *malloc(int size);
 64void free(void *where);
 65void __putstr(const char *s);
 66void __puthex(unsigned long value);
 67void __putdec(unsigned long value);
 68#define error_putstr(__x)  __putstr(__x)
 69#define error_puthex(__x)  __puthex(__x)
 70#define error_putdec(__x)  __putdec(__x)
 71
 72#ifdef CONFIG_X86_VERBOSE_BOOTUP
 73
 74#define debug_putstr(__x)  __putstr(__x)
 75#define debug_puthex(__x)  __puthex(__x)
 76#define debug_putaddr(__x) { \
 77		debug_putstr(#__x ": 0x"); \
 78		debug_puthex((unsigned long)(__x)); \
 79		debug_putstr("\n"); \
 80	}
 81
 82#else
 83
 84static inline void debug_putstr(const char *s)
 85{ }
 86static inline void debug_puthex(unsigned long value)
 87{ }
 88#define debug_putaddr(x) /* */
 89
 90#endif
 91
 
 92/* cmdline.c */
 93int cmdline_find_option(const char *option, char *buffer, int bufsize);
 94int cmdline_find_option_bool(const char *option);
 
 
 95
 96struct mem_vector {
 97	u64 start;
 98	u64 size;
 99};
100
101#ifdef CONFIG_RANDOMIZE_BASE
102/* kaslr.c */
103void choose_random_location(unsigned long input,
104			    unsigned long input_size,
105			    unsigned long *output,
106			    unsigned long output_size,
107			    unsigned long *virt_addr);
108#else
109static inline void choose_random_location(unsigned long input,
110					  unsigned long input_size,
111					  unsigned long *output,
112					  unsigned long output_size,
113					  unsigned long *virt_addr)
114{
 
115}
116#endif
117
118/* cpuflags.c */
119bool has_cpuflag(int flag);
120
121#ifdef CONFIG_X86_64
122extern int set_page_decrypted(unsigned long address);
123extern int set_page_encrypted(unsigned long address);
124extern int set_page_non_present(unsigned long address);
125extern unsigned char _pgtable[];
126#endif
127
128#ifdef CONFIG_EARLY_PRINTK
129/* early_serial_console.c */
130extern int early_serial_base;
131void console_init(void);
132#else
133static const int early_serial_base;
134static inline void console_init(void)
135{ }
136#endif
137
138#ifdef CONFIG_AMD_MEM_ENCRYPT
139void sev_enable(struct boot_params *bp);
140void snp_check_features(void);
141void sev_es_shutdown_ghcb(void);
142extern bool sev_es_check_ghcb_fault(unsigned long address);
143void snp_set_page_private(unsigned long paddr);
144void snp_set_page_shared(unsigned long paddr);
145void sev_prep_identity_maps(unsigned long top_level_pgt);
146#else
147static inline void sev_enable(struct boot_params *bp)
148{
149	/*
150	 * bp->cc_blob_address should only be set by boot/compressed kernel.
151	 * Initialize it to 0 unconditionally (thus here in this stub too) to
152	 * ensure that uninitialized values from buggy bootloaders aren't
153	 * propagated.
154	 */
155	if (bp)
156		bp->cc_blob_address = 0;
157}
158static inline void snp_check_features(void) { }
159static inline void sev_es_shutdown_ghcb(void) { }
160static inline bool sev_es_check_ghcb_fault(unsigned long address)
161{
162	return false;
163}
164static inline void snp_set_page_private(unsigned long paddr) { }
165static inline void snp_set_page_shared(unsigned long paddr) { }
166static inline void sev_prep_identity_maps(unsigned long top_level_pgt) { }
167#endif
168
169/* acpi.c */
170#ifdef CONFIG_ACPI
171acpi_physical_address get_rsdp_addr(void);
172#else
173static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
174#endif
175
176#if defined(CONFIG_RANDOMIZE_BASE) && defined(CONFIG_MEMORY_HOTREMOVE) && defined(CONFIG_ACPI)
177extern struct mem_vector immovable_mem[MAX_NUMNODES*2];
178int count_immovable_mem_regions(void);
179#else
180static inline int count_immovable_mem_regions(void) { return 0; }
181#endif
182
183/* ident_map_64.c */
184extern unsigned int __pgtable_l5_enabled, pgdir_shift, ptrs_per_p4d;
185extern void kernel_add_identity_map(unsigned long start, unsigned long end);
186
187/* Used by PAGE_KERN* macros: */
188extern pteval_t __default_kernel_pte_mask;
189
190/* idt_64.c */
191extern gate_desc boot_idt[BOOT_IDT_ENTRIES];
192extern struct desc_ptr boot_idt_desc;
193
194#ifdef CONFIG_X86_64
195void cleanup_exception_handling(void);
196#else
197static inline void cleanup_exception_handling(void) { }
198#endif
199
200/* IDT Entry Points */
201void boot_page_fault(void);
202void boot_nmi_trap(void);
203void boot_stage1_vc(void);
204void boot_stage2_vc(void);
205
206unsigned long sev_verify_cbit(unsigned long cr3);
207
208enum efi_type {
209	EFI_TYPE_64,
210	EFI_TYPE_32,
211	EFI_TYPE_NONE,
212};
213
214#ifdef CONFIG_EFI
215/* helpers for early EFI config table access */
216enum efi_type efi_get_type(struct boot_params *bp);
217unsigned long efi_get_system_table(struct boot_params *bp);
218int efi_get_conf_table(struct boot_params *bp, unsigned long *cfg_tbl_pa,
219		       unsigned int *cfg_tbl_len);
220unsigned long efi_find_vendor_table(struct boot_params *bp,
221				    unsigned long cfg_tbl_pa,
222				    unsigned int cfg_tbl_len,
223				    efi_guid_t guid);
224#else
225static inline enum efi_type efi_get_type(struct boot_params *bp)
226{
227	return EFI_TYPE_NONE;
228}
229
230static inline unsigned long efi_get_system_table(struct boot_params *bp)
231{
232	return 0;
233}
234
235static inline int efi_get_conf_table(struct boot_params *bp,
236				     unsigned long *cfg_tbl_pa,
237				     unsigned int *cfg_tbl_len)
238{
239	return -ENOENT;
240}
241
242static inline unsigned long efi_find_vendor_table(struct boot_params *bp,
243						  unsigned long cfg_tbl_pa,
244						  unsigned int cfg_tbl_len,
245						  efi_guid_t guid)
246{
247	return 0;
248}
249#endif /* CONFIG_EFI */
250
251#ifdef CONFIG_UNACCEPTED_MEMORY
252bool init_unaccepted_memory(void);
253#else
254static inline bool init_unaccepted_memory(void) { return false; }
255#endif
256
257/* Defined in EFI stub */
258extern struct efi_unaccepted_memory *unaccepted_table;
259void accept_memory(phys_addr_t start, phys_addr_t end);
260
261#endif /* BOOT_COMPRESSED_MISC_H */