xref: /linux/arch/x86/boot/compressed/sev.h (revision 547c5775a742d9c83891b629b75d1d4c8e88d8c0)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * AMD SEV header for early boot related functions.
4  *
5  * Author: Tom Lendacky <thomas.lendacky@amd.com>
6  */
7 
8 #ifndef BOOT_COMPRESSED_SEV_H
9 #define BOOT_COMPRESSED_SEV_H
10 
11 #ifdef CONFIG_AMD_MEM_ENCRYPT
12 
13 #include "../msr.h"
14 
15 void snp_accept_memory(phys_addr_t start, phys_addr_t end);
16 u64 sev_get_status(void);
17 bool early_is_sevsnp_guest(void);
18 
sev_es_rd_ghcb_msr(void)19 static inline u64 sev_es_rd_ghcb_msr(void)
20 {
21 	struct msr m;
22 
23 	boot_rdmsr(MSR_AMD64_SEV_ES_GHCB, &m);
24 
25 	return m.q;
26 }
27 
sev_es_wr_ghcb_msr(u64 val)28 static inline void sev_es_wr_ghcb_msr(u64 val)
29 {
30 	struct msr m;
31 
32 	m.q = val;
33 	boot_wrmsr(MSR_AMD64_SEV_ES_GHCB, &m);
34 }
35 
36 #else
37 
snp_accept_memory(phys_addr_t start,phys_addr_t end)38 static inline void snp_accept_memory(phys_addr_t start, phys_addr_t end) { }
sev_get_status(void)39 static inline u64 sev_get_status(void) { return 0; }
early_is_sevsnp_guest(void)40 static inline bool early_is_sevsnp_guest(void) { return false; }
41 
42 #endif
43 
44 #endif
45