From patchwork Mon Dec 18 10:00:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10118689 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 CFFA16019C for ; Mon, 18 Dec 2017 10:02:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC8F128DB1 for ; Mon, 18 Dec 2017 10:02:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B016728E35; Mon, 18 Dec 2017 10:02:43 +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 4912D28DB1 for ; Mon, 18 Dec 2017 10:02:43 +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=jxCEsOcM7JuAu3IT43pVLgpY2qwNh/LDohcHvOxY0gQ=; b=XZI7hkvUzhTQUpnLygbJw7xu5k zQLolfQ/QqV0oUYrFeRsGHO04azBfpfhcCO+L+DyNce3Ad2YsedZrieCw92bNnSAo8XqslCc3JrEU bMXt1byp/jkicw+ATfEEOIRcaRPuYK8+3T34Tvglv1lv+ptqEIKhcb2FwMOyVU5BWRmI5InQLinmQ 23RKL7JeJkbd0dM+f2JAqYOAWyEavKxMIdgwwsYngX9IvIcMtdlwBDvAY2ZBVG9SKF3chX3zTbnlP agiQOZGfQuu+8xK0riI1FO7XQYnP83QGPMOjX25MNQ9XXKjf50YUnTc8mw3WDjuLNsoYXAyLRzVva NBKklttw==; 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 1eQsFu-0007z9-Fy; Mon, 18 Dec 2017 10:02:42 +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 1eQsEw-0006ws-FD for linux-arm-kernel@lists.infradead.org; Mon, 18 Dec 2017 10:01:49 +0000 Received: by mail-wm0-x243.google.com with SMTP id f9so28336797wmh.0 for ; Mon, 18 Dec 2017 02:01:24 -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=eaCYT5IVBkY7fzoHZSaPP4uoysAkORRFiS2mqM2Nnak=; b=Nq4AhsAgKOg4h6Laxz5JQrSH/0rfZI007tEUvRW9gH7zImU3qmhh+fABy3cwHqVwYq eKVzKEE30+2qlxMbkSyRtqQ5LvN+g9cewgIOXLpl39NIC/gWjnjGMOyqvE89ZFQGTOwb MxafTeZ+Ixjw96RaIkvljILiEU71zO5nwqVSw= 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=eaCYT5IVBkY7fzoHZSaPP4uoysAkORRFiS2mqM2Nnak=; b=C1qTuFPpAGMkdEp49RzkN+y2c8Wlj6s+AtVK/JlpKPywLBLLwCVLQdf01XsI4hKq8E hhBdUv6zgd1AjyBJrbF2C9tmei8R17wGirBuUh5Vz7fX/fnIakL3w5etj7BhMfVy4WNP kO4Hs0XQ3uJtnlsSAnxwPEYGUqUZb9sLLsg7/DPxJQLK8z1TedIWbZkH8qXpGARJXpZA x3tUl7RCy5WPPvg/3uyr5m9GG6nRtREIbzdqwDhDJgIt6i+JA9cZ+gTluGBTbO3zg0UZ YEQTKE78cc8N0hehee0YcwA+v8+0muTmBOT2p1Y6fyzfrM7mWiX8PG3I22PiPYFSFD6i jO5w== X-Gm-Message-State: AKGB3mKaZsPiHKPRPmc5IgiquxQkvTmQmTWPNORHJIptuQWRoucTrN4Q 1MgAogc3s+BNYT5kdbgkctWpKA== X-Google-Smtp-Source: ACJfBot6+qtk9EppJQ3upIVkTKG/El6CkY0pCeZhjBp5yFVb9rGQiNOcX9Wg9lGUonDpCbwv3c3pjQ== X-Received: by 10.80.154.193 with SMTP id p59mr28754732edb.304.1513591283667; Mon, 18 Dec 2017 02:01:23 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id h16sm10403130edj.34.2017.12.18.02.01.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Dec 2017 02:01:22 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 5/5] KVM: arm/arm64: Fix timer enable flow Date: Mon, 18 Dec 2017 11:00:57 +0100 Message-Id: <20171218100057.7839-6-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171218100057.7839-1-christoffer.dall@linaro.org> References: <20171218100057.7839-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171218_020142_869605_C30C0B6A X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. 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 , Christoffer Dall , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, 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 Reviewed-by: Marc Zyngier Tested-by: Marc Zyngier Signed-off-by: Christoffer Dall --- 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;