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 Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0208FC4332F for ; Thu, 29 Dec 2022 13:02:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 63AA84B7C1; Thu, 29 Dec 2022 08:02:21 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sGrPmLQ1Awin; Thu, 29 Dec 2022 08:02:20 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 23D294B814; Thu, 29 Dec 2022 08:02:20 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 242D84B7FD for ; Thu, 29 Dec 2022 08:02:19 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XDrDgUIuKWY1 for ; Thu, 29 Dec 2022 08:02:18 -0500 (EST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id E1BB94B7C1 for ; Thu, 29 Dec 2022 08:02:17 -0500 (EST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 40BAE6173E; Thu, 29 Dec 2022 13:02:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BE07C433EF; Thu, 29 Dec 2022 13:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672318936; bh=rrOMS6JWy1WFDiSkkmKZJnG4y5ugZHFgDcLi/ReaVIw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nulAoRrgHQIkkvpDhF2T7ryJX3wU9J9R3QJneHPj7oOfTv1udwAibE+3oDzA8R3Q8 PhkZ/X1x0Mr/icqFIEHli61jQzuv8sFBs95UV77LDx7JewBHpi5h3lennbwOL28OAn VLflfRkg4SUbr5atAa/OE1+vAUniEq/5v+U5gSk5N6kKKXAOfkaoa/s3oXYqOOJrj6 wM7Btc207MM3hBJZ/1BFEGPvt5cpwFx/1VKgjArMTigyoQPjBgviYezwfUdYYU/4lC 5UybB/cNffKvfUKI6opXSUeSCWiButuj5LO2VAw/5vB+W3Q2JWRsze0INsDmuwkRS6 990fEywOyKFtw== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pAsY2-00Fhw7-Ca; Thu, 29 Dec 2022 13:02:14 +0000 Date: Thu, 29 Dec 2022 13:00:55 +0000 Message-ID: <87zgb6e54o.wl-maz@kernel.org> From: Marc Zyngier To: Ganapatrao Kulkarni Subject: Re: [PATCH 1/3] KVM: arm64: nv: only emulate timers that have not yet fired In-Reply-To: <20220824060304.21128-2-gankulkarni@os.amperecomputing.com> References: <20220824060304.21128-1-gankulkarni@os.amperecomputing.com> <20220824060304.21128-2-gankulkarni@os.amperecomputing.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: gankulkarni@os.amperecomputing.com, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, scott@os.amperecomputing.com, keyur@os.amperecomputing.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: scott@os.amperecomputing.com, kvm@vger.kernel.org, catalin.marinas@arm.com, keyur@os.amperecomputing.com, will@kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Wed, 24 Aug 2022 07:03:02 +0100, Ganapatrao Kulkarni wrote: > > From: D Scott Phillips > > The timer emulation logic goes into an infinite loop when the NestedVM(L2) > timer is being emulated. > > While the CPU is executing in L1 context, the L2 timers are emulated using > host hrtimer. When the delta of cval and current time reaches zero, the > vtimer interrupt is fired/forwarded to L2, however the emulation function > in Host-Hypervisor(L0) is still restarting the hrtimer with an expiry time > set to now, triggering hrtimer to fire immediately and resulting in a > continuous trigger of hrtimer and endless looping in the timer emulation. > > Adding a fix to avoid restarting of the hrtimer if the interrupt is > already fired. > > Signed-off-by: D Scott Phillips > Signed-off-by: Ganapatrao Kulkarni > --- > arch/arm64/kvm/arch_timer.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c > index 2371796b1ab5..27a6ec46803a 100644 > --- a/arch/arm64/kvm/arch_timer.c > +++ b/arch/arm64/kvm/arch_timer.c > @@ -472,7 +472,8 @@ static void timer_emulate(struct arch_timer_context *ctx) > return; > } > > - soft_timer_start(&ctx->hrtimer, kvm_timer_compute_delta(ctx)); > + if (!ctx->irq.level) > + soft_timer_start(&ctx->hrtimer, kvm_timer_compute_delta(ctx)); > } > > static void timer_save_state(struct arch_timer_context *ctx) I think this is a regression introduced by bee038a67487 ("KVM: arm/arm64: Rework the timer code to use a timer_map"), and you can see it because the comment in this function doesn't make much sense anymore. Does the following work for you, mostly restoring the original code? Thanks, M. diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index ad2a5df88810..4945c5b96f05 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -480,7 +480,7 @@ static void timer_emulate(struct arch_timer_context *ctx) * scheduled for the future. If the timer cannot fire at all, * then we also don't need a soft timer. */ - if (!kvm_timer_irq_can_fire(ctx)) { + if (should_fire || !kvm_timer_irq_can_fire(ctx)) { soft_timer_cancel(&ctx->hrtimer); return; } -- Without deviation from the norm, progress is not possible. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm