Skip to content

Commit

Permalink
cpu: Discover TDX guests based on cpuid information
Browse files Browse the repository at this point in the history
NFD already has the capability to discover whether baremetal / host
machines support Intel TDX.  Now, the next step is to add support for
discovering whether a node is TDX protected (as in, a virtual machine
started using Intel TDX).

In order to do so, we've decided to go for a new `cpu-security.tdx`
property, called `protected` (`cpu-security.tdx.protected`).

Signed-off-by: Hairong Chen <[email protected]>
Signed-off-by: Fabiano Fidêncio <[email protected]>
  • Loading branch information
hairongchen authored and fidencio committed Jun 5, 2023
1 parent 8a65d8f commit 0e1ed42
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
# - "SSE4"
# - "SSE42"
# - "SSSE3"
# - "TDX_GUEST"
# attributeWhitelist:
# kernel:
# kconfigFile: "/path/to/kconfig"
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/worker-configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ Note: overridden by `sources.cpu.cpuid.attributeWhitelist` (if specified)

Default: `[BMI1, BMI2, CLMUL, CMOV, CX16, ERMS, F16C, HTT, LZCNT, MMX, MMXEXT,
NX, POPCNT, RDRAND, RDSEED, RDTSCP, SGX, SGXLC, SSE, SSE2, SSE3, SSE4.1,
SSE4.2, SSSE3]`
SSE4.2, SSSE3, TDX_GUEST]`

Example:

Expand Down
1 change: 1 addition & 0 deletions docs/usage/customization-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,7 @@ The following features are available for matching:
| | | **`se.enabled`** | bool | `true` if IBM Secure Execution for Linux is available and has been enabled, otherwise does not exist
| | | **`tdx.enabled`** | bool | `true` if Intel TDX (Trusted Domain Extensions) is available on the host and has been enabled, otherwise does not exist
| | | **`tdx.total_keys`** | int | The total amount of keys an Intel TDX (Trusted Domain Extensions) host can provide. It's only present if `tdx.enabled` is `true`.
| | | **`tdx.protected`** | bool | `true` if a guest VM was started using Intel TDX (Trusted Domain Extensions), otherwise does not exist.
| | | **`sev.enabled`** | bool | `true` if AMD SEV (Secure Encrypted Virtualization) is available on the host and has been enabled, otherwise does not exist
| | | **`sev.es.enabled`** | bool | `true` if AMD SEV-ES (Encrypted State supported) is available on the host and has been enabled, otherwise does not exist
| | | **`sev.snp.enabled`** | bool | `true` if AMD SEV-SNP (Secure Nested Paging supported) is available on the host and has been enabled, otherwise does not exist
Expand Down
1 change: 1 addition & 0 deletions docs/usage/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ option of nfd-worker.
| **`cpu-security.sgx.enabled`** | true | Set to 'true' if Intel SGX is enabled in BIOS (based on a non-zero sum value of SGX EPC section sizes).
| **`cpu-security.se.enabled`** | true | Set to 'true' if IBM Secure Execution for Linux (IBM Z & LinuxONE) is available and enabled (requires `/sys/firmware/uv/prot_virt_host` facility)
| **`cpu-security.tdx.enabled`** | true | Set to 'true' if Intel TDX is available on the host and has been enabled (requires `/sys/module/kvm_intel/parameters/tdx`).
| **`cpu-security.tdx.protected`** | true | Set to 'true' if Intel TDX was used to start the guest node, based on the existence of the "TDX_GUEST" information as part of cpuid features.
| **`cpu-security.sev.enabled`** | true | Set to 'true' if ADM SEV is available on the host and has been enabled (requires `/sys/module/kvm_amd/parameters/sev`).
| **`cpu-security.sev.es.enabled`** | true | Set to 'true' if ADM SEV-ES is available on the host and has been enabled (requires `/sys/module/kvm_amd/parameters/sev_es`).
| **`cpu-security.sev.snp.enabled`**| true | Set to 'true' if ADM SEV-SNP is available on the host and has been enabled (requires `/sys/module/kvm_amd/parameters/sev_snp`).
Expand Down
1 change: 1 addition & 0 deletions source/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func newDefaultConfig() *Config {
"SSE4",
"SSE42",
"SSSE3",
"TDX_GUEST",
},
AttributeWhitelist: []string{},
},
Expand Down
8 changes: 8 additions & 0 deletions source/cpu/security_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func discoverSecurity() map[string]string {
}
}

if tdxProtected() {
elems["tdx.protected"] = "true"
}

if sevParameterEnabled("sev") {
elems["sev.enabled"] = "true"

Expand Down Expand Up @@ -102,6 +106,10 @@ func tdxEnabled() bool {
return false
}

func tdxProtected() bool {
return cpuid.CPU.Has(cpuid.TDX_GUEST)
}

func sevParameterEnabled(parameter string) bool {
// SEV-SNP is supported and enabled when the kvm module `sev_snp` parameter is set to `Y`
// SEV-SNP support infers SEV (-ES) support
Expand Down

0 comments on commit 0e1ed42

Please sign in to comment.