From patchwork Thu Dec 7 17:06:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10100253 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 7B08D60360 for ; Thu, 7 Dec 2017 17:10:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62FA623E64 for ; Thu, 7 Dec 2017 17:10:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5395228554; Thu, 7 Dec 2017 17:10:28 +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=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 EB57228554 for ; Thu, 7 Dec 2017 17:10: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=fzNlXoLwi/um1Bgj1SAw4Xc/daxVzwJHeux9jGl3fls=; b=Ps6yurqBKEU7L1luNJMLlw0QLs ZG+LUs+Vnt1l6Bv0L8Ghdb9Jv3rptsEuZgtte3otvrrqLMj2WbNo6JnRnIeoD1iEYhvYw6N0J8I6B BovCBrZrDPaLiNYr6y5Fx/i12kG4hgYfmQ5bmA9Izr1meV42YdstdLHwXkf+nesFTGglOxL0CWuif g68YcZJJcsC/oXO4qqFd5bqaG73pavRp6KrszwYsnaaaoaY3OOyn42WASEKqI2/Fa92V8+5oPkDx7 HI8oAy7Yh1QaxYtlq8a+Usb2aS6tMH0IutLvGxj+8yfJ/zgjxO9wClaMNNMl9pYyigIYpJGDyO4/k 8krhDAeA==; 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 1eMzgo-0007Fw-Bh; Thu, 07 Dec 2017 17:10:26 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eMzdq-00033H-RL for linux-arm-kernel@lists.infradead.org; Thu, 07 Dec 2017 17:07:34 +0000 Received: by mail-wm0-x242.google.com with SMTP id l141so14272151wmg.1 for ; Thu, 07 Dec 2017 09:07:04 -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=4+hV1mC94q4DqBK60SPrYVwCxz/JavWL8U4DF5cmW/k=; b=Mj4XAbcfxiKdTQIz1kLv9IS2KSXGusLwhYTO6v7Zqb2X3+wvL6FBBPEEZd7ELmHUYx QSLR8lS5tvG6X4SnikmCSZz5TYIfyJGhyiB5K2uUOGupcFOY5+0isFTJ/OA7RS/4x79P cRDjeYmqK9UAwm4u3Z9HcJ/Dn3UMvvJUXxEbo= 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=4+hV1mC94q4DqBK60SPrYVwCxz/JavWL8U4DF5cmW/k=; b=Zg7MfB3wTIVslwq0GpwlONlt+Ofeq9g2nCC5BW3Vc8A0URVFmq/NZixVP0LjpJVllU chRlH3m3T8M2BK1KwmseFDXoCe3WvBHvdeL2QuRbMkPnjwlV/M6msmhxZDx1rW17d6bZ Klt+FIrMo+zbjDp11QxljW/myFOBF7kUo9peg5D1b4a6DWfMxn5Vk3X3Eth28qsAMuTN jl3Xlldlxry0PX8DmziMaFgKi+23rnWTr6Tkjr2a2VpF4Gp0oLzWC20s2OHOfVPcgNCi V6j33OuMj+F5vuhxiIUJAeMjcT41zFQhlmn0aZlpmtqvLEV7+iXTgWoxvz7OkJeeoSc1 fV6w== X-Gm-Message-State: AJaThX5P2w3RCgGqmZ5Hi5idFvbsiAUhp2KgoixVm0D9CxH6GH2qcCtz xzGrHGBUu2TWXIfFQ7ODYvGf+g== X-Google-Smtp-Source: AGs4zMZuDlEgWGp9ZnWmF6jcVtjhxoGcukFz9lrbyVUf4CLG8jgeMZKtekvHO2eC5KgCihQdldSoyg== X-Received: by 10.80.161.37 with SMTP id 34mr31526236edj.15.1512666423365; Thu, 07 Dec 2017 09:07:03 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id a16sm2868270edd.19.2017.12.07.09.07.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Dec 2017 09:07:01 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 14/36] KVM: arm64: Remove noop calls to timer save/restore from VHE switch Date: Thu, 7 Dec 2017 18:06:08 +0100 Message-Id: <20171207170630.592-15-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171207170630.592-1-christoffer.dall@linaro.org> References: <20171207170630.592-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171207_090724_191929_D197A8A2 X-CRM114-Status: GOOD ( 14.64 ) 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 , Andrew Jones , Christoffer Dall , Shih-Wei Li , 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 The VHE switch function calls __timer_enable_traps and __timer_disable_traps which don't do anything on VHE systems. Therefore, simply remove these calls from the VHE switch function and make the functions non-conditional as they are now only called from the non-VHE switch path. Signed-off-by: Christoffer Dall Acked-by: Marc Zyngier --- arch/arm64/kvm/hyp/switch.c | 2 -- virt/kvm/arm/hyp/timer-sr.c | 36 ++++++++++++++---------------------- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index e783e2371b7c..09aafa0470f7 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -358,7 +358,6 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) __activate_vm(vcpu->kvm); __vgic_restore_state(vcpu); - __timer_enable_traps(vcpu); /* * We must restore the 32-bit state before the sysregs, thanks @@ -377,7 +376,6 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu) __sysreg_save_guest_state(guest_ctxt); __sysreg32_save_state(vcpu); - __timer_disable_traps(vcpu); __vgic_save_state(vcpu); __deactivate_traps(vcpu); diff --git a/virt/kvm/arm/hyp/timer-sr.c b/virt/kvm/arm/hyp/timer-sr.c index f24404b3c8df..752b37f9133c 100644 --- a/virt/kvm/arm/hyp/timer-sr.c +++ b/virt/kvm/arm/hyp/timer-sr.c @@ -29,32 +29,24 @@ void __hyp_text __kvm_timer_set_cntvoff(u32 cntvoff_low, u32 cntvoff_high) void __hyp_text __timer_disable_traps(struct kvm_vcpu *vcpu) { - /* - * We don't need to do this for VHE since the host kernel runs in EL2 - * with HCR_EL2.TGE ==1, which makes those bits have no impact. - */ - if (!has_vhe()) { - u64 val; + u64 val; - /* Allow physical timer/counter access for the host */ - val = read_sysreg(cnthctl_el2); - val |= CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN; - write_sysreg(val, cnthctl_el2); - } + /* Allow physical timer/counter access for the host */ + val = read_sysreg(cnthctl_el2); + val |= CNTHCTL_EL1PCTEN | CNTHCTL_EL1PCEN; + write_sysreg(val, cnthctl_el2); } void __hyp_text __timer_enable_traps(struct kvm_vcpu *vcpu) { - if (!has_vhe()) { - u64 val; + u64 val; - /* - * Disallow physical timer access for the guest - * Physical counter access is allowed - */ - val = read_sysreg(cnthctl_el2); - val &= ~CNTHCTL_EL1PCEN; - val |= CNTHCTL_EL1PCTEN; - write_sysreg(val, cnthctl_el2); - } + /* + * Disallow physical timer access for the guest + * Physical counter access is allowed + */ + val = read_sysreg(cnthctl_el2); + val &= ~CNTHCTL_EL1PCEN; + val |= CNTHCTL_EL1PCTEN; + write_sysreg(val, cnthctl_el2); }