xref: /kvm-unit-tests/lib/x86/amd_sev.h (revision b643ae6207dafcad8ad99f0d8a2ca8245c2ce993)
1 /*
2  * AMD SEV support in kvm-unit-tests
3  *
4  * Copyright (c) 2021, Google Inc
5  *
6  * Authors:
7  *   Zixuan Wang <zixuanwang@google.com>
8  *
9  * SPDX-License-Identifier: LGPL-2.0-or-later
10  */
11 
12 #ifndef _X86_AMD_SEV_H_
13 #define _X86_AMD_SEV_H_
14 
15 #ifdef CONFIG_EFI
16 
17 #include "libcflat.h"
18 #include "desc.h"
19 #include "asm/page.h"
20 #include "efi.h"
21 
22 /*
23  * AMD Programmer's Manual Volume 3
24  *   - Section "Function 8000_001Fh - Encrypted Memory Capabilities"
25  */
26 #define CPUID_FN_ENCRYPT_MEM_CAPAB    0x8000001f
27 
28 /*
29  * AMD Programmer's Manual Volume 2
30  *   - Section "SEV_STATUS MSR"
31  */
32 #define MSR_SEV_STATUS      0xc0010131
33 #define SEV_ENABLED_MASK    0b1
34 #define SEV_ES_ENABLED_MASK 0b10
35 
36 bool amd_sev_enabled(void);
37 efi_status_t setup_amd_sev(void);
38 
39 /*
40  * AMD Programmer's Manual Volume 2
41  *   - Section "GHCB"
42  */
43 #define SEV_ES_GHCB_MSR_INDEX 0xc0010130
44 
45 bool amd_sev_es_enabled(void);
46 efi_status_t setup_amd_sev_es(void);
47 void setup_ghcb_pte(pgd_t *page_table);
48 
49 unsigned long long get_amd_sev_c_bit_mask(void);
50 unsigned long long get_amd_sev_addr_upperbound(void);
51 
52 #endif /* CONFIG_EFI */
53 
54 #endif /* _X86_AMD_SEV_H_ */
55