From patchwork Wed Apr 5 09:28:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9663549 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 ADD0D602B8 for ; Wed, 5 Apr 2017 09:31:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC5302684F for ; Wed, 5 Apr 2017 09:31:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A123D2859A; Wed, 5 Apr 2017 09:31:02 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 493952684F for ; Wed, 5 Apr 2017 09:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932723AbdDEJ3U (ORCPT ); Wed, 5 Apr 2017 05:29:20 -0400 Received: from mail-wm0-f47.google.com ([74.125.82.47]:36688 "EHLO mail-wm0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932343AbdDEJ2R (ORCPT ); Wed, 5 Apr 2017 05:28:17 -0400 Received: by mail-wm0-f47.google.com with SMTP id o81so44970972wmb.1 for ; Wed, 05 Apr 2017 02:28:17 -0700 (PDT) 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=j6YjldhjiBNO2F9vObVCDikHvjFLCKjNh1sN0i5ey1E=; b=kjoTRBsPRzRX3M3jj1D4Ey/LyyI70qMdfSUosJzDE7VBmwiTs/2KklKkwvQYbhTcqj XFniw0FJGLUlgEpyeWK7Ypkcw9Y2L0NKxEbAePSRR/p+HK5LIJvgbMqk87pwRAoKREMf 0avqrSCSch7RlHep3DBpQI8J+N4jVbTH9lQYQ= 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=j6YjldhjiBNO2F9vObVCDikHvjFLCKjNh1sN0i5ey1E=; b=brPywUuobF4bH0tP8E2R/4q5Po34GbQKjtEqjRNKGJ6qLYp8uqrIKUR7NGs3j9kUCU 8COz/GeDYDdMigY9ZsR4xS/hyi59aGzZmaHDHOhR8lcV8PlLwtigAZSR1dw1iQYqwNzK DesGybMNt8ov5haSWgEpahDveNUFGMZ6wXB27IQMsmv2/9gamtmk7NNr2h3oQY8xamrB VNxhhD0730I2UwdHuXVcRD2nfvaXkz4CHUZcr+/+4rtlrd1R9TWxExF3ljG96Y/+dOaA TJl03DxrSBr+dN01FtdBPa2EaxmiBjRQChHDFsu5t1WLguK7B6BrsQazsM8bHw4M9p10 RKtg== X-Gm-Message-State: AFeK/H103rfSBrhs4+1oUY33fJbsONP/1S2RkdYmYru0YsebkOHp4ZEo GeXO3xBmYCCT7qjiPaIP9g== X-Received: by 10.28.129.83 with SMTP id c80mr17347872wmd.82.1491384496304; Wed, 05 Apr 2017 02:28:16 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id g23sm21578135wme.8.2017.04.05.02.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 05 Apr 2017 02:28:15 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Alexander Graf , Peter Maydell , Pekka Enberg , Christoffer Dall Subject: [PATCH v3 1/5] KVM: arm/arm64: Cleanup the arch timer code's irqchip checking Date: Wed, 5 Apr 2017 11:28:11 +0200 Message-Id: <20170405092815.22503-2-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170405092815.22503-1-cdall@linaro.org> References: <20170405092815.22503-1-cdall@linaro.org> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall Currently we check if we have an in-kernel irqchip and if the vgic was properly implemented several places in the arch timer code. But, we already predicate our enablement of the arm timers on having a valid and initialized gic, so we can simply check if the timers are enabled or not. This also gets rid of the ugly "error that's not an error but used to signal that the timer shouldn't poke the gic" construct we have. Signed-off-by: Christoffer Dall --- virt/kvm/arm/arch_timer.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 35d7100..363f0d2 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -189,8 +189,6 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, { int ret; - BUG_ON(!vgic_initialized(vcpu->kvm)); - timer_ctx->active_cleared_last = false; timer_ctx->irq.level = new_level; trace_kvm_timer_update_irq(vcpu->vcpu_id, timer_ctx->irq.irq, @@ -205,7 +203,7 @@ static void kvm_timer_update_irq(struct kvm_vcpu *vcpu, bool new_level, * Check if there was a change in the timer state (should we raise or lower * the line level to the GIC). */ -static int kvm_timer_update_state(struct kvm_vcpu *vcpu) +static void kvm_timer_update_state(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); @@ -217,16 +215,14 @@ static int kvm_timer_update_state(struct kvm_vcpu *vcpu) * because the guest would never see the interrupt. Instead wait * until we call this function from kvm_timer_flush_hwstate. */ - if (!vgic_initialized(vcpu->kvm) || !timer->enabled) - return -ENODEV; + if (!timer->enabled) + return; if (kvm_timer_should_fire(vtimer) != vtimer->irq.level) kvm_timer_update_irq(vcpu, !vtimer->irq.level, vtimer); if (kvm_timer_should_fire(ptimer) != ptimer->irq.level) kvm_timer_update_irq(vcpu, !ptimer->irq.level, ptimer); - - return 0; } /* Schedule the background timer for the emulated timer. */ @@ -295,13 +291,16 @@ void kvm_timer_unschedule(struct kvm_vcpu *vcpu) */ void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) { + struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); bool phys_active; int ret; - if (kvm_timer_update_state(vcpu)) + if (unlikely(!timer->enabled)) return; + kvm_timer_update_state(vcpu); + /* Set the background timer for the physical timer emulation. */ kvm_timer_emulate(vcpu, vcpu_ptimer(vcpu));