From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932972AbcGGDsF (ORCPT ); Wed, 6 Jul 2016 23:48:05 -0400 Received: from mail-pa0-f68.google.com ([209.85.220.68]:34193 "EHLO mail-pa0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756024AbcGGDsB (ORCPT ); Wed, 6 Jul 2016 23:48:01 -0400 From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Wanpeng Li , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Yunhong Jiang , Jan Kiszka , Haozhong Zhang Subject: [PATCH v3 2/2] KVM: nVMX: Fix preemption timer bit set in vmcs02 even if L1 doesn't enable it Date: Thu, 7 Jul 2016 11:46:56 +0800 Message-Id: <1467863216-5521-2-git-send-email-wanpeng.li@hotmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1467863216-5521-1-git-send-email-wanpeng.li@hotmail.com> References: <1467863216-5521-1-git-send-email-wanpeng.li@hotmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li We will go to vcpu_run() loop after L0 emulates VMRESUME which incurs kvm_sched_out and kvm_sched_in operations since cond_resched() will be called once need resched. Preemption timer will be reprogrammed if vCPU is scheduled to a different pCPU. Then the preemption timer bit of vmcs02 will be set if L0 enable preemption timer to run L1 even if L1 doesn't enable preemption timer to run L2. This patch fix it by don't reprogram preemption timer of vmcs02 if L1's vCPU is scheduled on diffent pCPU when we are in the way to vmresume nested guest. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Yunhong Jiang Cc: Jan Kiszka Cc: Haozhong Zhang Signed-off-by: Wanpeng Li --- arch/x86/kvm/x86.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0cc6cf8..e8fe16a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -2742,7 +2742,8 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) if (tsc_delta < 0) mark_tsc_unstable("KVM discovered backwards TSC"); - if (kvm_lapic_hv_timer_in_use(vcpu) && + if (!is_guest_mode(vcpu) && + kvm_lapic_hv_timer_in_use(vcpu) && kvm_x86_ops->set_hv_timer(vcpu, kvm_get_lapic_tscdeadline_msr(vcpu))) kvm_lapic_switch_to_sw_timer(vcpu); -- 1.9.1