| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
#include <stdint.h> |
| 5 |
|
| 6 |
/* Keep CVM detection logic in this file at feature parity with |
| 7 |
* that in src/efi/boot/vmm.c */ |
| 8 |
|
| 9 |
#define CPUID_PROCESSOR_INFO_AND_FEATURE_BITS UINT32_C(0x1) |
| 10 |
|
| 11 |
/* |
| 12 |
* AMD64 Architecture Programmer’s Manual Volume 3: |
| 13 |
* General-Purpose and System Instructions. |
| 14 |
* Chapter: E4.1 - Maximum Extended Function Number and Vendor String |
| 15 |
* https://www.amd.com/system/files/TechDocs/24594.pdf |
| 16 |
*/ |
| 17 |
#define CPUID_GET_HIGHEST_FUNCTION UINT32_C(0x80000000) |
| 18 |
|
| 19 |
/* |
| 20 |
* AMD64 Architecture Programmer’s Manual Volume 3: |
| 21 |
* General-Purpose and System Instructions. |
| 22 |
* Chapter: E4.17 - Encrypted Memory Capabilities |
| 23 |
* https://www.amd.com/system/files/TechDocs/24594.pdf |
| 24 |
*/ |
| 25 |
#define CPUID_AMD_GET_ENCRYPTED_MEMORY_CAPABILITIES UINT32_C(0x8000001f) |
| 26 |
|
| 27 |
/* |
| 28 |
* AMD64 Architecture Programmer’s Manual Volume 3: |
| 29 |
* General-Purpose and System Instructions. |
| 30 |
* Chapter: 15.34.10 - SEV_STATUS MSR |
| 31 |
* https://www.amd.com/system/files/TechDocs/24593.pdf |
| 32 |
*/ |
| 33 |
#define MSR_AMD64_SEV UINT32_C(0xc0010131) |
| 34 |
|
| 35 |
/* |
| 36 |
* Intel® TDX Module v1.5 Base Architecture Specification |
| 37 |
* Chapter: 11.2 |
| 38 |
* https://www.intel.com/content/www/us/en/content-details/733575/intel-tdx-module-v1-5-base-architecture-specification.html |
| 39 |
*/ |
| 40 |
|
| 41 |
#define CPUID_INTEL_TDX_ENUMERATION UINT32_C(0x21) |
| 42 |
|
| 43 |
/* Requirements for Implementing the Microsoft Hypervisor Interface |
| 44 |
* https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/tlfs/tlfs |
| 45 |
*/ |
| 46 |
#define CPUID_HYPERV_VENDOR_AND_MAX_FUNCTIONS UINT32_C(0x40000000) |
| 47 |
|
| 48 |
#define CPUID_HYPERV_FEATURES UINT32_C(0x40000003) |
| 49 |
|
| 50 |
#define CPUID_HYPERV_ISOLATION_CONFIG UINT32_C(0x4000000C) |
| 51 |
|
| 52 |
#define CPUID_HYPERV_MIN UINT32_C(0x40000005) |
| 53 |
#define CPUID_HYPERV_MAX UINT32_C(0x4000ffff) |
| 54 |
|
| 55 |
#define CPUID_SIG_AMD "AuthenticAMD" |
| 56 |
#define CPUID_SIG_INTEL "GenuineIntel" |
| 57 |
#define CPUID_SIG_INTEL_TDX "IntelTDX " |
| 58 |
#define CPUID_SIG_HYPERV "Microsoft Hv" |
| 59 |
|
| 60 |
/* ecx bit 31: set => hyperpvisor, unset => bare metal */ |
| 61 |
#define CPUID_FEATURE_HYPERVISOR (UINT32_C(1) << 31) |
| 62 |
|
| 63 |
/* Linux include/asm-generic/hyperv-tlfs.h */ |
| 64 |
#define CPUID_HYPERV_CPU_MANAGEMENT (UINT32_C(1) << 12) /* root partition */ |
| 65 |
#define CPUID_HYPERV_ISOLATION (UINT32_C(1) << 22) /* confidential VM partition */ |
| 66 |
|
| 67 |
#define CPUID_HYPERV_ISOLATION_TYPE_MASK UINT32_C(0xf) |
| 68 |
#define CPUID_HYPERV_ISOLATION_TYPE_SNP 2 |
| 69 |
#define CPUID_HYPERV_ISOLATION_TYPE_TDX 3 |
| 70 |
|
| 71 |
#define EAX_SEV (UINT32_C(1) << 1) |
| 72 |
#define MSR_SEV (UINT64_C(1) << 0) |
| 73 |
#define MSR_SEV_ES (UINT64_C(1) << 1) |
| 74 |
#define MSR_SEV_SNP (UINT64_C(1) << 2) |