Skip to contentSkip to conversation

KVM: Don't automatically expose the TSC deadline timer in cpuid

PATCH In review Avi Kivity 5 participants 13 messages Dec 25, 2011 – Dec 26, 2011

Subsystems (4)
lore
Share & tools
lore

Avi Kivity

author
#0 lore raw

PATCH 1/1 KVM: Don't automatically expose the TSC deadline timer in cpuid

From: Jan Kiszka <[email protected]>

Unlike all of the other cpuid bits, the TSC deadline timer bit is set unconditionally, regardless of what userspace wants.

This is broken in several ways:
- if userspace doesn't use KVM_CREATE_IRQCHIP, and doesn't emulate the TSC deadline timer feature, a guest that uses the feature will break
- live migration to older host kernels that don't support the TSC deadline timer will cause the feature to be pulled from under the guest's feet; breaking it
- guests that are broken wrt the feature will fail.

Fix by not enabling the feature automatically; instead report it to userspace. Because the feature depends on KVM_CREATE_IRQCHIP, which we cannot guarantee will be called, we expose it via a KVM_CAP_TSC_DEADLINE_TIMER and not KVM_GET_SUPPORTED_CPUID.

Fixes the Illumos guest kernel, which uses the TSC deadline timer feature.

[avi: add the KVM_CAP + documentation]

---

As we're running out of time and everyone's checking their socks instead of inboxes I've added the missing parts myself. Jan, if you accidentally see this, please review and add your signoff.

 Documentation/virtual/kvm/api.txt |    9 +++++++++
 arch/x86/kvm/cpuid.c              |   16 ++++++----------
 arch/x86/kvm/x86.c                |    3 +++
 include/linux/kvm.h               |    1 +
 4 files changed, 19 insertions(+), 10 deletions(-)
Documentation/virtual/kvm/api.txt +9 -0
index 5b03eee..da1f8fd 100644
@@ -1100,6 +1100,15 @@ emulate them efficiently. The fields in each entry are defined as follows:
    eax, ebx, ecx, edx: the values returned by the cpuid instruction for
          this function/index combination
 
+The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
+as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
+support.  Instead it is reported via
+
+  ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
+
+if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the
+feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
+
 4.47 KVM_PPC_GET_PVINFO
 
 Capability: KVM_CAP_PPC_GET_PVINFO
arch/x86/kvm/cpuid.c +6 -10
index 230f713..89b02bf 100644
@@ -27,7 +27,6 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
 {
 	struct kvm_cpuid_entry2 *best;
 	struct kvm_lapic *apic = vcpu->arch.apic;
-	u32 timer_mode_mask;
 
 	best = kvm_find_cpuid_entry(vcpu, 1, 0);
 	if (!best)
@@ -40,15 +39,12 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
 			best->ecx |= bit(X86_FEATURE_OSXSAVE);
 	}
 
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-		best->function == 0x1) {
-		best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER);
-		timer_mode_mask = 3 << 17;
-	} else
-		timer_mode_mask = 1 << 17;
-
-	if (apic)
-		apic->lapic_timer.timer_mode_mask = timer_mode_mask;
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}
 
 	kvm_pmu_cpuid_update(vcpu);
 }
arch/x86/kvm/x86.c +3 -0
index df23dff..1171def 100644
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_TSC_CONTROL:
 		r = kvm_has_tsc_control;
 		break;
+	case KVM_CAP_TSC_DEADLINE_TIMER:
+		r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+		break;
 	default:
 		r = 0;
 		break;
include/linux/kvm.h +1 -0
index c3892fc..68e67e5 100644
@@ -557,6 +557,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_S390_GMAP 71
+#define KVM_CAP_TSC_DEADLINE_TIMER 72
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
Signature · 1 line
1.7.7.1
#1 lore raw
Quoted 22 lines · Avi Kivity

From: Jan Kiszka <[email protected]>

Unlike all of the other cpuid bits, the TSC deadline timer bit is set unconditionally, regardless of what userspace wants.

