Skip to contentSkip to conversation

kvmtool: expose the TSC Deadline Timer feature to the guest

PATCH In review Dimitri John Ledkov 2 participants 2 messages Sep 29, 2015 – Sep 30, 2015 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvmtool: expose the TSC Deadline Timer feature to the guest

From: Arjan van de Ven <[email protected]>

with the TSC deadline timer feature, we don't need to calibrate the apic timers anymore, which saves more than 100 milliseconds of boot time.

---
 x86/cpuid.c | 3 +++
 1 file changed, 3 insertions(+)
x86/cpuid.c +3 -0
index c3b67d9..1d8bd23 100644
@@ -31,6 +31,9 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
 			/* Set X86_FEATURE_HYPERVISOR */
 			if (entry->index == 0)
 				entry->ecx |= (1 << 31);
+                        /* Set CPUID_EXT_TSC_DEADLINE_TIMER*/
+			if (entry->index == 0)
+				entry->ecx |= (1 << 24);
 			break;
 		case 6:
 			/* Clear X86_FEATURE_EPB */
Signature · 1 line
2.1.4
#1 lore raw

Hi Dimitri,

Quoted 16 lines · Dimitri John Ledkov

From: Arjan van de Ven <[email protected]>

with the TSC deadline timer feature, we don't need to calibrate the apic timers anymore, which saves more than 100 milliseconds of boot time.

---
 x86/cpuid.c | 3 +++
 1 file changed, 3 insertions(+)
x86/cpuid.c +0 -0
index c3b67d9..1d8bd23 100644

x86/cpuid.c static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid) · line 36

Quoted 6 lines
x86/cpuid.c +3 -0
@@ -31,6 +31,9 @@ static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
 			/* Set X86_FEATURE_HYPERVISOR */
 			if (entry->index == 0)
 				entry->ecx |= (1 << 31);
+                        /* Set CPUID_EXT_TSC_DEADLINE_TIMER*/
+			if (entry->index == 0)
+				entry->ecx |= (1 << 24);

This can only be enabled if the kernel supports emulation of that feature (reported via KVM_CAP_TSC_DEADLINE_TIMER)
(cf: Documentation/virtual/kvm/api.txt and respective QEMU code in target-i386/kvm.c)

Cheers,
Andre.

Quoted 4 lines
x86/cpuid.c +0 -0
 			break;
 		case 6:
 			/* Clear X86_FEATURE_EPB */