From patchwork Fri Jan 12 12:07:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10160631 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 3435060327 for ; Fri, 12 Jan 2018 12:24:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1982627968 for ; Fri, 12 Jan 2018 12:24:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D2DB289D3; Fri, 12 Jan 2018 12:24:08 +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 B46F727968 for ; Fri, 12 Jan 2018 12:24:07 +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=rXC2+jLzMvq3RX6LncQl9HBjiV2cTP5Q3lghFG3d1K8=; b=KCSBA4rMau7wCAzYW1EKUxAvXP FCb3g2ky8suQ1Rh74jDkSZ9VhFXuFzJyXCH3UtAoGwqWqh06MPTQX3MsFHSU4O9hq5/NTM42xyZvM 0gSAgTSxkudzY0W3qyJ90P6MQvoGBQ1HWD55OzPqJWpfgKV5vL0Yu3gKTAdxkY7M5xzIxZWTpBMUI 76eDfhQLzT9Gum4fQ9Iur1Vh50a5hM3n5RPwqyUjTeB28RsRd4uHulfRAdXEA47LvUKlncld9YYJ3 AvKoHcQSwgyLuYG2LYD/v2IFEzhhkvw2tZPB1dGsZ1px2QAYTKr6spEf/0cpY6MSinRGW6yTB25NV SKSaM6xw==; 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 1eZyNS-0007nt-3j; Fri, 12 Jan 2018 12:24:06 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZy8B-0000R9-RQ for linux-arm-kernel@lists.infradead.org; Fri, 12 Jan 2018 12:08:24 +0000 Received: by mail-wm0-x241.google.com with SMTP id t8so11610884wmc.3 for ; Fri, 12 Jan 2018 04:08:18 -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=4m8ddS6EohxCOkjMMGxU4FW4diorJ3hPXOAru3SRc9E=; b=cTExhPpybRCT/pkaSCO32ub0VlG7CNWSviBQZ3CU7QkJQVhtS5Nn6AM6IyCBxUVZ31 uTbu04SlNIWBFD5GCceV8u5k7qE2l/0w+c68+xumtmRzvWDcwFWJd8nhrSYVV/9jgZZx qksfdl5nWwcszZlzOKdiK6KER4J/yyNv7SBdo= 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=4m8ddS6EohxCOkjMMGxU4FW4diorJ3hPXOAru3SRc9E=; b=HDv14EH3i3Xu6nElzOTOzeOaK3BERlQQZLDy5LRglrN2wGzjB3UiC/B1xUK7L7mjbt +IasGwsPeAixtTmddxfW3ITA78X0VHWKeHzQLFXJhToE1s1BQ6k4JpQo8p4P/1T7ZOz0 Dl0p2FdNg7w/xt+xAPAVXLau5fAcJkGBVzS8G6sqkSoGG1BBulEtyGG8L9JZWjdiKMKN zudaLmE5bTqydRPQgfkitFuib5ad3QXN25w1zw4v65j6q7Z+P6+5zlhpzd31vTvWa9uF FO+fpcj0waAr/Yrgh3ZFxkr25a5SWy9zN1uwLuYvBKoTy0PnR2V3r8uSMXGFmWV7fseQ U8TQ== X-Gm-Message-State: AKGB3mJp8WRtyUtTjdwANxG+T42LvLd8Zk9k9allw9dGKuQ5qFbZOzbF BOCWW5aDlF9Rs9L+oIbqvR+zeg== X-Google-Smtp-Source: ACJfBosuNDkYLZt6JjY2KkkgRQxhOpDqj41yL2rNUd9GCv/5nyAbdj4v+PWzcqZR+P/3fj6MJOLQnA== X-Received: by 10.80.184.103 with SMTP id k36mr35369540ede.102.1515758897244; Fri, 12 Jan 2018 04:08:17 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id f16sm13489705edj.65.2018.01.12.04.08.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Jan 2018 04:08:16 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 17/41] KVM: arm64: Remove noop calls to timer save/restore from VHE switch Date: Fri, 12 Jan 2018 13:07:23 +0100 Message-Id: <20180112120747.27999-18-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180112120747.27999-1-christoffer.dall@linaro.org> References: <20180112120747.27999-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180112_040820_073045_3E33C36B X-CRM114-Status: GOOD ( 14.54 ) 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. Acked-by: Marc Zyngier Signed-off-by: Christoffer Dall --- 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 9aadef6966bf..6175fcb33ed2 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -354,7 +354,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 @@ -373,7 +372,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); }