| .. | .. |
|---|
| 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 | +void __init sev_es_init_vc_handling(void); |
|---|
| 53 | 51 | bool sme_active(void); |
|---|
| 54 | 52 | bool sev_active(void); |
|---|
| 53 | +bool sev_es_active(void); |
|---|
| 55 | 54 | |
|---|
| 56 | | -#define __bss_decrypted __attribute__((__section__(".bss..decrypted"))) |
|---|
| 55 | +void __init mem_encrypt_init(void); |
|---|
| 56 | + |
|---|
| 57 | +#define __bss_decrypted __section(".bss..decrypted") |
|---|
| 57 | 58 | |
|---|
| 58 | 59 | #else /* !CONFIG_AMD_MEM_ENCRYPT */ |
|---|
| 59 | 60 | |
|---|
| .. | .. |
|---|
| 72 | 73 | static inline void __init sme_encrypt_kernel(struct boot_params *bp) { } |
|---|
| 73 | 74 | static inline void __init sme_enable(struct boot_params *bp) { } |
|---|
| 74 | 75 | |
|---|
| 76 | +static inline void sev_es_init_vc_handling(void) { } |
|---|
| 75 | 77 | static inline bool sme_active(void) { return false; } |
|---|
| 76 | 78 | static inline bool sev_active(void) { return false; } |
|---|
| 79 | +static inline bool sev_es_active(void) { return false; } |
|---|
| 77 | 80 | |
|---|
| 78 | 81 | static inline int __init |
|---|
| 79 | 82 | early_set_memory_decrypted(unsigned long vaddr, unsigned long size) { return 0; } |
|---|
| 80 | 83 | static inline int __init |
|---|
| 81 | 84 | 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) { } |
|---|
| 82 | 89 | |
|---|
| 83 | 90 | #define __bss_decrypted |
|---|
| 84 | 91 | |
|---|
| .. | .. |
|---|
| 95 | 102 | |
|---|
| 96 | 103 | extern char __start_bss_decrypted[], __end_bss_decrypted[], __start_bss_decrypted_unused[]; |
|---|
| 97 | 104 | |
|---|
| 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 | + |
|---|
| 98 | 115 | #endif /* __ASSEMBLY__ */ |
|---|
| 99 | 116 | |
|---|
| 100 | 117 | #endif /* __X86_MEM_ENCRYPT_H__ */ |
|---|