mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-27 16:49:22 -04:00
The boot_{rdmsr,wrmsr}() helpers are *just* the barebones MSR access
functionality, without any tracing or exception handling glue as it is done in
kernel proper.
Move these helpers to asm/shared/msr.h and rename to raw_{rdmsr,wrmsr}() to
indicate what they are.
[ bp: Correct the reason why those helpers exist. I should've caught that in
the original patch that added them:
176db62257 ("x86/boot: Introduce helpers for MSR reads/writes"
but oh well...
- fixup include path delimiters to <> ]
Signed-off-by: John Allen <john.allen@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://patch.msgid.link/all/20250924200852.4452-2-john.allen@amd.com
45 lines
848 B
C
45 lines
848 B
C
/* 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
|
|
|
|
#include <asm/shared/msr.h>
|
|
|
|
void snp_accept_memory(phys_addr_t start, phys_addr_t end);
|
|
u64 sev_get_status(void);
|
|
bool early_is_sevsnp_guest(void);
|
|
|
|
static inline u64 sev_es_rd_ghcb_msr(void)
|
|
{
|
|
struct msr m;
|
|
|
|
raw_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;
|
|
raw_wrmsr(MSR_AMD64_SEV_ES_GHCB, &m);
|
|
}
|
|
|
|
#else
|
|
|
|
static inline void snp_accept_memory(phys_addr_t start, phys_addr_t end) { }
|
|
static inline u64 sev_get_status(void) { return 0; }
|
|
static inline bool early_is_sevsnp_guest(void) { return false; }
|
|
|
|
#endif
|
|
|
|
#endif
|