x86/tdx: Mark TSC reliable
Subsystems (2)
PATCH v2 1/1 x86/tdx: Mark TSC reliable
In x86 virtualization environments, including TDX, RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. On the other hand, other clock sources (such as HPET, ACPI timer, APIC, etc.) necessitate VM exits to implement, resulting in more fluctuating measurements compared to TSC. Thus, those clock sources are not effective for calibrating TSC.
In TD guests, TSC is virtualized by the TDX module, which ensures:
- Virtual TSC values are consistent among all the TD’s VCPUs;
- Monotonously incrementing for any single VCPU;
- The frequency is determined by TD configuration. The host TSC is invariant on platforms where TDX is available.
Reliable TSC is architectural guarantee for the TDX platform and it must work for any sane TDX implementation.
Use TSC as the only reliable clock source in TD guests, bypassing unstable calibration.
---
v2:
- Slightly updated commit message;
--- arch/x86/coco/tdx/tdx.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/coco/tdx/tdx.c +3 -0
@@ -769,6 +769,9 @@ void __init tdx_early_init(void)setup_force_cpu_cap (X86_FEATURE_TDX_GUEST ); +/* TSC is the only reliable clock in TDX guest */ +setup_force_cpu_cap (X86_FEATURE_TSC_RELIABLE ); + cc_vendor =CC_VENDOR_INTEL ;tdx_parse_tdinfo (&cc_mask);cc_set_mask (cc_mask);
Signature · 1 line
2.41.0
Quoted 17 lines · Kirill A. Shutemov
In x86 virtualization environments, including TDX, RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. On the other hand, other clock sources (such as HPET, ACPI timer, APIC, etc.) necessitate VM exits to implement, resulting in more fluctuating measurements compared to TSC. Thus, those clock sources are not effective for calibrating TSC.
In TD guests, TSC is virtualized by the TDX module, which ensures:
- Virtual TSC values are consistent among all the TD’s VCPUs;
- Monotonously incrementing for any single VCPU;
- The frequency is determined by TD configuration. The host TSC is invariant on platforms where TDX is available.Reliable TSC is architectural guarantee for the TDX platform and it must work for any sane TDX implementation.
Quoted 8 lines
Use TSC as the only reliable clock source in TD guests, bypassing unstable calibration.
Signed-off-by Kirill A. Shutemov <[email protected]>---
v2:
- Slightly updated commit message;
---
Looks good to me.
Quoted 17 lines
arch/x86/coco/tdx/tdx.c | 3 +++ 1 file changed, 3 insertions(+)arch/x86/coco/tdx/tdx.c +3
-0@@ -769,6 +769,9 @@ void __init tdx_early_init(void)setup_force_cpu_cap (X86_FEATURE_TDX_GUEST ); +/* TSC is the only reliable clock in TDX guest */ +setup_force_cpu_cap (X86_FEATURE_TSC_RELIABLE ); + cc_vendor =CC_VENDOR_INTEL ;tdx_parse_tdinfo (&cc_mask);cc_set_mask (cc_mask);
Signature · 2 lines
Sathyanarayanan Kuppuswamy Linux Kernel Developer
Quoted 11 lines · Kirill A. Shutemov
In x86 virtualization environments, including TDX, RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. On the other hand, other clock sources (such as HPET, ACPI timer, APIC, etc.) necessitate VM exits to implement, resulting in more fluctuating measurements compared to TSC. Thus, those clock sources are not effective for calibrating TSC.
In TD guests, TSC is virtualized by the TDX module, which ensures:
- Virtual TSC values are consistent among all the TD’s VCPUs;
- Monotonously incrementing for any single VCPU;
Nit:
- Virtual TSC is monotonously incrementing ...
Otherwise here "incrementing" looks like a noun, which means you need to use "monotonous" rather than "monotonously".
Quoted 10 lines
- The frequency is determined by TD configuration. The host TSC is invariant on platforms where TDX is available.
Reliable TSC is architectural guarantee for the TDX platform and it must work for any sane TDX implementation.
Use TSC as the only reliable clock source in TD guests, bypassing unstable calibration.
Signed-off-by Kirill A. Shutemov <[email protected]>
Quoted 13 lines · Kai
Quoted 11 lines · Kirill A. Shutemov
In x86 virtualization environments, including TDX, RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. On the other hand, other clock sources (such as HPET, ACPI timer, APIC, etc.) necessitate VM exits to implement, resulting in more fluctuating measurements compared to TSC. Thus, those clock sources are not effective for calibrating TSC.
In TD guests, TSC is virtualized by the TDX module, which ensures:
- Virtual TSC values are consistent among all the TD’s VCPUs;
- Monotonously incrementing for any single VCPU;
Quoted 6 lines
Nit:
- Virtual TSC is monotonously incrementing ...
Otherwise here "incrementing" looks like a noun, which means you need to use "monotonous" rather than "monotonously".
Okay, will update.
Quoted 6 lines
Quoted 6 lines
- The frequency is determined by TD configuration. The host TSC is invariant on platforms where TDX is available.
Reliable TSC is architectural guarantee for the TDX platform and it must work for any sane TDX implementation.
Quoted 6 lines
Quoted 4 lines
Use TSC as the only reliable clock source in TD guests, bypassing unstable calibration.
Signed-off-by Kirill A. Shutemov <[email protected]>Acked-by Kai Huang <[email protected]>
Thanks.
Signature · 1 line
Kiryl Shutsemau / Kirill A. Shutemov
Quoted 46 lines · Kirill A. Shutemov
In x86 virtualization environments, including TDX, RDTSC instruction is handled without causing a VM exit, resulting in minimal overhead and jitters. On the other hand, other clock sources (such as HPET, ACPI timer, APIC, etc.) necessitate VM exits to implement, resulting in more fluctuating measurements compared to TSC. Thus, those clock sources are not effective for calibrating TSC.
In TD guests, TSC is virtualized by the TDX module, which ensures:
- Virtual TSC values are consistent among all the TD’s VCPUs;
- Monotonously incrementing for any single VCPU;
- The frequency is determined by TD configuration. The host TSC is invariant on platforms where TDX is available.Reliable TSC is architectural guarantee for the TDX platform and it must work for any sane TDX implementation.
Use TSC as the only reliable clock source in TD guests, bypassing unstable calibration.
Signed-off-by Kirill A. Shutemov <[email protected]>---
v2:
- Slightly updated commit message;--- arch/x86/coco/tdx/tdx.c | 3 +++ 1 file changed, 3 insertions(+)arch/x86/coco/tdx/tdx.c +3
-0@@ -769,6 +769,9 @@ void __init tdx_early_init(void)setup_force_cpu_cap (X86_FEATURE_TDX_GUEST ); +/* TSC is the only reliable clock in TDX guest */ +setup_force_cpu_cap (X86_FEATURE_TSC_RELIABLE ); + cc_vendor =CC_VENDOR_INTEL ;tdx_parse_tdinfo (&cc_mask);cc_set_mask (cc_mask);Signature · 1 line
2.41.0
Signature · 1 line
Isaku Yamahata <[email protected]>