mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 13:14:07 +08:00
- Some SEV and CC platform helpers cleanup and simplifications now that
the usage patterns are becoming apparent -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEzv7L6UO9uDPlPSfHEsHwGGHeVUoFAmSa9CoACgkQEsHwGGHe VUr1NhAAjmOq/T41u3FCSU6fZ8gXo5UkIUT13a6cx+6Omx9waJn5G0xdf/380vQN RPRTcc4cfQHCdnIeHgiz1YtCh1ljxXswOSbexHgWHjEcqadgxkZTlKaBEbqyEwLI lnRRsowfk7J/8RsYqtzuBvGaWNliiszWE8iayruI1IL+FoEDLlLx1GNYqusP5WIs 0KYm919Zozl8FEZjP47nH4bab1RcE+HGmLG7UEBmR0zHl4cc7iN3wpv2o/vDxVzR /KP8a2G7J/xjllGW+OP81dFCS7iklHpNuaxQS73fDIL7ll2VDqNemh4ivykCrplo 93twODBwKboKmZhnKc0M2axm5JGGx7IC3KTqEUHzb2Wo4bZCYnrj+9Utzxsa3FxB m0BSUcmBqzZCsHCbu62N66l1NlB32EnMO80/45NrgGi62YiGP8qQNhy3TiceUNle NHFkQmRZwLyW5YC1ntSK8fwSu4GrMG1MG/eRfMPDmmsYogiZUm2KIj7XKy3dKXR6 maqifh/raPk3rL+7cl9BQleCDLjnkHNxFxFa329P9K4wrtqn7Ley4izWYAUYhNrl VOjLs+thTwEmPPgpo/K1wAbR/PjLdmSQ/fQR6w7eUrzNVnm5ndXzhTUcIawycG3T haVry+xPMIRlLCIg+dkrwwNcTW1y/X3K4SmgnjLLF57lZFn9UJc= =Aj6p -----END PGP SIGNATURE----- Merge tag 'x86_sev_for_v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip Pull x86 SEV updates from Borislav Petkov: - Some SEV and CC platform helpers cleanup and simplifications now that the usage patterns are becoming apparent [ I'm sure I'm the only one that has gets confused by all the TLAs, but in case there are others: here SEV is AMD's "Secure Encrypted Virtualization" and CC is generic "Confidential Computing". There's also Intel SGX (Software Guard Extensions) and TDX (Trust Domain Extensions), along with all the vendor memory encryption extensions (SME, TSME, TME, and WTF). And then we have arm64 with RMA and CCA, and I probably forgot another dozen or so related acronyms - Linus ] * tag 'x86_sev_for_v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/coco: Get rid of accessor functions x86/sev: Get rid of special sev_es_enable_key x86/coco: Mark cc_platform_has() and descendants noinstr
This commit is contained in:
commit
12dc010071
@ -13,10 +13,10 @@
|
||||
#include <asm/coco.h>
|
||||
#include <asm/processor.h>
|
||||
|
||||
enum cc_vendor cc_vendor __ro_after_init;
|
||||
enum cc_vendor cc_vendor __ro_after_init = CC_VENDOR_NONE;
|
||||
static u64 cc_mask __ro_after_init;
|
||||
|
||||
static bool intel_cc_platform_has(enum cc_attr attr)
|
||||
static bool noinstr intel_cc_platform_has(enum cc_attr attr)
|
||||
{
|
||||
switch (attr) {
|
||||
case CC_ATTR_GUEST_UNROLL_STRING_IO:
|
||||
@ -34,7 +34,7 @@ static bool intel_cc_platform_has(enum cc_attr attr)
|
||||
* the other levels of SME/SEV functionality, including C-bit
|
||||
* based SEV-SNP, are not enabled.
|
||||
*/
|
||||
static __maybe_unused bool amd_cc_platform_vtom(enum cc_attr attr)
|
||||
static __maybe_unused __always_inline bool amd_cc_platform_vtom(enum cc_attr attr)
|
||||
{
|
||||
switch (attr) {
|
||||
case CC_ATTR_GUEST_MEM_ENCRYPT:
|
||||
@ -58,7 +58,7 @@ static __maybe_unused bool amd_cc_platform_vtom(enum cc_attr attr)
|
||||
* the trampoline area must be encrypted.
|
||||
*/
|
||||
|
||||
static bool amd_cc_platform_has(enum cc_attr attr)
|
||||
static bool noinstr amd_cc_platform_has(enum cc_attr attr)
|
||||
{
|
||||
#ifdef CONFIG_AMD_MEM_ENCRYPT
|
||||
|
||||
@ -97,7 +97,7 @@ static bool amd_cc_platform_has(enum cc_attr attr)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cc_platform_has(enum cc_attr attr)
|
||||
bool noinstr cc_platform_has(enum cc_attr attr)
|
||||
{
|
||||
switch (cc_vendor) {
|
||||
case CC_VENDOR_AMD:
|
||||
|
@ -769,7 +769,7 @@ void __init tdx_early_init(void)
|
||||
|
||||
setup_force_cpu_cap(X86_FEATURE_TDX_GUEST);
|
||||
|
||||
cc_set_vendor(CC_VENDOR_INTEL);
|
||||
cc_vendor = CC_VENDOR_INTEL;
|
||||
tdx_parse_tdinfo(&cc_mask);
|
||||
cc_set_mask(cc_mask);
|
||||
|
||||
|
@ -365,7 +365,7 @@ void __init hv_vtom_init(void)
|
||||
* Set it here to indicate a vTOM VM.
|
||||
*/
|
||||
sev_status = MSR_AMD64_SNP_VTOM;
|
||||
cc_set_vendor(CC_VENDOR_AMD);
|
||||
cc_vendor = CC_VENDOR_AMD;
|
||||
cc_set_mask(ms_hyperv.shared_gpa_boundary);
|
||||
physical_mask &= ms_hyperv.shared_gpa_boundary - 1;
|
||||
|
||||
|
@ -10,30 +10,13 @@ enum cc_vendor {
|
||||
CC_VENDOR_INTEL,
|
||||
};
|
||||
|
||||
#ifdef CONFIG_ARCH_HAS_CC_PLATFORM
|
||||
extern enum cc_vendor cc_vendor;
|
||||
|
||||
static inline enum cc_vendor cc_get_vendor(void)
|
||||
{
|
||||
return cc_vendor;
|
||||
}
|
||||
|
||||
static inline void cc_set_vendor(enum cc_vendor vendor)
|
||||
{
|
||||
cc_vendor = vendor;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_HAS_CC_PLATFORM
|
||||
void cc_set_mask(u64 mask);
|
||||
u64 cc_mkenc(u64 val);
|
||||
u64 cc_mkdec(u64 val);
|
||||
#else
|
||||
static inline enum cc_vendor cc_get_vendor(void)
|
||||
{
|
||||
return CC_VENDOR_NONE;
|
||||
}
|
||||
|
||||
static inline void cc_set_vendor(enum cc_vendor vendor) { }
|
||||
|
||||
static inline u64 cc_mkenc(u64 val)
|
||||
{
|
||||
return val;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <asm/insn.h>
|
||||
#include <asm/sev-common.h>
|
||||
#include <asm/bootparam.h>
|
||||
#include <asm/coco.h>
|
||||
|
||||
#define GHCB_PROTOCOL_MIN 1ULL
|
||||
#define GHCB_PROTOCOL_MAX 2ULL
|
||||
@ -140,24 +141,26 @@ struct snp_secrets_page_layout {
|
||||
} __packed;
|
||||
|
||||
#ifdef CONFIG_AMD_MEM_ENCRYPT
|
||||
extern struct static_key_false sev_es_enable_key;
|
||||
extern void __sev_es_ist_enter(struct pt_regs *regs);
|
||||
extern void __sev_es_ist_exit(void);
|
||||
static __always_inline void sev_es_ist_enter(struct pt_regs *regs)
|
||||
{
|
||||
if (static_branch_unlikely(&sev_es_enable_key))
|
||||
if (cc_vendor == CC_VENDOR_AMD &&
|
||||
cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
|
||||
__sev_es_ist_enter(regs);
|
||||
}
|
||||
static __always_inline void sev_es_ist_exit(void)
|
||||
{
|
||||
if (static_branch_unlikely(&sev_es_enable_key))
|
||||
if (cc_vendor == CC_VENDOR_AMD &&
|
||||
cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
|
||||
__sev_es_ist_exit();
|
||||
}
|
||||
extern int sev_es_setup_ap_jump_table(struct real_mode_header *rmh);
|
||||
extern void __sev_es_nmi_complete(void);
|
||||
static __always_inline void sev_es_nmi_complete(void)
|
||||
{
|
||||
if (static_branch_unlikely(&sev_es_enable_key))
|
||||
if (cc_vendor == CC_VENDOR_AMD &&
|
||||
cc_platform_has(CC_ATTR_GUEST_STATE_ENCRYPT))
|
||||
__sev_es_nmi_complete();
|
||||
}
|
||||
extern int __init sev_es_efi_map_ghcbs(pgd_t *pgd);
|
||||
|
@ -113,8 +113,6 @@ struct ghcb_state {
|
||||
};
|
||||
|
||||
static DEFINE_PER_CPU(struct sev_es_runtime_data*, runtime_data);
|
||||
DEFINE_STATIC_KEY_FALSE(sev_es_enable_key);
|
||||
|
||||
static DEFINE_PER_CPU(struct sev_es_save_area *, sev_vmsa);
|
||||
|
||||
struct sev_config {
|
||||
@ -1355,9 +1353,6 @@ void __init sev_es_init_vc_handling(void)
|
||||
sev_es_terminate(SEV_TERM_SET_GEN, GHCB_SNP_UNSUPPORTED);
|
||||
}
|
||||
|
||||
/* Enable SEV-ES special handling */
|
||||
static_branch_enable(&sev_es_enable_key);
|
||||
|
||||
/* Initialize per-cpu GHCB pages */
|
||||
for_each_possible_cpu(cpu) {
|
||||
alloc_runtime_data(cpu);
|
||||
|
@ -612,7 +612,7 @@ void __init sme_enable(struct boot_params *bp)
|
||||
out:
|
||||
if (sme_me_mask) {
|
||||
physical_mask &= ~sme_me_mask;
|
||||
cc_set_vendor(CC_VENDOR_AMD);
|
||||
cc_vendor = CC_VENDOR_AMD;
|
||||
cc_set_mask(sme_me_mask);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user