]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
x86/sev: Improve handling of writes to intercepted TSC MSRs
authorNikunj A Dadhania <nikunj@amd.com>
Tue, 22 Jul 2025 07:48:53 +0000 (13:18 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Aug 2025 16:41:34 +0000 (18:41 +0200)
commit75a29321166d9394fe7bee3efe71d8178968bdcb
tree5f47b029a54e03e977f4a16820e0f177c212557d
parentdef861962f874bfd8def0472c49db59bb32b3213
x86/sev: Improve handling of writes to intercepted TSC MSRs

[ Upstream commit 5eb1bcdb6a8c088514019c3a9bda5d565beed1af ]

Currently, when a Secure TSC enabled SNP guest attempts to write to the
intercepted GUEST_TSC_FREQ MSR (a read-only MSR), the guest kernel response
incorrectly implies a VMM configuration error, when in fact it is the usual
VMM configuration to intercept writes to read-only MSRs, unless explicitly
documented.

Modify the intercepted TSC MSR #VC handling:
* Write to GUEST_TSC_FREQ will generate a #GP instead of terminating the
  guest
* Write to MSR_IA32_TSC will generate a #GP instead of silently ignoring it

However, continue to terminate the guest when reading from intercepted
GUEST_TSC_FREQ MSR with Secure TSC enabled, as intercepted reads indicate an
improper VMM configuration for Secure TSC enabled SNP guests.

  [ bp: simplify comment. ]

Fixes: 38cc6495cdec ("x86/sev: Prevent GUEST_TSC_FREQ MSR interception for Secure TSC enabled guests")
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Nikunj A Dadhania <nikunj@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/20250722074853.22253-1-nikunj@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/coco/sev/vc-handle.c