hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
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,16 @@
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
+void __init sev_es_init_vc_handling(void);
5351 bool sme_active(void);
5452 bool sev_active(void);
53
+bool sev_es_active(void);
5554
56
-#define __bss_decrypted __attribute__((__section__(".bss..decrypted")))
55
+void __init mem_encrypt_init(void);
56
+
57
+#define __bss_decrypted __section(".bss..decrypted")
5758
5859 #else /* !CONFIG_AMD_MEM_ENCRYPT */
5960
....@@ -72,13 +73,19 @@
7273 static inline void __init sme_encrypt_kernel(struct boot_params *bp) { }
7374 static inline void __init sme_enable(struct boot_params *bp) { }
7475
76
+static inline void sev_es_init_vc_handling(void) { }
7577 static inline bool sme_active(void) { return false; }
7678 static inline bool sev_active(void) { return false; }
79
+static inline bool sev_es_active(void) { return false; }
7780
7881 static inline int __init
7982 early_set_memory_decrypted(unsigned long vaddr, unsigned long size) { return 0; }
8083 static inline int __init
8184 early_set_memory_encrypted(unsigned long vaddr, unsigned long size) { return 0; }
85
+
86
+static inline void mem_encrypt_free_decrypted_mem(void) { }
87
+
88
+static inline void mem_encrypt_init(void) { }
8289
8390 #define __bss_decrypted
8491
....@@ -95,6 +102,16 @@
95102
96103 extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[];
97104
105
+static inline bool mem_encrypt_active(void)
106
+{
107
+ return sme_me_mask;
108
+}
109
+
110
+static inline u64 sme_get_me_mask(void)
111
+{
112
+ return sme_me_mask;
113
+}
114
+
98115 #endif /* __ASSEMBLY__ */
99116
100117 #endif /* __X86_MEM_ENCRYPT_H__ */