Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Confidential Computing Platform Capability checks
0004  *
0005  * Copyright (C) 2021 Advanced Micro Devices, Inc.
0006  *
0007  * Author: Tom Lendacky <thomas.lendacky@amd.com>
0008  */
0009 
0010 #ifndef _LINUX_CC_PLATFORM_H
0011 #define _LINUX_CC_PLATFORM_H
0012 
0013 #include <linux/types.h>
0014 #include <linux/stddef.h>
0015 
0016 /**
0017  * enum cc_attr - Confidential computing attributes
0018  *
0019  * These attributes represent confidential computing features that are
0020  * currently active.
0021  */
0022 enum cc_attr {
0023     /**
0024      * @CC_ATTR_MEM_ENCRYPT: Memory encryption is active
0025      *
0026      * The platform/OS is running with active memory encryption. This
0027      * includes running either as a bare-metal system or a hypervisor
0028      * and actively using memory encryption or as a guest/virtual machine
0029      * and actively using memory encryption.
0030      *
0031      * Examples include SME, SEV and SEV-ES.
0032      */
0033     CC_ATTR_MEM_ENCRYPT,
0034 
0035     /**
0036      * @CC_ATTR_HOST_MEM_ENCRYPT: Host memory encryption is active
0037      *
0038      * The platform/OS is running as a bare-metal system or a hypervisor
0039      * and actively using memory encryption.
0040      *
0041      * Examples include SME.
0042      */
0043     CC_ATTR_HOST_MEM_ENCRYPT,
0044 
0045     /**
0046      * @CC_ATTR_GUEST_MEM_ENCRYPT: Guest memory encryption is active
0047      *
0048      * The platform/OS is running as a guest/virtual machine and actively
0049      * using memory encryption.
0050      *
0051      * Examples include SEV and SEV-ES.
0052      */
0053     CC_ATTR_GUEST_MEM_ENCRYPT,
0054 
0055     /**
0056      * @CC_ATTR_GUEST_STATE_ENCRYPT: Guest state encryption is active
0057      *
0058      * The platform/OS is running as a guest/virtual machine and actively
0059      * using memory encryption and register state encryption.
0060      *
0061      * Examples include SEV-ES.
0062      */
0063     CC_ATTR_GUEST_STATE_ENCRYPT,
0064 
0065     /**
0066      * @CC_ATTR_GUEST_UNROLL_STRING_IO: String I/O is implemented with
0067      *                                  IN/OUT instructions
0068      *
0069      * The platform/OS is running as a guest/virtual machine and uses
0070      * IN/OUT instructions in place of string I/O.
0071      *
0072      * Examples include TDX guest & SEV.
0073      */
0074     CC_ATTR_GUEST_UNROLL_STRING_IO,
0075 
0076     /**
0077      * @CC_ATTR_SEV_SNP: Guest SNP is active.
0078      *
0079      * The platform/OS is running as a guest/virtual machine and actively
0080      * using AMD SEV-SNP features.
0081      */
0082     CC_ATTR_GUEST_SEV_SNP,
0083 
0084     /**
0085      * @CC_ATTR_HOTPLUG_DISABLED: Hotplug is not supported or disabled.
0086      *
0087      * The platform/OS is running as a guest/virtual machine does not
0088      * support CPU hotplug feature.
0089      *
0090      * Examples include TDX Guest.
0091      */
0092     CC_ATTR_HOTPLUG_DISABLED,
0093 };
0094 
0095 #ifdef CONFIG_ARCH_HAS_CC_PLATFORM
0096 
0097 /**
0098  * cc_platform_has() - Checks if the specified cc_attr attribute is active
0099  * @attr: Confidential computing attribute to check
0100  *
0101  * The cc_platform_has() function will return an indicator as to whether the
0102  * specified Confidential Computing attribute is currently active.
0103  *
0104  * Context: Any context
0105  * Return:
0106  * * TRUE  - Specified Confidential Computing attribute is active
0107  * * FALSE - Specified Confidential Computing attribute is not active
0108  */
0109 bool cc_platform_has(enum cc_attr attr);
0110 
0111 #else   /* !CONFIG_ARCH_HAS_CC_PLATFORM */
0112 
0113 static inline bool cc_platform_has(enum cc_attr attr) { return false; }
0114 
0115 #endif  /* CONFIG_ARCH_HAS_CC_PLATFORM */
0116 
0117 #endif  /* _LINUX_CC_PLATFORM_H */