Skip to content

Commit eef679a

Browse files
nikunjadbp3tk0v
authored andcommitted
x86/sev: Prevent RDTSC/RDTSCP interception for Secure TSC enabled guests
The hypervisor should not be intercepting RDTSC/RDTSCP when Secure TSC is enabled. A #VC exception will be generated if the RDTSC/RDTSCP instructions are being intercepted. If this should occur and Secure TSC is enabled, guest execution should be terminated as the guest cannot rely on the TSC value provided by the hypervisor. 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 38cc649 commit eef679a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/x86/coco/sev/shared.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,16 @@ static enum es_result vc_handle_rdtsc(struct ghcb *ghcb,
11401140
bool rdtscp = (exit_code == SVM_EXIT_RDTSCP);
11411141
enum es_result ret;
11421142

1143+
/*
1144+
* The hypervisor should not be intercepting RDTSC/RDTSCP when Secure
1145+
* TSC is enabled. A #VC exception will be generated if the RDTSC/RDTSCP
1146+
* instructions are being intercepted. If this should occur and Secure
1147+
* TSC is enabled, guest execution should be terminated as the guest
1148+
* cannot rely on the TSC value provided by the hypervisor.
1149+
*/
1150+
if (sev_status & MSR_AMD64_SNP_SECURE_TSC)
1151+
return ES_VMM_ERROR;
1152+
11431153
ret = sev_es_ghcb_hv_call(ghcb, ctxt, exit_code, 0, 0);
11441154
if (ret != ES_OK)
11451155
return ret;

0 commit comments

Comments
 (0)