.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * AMD Memory Encryption Support |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2016 Advanced Micro Devices, Inc. |
---|
5 | 6 | * |
---|
6 | 7 | * Author: Tom Lendacky <thomas.lendacky@amd.com> |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or modify |
---|
9 | | - * it under the terms of the GNU General Public License version 2 as |
---|
10 | | - * published by the Free Software Foundation. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | #ifndef __X86_MEM_ENCRYPT_H__ |
---|
.. | .. |
---|
16 | 13 | #ifndef __ASSEMBLY__ |
---|
17 | 14 | |
---|
18 | 15 | #include <linux/init.h> |
---|
| 16 | +#include <linux/cc_platform.h> |
---|
19 | 17 | |
---|
20 | 18 | #include <asm/bootparam.h> |
---|
21 | 19 | |
---|
22 | 20 | #ifdef CONFIG_AMD_MEM_ENCRYPT |
---|
23 | 21 | |
---|
24 | 22 | extern u64 sme_me_mask; |
---|
| 23 | +extern u64 sev_status; |
---|
25 | 24 | extern bool sev_enabled; |
---|
26 | 25 | |
---|
27 | 26 | void sme_encrypt_execute(unsigned long encrypted_kernel_vaddr, |
---|
.. | .. |
---|
46 | 45 | int __init early_set_memory_decrypted(unsigned long vaddr, unsigned long size); |
---|
47 | 46 | int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size); |
---|
48 | 47 | |
---|
49 | | -/* Architecture __weak replacement functions */ |
---|
50 | | -void __init mem_encrypt_init(void); |
---|
51 | 48 | void __init mem_encrypt_free_decrypted_mem(void); |
---|
52 | 49 | |
---|
| 50 | +/* Architecture __weak replacement functions */ |
---|
| 51 | +void __init mem_encrypt_init(void); |
---|
| 52 | + |
---|
| 53 | +void __init sev_es_init_vc_handling(void); |
---|
53 | 54 | bool sme_active(void); |
---|
54 | 55 | bool sev_active(void); |
---|
| 56 | +bool sev_es_active(void); |
---|
55 | 57 | |
---|
56 | | -#define __bss_decrypted __attribute__((__section__(".bss..decrypted"))) |
---|
| 58 | +#define __bss_decrypted __section(".bss..decrypted") |
---|
57 | 59 | |
---|
58 | 60 | #else /* !CONFIG_AMD_MEM_ENCRYPT */ |
---|
59 | 61 | |
---|
.. | .. |
---|
72 | 74 | static inline void __init sme_encrypt_kernel(struct boot_params *bp) { } |
---|
73 | 75 | static inline void __init sme_enable(struct boot_params *bp) { } |
---|
74 | 76 | |
---|
| 77 | +static inline void sev_es_init_vc_handling(void) { } |
---|
75 | 78 | static inline bool sme_active(void) { return false; } |
---|
76 | 79 | static inline bool sev_active(void) { return false; } |
---|
| 80 | +static inline bool sev_es_active(void) { return false; } |
---|
77 | 81 | |
---|
78 | 82 | static inline int __init |
---|
79 | 83 | early_set_memory_decrypted(unsigned long vaddr, unsigned long size) { return 0; } |
---|
80 | 84 | static inline int __init |
---|
81 | 85 | early_set_memory_encrypted(unsigned long vaddr, unsigned long size) { return 0; } |
---|
| 86 | + |
---|
| 87 | +static inline void mem_encrypt_free_decrypted_mem(void) { } |
---|
82 | 88 | |
---|
83 | 89 | #define __bss_decrypted |
---|
84 | 90 | |
---|
.. | .. |
---|
95 | 101 | |
---|
96 | 102 | extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; |
---|
97 | 103 | |
---|
| 104 | +static inline bool mem_encrypt_active(void) |
---|
| 105 | +{ |
---|
| 106 | + return sme_me_mask; |
---|
| 107 | +} |
---|
| 108 | + |
---|
| 109 | +static inline u64 sme_get_me_mask(void) |
---|
| 110 | +{ |
---|
| 111 | + return sme_me_mask; |
---|
| 112 | +} |
---|
| 113 | + |
---|
98 | 114 | #endif /* __ASSEMBLY__ */ |
---|
99 | 115 | |
---|
100 | 116 | #endif /* __X86_MEM_ENCRYPT_H__ */ |
---|