From patchwork Tue Feb 27 11:34:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10245013 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 31DE060362 for ; Tue, 27 Feb 2018 12:08:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20C79287A7 for ; Tue, 27 Feb 2018 12:08:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 158B928878; Tue, 27 Feb 2018 12:08:45 +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 [198.137.202.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 84AEE287A7 for ; Tue, 27 Feb 2018 12:08:44 +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=x4oddV8yhkyXdQZMcTuykP40KSGZEANJD/GuTfzAhoA=; b=gOroxsBDOYoBuoFgUynr4lDv7A Y0EZZw47+ySkU3pbhlUMl6lxDD2MCkXL9tgJ+HnN8iGzgvElLfq8LleUXzFbJyLs5NYlf+cvHU2MT 4YAA229dJzh5MKJdDF0wMUljhNoDkshM8HzZpLP9xNkuNwTTzW3aEIRGOT2UzarT7qLyY/Cr9WMjS VrHCAVq6uSIkLASUTHexbimRcyxXrEvZD+MXm/Q5eI/0Q3DfvYk5nV9VPGqrJ1SA5UrQ7Dj7grqbo KXeJnsthtXNKdB7bkaF/8RjHG6kOB4O3+kOM0UesiLNYHWq+/iDBr2+jUX1GKJMLujbrnBTimToUJ vTdtguyQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqe3k-0003j5-6s; Tue, 27 Feb 2018 12:08:40 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqdXD-0006dY-TA for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 11:35:27 +0000 Received: by mail-wm0-x243.google.com with SMTP id 191so23155264wmm.4 for ; Tue, 27 Feb 2018 03:34:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=christofferdall-dk.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=qbiMtHWWFJUjAzCm6fqtzQPXMtZbUCk/SUwVI2PrAL8=; b=D/Qm8Gok8tm81jNEaYsRCa2i/MDTD8t15u8mmde5yCJDHD62d2uqFzugX7sTZl20ZI DuajNolc+Nzp/DZGAA71l8RnP1M7PtaEdFKMbljdDlFw6r5qdbNjn8AQoeZcz+g95gxJ jO8DWMtmLLCJx4eoVhuZYkvh3xvSE5069T1mSgOxRS0vXJYuen0/L8DuWv4DOEPYlPsW V+xT707Wxj1a7vVAvrgTHQoRLEXRn9JYrh/csK0+3rj9b26ySD05hwyJVkx/PkQUAACS 3sZ5cPckwYxeXvhouHcQMeHh5//uOizY0ZabqJG1MU06LkZRacXU2ktIIGzM65pyHDnG CZRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=qbiMtHWWFJUjAzCm6fqtzQPXMtZbUCk/SUwVI2PrAL8=; b=p9bkffrvjyXapH5rTBcGNJottpWVP4xb2XQqvs460IkfW+DoiWNpM7qLS5WxXsNVSM n7+SI94RgIhXZlEboODU49+D9Y4qTfUAYWKyTuH4r9oPs+0swY5Q5d0Gg04kyKP9wZDy O69HcrgRJk3kYZm0K4vOSFAihAl1iXd49ZnMecFiEI3RGl4E3fWsv9Gl5GJcTIXdvS5/ 9ZRqHxrVLmyyC3SdUkAiSIC7KHbMncE9/6ASFSNNLQ3SR+vrXVpsYtqv7NznSiuCKMzR 00awO86CJaAHHAXhETntHTloaTeMjpMzco/11jNJsxP9C8GKkym8Br/w2GOdpRC+yLtW u9OQ== X-Gm-Message-State: APf1xPCXv4k6ndX2vmfhcWJ4HUhHKVcNfnvzg6yYOEYqyIuiuDkx1sGX OKK0gDJxR0WLF++h9nTz/PXazQ== X-Google-Smtp-Source: AG47ELvRqCIqT6yuCdQgLzPyX9P6d/6IshGkMosNlLZsxfiZ7SqtAAsxVzP+L5lK34dlWRARCBDkMA== X-Received: by 10.80.224.205 with SMTP id j13mr5999274edl.304.1519731294982; Tue, 27 Feb 2018 03:34:54 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id m1sm9176786ede.39.2018.02.27.03.34.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 03:34:54 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 16/40] KVM: arm64: Remove noop calls to timer save/restore from VHE switch Date: Tue, 27 Feb 2018 12:34:05 +0100 Message-Id: <20180227113429.637-17-cdall@kernel.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180227113429.637-1-cdall@kernel.org> References: <20180227113429.637-1-cdall@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_033504_880672_74396C4F X-CRM114-Status: GOOD ( 16.40 ) 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: Andrew Jones , kvm@vger.kernel.org, Marc Zyngier , Tomasz Nowicki , Julien Grall , Yury Norov , Dave Martin , Shih-Wei Li 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 From: Christoffer Dall 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. Acked-by: Marc Zyngier Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- Notes: Changes since v2: - Added comment explaining the timer enable/disable functions are for !VHE only. arch/arm64/kvm/hyp/switch.c | 2 -- virt/kvm/arm/hyp/timer-sr.c | 44 ++++++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 9ffd802e775d..307f8c1fcc2f 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -379,7 +379,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 @@ -400,7 +399,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..77754a62eb0c 100644 --- a/virt/kvm/arm/hyp/timer-sr.c +++ b/virt/kvm/arm/hyp/timer-sr.c @@ -27,34 +27,34 @@ void __hyp_text __kvm_timer_set_cntvoff(u32 cntvoff_low, u32 cntvoff_high) write_sysreg(cntvoff, cntvoff_el2); } +/* + * Should only be called on non-VHE systems. + * VHE systems use EL2 timers and configure EL1 timers in kvm_timer_init_vhe(). + */ 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); } +/* + * Should only be called on non-VHE systems. + * VHE systems use EL2 timers and configure EL1 timers in kvm_timer_init_vhe(). + */ 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); }