-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add TDX Guest detection #132
Add TDX Guest detection #132
Conversation
d433ae3
to
edf242a
Compare
Updated as I forgot to add the newly added feature to |
@klauspost, I'm not exactly sure why the tests are failing and what kind of action is needed from my side. Any help is super appreciated. |
Do you have any link for references? I googled a bit but couldn't find anything in I prefer to not have vendor specifics in there, and checking for the function should be correct anyway: if mfi >= 0x21 { I am looking for a feature bit, instead of a string to compare. If you want to positively know it is Intel TDX, we can add |
I'm sorry, it seems that GitHub "ate" the link I provided as part of the commit message in the PR description. You can also check this kernel link for reference: https://elixir.bootlin.com/linux/latest/source/arch/x86/include/asm/shared/tdx.h#L12 I'll update the PR following your suggestions. |
@klauspost, regarding the tests failures, is there something I'm clearly missing that I should do to make them happy? |
@fidencio It will blow up if the maxfunction number is exceeded. The "mfi" should be checked. Does the VM update that appropriately, so we can see leaf 21 is available? |
If you add the check, I'll accept it without more changes. |
It does, I just retested the cases here.
Cool, so can I leave this with the string compare? To be honest, I didn't fully understand the changes needed for adding a new flag, but I'd be up to doing that if you prefer. |
We need to be able to detect that a guest is running using Intel TDX (Trusted Domain Extensions). As the TDX Guests have their own cpuid leaf (0x21, 0), we can easily detected them by checking its cpuid. THe information provided here can be confirmed in the Intel TDX Module v1.5 Base Architecture Specificication[0], section 11.2 "Guest TD Run Time Environment Enumeration". What we're exposing, in the end, is a new feature called "TDX_GUEST", and this is the result of running cpuid with this patch applied on a TDX guest VM, and on a "vanilla" guest VM. TDX Guest VM: ``` Name: Vendor String: GenuineIntel Vendor ID: Intel PhysicalCores: 0 Threads Per Core: 1 Logical Cores: 0 CPU Family 6 Model: 143 Stepping: 4 Features: ADX,AESNI,AMXBF16,AMXINT8,AMXTILE,AVX,AVX2,AVX512BF16,AVX512BITALG,AVXX 512BW,AVX512CD,AVX512DQ,AVX512F,AVX512FP16,AVX512IFMA,AVX512VBMI,AVX512VBMI2,AVXX 512VL,AVX512VNNI,AVX512VPOPCNTDQ,AVXVNNI,AVXVNNIINT8,BMI1,BMI2,CLDEMOTE,CLMUL,CMM OV,CMPSB_SCADBS_SHORT,CMPXCHG8,CX16,ERMS,F16C,FLUSH_L1D,FMA3,FSRM,FXSR,FXSROPT,GG FNI,HLE,HYPERVISOR,IA32_ARCH_CAP,IA32_CORE_CAP,IBPB,LAHF,LZCNT,MD_CLEAR,MMX,MOVBB E,MOVDIR64B,MOVDIRI,MOVSB_ZL,NX,OSXSAVE,POPCNT,PREFETCHI,RDRAND,RDSEED,RDTSCP,RTT M,SERIALIZE,SHA,SPEC_CTRL_SSBD,SSE,SSE2,SSE3,SSE4,SSE42,SSSE3,STIBP,STOSB_SHORT,, SYSCALL,SYSEE,TDX_GUEST,TSXLDTRK,VAES,VPCLMULQDQ,WAITPKG,WBNOINVD,X87,XGETBV1,XSS AVE,XSAVEC,XSAVEOPT,XSAVES Microarchitecture level: 4 Cacheline bytes: 64 L1 Instruction Cache: 32768 bytes L1 Data Cache: 32768 bytes L2 Cache: 4194304 bytes L3 Cache: 16777216 bytes Frequency: 1000000000 Hz ``` Vanilla Guest VM: ``` Name: Genuine Intel(R) CPU 0000%@ Vendor String: GenuineIntel Vendor ID: Intel PhysicalCores: 1 Threads Per Core: 1 Logical Cores: 1 CPU Family 6 Model: 143 Stepping: 4 Features: ADX,AESNI,AMXBF16,AMXINT8,AMXTILE,AVX,AVX2,AVX512BF16,AVX512BITALG,AVXX 512BW,AVX512CD,AVX512DQ,AVX512F,AVX512FP16,AVX512IFMA,AVX512VBMI,AVX512VBMI2,AVXX 512VL,AVX512VNNI,AVX512VPOPCNTDQ,AVXVNNI,AVXVNNIINT8,BMI1,BMI2,CLDEMOTE,CLMUL,CMM OV,CMPXCHG8,CX16,ERMS,F16C,FMA3,FSRM,FXSR,FXSROPT,GFNI,HLE,HYPERVISOR,IA32_ARCH__ CAP,IBPB,IBRS,LAHF,LZCNT,MD_CLEAR,MMX,MOVBE,MOVDIR64B,MOVDIRI,NX,OSXSAVE,POPCNT,, PREFETCHI,RDRAND,RDSEED,RDTSCP,RTM,SERIALIZE,SGX,SGXLC,SHA,SPEC_CTRL_SSBD,SSE,SSS E2,SSE3,SSE4,SSE42,SSSE3,STIBP,SYSCALL,SYSEE,TSXLDTRK,VAES,VMX,VPCLMULQDQ,WAITPKK G,WBNOINVD,X87,XGETBV1,XSAVE,XSAVEC,XSAVEOPT,XSAVES Microarchitecture level: 4 Cacheline bytes: 64 L1 Instruction Cache: 32768 bytes L1 Data Cache: 32768 bytes L2 Cache: 4194304 bytes L3 Cache: 16777216 bytes SGX: {Available:true LaunchControl:true SGX1Supported:true SGX2Supported:true Maa xEnclaveSizeNot64:2147483648 MaxEnclaveSize64:72057594037927936 EPCSections:[]} ``` [0]: https://cdrdv2.intel.com/v1/dl/getContent/733575 Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
edf242a
to
dac402d
Compare
Updated removing the vendor specific test and using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/klauspost/cpuid/v2](https://github.com/klauspost/cpuid) | indirect | patch | `v2.2.3` -> `v2.2.5` | --- ### Release Notes <details> <summary>klauspost/cpuid (github.com/klauspost/cpuid/v2)</summary> ### [`v2.2.5`](https://github.com/klauspost/cpuid/releases/tag/v2.2.5) [Compare Source](https://github.com/klauspost/cpuid/compare/v2.2.4...v2.2.5) #### What's Changed - Update golang.org/x/sys by [@​klauspost](https://github.com/klauspost) in [https://github.com/klauspost/cpuid/pull/130](https://github.com/klauspost/cpuid/pull/130) - Fix AVXVNNIINT8, AVXNECONVERT, PREFETCHI [https://github.com/klauspost/cpuid/pull/131](https://github.com/klauspost/cpuid/pull/131) - Add TDX Guest detection by [@​fidencio](https://github.com/fidencio) in [https://github.com/klauspost/cpuid/pull/132](https://github.com/klauspost/cpuid/pull/132) #### New Contributors - [@​fidencio](https://github.com/fidencio) made their first contribution in [https://github.com/klauspost/cpuid/pull/132](https://github.com/klauspost/cpuid/pull/132) **Full Changelog**: klauspost/cpuid@v2.2.4...v2.2.5 ### [`v2.2.4`](https://github.com/klauspost/cpuid/releases/tag/v2.2.4) [Compare Source](https://github.com/klauspost/cpuid/compare/v2.2.3...v2.2.4) #### What's Changed - Add more Intel mitigation flags by [@​klauspost](https://github.com/klauspost) in [https://github.com/klauspost/cpuid/pull/128](https://github.com/klauspost/cpuid/pull/128) - Add more Intel Sierra Forest instructions by [@​fmuyassarov](https://github.com/fmuyassarov) in [https://github.com/klauspost/cpuid/pull/129](https://github.com/klauspost/cpuid/pull/129) **Full Changelog**: klauspost/cpuid@v2.2.3...v2.2.4 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTEuMCIsInVwZGF0ZWRJblZlciI6IjM1LjE1MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/klauspost/cpuid/v2](https://github.com/klauspost/cpuid) | indirect | patch | `v2.2.4` -> `v2.2.5` | --- ### Release Notes <details> <summary>klauspost/cpuid (github.com/klauspost/cpuid/v2)</summary> ### [`v2.2.5`](https://github.com/klauspost/cpuid/releases/tag/v2.2.5) [Compare Source](https://github.com/klauspost/cpuid/compare/v2.2.4...v2.2.5) #### What's Changed - Update golang.org/x/sys by [@​klauspost](https://github.com/klauspost) in [https://github.com/klauspost/cpuid/pull/130](https://github.com/klauspost/cpuid/pull/130) - Fix AVXVNNIINT8, AVXNECONVERT, PREFETCHI [https://github.com/klauspost/cpuid/pull/131](https://github.com/klauspost/cpuid/pull/131) - Add TDX Guest detection by [@​fidencio](https://github.com/fidencio) in [https://github.com/klauspost/cpuid/pull/132](https://github.com/klauspost/cpuid/pull/132) #### New Contributors - [@​fidencio](https://github.com/fidencio) made their first contribution in [https://github.com/klauspost/cpuid/pull/132](https://github.com/klauspost/cpuid/pull/132) **Full Changelog**: klauspost/cpuid@v2.2.4...v2.2.5 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on the first day of the month" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xNTEuMCIsInVwZGF0ZWRJblZlciI6IjM1LjE1MS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
We need to be able to detect that a guest is running using Intel TDX (Trusted Domain Extensions).
As the TDX Guests have their own cpuid leaf (0x21, 0), we can easily detected them by checking its cpuid.
THe information provided here can be confirmed in the Intel TDX Module v1.5 Base Architecture Specificication0, section 11.2 "Guest TD Run Time Environment Enumeration".
What we're exposing, in the end, is a new feature called "TDX_GUEST", and this is the result of running cpuid with this patch applied on a TDX guest VM, and on a "vanilla" guest VM.
TDX Guest VM:
Vanilla Guest VM: