Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Quick reference for diagnosing and fixing `snphost ok` test failures.
| **SME** | [SME Support](#sme-support) | | [SME Enabled](#sme-enabled) | | | | |
| **SEV** | [SEV Support](#sev-support) | [Max Guests](#maximum-encrypted-guests)<br><br>[Page Flush MSR](#page-flush-msr-support) | [ASID Limits](#minimum-sev-only-asid) | [SEV Initialized](#sev-initialized) | [SEV Enabled in KVM](#sev-enabled-in-kvm) | | |
| **SEV-ES** | [SEV-ES Support](#sev-es-support) | | | [SEV-ES Initialized](#sev-es-initialized) | [SEV-ES Enabled in KVM](#sev-es-enabled-in-kvm) | | |
| **SEV-SNP** | [SEV-SNP Support](#sev-snp-support) | [VMPL Support](#vmpl-support--count) | [SNP Enabled](#snp-enabled)<br><br>[RMP Addresses](#rmp-addresses) | [SNP Initialized](#snp-initialized)<br><br>[RMP Initialized](#rmp-initialized) | [SEV-SNP Enabled in KVM](#sev-snp-enabled-in-kvm) | [Memory Alias Check](#memory-alias-check)<br><br>[TCB Comparison](#tcb-version-comparison) | [Secure TSC](#secure-tsc) |
| **SEV-SNP** | [SEV-SNP Support](#sev-snp-support) | [VMPL Support](#vmpl-support--count) | [SNP Enabled](#snp-enabled)<br><br>[RMP Addresses](#rmp-addresses) | [SNP Initialized](#snp-initialized)<br><br>[RMP Initialized](#rmp-initialized) | [SEV-SNP Enabled in KVM](#sev-snp-enabled-in-kvm) | [Memory Alias Check](#memory-alias-check)<br><br>[TCB Comparison](#tcb-version-comparison) | [Secure TSC](#secure-tsc)<br><br>[Ciphertext Hiding](#ciphertext-hiding) |

**Column Descriptions:**
- **CPU Support**: CPUID checks - does the processor have this feature?
Expand Down Expand Up @@ -578,6 +578,47 @@ sudo snphost ok --verbose

---

### Ciphertext Hiding

**Tests:** Platform support and enablement of ciphertext hiding for SNP guest private memory.

Ciphertext hiding prevents disallowed host accesses to SNP guest private memory from reading ciphertext. Such reads return a constant default value (`0xff`) instead.

Hardware and firmware support: `SNP_PLATFORM_STATUS` reports `CIPHERTEXT_HIDING_DRAM_CAP` when the platform is capable of ciphertext hiding. The test reports this as unavailable when the bit is clear.

Kernel enablement: Set a nonzero `ciphertext_hiding_asids=<N>` parameter when loading `kvm_amd`. During `SEV_PLATFORM_INIT`, KVM passes this value to firmware as the maximum SNP ASID. Firmware sets `CIPHERTEXT_HIDING_DRAM_EN` only when ciphertext hiding is enabled through that initialization; `snphost ok --features` checks this bit as the end-to-end kernel and firmware enablement check.

**Platform Requirements:**
- AMD EPYC 9005+ processor
- Enable the BIOS setting: AMD CBS → UMC Common Options → DDR RAS → ECC Configuration → CipherText Hiding Enable
- A kernel with KVM ciphertext-hiding support
- A nonzero `ciphertext_hiding_asids` value when loading `kvm_amd`

**Check:**
```bash
# Include optional feature checks
snphost ok --features --verbose

# Confirm the configured ASID count (nonzero enables ciphertext hiding)
cat /sys/module/kvm_amd/parameters/ciphertext_hiding_asids
```

**Enable:**
```bash
# Example: reserve 16 ASIDs for SNP guests and enable ciphertext hiding
modprobe kvm_amd ciphertext_hiding_asids=16
```

The parameter partitions the joint SEV-ES/SEV-SNP ASID space. Increasing the SNP ASID allocation reduces the ASIDs available to SEV-ES guests; assigning all available ASIDs to SNP effectively disables SEV-ES.

**References:**

[SEV Secure Nested Paging Firmware ABI Specification, Revision 1.58, Section 8.5 SNP_PLATFORM_STATUS](https://www.amd.com/content/dam/amd/en/documents/developer/56860.pdf)
[Linux KVM SEV ciphertext-hiding support](https://github.com/torvalds/linux/blob/master/arch/x86/kvm/svm/sev.c)
[Linux kernel parameters: `kvm-amd.ciphertext_hiding_asids`](https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html)

---

## Why /dev/sev Doesn't Exist

If `/dev/sev` is missing, multiple tests will fail (firmware version, SEV/SNP initialized, TCB comparison, etc.). Use this table to identify and fix the root cause:
Expand Down
48 changes: 46 additions & 2 deletions src/ok/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,48 @@ fn collect_tests() -> Vec<Test> {
},
sub: vec![],
},

Test {
name: "(Optional Feature) Ciphertext Hiding",
gen_mask: SNP_MASK,
run: Box::new(|| match snp_platform_status() {
Ok(status) if !status.platform_policy.ciphertext_hiding_dram_cap() => {
TestResult {
name: format!("({}) Ciphertext Hiding", TestCategory::OptionalFeatures),
stat: TestState::Fail,
mesg: Some("Ciphertext Hiding is unavailable".to_string()),
}
}
Ok(status) if !status.platform_policy.ciphertext_hiding_dram_en() => {
TestResult {
name: format!("({}) Ciphertext Hiding", TestCategory::OptionalFeatures),
stat: TestState::Fail,
mesg: Some("Ciphertext Hiding is available, but not enabled".to_string()),
}
}
Ok(_) => TestResult {
name: format!("({}) Ciphertext Hiding", TestCategory::OptionalFeatures),
stat: TestState::Pass,
mesg: Some("Ciphertext Hiding is available and enabled".to_string()),
},
Err(e) => TestResult {
name: format!("({}) Ciphertext Hiding", TestCategory::OptionalFeatures),
stat: TestState::Fail,
mesg: Some(format!("{:#}", e)),
},
}
),
meta: TestMetadata {
category: TestCategory::OptionalFeatures,
description: "Checks SNP platform status to verify ciphertext hiding support and enablement",
fix_hint: "- AMD EPYC 9005+\n\
- Enable in BIOS using the following setting to make the feature capable: AMD CBS → UMC Common Options → DDR RAS → ECC Configuration → CipherText Hiding Enable\n\
- Enable in kernel by adding the following parameter ciphertext_hiding_asids=<N> to kvm_amd kernel module.",
},

sub: vec![]
},

Test {
name: "SEV-SNP",
gen_mask: SNP_MASK,
Expand Down Expand Up @@ -975,7 +1017,8 @@ fn render_verbose(results: &[TestResultNode]) {
}
let hint_str = effective_hint(&node.meta, &node.result.mesg);
if node.result.stat == TestState::Fail && !hint_str.is_empty() {
println!(" {} {}", "Recommended:".yellow(), hint_str);
let hint = hint_str.replace('\n', "\n ");
println!(" {} {}", "Recommended:".yellow(), hint);
}
}
}
Expand All @@ -995,7 +1038,8 @@ fn render_verbose(results: &[TestResultNode]) {
let hint_str = effective_hint(&node.meta, &node.result.mesg);
println!(" {}. {} [FAIL]", i + 1, node.result.name);
if !hint_str.is_empty() {
println!(" {} {}", "Hint:".blue(), hint_str);
let hint = hint_str.replace('\n', "\n ");
println!(" {} {}", "Hint:".blue(), hint);
}
}
println!();
Expand Down
Loading