KVM: LAPIC: Return 0 when getting the tscdeadline timer if the lapic is hw disabled
PATCH v2 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.
---
v1 -> v2:
* fix indentation
arch/x86/kvm/lapic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/lapic.c +1 -2
@@ -2183,8 +2183,7 @@ u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu) {struct kvm_lapic *apic = vcpu->arch.apic; -if (!lapic_in_kernel (vcpu) || - !apic_lvtt_tscdeadline (apic)) +if (!kvm_apic_present (vcpu) || !apic_lvtt_tscdeadline (apic))return 0 ;return apic->lapic_timer.tscdeadline;
Signature · 1 line
2.7.4
PATCH v2 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.
---
v1 -> v2:
* fix indentation
arch/x86/kvm/lapic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/lapic.c +1 -2
@@ -2193,8 +2193,7 @@ 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
Re: [PATCH v2 2/2] KVM: LAPIC: Guarantee the timer is in tsc-deadline mode when setting
Quoted 7 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
Check
apic_lvtt_tscdeadline()mode directly instead ofapic_lvtt_oneshot()andapic_lvtt_period()to guarantee the timer is in tsc-deadline mode when wrmsrMSR_IA32_TSCDEADLINE.Signed-off-by Wanpeng Li <[email protected]>
Gah, I take back my comment about squashing these, I assumed this was the same fix but just in the write path.
Quoted 24 lines
---
v1 -> v2:
* fix indentationarch/x86/kvm/lapic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/x86/kvm/lapic.c +1
-2@@ -2193,8 +2193,7 @@ 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
Re: [PATCH v2 2/2] KVM: LAPIC: Guarantee the timer is in tsc-deadline mode when setting
In reply to Wanpeng Liping :)
Quoted 32 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
Check
apic_lvtt_tscdeadline()mode directly instead ofapic_lvtt_oneshot()andapic_lvtt_period()to guarantee the timer is in tsc-deadline mode when wrmsrMSR_IA32_TSCDEADLINE.Signed-off-by Wanpeng Li <[email protected]>---
v1 -> v2:
* fix indentationarch/x86/kvm/lapic.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)arch/x86/kvm/lapic.c +1
-3@@ -2193,8 +2193,7 @@ 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); --2.7.4
Re: [PATCH v2 2/2] KVM: LAPIC: Guarantee the timer is in tsc-deadline mode when setting
In reply to Wanpeng LiQuoted 8 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
Check
apic_lvtt_tscdeadline()mode directly instead ofapic_lvtt_oneshot()andapic_lvtt_period()to guarantee the timer is in tsc-deadline mode when wrmsrMSR_IA32_TSCDEADLINE.Signed-off-by Wanpeng Li <[email protected]>---
Quoted 3 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
Return 0 when getting the tscdeadline timer if the lapic is hw disabled.
It'd be helpful to reference the SDM for the general behavior of the MSR.
In other timer modes (LVT bit 18 = 0), the IA32_TSC_DEADLINE MSR reads zero and writes are ignored.
I'd also vote to squash the two patches together, they really are paired changes to match the architectural behavior.
Quoted 7 lines · Wanpeng Li
From: Wanpeng Li <[email protected]>
Return 0 when getting the tscdeadline timer if the lapic is hw disabled.
Suggested-by Paolo Bonzini <[email protected]>Signed-off-by Wanpeng Li <[email protected]>---