2023-06-06 09:51:26 -05:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* AMD SEV header for early boot related functions.
|
|
|
|
*
|
|
|
|
* Author: Tom Lendacky <thomas.lendacky@amd.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BOOT_COMPRESSED_SEV_H
|
|
|
|
#define BOOT_COMPRESSED_SEV_H
|
|
|
|
|
|
|
|
#ifdef CONFIG_AMD_MEM_ENCRYPT
|
|
|
|
|
2025-05-04 11:52:36 +02:00
|
|
|
#include "../msr.h"
|
|
|
|
|
2023-06-06 09:51:26 -05:00
|
|
|
void snp_accept_memory(phys_addr_t start, phys_addr_t end);
|
2025-04-17 22:21:21 +02:00
|
|
|
u64 sev_get_status(void);
|
2025-04-28 19:43:22 +02:00
|
|
|
bool early_is_sevsnp_guest(void);
|
2023-06-06 09:51:26 -05:00
|
|
|
|
2025-05-04 11:52:36 +02:00
|
|
|
static inline u64 sev_es_rd_ghcb_msr(void)
|
|
|
|
{
|
|
|
|
struct msr m;
|
|
|
|
|
|
|
|
boot_rdmsr(MSR_AMD64_SEV_ES_GHCB, &m);
|
|
|
|
|
|
|
|
return m.q;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void sev_es_wr_ghcb_msr(u64 val)
|
|
|
|
{
|
|
|
|
struct msr m;
|
|
|
|
|
|
|
|
m.q = val;
|
|
|
|
boot_wrmsr(MSR_AMD64_SEV_ES_GHCB, &m);
|
|
|
|
}
|
|
|
|
|
2023-06-06 09:51:26 -05:00
|
|
|
#else
|
|
|
|
|
|
|
|
static inline void snp_accept_memory(phys_addr_t start, phys_addr_t end) { }
|
2025-04-17 22:21:21 +02:00
|
|
|
static inline u64 sev_get_status(void) { return 0; }
|
2025-04-28 19:43:22 +02:00
|
|
|
static inline bool early_is_sevsnp_guest(void) { return false; }
|
2023-06-06 09:51:26 -05:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|