Skip to contentSkip to conversation

CVE-2025-38508: x86/sev: Use TSC_FACTOR for Secure TSC frequency calculation

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Aug 16, 2025

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

x86/sev: Use TSC_FACTOR for Secure TSC frequency calculation

When using Secure TSC, the GUEST_TSC_FREQ MSR reports a frequency based on the nominal P0 frequency, which deviates slightly (typically ~0.2%) from the actual mean TSC frequency due to clocking parameters.

Over extended VM uptime, this discrepancy accumulates, causing clock skew between the hypervisor and a SEV-SNP VM, leading to early timer interrupts as perceived by the guest.

The guest kernel relies on the reported nominal frequency for TSC-based timekeeping, while the actual frequency set during SNP_LAUNCH_START may differ. This mismatch results in inaccurate time calculations, causing the guest to perceive hrtimers as firing earlier than expected.

Utilize the TSC_FACTOR from the SEV firmware's secrets page (see "Secrets Page Format" in the SNP Firmware ABI Specification) to calculate the mean TSC frequency, ensuring accurate timekeeping and mitigating clock skew in SEV-SNP VMs.

Use early_ioremap_encrypted() to map the secrets page as ioremap_encrypted() uses kmalloc() which is not available during early TSC initialization and causes a panic.

[ bp: Drop the silly dummy var:

    https://lore.kernel.org/r/20250630192726.GBaGLlHl84xIopx4Pt@fat_crate.local ]

The Linux kernel CVE team has assigned CVE-2025-38508 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.14 with commit 73bbf3b0fbba9aa27fef07a1fbd837661a863f03 and fixed in 6.15.7 with commit d0195c42e65805938c9eb507657e7cdf8e1e9522
	Issue introduced in 6.14 with commit 73bbf3b0fbba9aa27fef07a1fbd837661a863f03 and fixed in 6.16 with commit 52e1a03e6cf61ae165f59f41c44394a653a0a788

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2025-38508

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:

	arch/x86/coco/sev/core.c
	arch/x86/include/asm/sev.h

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/d0195c42e65805938c9eb507657e7cdf8e1e9522
	https://git.kernel.org/stable/c/52e1a03e6cf61ae165f59f41c44394a653a0a788