Skip to contentSkip to conversation

KVM: x86: Pass host's CPUID.16H through to KVM_GET_SUPPORTED_CPUID

PATCH In review Jim Mattson 2 participants 3 messages Sep 23, 2022 – Sep 26, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86: Pass host's CPUID.16H through to KVM_GET_SUPPORTED_CPUID

In the default configuration, the guest TSC frequency is the same as the host TSC frequency. Similarly, the maximum frequency of the virtual CPU is the same as the maximum frequency of the physical CPU. Also, the bus (reference) frequency of the virtual CPU matches that of the physical CPU.

Pass this information directly from host CPUID.16H to guest CPUID.16H in KVM_GET_SUPPORTED_CPUID.

---
 arch/x86/kvm/cpuid.c | 3 +++
 1 file changed, 3 insertions(+)
arch/x86/kvm/cpuid.c +3 -0
index 675eb9ae3948..1527f467d4f8 100644
@@ -1043,6 +1043,9 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function)
 				goto out;
 		}
 		break;
+	/* Processor Frequency Information */
+	case 0x16:
+		break;
 	/* Intel AMX TILE */
 	case 0x1d:
 		if (!kvm_cpu_cap_has(X86_FEATURE_AMX_TILE)) {
Signature · 1 line
2.37.3.998.g577e59143f-goog
#1 lore raw
Quoted 4 lines · Jim Mattson

In the default configuration, the guest TSC frequency is the same as the host TSC frequency. Similarly, the maximum frequency of the virtual CPU is the same as the maximum frequency of the physical CPU.

Under the hood, yes, but after the VM is migrated, isn't it possible that the host frequencies are completely disjoint from the frequencies that are enumerated to the guest?

Quoted 5 lines

Also, the bus (reference) frequency of the virtual CPU matches that of the physical CPU.

Pass this information directly from host CPUID.16H to guest CPUID.16H in KVM_GET_SUPPORTED_CPUID.

What about "solving" this via documentation, same as CPUID.15H? If the API were KVM_GET_DEFAULT_CPUID, then enumerating host properties makes sense, but from a very pedantic point of view, the "supported" frequencies are just about anything.

Somewhat of a moot point, as the leaf comes with "informational only" disclaimer.

The returned information should not be used for any other purpose as the returned information does not accurately correlate to information / counters returned by other processor interfaces.

#2 lore raw
Quoted 14 lines · Sean Christopherson
Quoted 4 lines · Jim Mattson

In the default configuration, the guest TSC frequency is the same as the host TSC frequency. Similarly, the maximum frequency of the virtual CPU is the same as the maximum frequency of the physical CPU.

Under the hood, yes, but after the VM is migrated, isn't it possible that the host frequencies are completely disjoint from the frequencies that are enumerated to the guest?

Quoted 3 lines

Also, the bus (reference) frequency of the virtual CPU matches that of the physical CPU.

Quoted 6 lines
Quoted 2 lines

Pass this information directly from host CPUID.16H to guest CPUID.16H in KVM_GET_SUPPORTED_CPUID.

What about "solving" this via documentation, same as CPUID.15H? If the API were KVM_GET_DEFAULT_CPUID, then enumerating host properties makes sense, but from a very pedantic point of view, the "supported" frequencies are just about anything.

Fair enough. Userspace will just have to figure out how to populate this leaf on its own (or leave it blank).

Quoted 5 lines

Somewhat of a moot point, as the leaf comes with "informational only" disclaimer.

The returned information should not be used for any other purpose as the returned information does not accurately correlate to information / counters returned by other processor interfaces.