The cpuid_values array is dynamically allocated (declared 0-size array).
This make ubsan raising an runtime error array-index-out-of-bounds:
[ 392.138526] UBSAN: array-index-out-of-bounds in /build/linux-unstable-kzfBPB/linux-unstable-6.5.0/arch/x86/kvm/vmx/tdx.c:2609:59
[ 392.139283] index 1 is out of range for type 'tdx_cpuid_value [*]'
742ede9...
by
"Kirill A. Shutemov" <email address hidden>
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.
Signed-off-by: Kirill A. Shutemov <email address hidden>
bump KVM_EXIT_MEMORY_FAULT to avoid merge conflict
To avoid merge conflict with the upstream, bump KVM_EXIT_MEMORY_FAULT
instead of using the next unused value.
TODO: once the patch is upstreamed, remove this patch and correct
KVM_EXIT_MEMORY_FAULT.