From patchwork Mon Jul 17 14:27:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 9845407 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 4ED1460386 for ; Mon, 17 Jul 2017 15:02:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40FEF28540 for ; Mon, 17 Jul 2017 15:02:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 356BC28541; Mon, 17 Jul 2017 15:02:22 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable 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 A4ABE28542 for ; Mon, 17 Jul 2017 15:02:21 +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=sP4DvbPhBotugMJiJV7b0rZIjmlH4LXTk5OvRrEsSIE=; b=aw3bU1NCWSYQbtN2I/WD5qkezt Fz/EJUaOMvthJBrsdpJmyCbh26cJwNvc72qWyI6iEVvbK634sM/2JcpEYaY7YVorfsCqDjDFbxc7e lnsY+JPemoMeHOfhEw9730vqJ7mBgHTuIXn4c2f+gb+eCMz8sugpZ1ZNAq/pM/LEw1v7mB+cHy8fm gnr4HPsP2NpvNEY5XK9R4OqWl/Pv7D7lODk5AVaWmgk1I/hSz2cv+p7+ekTPVgJDEiC0gvBxqcaye Li2DX44FlaVWjTyeqPiG7BLfIZ8Ffl6osVwq9BjtZEbVnVHx4DC9FjFQ9QwBMC8lsZOQK+72y8UgN LAbmR5Kw==; 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 1dX7XQ-0008My-6C; Mon, 17 Jul 2017 15:02:20 +0000 Received: from casper.infradead.org ([85.118.1.10]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dX7Ku-0007xm-2h for linux-arm-kernel@bombadil.infradead.org; Mon, 17 Jul 2017 14:49:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=8CalETVQBpE4fOCQ+GMp0uHRFBILvuGheSxODtqhDlk=; b=j1uC1XDjv3XDlusxKtii6fnWo kros+0CqOfcXQOYcxL13LMZnnkuDguL3AdHpDrJzbdCQKUVjas6AzSnkfmchFH4lgLzfl624eY8Ro Fscf0bGchsFbjU3Dlp9/Z4Ri9zWXyUmAsozYvY2zKINlhjU+T8bL4WOtL9O+PL8LRMMN7iR0cS550 8TpopaqKDOJlsEtjsdyTZw6ecNzL6CaVQJ/rPmJ+sTM3q6pDE8f7ZMNHhHbGXb3A2W46FWfmRfFH3 WM14oIgTL/aWXZRQGBqCxLET74i+alvi73l66tzii0jNPBZvclc86cYOkNfMVS3W5jGqQbl8scUPE +lud4+XSw==; Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dX70F-0001ol-S7 for linux-arm-kernel@lists.infradead.org; Mon, 17 Jul 2017 14:28:06 +0000 Received: by mail-wm0-x22a.google.com with SMTP id t70so17263562wmt.1 for ; Mon, 17 Jul 2017 07:27:43 -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=8CalETVQBpE4fOCQ+GMp0uHRFBILvuGheSxODtqhDlk=; b=Sx9+eks7bj3lTRel1UpO0ng6Hup5NQk/BQ1m82BtUJGZEFu9SFrT3QLUoy7F9I9hyX Y0GueQdv4+evXTLN9SxnQ2RzftDLdXT6b7saLGADZn072aqaOT67z4kbaDcPtLd751Be Iqpy7KbbmgPrQHg34QhQm9GV4wvtN9RmxhSNU= 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=8CalETVQBpE4fOCQ+GMp0uHRFBILvuGheSxODtqhDlk=; b=Ei5EB5eO/NoxKi/w5ETbYOSAEcA1sy3s97teQyIx/D7NWbpnoIgS/cbi9zjvgAHSDH DXuI10c/LLWoCd8nmJeSQDUvwU26NuGoDWUAL3d6cFG2DVM7hsrm0LERaZA5c2rMBL7H u4LkQ42iVcx+1RuiHAhkPsSPSylvfOtPZx3Yd8SlFBsJbXgq+m9EMNbqfzrpdc3+NepF H07GsteYmadZ+q8Xu+EcFBrzu4q91rOVRR6d0lttnwa6OTi7Ek4gwc5cIH+V8TisFn+N sipt4xT8z0+EXujMooQa90nwEH6Lfti6C6EjW2aSIJLpGNyqBM60XAZc7CVp/3KLL13G HcAQ== X-Gm-Message-State: AIVw111XEDGDcLdUqxPymi6mRYniDQDBSIGtQR1PgoJLm+K/Ka679Mkw DpV1LpbFBqv/9Lex5KHLCg== X-Received: by 10.80.222.138 with SMTP id c10mr17245492edl.97.1500301662418; Mon, 17 Jul 2017 07:27:42 -0700 (PDT) Received: from localhost.localdomain (xd93ddc2d.cust.hiper.dk. [217.61.220.45]) by smtp.gmail.com with ESMTPSA id b30sm9428952edd.6.2017.07.17.07.27.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 07:27:41 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH v2 18/19] KVM: arm/arm64: Get rid of kvm_timer_flush_hwstate Date: Mon, 17 Jul 2017 16:27:17 +0200 Message-Id: <20170717142718.13853-19-cdall@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170717142718.13853-1-cdall@linaro.org> References: <20170717142718.13853-1-cdall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170717_152803_928762_A5758E2C X-CRM114-Status: GOOD ( 17.69 ) 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 , 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 Now when both the vtimer and the ptimer when using both the in-kernel vgic emulation and a userspace IRQ chip are driven by the timer signals and at the vcpu load/put boundaries, instead of recomputing the timer state at every entry/exit to/from the guest, we can get entirely rid of the flush hwstate function. Signed-off-by: Christoffer Dall --- include/kvm/arm_arch_timer.h | 1 - virt/kvm/arm/arch_timer.c | 24 ------------------------ virt/kvm/arm/arm.c | 1 - 3 files changed, 26 deletions(-) diff --git a/include/kvm/arm_arch_timer.h b/include/kvm/arm_arch_timer.h index 8e5ed54..af29563 100644 --- a/include/kvm/arm_arch_timer.h +++ b/include/kvm/arm_arch_timer.h @@ -61,7 +61,6 @@ int kvm_timer_hyp_init(void); int kvm_timer_enable(struct kvm_vcpu *vcpu); int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu); void kvm_timer_vcpu_init(struct kvm_vcpu *vcpu); -void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu); void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu); bool kvm_timer_should_notify_user(struct kvm_vcpu *vcpu); void kvm_timer_update_run(struct kvm_vcpu *vcpu); diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index aa18a5d..f92459a 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -302,12 +302,6 @@ static void kvm_timer_update_state(struct kvm_vcpu *vcpu) struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); struct arch_timer_context *ptimer = vcpu_ptimer(vcpu); - /* - * If userspace modified the timer registers via SET_ONE_REG before - * the vgic was initialized, we mustn't set the vtimer->irq.level value - * because the guest would never see the interrupt. Instead wait - * until we call this function from kvm_timer_flush_hwstate. - */ if (unlikely(!timer->enabled)) return; @@ -493,24 +487,6 @@ bool kvm_timer_should_notify_user(struct kvm_vcpu *vcpu) ptimer->irq.level != plevel; } -/** - * kvm_timer_flush_hwstate - prepare timers before running the vcpu - * @vcpu: The vcpu pointer - * - * Check if the virtual timer has expired while we were running in the host, - * and inject an interrupt if that was the case, making sure the timer is - * masked or disabled on the host so that we keep executing. Also schedule a - * software timer for the physical timer if it is enabled. - */ -void kvm_timer_flush_hwstate(struct kvm_vcpu *vcpu) -{ - struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; - struct arch_timer_context *ptimer = vcpu_ptimer(vcpu); - - if (unlikely(!timer->enabled)) - return; -} - void kvm_timer_vcpu_put(struct kvm_vcpu *vcpu) { struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index aed3e5c..6322605 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -651,7 +651,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run) local_irq_disable(); - kvm_timer_flush_hwstate(vcpu); kvm_vgic_flush_hwstate(vcpu); /*