From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B10B1C04AAC for ; Mon, 20 May 2019 12:30:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87C1221726 for ; Mon, 20 May 2019 12:30:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355423; bh=H6qYUOT9E37EvFF2R2H/o2TLbrpZMRWCgqi4IEYCAG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=q3IltQuhmTAtPFuoGtmDpTpEJl10FzXNMczBU1sF4sErfnKD5IC3yurp4ylUNcKBd fX+nqrtVQMVuuygCwYTe507StlSTHYeUrPlXaWskloGK8XOz8JN/l4zF6lECA+M/sp HwUNieRxq0sJ2vFa1rEcPLHolaY/+DmcT/2B+V94= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390086AbfETMaW (ORCPT ); Mon, 20 May 2019 08:30:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:46582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388778AbfETMaS (ORCPT ); Mon, 20 May 2019 08:30:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A82C620675; Mon, 20 May 2019 12:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355418; bh=H6qYUOT9E37EvFF2R2H/o2TLbrpZMRWCgqi4IEYCAG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9QyyOqRemBMfgX8K5lnikjuvrZF87V6WJmxQhjjv+VJgzLVRyCtxTaFXdQnMbNN3 UzR6ZiRwG71KcQcalJU2iGhAzhAcgd3ZTmM3qGG4cq1QgKULVhS2HCvIjCDQKLzNiJ ZRWumlXMmGYXCcqazi5PRZ34OJ0599WoKvjzA9QY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wanpeng Li , Liran Alon , Sean Christopherson , Paolo Bonzini Subject: [PATCH 5.0 112/123] KVM: lapic: Busy wait for timer to expire when using hv_timer Date: Mon, 20 May 2019 14:14:52 +0200 Message-Id: <20190520115252.567542703@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Christopherson commit ee66e453db13d4837a0dcf9d43efa7a88603161b upstream. ...now that VMX's preemption timer, i.e. the hv_timer, also adjusts its programmed time based on lapic_timer_advance_ns. Without the delay, a guest can see a timer interrupt arrive before the requested time when KVM is using the hv_timer to emulate the guest's interrupt. Fixes: c5ce8235cffa0 ("KVM: VMX: Optimize tscdeadline timer latency") Cc: Cc: Wanpeng Li Reviewed-by: Liran Alon Signed-off-by: Sean Christopherson Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/lapic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1453,7 +1453,7 @@ static void apic_timer_expired(struct kv if (swait_active(q)) swake_up_one(q); - if (apic_lvtt_tscdeadline(apic)) + if (apic_lvtt_tscdeadline(apic) || ktimer->hv_timer_in_use) ktimer->expired_tscdeadline = ktimer->tscdeadline; }