146b49b12STom Lendacky /* SPDX-License-Identifier: GPL-2.0-only */ 246b49b12STom Lendacky /* 346b49b12STom Lendacky * Confidential Computing Platform Capability checks 446b49b12STom Lendacky * 546b49b12STom Lendacky * Copyright (C) 2021 Advanced Micro Devices, Inc. 646b49b12STom Lendacky * 746b49b12STom Lendacky * Author: Tom Lendacky <thomas.lendacky@amd.com> 846b49b12STom Lendacky */ 946b49b12STom Lendacky 1046b49b12STom Lendacky #ifndef _LINUX_CC_PLATFORM_H 1146b49b12STom Lendacky #define _LINUX_CC_PLATFORM_H 1246b49b12STom Lendacky 1346b49b12STom Lendacky #include <linux/types.h> 1446b49b12STom Lendacky #include <linux/stddef.h> 1546b49b12STom Lendacky 1646b49b12STom Lendacky /** 1746b49b12STom Lendacky * enum cc_attr - Confidential computing attributes 1846b49b12STom Lendacky * 1946b49b12STom Lendacky * These attributes represent confidential computing features that are 2046b49b12STom Lendacky * currently active. 2146b49b12STom Lendacky */ 2246b49b12STom Lendacky enum cc_attr { 2346b49b12STom Lendacky /** 2446b49b12STom Lendacky * @CC_ATTR_MEM_ENCRYPT: Memory encryption is active 2546b49b12STom Lendacky * 2646b49b12STom Lendacky * The platform/OS is running with active memory encryption. This 2746b49b12STom Lendacky * includes running either as a bare-metal system or a hypervisor 2846b49b12STom Lendacky * and actively using memory encryption or as a guest/virtual machine 2946b49b12STom Lendacky * and actively using memory encryption. 3046b49b12STom Lendacky * 3146b49b12STom Lendacky * Examples include SME, SEV and SEV-ES. 3246b49b12STom Lendacky */ 3346b49b12STom Lendacky CC_ATTR_MEM_ENCRYPT, 3446b49b12STom Lendacky 3546b49b12STom Lendacky /** 3646b49b12STom Lendacky * @CC_ATTR_HOST_MEM_ENCRYPT: Host memory encryption is active 3746b49b12STom Lendacky * 3846b49b12STom Lendacky * The platform/OS is running as a bare-metal system or a hypervisor 3946b49b12STom Lendacky * and actively using memory encryption. 4046b49b12STom Lendacky * 4146b49b12STom Lendacky * Examples include SME. 4246b49b12STom Lendacky */ 4346b49b12STom Lendacky CC_ATTR_HOST_MEM_ENCRYPT, 4446b49b12STom Lendacky 4546b49b12STom Lendacky /** 4646b49b12STom Lendacky * @CC_ATTR_GUEST_MEM_ENCRYPT: Guest memory encryption is active 4746b49b12STom Lendacky * 4846b49b12STom Lendacky * The platform/OS is running as a guest/virtual machine and actively 4946b49b12STom Lendacky * using memory encryption. 5046b49b12STom Lendacky * 5146b49b12STom Lendacky * Examples include SEV and SEV-ES. 5246b49b12STom Lendacky */ 5346b49b12STom Lendacky CC_ATTR_GUEST_MEM_ENCRYPT, 5446b49b12STom Lendacky 5546b49b12STom Lendacky /** 5646b49b12STom Lendacky * @CC_ATTR_GUEST_STATE_ENCRYPT: Guest state encryption is active 5746b49b12STom Lendacky * 5846b49b12STom Lendacky * The platform/OS is running as a guest/virtual machine and actively 5946b49b12STom Lendacky * using memory encryption and register state encryption. 6046b49b12STom Lendacky * 6146b49b12STom Lendacky * Examples include SEV-ES. 6246b49b12STom Lendacky */ 6346b49b12STom Lendacky CC_ATTR_GUEST_STATE_ENCRYPT, 648260b982SKuppuswamy Sathyanarayanan 658260b982SKuppuswamy Sathyanarayanan /** 668260b982SKuppuswamy Sathyanarayanan * @CC_ATTR_GUEST_UNROLL_STRING_IO: String I/O is implemented with 678260b982SKuppuswamy Sathyanarayanan * IN/OUT instructions 688260b982SKuppuswamy Sathyanarayanan * 698260b982SKuppuswamy Sathyanarayanan * The platform/OS is running as a guest/virtual machine and uses 708260b982SKuppuswamy Sathyanarayanan * IN/OUT instructions in place of string I/O. 718260b982SKuppuswamy Sathyanarayanan * 728260b982SKuppuswamy Sathyanarayanan * Examples include TDX guest & SEV. 738260b982SKuppuswamy Sathyanarayanan */ 748260b982SKuppuswamy Sathyanarayanan CC_ATTR_GUEST_UNROLL_STRING_IO, 75*bae1a962SKuppuswamy Sathyanarayanan 76*bae1a962SKuppuswamy Sathyanarayanan /** 77*bae1a962SKuppuswamy Sathyanarayanan * @CC_ATTR_SEV_SNP: Guest SNP is active. 78*bae1a962SKuppuswamy Sathyanarayanan * 79*bae1a962SKuppuswamy Sathyanarayanan * The platform/OS is running as a guest/virtual machine and actively 80*bae1a962SKuppuswamy Sathyanarayanan * using AMD SEV-SNP features. 81*bae1a962SKuppuswamy Sathyanarayanan */ 82*bae1a962SKuppuswamy Sathyanarayanan CC_ATTR_GUEST_SEV_SNP, 83*bae1a962SKuppuswamy Sathyanarayanan 84*bae1a962SKuppuswamy Sathyanarayanan /** 8546b49b12STom Lendacky * @CC_ATTR_HOTPLUG_DISABLED: Hotplug is not supported or disabled. 8646b49b12STom Lendacky * 8746b49b12STom Lendacky * The platform/OS is running as a guest/virtual machine does not 8846b49b12STom Lendacky * support CPU hotplug feature. 8946b49b12STom Lendacky * 9046b49b12STom Lendacky * Examples include TDX Guest. 9146b49b12STom Lendacky */ 9246b49b12STom Lendacky CC_ATTR_HOTPLUG_DISABLED, 9346b49b12STom Lendacky }; 9446b49b12STom Lendacky 9546b49b12STom Lendacky #ifdef CONFIG_ARCH_HAS_CC_PLATFORM 9646b49b12STom Lendacky 9746b49b12STom Lendacky /** 9846b49b12STom Lendacky * cc_platform_has() - Checks if the specified cc_attr attribute is active 9946b49b12STom Lendacky * @attr: Confidential computing attribute to check 10046b49b12STom Lendacky * 10146b49b12STom Lendacky * The cc_platform_has() function will return an indicator as to whether the 10246b49b12STom Lendacky * specified Confidential Computing attribute is currently active. 10346b49b12STom Lendacky * 10446b49b12STom Lendacky * Context: Any context 10546b49b12STom Lendacky * Return: 10646b49b12STom Lendacky * * TRUE - Specified Confidential Computing attribute is active 10746b49b12STom Lendacky * * FALSE - Specified Confidential Computing attribute is not active 10846b49b12STom Lendacky */ 10946b49b12STom Lendacky bool cc_platform_has(enum cc_attr attr); 110 111 #else /* !CONFIG_ARCH_HAS_CC_PLATFORM */ 112 cc_platform_has(enum cc_attr attr)113static inline bool cc_platform_has(enum cc_attr attr) { return false; } 114 115 #endif /* CONFIG_ARCH_HAS_CC_PLATFORM */ 116 117 #endif /* _LINUX_CC_PLATFORM_H */ 118