This is broken in several ways:
- if userspace doesn't use KVM_CREATE_IRQCHIP, and doesn't emulate the TSC deadline timer feature, a guest that uses the feature will break
- live migration to older host kernels that don't support the TSC deadline timer will cause the feature to be pulled from under the guest's feet; breaking it
- guests that are broken wrt the feature will fail.

Fix by not enabling the feature automatically; instead report it to userspace. Because the feature depends on KVM_CREATE_IRQCHIP, which we cannot guarantee will be called, we expose it via a KVM_CAP_TSC_DEADLINE_TIMER and not KVM_GET_SUPPORTED_CPUID.

Fixes the Illumos guest kernel, which uses the TSC deadline timer feature.

[avi: add the KVM_CAP + documentation]

Quoted 7 lines

---

As we're running out of time and everyone's checking their socks instead of inboxes I've added the missing parts myself. Jan, if you accidentally see this, please review and add your signoff.

I'm sorry for not holding my promise, was distracted the past days. Patch looks good to me, just some minor phrasing corrections below.

Signed-off-by; Jan Kiszka <[email protected]>

Quoted 12 lines
 Documentation/virtual/kvm/api.txt |    9 +++++++++
 arch/x86/kvm/cpuid.c              |   16 ++++++----------
 arch/x86/kvm/x86.c                |    3 +++
 include/linux/kvm.h               |    1 +
 4 files changed, 19 insertions(+), 10 deletions(-)
Documentation/virtual/kvm/api.txt +0 -0
index 5b03eee..da1f8fd 100644

Documentation/virtual/kvm/api.txt emulate them efficiently. The fields in each entry are defined as follows: · line 1109

Quoted 10 lines
Documentation/virtual/kvm/api.txt +7 -0
@@ -1100,6 +1100,15 @@ emulate them efficiently. The fields in each entry are defined as follows:
    eax, ebx, ecx, edx: the values returned by the cpuid instruction for
          this function/index combination
 
+The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
+as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
+support.  Instead it is reported via
+
+  ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
+
+if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the

^^^ ^^^
and you

Quoted 58 lines
Documentation/virtual/kvm/api.txt +2 -0
+feature in userspace, then you can enable the feature for KVM_SET_CPUID2.
+
 4.47 KVM_PPC_GET_PVINFO
 
 Capability: KVM_CAP_PPC_GET_PVINFO
arch/x86/kvm/cpuid.c +6 -10
index 230f713..89b02bf 100644
@@ -27,7 +27,6 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
 {
 	struct kvm_cpuid_entry2 *best;
 	struct kvm_lapic *apic = vcpu->arch.apic;
-	u32 timer_mode_mask;
 
 	best = kvm_find_cpuid_entry(vcpu, 1, 0);
 	if (!best)
@@ -40,15 +39,12 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
 			best->ecx |= bit(X86_FEATURE_OSXSAVE);
 	}
 
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-		best->function == 0x1) {
-		best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER);
-		timer_mode_mask = 3 << 17;
-	} else
-		timer_mode_mask = 1 << 17;
-
-	if (apic)
-		apic->lapic_timer.timer_mode_mask = timer_mode_mask;
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}
 
 	kvm_pmu_cpuid_update(vcpu);
 }
arch/x86/kvm/x86.c +3 -0
index df23dff..1171def 100644
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_TSC_CONTROL:
 		r = kvm_has_tsc_control;
 		break;
+	case KVM_CAP_TSC_DEADLINE_TIMER:
+		r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+		break;
 	default:
 		r = 0;
 		break;
include/linux/kvm.h +0 -0
index c3892fc..68e67e5 100644

