Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp477055pxj; Tue, 18 May 2021 07:35:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKquRS0hm4V/7wI6Tn2zDE8zS3LYL6mf7iljM1luZB8qZGuvaJAGh8T8Es9iHRHedmVT9v X-Received: by 2002:a17:906:b048:: with SMTP id bj8mr6364278ejb.236.1621348554392; Tue, 18 May 2021 07:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621348554; cv=none; d=google.com; s=arc-20160816; b=Q35eqz7TXwAtIjuKn8dVGS05EjuyHQzeKj1PrFUE+FaFqK0hOAD5ozFcSquNe6wpSl /A831ZqwK5LImOjM1Q9Fx3i/iFf3iUj6d6mhIUdDv1RSY/KbJ8ll0ncleHVTtznHF5hW lfcaEU0ojbbYv875JSmwcLiCHlJEEQUyHnDNUL5TkNZs9Mf2MG5mEEGyKyUbJG6pG06p jUzZNfZ4829fmrzOg0S0cB0PcBA1B4Ir7eZnHt02Xts6A2ddoaKlWlWx95JBELRq+gx0 kYxV69FvXBKJ0PGpJsZpOKLVP05M32U83Z1wB2k1diffV4/6pjzoKVRQpcFeLMR0RDWi 00mg== 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=EmNcGsDkbJj3RHfeeqoaetqV/f7sZA66vDXWzZZxz58=; b=tAv0IWC5PzVPlcqh0FEc+Y4tshlj9Sq9XJ3hT/rPeP+xU3UAjY2XDXDAuvBZqRKfGy Co1OLjhGiOuHbreakEa+zZPNglRZ2J8XADU+DfAmaN4pxVS52a3SxAYUKqxXqFmRlREL Zu///+NIlR4TJHWWLX11+pfa7Y4tWWDOY69lQVEwNjayMRB9Fi9qScru+24yFw4uNs8s Vx9ALd8WMnMkJ6CkPm1vaLdbscbmLDWAwV6q1DEu7sgRCab0ICNpQszdnJ/1KyP6e1lp Bm+u7Ev352vcmRfs56vxdVLowHya3kxaIqU3x0GJDup1BMXIF6KJMykhqGsjUQ4/Qiru Bf6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ao4riwsH; 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 p3si17724318ejo.95.2021.05.18.07.35.06; Tue, 18 May 2021 07:35:54 -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=Ao4riwsH; 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 S1344670AbhEQPpX (ORCPT + 99 others); Mon, 17 May 2021 11:45:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:53306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245497AbhEQP3u (ORCPT ); Mon, 17 May 2021 11:29:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 03AE7613F5; Mon, 17 May 2021 14:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262258; bh=2ZG0b9EVKtAyzoHzd47jQfWhZOI9s3h/S+m0CpotFg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ao4riwsHDtJizCzo3beXqJMkN75fANOOW+APbpsnpgWg8XWTn0QRD7HLr+NMzDyi1 Iey2l6gT7eCNiHpVPBWh83pkCdsTB4yjLqinD+U/iPT89cC7dZEqpFXrtykbUnQd4K kxJoqs9i7HBaU5X0hrFDnsv7FOsKyw1DMgrS12rM= 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.11 251/329] KVM: LAPIC: Accurately guarantee busy wait for timer to expire when using hv_timer Date: Mon, 17 May 2021 16:02:42 +0200 Message-Id: <20210517140310.597532327@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.043055203@linuxfoundation.org> References: <20210517140302.043055203@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 570fa298083c..70eb00f4317f 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