Skip to content

Commit 0a2a98f

Browse files
nikunjadbp3tk0v
authored andcommitted
x86/sev: Mark the TSC in a secure TSC guest as reliable
In SNP guest environment with Secure TSC enabled, unlike other clock sources (such as HPET, ACPI timer, APIC, etc), the RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. Even when the host CPU's TSC is tampered with, the Secure TSC enabled guest keeps on ticking forward. Hence, mark Secure TSC as the only reliable clock source, bypassing unstable calibration. [ bp: Massage. ] Signed-off-by: Nikunj A Dadhania <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Tom Lendacky <[email protected]> Tested-by: Peter Gonda <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eef679a commit 0a2a98f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/x86/mm/mem_encrypt_amd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ void __init sme_early_init(void)
541541
* kernel mapped.
542542
*/
543543
snp_update_svsm_ca();
544+
545+
if (sev_status & MSR_AMD64_SNP_SECURE_TSC)
546+
setup_force_cpu_cap(X86_FEATURE_TSC_RELIABLE);
544547
}
545548

546549
void __init mem_encrypt_free_decrypted_mem(void)

0 commit comments

Comments
 (0)