include/linux/kvm.h struct kvm_ppc_pvinfo { · line 563

Quoted 7 lines
include/linux/kvm.h +1 -0
@@ -557,6 +557,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_S390_GMAP 71
+#define KVM_CAP_TSC_DEADLINE_TIMER 72
 
 #ifdef KVM_CAP_IRQ_ROUTING
 

Thanks,
Jan

author
#2 lore raw
Quoted 27 lines · Jan Kiszka
Quoted 26 lines · Avi Kivity

From: Jan Kiszka <[email protected]>

Unlike all of the other cpuid bits, the TSC deadline timer bit is set unconditionally, regardless of what userspace wants.

This is broken in several ways:
- if userspace doesn't use KVM_CREATE_IRQCHIP, and doesn't emulate the TSC deadline timer feature, a guest that uses the feature will break
- live migration to older host kernels that don't support the TSC deadline timer will cause the feature to be pulled from under the guest's feet; breaking it
- guests that are broken wrt the feature will fail.

Fix by not enabling the feature automatically; instead report it to userspace. Because the feature depends on KVM_CREATE_IRQCHIP, which we cannot guarantee will be called, we expose it via a KVM_CAP_TSC_DEADLINE_TIMER and not KVM_GET_SUPPORTED_CPUID.

Fixes the Illumos guest kernel, which uses the TSC deadline timer feature.

[avi: add the KVM_CAP + documentation]

---

Quoted 6 lines
Quoted 3 lines

As we're running out of time and everyone's checking their socks instead of inboxes I've added the missing parts myself. Jan, if you accidentally see this, please review and add your signoff.

I'm sorry for not holding my promise, was distracted the past days. Patch looks good to me, just some minor phrasing corrections below.

Not a problem at all, I can guess you had much better things to do.

Quoted 18 lines

Signed-off-by; Jan Kiszka <[email protected]>

Quoted 15 lines
 Documentation/virtual/kvm/api.txt |    9 +++++++++
 arch/x86/kvm/cpuid.c              |   16 ++++++----------
 arch/x86/kvm/x86.c                |    3 +++
 include/linux/kvm.h               |    1 +
 4 files changed, 19 insertions(+), 10 deletions(-)
Documentation/virtual/kvm/api.txt +0 -0
index 5b03eee..da1f8fd 100644
@@ -1100,6 +1100,15 @@ emulate them efficiently. The fields in each entry are defined as follows:
    eax, ebx, ecx, edx: the values returned by the cpuid instruction for
          this function/index combination
 
Quoted 10 lines

Documentation/virtual/kvm/api.txt emulate them efficiently. The fields in each entry are defined as follows: · line 1109

Quoted 7 lines
Documentation/virtual/kvm/api.txt +7 -0
+The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
+as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
+support.  Instead it is reported via
+
+  ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
+
+if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the

^^^ ^^^
and you

Thanks, added your signoff and adjusted this.

Signature · 1 line
error compiling committee.c: too many arguments to function
#3 lore raw
In reply to Avi Kivity

Documentation/virtual/kvm/api.txt emulate them efficiently. The fields in each entry are defined as follows: · line 1110

Quoted 8 lines · Avi Kivity
Documentation/virtual/kvm/api.txt +8 -0
+The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
+as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
+support.  Instead it is reported via
+
+  ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
+
+if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the
+feature in userspace, then you can enable the feature for KVM_SET_CPUID2.

Thats a bit strange, it's going to be a somewhat ugly special case in userspace code. It also means we can't simply proxy through CPUID from kernel to the guest and only disable things we don't support, we now have to enable them as well.

arch/x86/kvm/cpuid.c void kvm_update_cpuid(struct kvm_vcpu *vcpu) · line 47

Quoted 6 lines
arch/x86/kvm/cpuid.c +6 -0
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}

Can we change these to be:

if(...)

	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC | APIC_LVT_TIMER_TSCDEADLINE;
else
	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC;
Signature · 1 line
Sasha.
#4 lore raw
Quoted 10 lines · Sasha Levin

arch/x86/kvm/cpuid.c void kvm_update_cpuid(struct kvm_vcpu *vcpu) · line 47

Quoted 6 lines · Avi Kivity
arch/x86/kvm/cpuid.c +6 -0
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}

Can we change these to be:

Quoted 4 lines

if(...)

	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC | APIC_LVT_TIMER_TSCDEADLINE;
else
	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC;

Actually,

apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC; if(...)

	apic->lapic_timer.timer_mode_mask |= APIC_LVT_TIMER_TSCDEADLINE;
Signature · 1 line
Sasha.
#5 lore raw
Quoted 16 lines · Sasha Levin
Quoted 10 lines · Sasha Levin

arch/x86/kvm/cpuid.c void kvm_update_cpuid(struct kvm_vcpu *vcpu) · line 47

Quoted 6 lines · Avi Kivity
arch/x86/kvm/cpuid.c +6 -0
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}

Can we change these to be:

Quoted 4 lines

if(...)

	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC |
	APIC_LVT_TIMER_TSCDEADLINE; else apic->lapic_timer.timer_mode_mask

= APIC_LVT_TIMER_PERIODIC;

Quoted 5 lines

Actually,

apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC; if(...)

	apic->lapic_timer.timer_mode_mask |= APIC_LVT_TIMER_TSCDEADLINE;

Is it good semantically? APIC_LVT_TIMER_PERIODIC and APIC_LVT_TIMER_TSCDEADLINE is timer mode, where timer_mode_mask is timer mode mask.

Thanks,
Jinsong

#6 lore raw
In reply to Sasha Levin
Quoted 12 lines · Sasha Levin

Documentation/virtual/kvm/api.txt emulate them efficiently. The fields in each entry are defined as follows: · line 1110

Quoted 8 lines · Avi Kivity
Documentation/virtual/kvm/api.txt +8 -0
+The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned
+as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC
+support.  Instead it is reported via
+
+  ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
+
+if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the
+feature in userspace, then you can enable the feature for KVM_SET_CPUID2.

Thats a bit strange, it's going to be a somewhat ugly special case in userspace code.

Just add something like

if (kvm_has_cap_tscdeadline())
set_cpuid_feature_bit(vcpu, tcs_deadline)

to the in-kernel apic setup code in userland.

Quoted 3 lines

It also means we can't simply proxy through CPUID from kernel to the guest and only disable things we don't support, we now have to enable them as well.

That's unavoidable as you can't tell for sure if TSC_DEADLINE can be supported at all times the user may invoke KVM_GET_SUPPORTED_CPUID - that depends on the dynamic VM configuration.

Just proxying the bits through like kvmtool may do right now is a very special case KVM can't support due to existing user space code and the needs of migration.

Quoted 10 lines

arch/x86/kvm/cpuid.c void kvm_update_cpuid(struct kvm_vcpu *vcpu) · line 47

Quoted 7 lines
arch/x86/kvm/cpuid.c +6 -0
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}

Can we change these to be:

Quoted 5 lines

if(...)

	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC | APIC_LVT_TIMER_TSCDEADLINE;
else
	apic->lapic_timer.timer_mode_mask = APIC_LVT_TIMER_PERIODIC;

Yep, using symbols is better. As the patch needs some polishing regarding the doc wording, I think this could be cleaned up as well.

Jan

#7 lore raw
In reply to Avi Kivity
Quoted 102 lines · Avi Kivity

From: Jan Kiszka <[email protected]>

Unlike all of the other cpuid bits, the TSC deadline timer bit is set unconditionally, regardless of what userspace wants.

This is broken in several ways:
- if userspace doesn't use KVM_CREATE_IRQCHIP, and doesn't emulate the TSC deadline timer feature, a guest that uses the feature will
break - live migration to older host kernels that don't support the
TSC deadline timer will cause the feature to be pulled from under the guest's feet; breaking it
- guests that are broken wrt the feature will fail.

Fix by not enabling the feature automatically; instead report it to userspace.
Because the feature depends on KVM_CREATE_IRQCHIP, which we cannot guarantee
will be called, we expose it via a KVM_CAP_TSC_DEADLINE_TIMER and not KVM_GET_SUPPORTED_CPUID.

Fixes the Illumos guest kernel, which uses the TSC deadline timer feature.

[avi: add the KVM_CAP + documentation]

---

