hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/x86/include/asm/mem_encrypt.h
....@@ -1,13 +1,10 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * AMD Memory Encryption Support
34 *
45 * Copyright (C) 2016 Advanced Micro Devices, Inc.
56 *
67 * 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.
118 */
129
1310 #ifndef __X86_MEM_ENCRYPT_H__
....@@ -16,12 +13,14 @@
1613 #ifndef __ASSEMBLY__
1714
1815 #include <linux/init.h>
16
+#include <linux/cc_platform.h>
1917
2018 #include <asm/bootparam.h>
2119
2220 #ifdef CONFIG_AMD_MEM_ENCRYPT
2321
2422 extern u64 sme_me_mask;
23
+extern u64 sev_status;
2524 extern bool sev_enabled;
2625
2726 void sme_encrypt_execute(unsigned long encrypted_kernel_vaddr,
....@@ -46,14 +45,17 @@
4645 int __init early_set_memory_decrypted(unsigned long vaddr, unsigned long size);
4746 int __init early_set_memory_encrypted(unsigned long vaddr, unsigned long size);
4847
49
-/* Architecture __weak replacement functions */
50
-void __init mem_encrypt_init(void);
5148 void __init mem_encrypt_free_decrypted_mem(void);
5249
50
+/* Architecture __weak replacement functions */
51
+void __init mem_encrypt_init(void);
52
+
53
+void __init sev_es_init_vc_handling(void);
5354 bool sme_active(void);
5455 bool sev_active(void);
56
+bool sev_es_active(void);
5557
56
-#define __bss_decrypted __attribute__((__section__(".bss..decrypted")))
58
+#define __bss_decrypted __section(".bss..decrypted")
5759
5860 #else /* !CONFIG_AMD_MEM_ENCRYPT */
5961
....@@ -72,13 +74,17 @@
7274 static inline void __init sme_encrypt_kernel(struct boot_params *bp) { }
7375 static inline void __init sme_enable(struct boot_params *bp) { }
7476
77
+static inline void sev_es_init_vc_handling(void) { }
7578 static inline bool sme_active(void) { return false; }
7679 static inline bool sev_active(void) { return false; }
80
+static inline bool sev_es_active(void) { return false; }
7781
7882 static inline int __init
7983 early_set_memory_decrypted(unsigned long vaddr, unsigned long size) { return 0; }
8084 static inline int __init
8185 early_set_memory_encrypted(unsigned long vaddr, unsigned long size) { return 0; }
86
+
87
+static inline void mem_encrypt_free_decrypted_mem(void) { }
8288
8389 #define __bss_decrypted
8490
....@@ -95,6 +101,16 @@
95101
96102 extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[];
97103
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
+
98114 #endif /* __ASSEMBLY__ */
99115
100116 #endif /* __X86_MEM_ENCRYPT_H__ */