Skip to contentSkip to conversation

KVM: LAPIC: Return 0 when getting the tscdeadline timer if the lapic is hw disabled

PATCH Superseded Wanpeng Li 2 participants 5 messages Aug 4, 2020 – Aug 10, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Wanpeng Li

author
#0 lore raw

PATCH 1/2 KVM: LAPIC: Return 0 when getting the tscdeadline timer if the lapic is hw disabled

From: Wanpeng Li <[email protected]>

Return 0 when getting the tscdeadline timer if the lapic is hw disabled

---
 arch/x86/kvm/lapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +1 -1
index cfb8504..d89ab48 100644
@@ -2182,7 +2182,7 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu)
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (!lapic_in_kernel(vcpu) ||
+	if (!kvm_apic_present(vcpu) ||
 		!apic_lvtt_tscdeadline(apic))
 		return 0;
 
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 KVM: LAPIC: Guarantee the timer is in tsc-deadline mode when setting

From: Wanpeng Li <[email protected]>

Check apic_lvtt_tscdeadline() mode directly instead of apic_lvtt_oneshot() and apic_lvtt_period() to guarantee the timer is in tsc-deadline mode when wrmsr MSR_IA32_TSCDEADLINE.

---
 arch/x86/kvm/lapic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/lapic.c +2 -2
index d89ab48..7b11fa8 100644
@@ -2193,8 +2193,8 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data)
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (!kvm_apic_present(vcpu) || apic_lvtt_oneshot(apic) ||
-			apic_lvtt_period(apic))
+	if (!kvm_apic_present(vcpu) ||
+		!apic_lvtt_tscdeadline(apic))
 		return;
 
 	hrtimer_cancel(&apic->lapic_timer.timer);
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 2/2] KVM: LAPIC: Guarantee the timer is in tsc-deadline mode when setting

Quoted 16 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Check apic_lvtt_tscdeadline() mode directly instead of apic_lvtt_oneshot() and apic_lvtt_period() to guarantee the timer is in tsc-deadline mode when wrmsr MSR_IA32_TSCDEADLINE.

---
 arch/x86/kvm/lapic.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kvm/lapic.c +0 -0
index d89ab48..7b11fa8 100644

arch/x86/kvm/lapic.c void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data) · line 2197

Quoted 7 lines
arch/x86/kvm/lapic.c +2 -2
@@ -2193,8 +2193,8 @@ void kvm_set_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu, u64 data)
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (!kvm_apic_present(vcpu) || apic_lvtt_oneshot(apic) ||
-			apic_lvtt_period(apic))
+	if (!kvm_apic_present(vcpu) ||
+		!apic_lvtt_tscdeadline(apic))

Definitely prefer to fix the indentation here since both lines are touched anyways.

Quoted 6 lines
arch/x86/kvm/lapic.c +0 -0
 		return;
 
 	hrtimer_cancel(&apic->lapic_timer.timer);
Signature · 1 line
2.7.4
#3 lore raw
In reply to Wanpeng Li
Quoted 15 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Return 0 when getting the tscdeadline timer if the lapic is hw disabled

---
 arch/x86/kvm/lapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +0 -0
index cfb8504..d89ab48 100644

arch/x86/kvm/lapic.c u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) · line 2186

Quoted 6 lines
arch/x86/kvm/lapic.c +1 -1
@@ -2182,7 +2182,7 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu)
 {
 	struct kvm_lapic *apic = vcpu->arch.apic;
 
-	if (!lapic_in_kernel(vcpu) ||
+	if (!kvm_apic_present(vcpu) ||
 		!apic_lvtt_tscdeadline(apic))

Paolo, want want to fix up the indentation when applying?

	if (!kvm_apic_present(vcpu) || !apic_lvtt_tscdeadline(apic)
Quoted 5 lines
arch/x86/kvm/lapic.c +0 -0
 		return 0;
 
Signature · 1 line
2.7.4
author
#4 lore raw
Quoted 20 lines · Sean Christopherson
Quoted 18 lines · Wanpeng Li

From: Wanpeng Li <[email protected]>

Return 0 when getting the tscdeadline timer if the lapic is hw disabled

---
 arch/x86/kvm/lapic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kvm/lapic.c +0 -0
index cfb8504..d89ab48 100644
@@ -2182,7 +2182,7 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu)
 {
      struct kvm_lapic *apic = vcpu->arch.apic;
 
Quoted 7 lines

arch/x86/kvm/lapic.c u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) · line 2186

Quoted 3 lines
arch/x86/kvm/lapic.c +1 -1
-     if (!lapic_in_kernel(vcpu) ||
+     if (!kvm_apic_present(vcpu) ||
              !apic_lvtt_tscdeadline(apic))

Paolo, want want to fix up the indentation when applying?

        if (!kvm_apic_present(vcpu) || !apic_lvtt_tscdeadline(apic)

Agreed, Paolo do you need I send another version or you can fix up when applying?

Wanpeng