Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp572367pxj; Tue, 18 May 2021 09:29:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxc+a18+1r3NHMwdyZ1CnyjGH5aQzWjxtb4vdYCJbd+Nr6fK3wxqdbjeSbKQNsRTgSDcSur X-Received: by 2002:a50:8e44:: with SMTP id 4mr8132372edx.244.1621355366117; Tue, 18 May 2021 09:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621355366; cv=none; d=google.com; s=arc-20160816; b=QAX65rE6yfUHOtfVjtCy0tdwJ2rEKGtiIK5SxOy418rjzinlZWen/oEP+wF1RoCI/0 O0325noMz/gSkWhRpmxCoUa1LS1+aZUAYHlVhhVcgnwPGHTjHZ/RPQof/PvH4A4fdLRI Wl5Yb1Iz59rb3jgZJ7InThsU8PIBIjGnZVxW01oaBOVP5V1vyuPcoTA+Ndj+veb33zmf Vk8NN6bZT9MtRRyCROqLOFMmgayu8x7f/+z8ywxoI+qkOTOo+wTDJsQ1ubJ9SPKTeTLR kBbatbcmDrbcSbdIYAf4NXB4WBo2e4vS+pjuq6b+TKBk1/MmXZ61YQsNZzJA3GSBhGvQ SFBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XkqJfyutyzNNOvYg4/g2P7zaKYKdgkj1X12UAJ0RPyU=; b=UqQy1/oNZ2WCnUKU+V7ldbGiDlRggTMJW3XYstFCu4cEiDrJ1QZd2ZlmBZbjTNEKAD aY/+xYI8eg12SwHVJQOzLRfykXmtkv2AbvObF5QnmgNAPgxQKwPkKtx7DvXB0rOK1HwM pH5wb8jbbXt4UGZLGh7JHAtj6e7oTQhx29XBX+hgGgiznXc/IHfKtBVU8m737ED3Iu2E 3NMxFEHuoW7bcQKZsMEporHoggBg1b5XAU1/38yxvMb32Y17q/xxi1w76/Dbr1cZ4JeM sOT/khpmWTiDS0CMsAVB+K1KUt2dS9/NDpQ+9HFvjZIuCbXN/eLOs4YdQSTjLIzrvkCR dt1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dRX8adm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf18si11372184edb.292.2021.05.18.09.29.02; Tue, 18 May 2021 09:29:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dRX8adm7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245350AbhEQQCx (ORCPT + 99 others); Mon, 17 May 2021 12:02:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:52294 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343629AbhEQPmN (ORCPT ); Mon, 17 May 2021 11:42:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 34DDF6198B; Mon, 17 May 2021 14:42:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262551; bh=dZXU+yJRdUHUJdDNVw1EqzrfWGGrCG60z/TqiAep5+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dRX8adm73LolA5bFvCTlX+1ZyUwrEhJX6cJBFtaaovMEVqHGr3bvCTmWcl0p4eG6K KWoOYNmP2IKFA1bPtEyEInHeSCU2VLj6ua3piXQ7IKKYPg9omoYqtsN1VzjAojHte7 uuGZGrUkuU9ApYXLzC22D7r4+NwwjyuXAtRsWt7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sean Christopherson , Wanpeng Li , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 212/289] KVM: LAPIC: Accurately guarantee busy wait for timer to expire when using hv_timer Date: Mon, 17 May 2021 16:02:17 +0200 Message-Id: <20210517140312.258680324@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li [ Upstream commit d981dd15498b188636ec5a7d8ad485e650f63d8d ] Commit ee66e453db13d (KVM: lapic: Busy wait for timer to expire when using hv_timer) tries to set ktime->expired_tscdeadline by checking ktime->hv_timer_in_use since lapic timer oneshot/periodic modes which are emulated by vmx preemption timer also get advanced, they leverage the same vmx preemption timer logic with tsc-deadline mode. However, ktime->hv_timer_in_use is cleared before apic_timer_expired() handling, let's delay this clearing in preemption-disabled region. Fixes: ee66e453db13d ("KVM: lapic: Busy wait for timer to expire when using hv_timer") Reviewed-by: Sean Christopherson Signed-off-by: Wanpeng Li Message-Id: <1619608082-4187-1-git-send-email-wanpengli@tencent.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 4ca81ae9bc8a..5759eb075d2f 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1908,8 +1908,8 @@ void kvm_lapic_expired_hv_timer(struct kvm_vcpu *vcpu) if (!apic->lapic_timer.hv_timer_in_use) goto out; WARN_ON(rcuwait_active(&vcpu->wait)); - cancel_hv_timer(apic); apic_timer_expired(apic, false); + cancel_hv_timer(apic); if (apic_lvtt_period(apic) && apic->lapic_timer.period) { advance_periodic_target_expiration(apic); -- 2.30.2