From patchwork Fri Dec 15 14:16:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10115249 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE6EE602C2 for ; Fri, 15 Dec 2017 14:18:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5CC729F6B for ; Fri, 15 Dec 2017 14:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A38B29F6F; Fri, 15 Dec 2017 14:18:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 266F129F6B for ; Fri, 15 Dec 2017 14:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=SBO8qsmWeLIkQDb2KFFJO8Zz6Gn2mnV4Sg5hyR4TTPY=; b=fIFkEq9Aml6RigT4IAumAY1WwS sqbZWj0k4AxN8zyL3QTrA5gezZaIXuMwUjPEfC9MYPFfeFXIGagqs3pJkWenQU/1MoQ6s9tZg4mWn oaQjAhCV45VfI0ppmDDyJoSlOs33LnkL1vDPeJXS1egZzAm3FfaSbBj9hoeXhMg+vC/y8SS46pU7Q f1D0uhIsGvqHc7dU0AqXi809HT0DMTMWLDrKYNVAu3axdXfm8WoGpIzwG6Trk5h9BUhJYJGE6NuH+ d6NIJtvpn54eWWz2klQN9bXwxzIx+csh10IctzIRUOD3sxbPG0ELnNdsX4YD/EUXmHYll8qW6PYDe eqY6OWrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ePqoj-0005nh-Jz; Fri, 15 Dec 2017 14:18:25 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ePqnt-0004vU-Uu for linux-arm-kernel@lists.infradead.org; Fri, 15 Dec 2017 14:17:35 +0000 Received: by mail-wm0-x243.google.com with SMTP id i11so17816282wmf.4 for ; Fri, 15 Dec 2017 06:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=a36rOW8OaBGvyjMPM0UQKITCudrdr4NsEv413fdopL4=; b=clcL8zzxxLcXKZyBT+WHEqFX+NMnaH+1HJznXGiukoMrmzyShFay5ObH5zi4NEKJe1 vWkAkDALAMo4Ds1sFDHC85yyZx8qEICRea/CCJOyvTjtJyK9+ee6ASSJVHb+FoOJellZ BDff9uucCsL4XKXaP5/2M82e6POiqxFL7jfp4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=a36rOW8OaBGvyjMPM0UQKITCudrdr4NsEv413fdopL4=; b=ePJF9bTjbyp91+PrRblFRSUjQ4yCXwPPMXaPgjKNlzeU7IJ4llr9/f3+zCtLPgLgcZ Ga6Pc/vDskivKpv0JymF4N2kOZT0thSIL4IYTdZoO5rJd16bqw/dGCDX82BvgjZ9XfVS R23xHulXdBkouSI+e7flfa1vIcg+qnFJu16hc85kqkGo1kHH9f326fixuZj5HdsRI0uw iVALQG194OfEkFx6yFLEZC9gC/tQz7/ERm8qXCb5mz0BBOsrgs6BymJUknpDKlocVVEL i4mWLS3Zhk5aeyXVn8yNRqkF926WRUSZrF3TuJtG9X4sp8EKGwAXbykY0pmKqIDj1G/W FvJw== X-Gm-Message-State: AKGB3mIM1kPNR2nADbEb0ZpEVz8zMpszgKDo3PTMVK9eix6H0eqnguo6 sgF90dQvKipZLhMuLZ8qFsZb7Q== X-Google-Smtp-Source: ACJfBot5Q+auBCNUcHAyFkvW+CAzLi2IEteF78jEcqQs8V9WyYK2UNmD2/OqyytJgNTESqRjF3SQVA== X-Received: by 10.80.169.115 with SMTP id m48mr17283833edc.118.1513347432075; Fri, 15 Dec 2017 06:17:12 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id 4sm5293320edf.81.2017.12.15.06.17.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 06:17:10 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/2] KVM: arm/arm64: Fix timer enable flow Date: Fri, 15 Dec 2017 15:16:56 +0100 Message-Id: <20171215141656.25815-3-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171215141656.25815-1-christoffer.dall@linaro.org> References: <20171215141656.25815-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171215_061734_153872_E00417AC X-CRM114-Status: GOOD ( 10.12 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marc Zyngier , Jia He , Christoffer Dall , kvm@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP When enabling the timer on the first run, we fail to ever restore the state and mark it as loaded. That means, that in the initial entry to the VCPU ioctl, unless we exit to userspace for some reason such as a pending signal, if the guest programs a timer and blocks, we will wait forever, because we never read back the hardware state (the loaded flag is not set), and so we think the timer is disabled, and we never schedule a background soft timer. The end result? The VCPU blocks forever, and the only solution is to kill the thread. Fixes: 4a2c4da1250d ("arm/arm64: KVM: Load the timer state when enabling the timer") Reported-by: Marc Zyngier Signed-off-by: Christoffer Dall Reviewed-by: Marc Zyngier Tested-by: Marc Zyngier --- virt/kvm/arm/arch_timer.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 14c018f990a7..cc29a8148328 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -846,10 +846,7 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) no_vgic: preempt_disable(); timer->enabled = 1; - if (!irqchip_in_kernel(vcpu->kvm)) - kvm_timer_vcpu_load_user(vcpu); - else - kvm_timer_vcpu_load_vgic(vcpu); + kvm_timer_vcpu_load(vcpu); preempt_enable(); return 0;