As we're running out of time and everyone's checking their socks instead of
inboxes I've added the missing parts myself. Jan, if you accidentally see
this, please review and add your signoff.

 Documentation/virtual/kvm/api.txt |    9 +++++++++
 arch/x86/kvm/cpuid.c              |   16 ++++++----------
 arch/x86/kvm/x86.c                |    3 +++
 include/linux/kvm.h               |    1 +
 4 files changed, 19 insertions(+), 10 deletions(-)
Documentation/virtual/kvm/api.txt +0 -0
index 5b03eee..da1f8fd 100644
@@ -1100,6 +1100,15 @@ emulate them efficiently. The fields in each
    entry are defined as follows: eax, ebx, ecx, edx: the values
          returned by the cpuid instruction for this function/index

combination

+The TSC deadline timer feature (CPUID leaf 1, ecx[24]) is always returned +as false, since the feature depends on KVM_CREATE_IRQCHIP for local APIC +support. Instead it is reported via

Documentation/virtual/kvm/api.txt +5 -0
+
+  ioctl(KVM_CHECK_EXTENSION, KVM_CAP_TSC_DEADLINE_TIMER)
+
+if that returns true you use KVM_CREATE_IRQCHIP, or if emulate the
+feature in userspace, then you can enable the feature for

KVM_SET_CPUID2. +
4.47 KVM_PPC_GET_PVINFO

Capability: KVM_CAP_PPC_GET_PVINFO

arch/x86/kvm/cpuid.c +6 -10
index 230f713..89b02bf 100644
@@ -27,7 +27,6 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
 {
 	struct kvm_cpuid_entry2 *best;
 	struct kvm_lapic *apic = vcpu->arch.apic;
-	u32 timer_mode_mask;
 
 	best = kvm_find_cpuid_entry(vcpu, 1, 0);
 	if (!best)
@@ -40,15 +39,12 @@ void kvm_update_cpuid(struct kvm_vcpu *vcpu)
 			best->ecx |= bit(X86_FEATURE_OSXSAVE);
 	}
 
-	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-		best->function == 0x1) {
-		best->ecx |= bit(X86_FEATURE_TSC_DEADLINE_TIMER);
-		timer_mode_mask = 3 << 17;
-	} else
-		timer_mode_mask = 1 << 17;
-
-	if (apic)
-		apic->lapic_timer.timer_mode_mask = timer_mode_mask;
+	if (apic) {
+		if (best->ecx & bit(X86_FEATURE_TSC_DEADLINE_TIMER))
+			apic->lapic_timer.timer_mode_mask = 3 << 17;
+		else
+			apic->lapic_timer.timer_mode_mask = 1 << 17;
+	}
 
 	kvm_pmu_cpuid_update(vcpu);
 }
arch/x86/kvm/x86.c +0 -0
index df23dff..1171def 100644

arch/x86/kvm/x86.c int kvm_dev_ioctl_check_extension(long ext) · line 2094

Quoted 6 lines
arch/x86/kvm/x86.c +3 -0
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
 	case KVM_CAP_TSC_CONTROL:
 		r = kvm_has_tsc_control;
 		break;
+	case KVM_CAP_TSC_DEADLINE_TIMER:
+		r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+		break;

kvm tsc deadline timer is pure software emulated, not depend on host physically.

Thanks,
Jinsong

Quoted 14 lines
arch/x86/kvm/x86.c +0 -0
 	default:
 		r = 0;
 		break;
include/linux/kvm.h +1 -0
index c3892fc..68e67e5 100644
@@ -557,6 +557,7 @@ struct kvm_ppc_pvinfo {
 #define KVM_CAP_MAX_VCPUS 66       /* returns max vcpus per vm */
 #define KVM_CAP_PPC_PAPR 68
 #define KVM_CAP_S390_GMAP 71
+#define KVM_CAP_TSC_DEADLINE_TIMER 72
 
 #ifdef KVM_CAP_IRQ_ROUTING
author
#8 lore raw
Quoted 6 lines · Jinsong
Quoted 6 lines

}

arch/x86/kvm/x86.c +0 -0
index df23dff..1171def 100644
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
Quoted 8 lines

