From patchwork Tue Nov 7 10:47:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10046465 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 C520E60247 for ; Tue, 7 Nov 2017 11:06:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FFB929CEC for ; Tue, 7 Nov 2017 11:06:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94A8C29D1B; Tue, 7 Nov 2017 11:06: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 36A0B29CEC for ; Tue, 7 Nov 2017 11:06: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=MO41W/3xnF6AsyHQUKzqY4tBQr2n0mb1bZXo13y8VzY=; b=VrGwMMuN5rG6+pvFqHEQNInTeV BvLYzQxGa2HrhvPXfpyWiWnburt2vb+arKUHdrLO3gUcD8c3fuaePSNHy110iJ032rCUc4wHbXjCJ BAy+7pYHUPng/LTcxhxfc74Fe3HnzzQ5VDQlGeRQow62kZLO8wA87Xs9vg3/BTXOwRGC0YoTysmsq 95G6MmvMpNm+5nYfG+Ce46KDypWhZmXNNQnG2aLJ3185Pu+1BST1pADqAaC7raVi/0NoIK5/A/Z1L qpw2yaWLHiiEF1Y75tzQi86o3DHYr+gHubzJozdXfBY6d1N2oCQHNX7qde3Hwd6WWq4s/qyko4iIk j5bdR3RA==; 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 1eC1iH-0002u5-0F; Tue, 07 Nov 2017 11:06:37 +0000 Received: from merlin.infradead.org ([205.233.59.134]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eC1RM-0001TG-2Q for linux-arm-kernel@bombadil.infradead.org; Tue, 07 Nov 2017 10:49:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fMQ4oNE55hiyoOwgXjfXD4GLpeWp7FnZbmjYAkziyDo=; b=tVCFUi8xHEervlIXD+CbDlQlI LuynMSm1HeU3H9nFni8BMK1kfsZDlNWSj7deCKH0prvzcpA6wZ6t2i8w+S/TQR+J9ruEopoEUij+2 lKMADudUf1hxzNlolkN3ZytLkTXEv3gyXTe05ysK65iGP32/+QKiM4Nln/AXEZa9+xYpNJrWTkCgU Q0tiYJn0SamVGvna94g57+R0W+oZn/4Xd9/m2jdb280xDjbycZNYnFc0liXZrYaIhPcPURLusfABb vnChKOwMJ1Win93B748HoI3kxFkiJmzD3bL2hfzlRdE+dYqqROtBjlVcbk+gnGMlYRPCpm79KpnD7 +8jXqsMQQ==; Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eC1RI-0005b6-Hs for linux-arm-kernel@lists.infradead.org; Tue, 07 Nov 2017 10:49:05 +0000 Received: by mail-wm0-x242.google.com with SMTP id t139so2851002wmt.1 for ; Tue, 07 Nov 2017 02:48:40 -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=fMQ4oNE55hiyoOwgXjfXD4GLpeWp7FnZbmjYAkziyDo=; b=hmNI6JslkPjAsP4mnX+z27rIiHZrPpYMEavgKIBBc7ltWo1p/oc9H77HO+0ZkYBPm4 ityaaKjlyk5IbzJxn6kzktiKHkqIJbdk7o1aReRp6+MtyGxR+ovZ8yAZ3LTt6iCOcxDm sMAPvmwH/Q3cpE5sS5qsGGma87Ojaps6bU4Ss= 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=fMQ4oNE55hiyoOwgXjfXD4GLpeWp7FnZbmjYAkziyDo=; b=L/UqwGrX2OE4Ill5homxgjhy6suvVlN0peE+xbUVewd7rLraa0XUa8C4rkDASXkBE0 +EXHI5OXHMp4E0qyUZ+ozOOlYHClSg0XqjhgiS5pWiPpZSulRGM8btfSrdnkSI1Qs72d P/fj9Ylp8qDBOslK/JuGk7TDjshOW6H4uWALBbS8tN60poyS1pXJSWXLu63UeOSCy62y KDLtXf1mhRNBeMq9t67M4ElPCERDFMWgyYet0mXDe8/vGOAdimCmR11XbhRBrOLpp//w WVMlrvGnM1MlxL1ThsiML/5f1hDcnS2CAa0J6klzdsDo033ZpI8Buvjsyxt3QxPVqLHx IVbQ== X-Gm-Message-State: AMCzsaVgqNhy0+it7FALLKicVAXc3uprEb122H4xhzLeThgMBXuI1Poz BnY8ONCA1a65yt5kzgYXg83jyw== X-Google-Smtp-Source: ABhQp+SJ7RIMFZsFvWL9yZ4mH+W/o2ZnsZCckstpSUVHo1for7f77lQ3Ty/k9426k49r+XwWKOrHCQ== X-Received: by 10.80.180.18 with SMTP id b18mr24355265edh.136.1510051717019; Tue, 07 Nov 2017 02:48:37 -0800 (PST) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id q12sm1044958edj.29.2017.11.07.02.48.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Nov 2017 02:48:36 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PULL 19/26] arm/arm64: KVM: Load the timer state when enabling the timer Date: Tue, 7 Nov 2017 11:47:52 +0100 Message-Id: <20171107104800.30021-20-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171107104800.30021-1-christoffer.dall@linaro.org> References: <20171107104800.30021-1-christoffer.dall@linaro.org> 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, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.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 After being lazy with saving/restoring the timer state, we defer that work to vcpu_load and vcpu_put, which ensure that the timer state is loaded on the hardware timers whenever the VCPU runs. Unfortunately, we are failing to do that the first time vcpu_load() runs, because the timer has not yet been enabled at that time. As long as the initialized timer state matches what happens to be in the hardware (a disabled timer, because we never leave the timer screaming), this does not show up as a problem, but is nevertheless incorrect. The solution is simple; disable preemption while setting the timer to be enabled, and call the timer load function when first enabling the timer. Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 2035cf251701..4db54ff08d9e 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -861,7 +861,11 @@ int kvm_timer_enable(struct kvm_vcpu *vcpu) return ret; no_vgic: + preempt_disable(); timer->enabled = 1; + kvm_timer_vcpu_load_vgic(vcpu); + preempt_enable(); + return 0; }