arch/x86/kvm/x86.c int kvm_dev_ioctl_check_extension(long ext) · line 2094

Quoted 6 lines
arch/x86/kvm/x86.c +3 -0
 	case KVM_CAP_TSC_CONTROL:
 		r = kvm_has_tsc_control;
 		break;
+	case KVM_CAP_TSC_DEADLINE_TIMER:
+		r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+		break;

kvm tsc deadline timer is pure software emulated, not depend on host physically.

Yeah, I want to reconsider it in the 3.3 cycle. I'm not so hot on exposing non hardware features anymore, at least we want better reporting to userspace.

Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw
Quoted 16 lines · Avi Kivity
Quoted 6 lines · Jinsong
Quoted 6 lines

 }

arch/x86/kvm/x86.c +0 -0
index df23dff..1171def 100644
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
Quoted 8 lines
Quoted 6 lines

    case KVM_CAP_TSC_CONTROL:
            r = kvm_has_tsc_control;
            break;
+   case KVM_CAP_TSC_DEADLINE_TIMER:
+           r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+           break;

kvm tsc deadline timer is pure software emulated, not depend on host physically.

Quoted 4 lines

Yeah, I want to reconsider it in the 3.3 cycle.  I'm not so hot on exposing non hardware features anymore, at least we want better reporting to userspace.

Just as a reminder, could you please revert the problematic commit (a3e06bbe) for 3.2?

author
#10 lore raw
Quoted 17 lines · Alexey Zaytsev
Quoted 16 lines · Avi Kivity
Quoted 14 lines · Jinsong

arch/x86/kvm/x86.c int kvm_dev_ioctl_check_extension(long ext) · line 2094

Quoted 12 lines

}

arch/x86/kvm/x86.c +3 -0
index df23dff..1171def 100644
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
    case KVM_CAP_TSC_CONTROL:
            r = kvm_has_tsc_control;
            break;
+   case KVM_CAP_TSC_DEADLINE_TIMER:
+           r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+           break;

kvm tsc deadline timer is pure software emulated, not depend on host physically.

Quoted 7 lines
Quoted 4 lines

Yeah, I want to reconsider it in the 3.3 cycle. I'm not so hot on exposing non hardware features anymore, at least we want better reporting to userspace.

Just as a reminder, could you please revert the problematic commit (a3e06bbe) for 3.2?

I plan to post this as a fix.

If you can, please test it:

git://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-updates/3.2

Signature · 1 line
error compiling committee.c: too many arguments to function
#11 lore raw
Quoted 23 lines · Avi Kivity
Quoted 22 lines · Alexey Zaytsev
Quoted 20 lines · Avi Kivity
Quoted 6 lines · Jinsong
Quoted 6 lines

 }

arch/x86/kvm/x86.c +0 -0
index df23dff..1171def 100644
@@ -2089,6 +2089,9 @@ int kvm_dev_ioctl_check_extension(long ext)
Quoted 8 lines
Quoted 6 lines

    case KVM_CAP_TSC_CONTROL:
            r = kvm_has_tsc_control;
            break;
+   case KVM_CAP_TSC_DEADLINE_TIMER:
+           r = boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER);
+           break;

kvm tsc deadline timer is pure software emulated, not depend on host physically.

Yeah, I want to reconsider it in the 3.3 cycle.  I'm not so hot on exposing non hardware features anymore, at least we want better reporting to userspace.

Quoted 9 lines
Quoted 2 lines

Just as a reminder, could you please revert the problematic commit (a3e06bbe) for 3.2?

I plan to post this as a fix.

If  you can, please test it:

 git://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-updates/3.2

Works for me, thank you.

author
#12 lore raw
Quoted 7 lines · Alexey Zaytsev
Quoted 5 lines

If you can, please test it:

git://git.kernel.org/pub/scm/virt/kvm/kvm.git kvm-updates/3.2

Works for me, thank you.

Thanks, added your Tested-by:.

Signature · 1 line
error compiling committee.c: too many arguments to function