From patchwork Thu Feb 15 21:03:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 10223711 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 8A416602CB for ; Thu, 15 Feb 2018 21:29:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 79BC02953E for ; Thu, 15 Feb 2018 21:29:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D46629541; Thu, 15 Feb 2018 21:29:27 +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 150E42953E for ; Thu, 15 Feb 2018 21:29:27 +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=34hkgze5bcV8XZqY/YO9ROGJUo2OSjw6sdoj+/pzzYQ=; b=Qva9L8JNIJt8l9IE2Bi7wOiRV8 OsHGl/Y1cPYy13HRmv5eoIQpQTmI27DUhWfKhN9xiojCTsF420u9ThSni4WQFL8e9D1RzwCxz2x+T ZITyHFziQMqWkQ6aPUmHvB+iSqSaIlanhz+mMDz7RfOejsFPG3oTvLVXY7WjsCUStNyQTP2n479Ai jMe5gm8xeKtUYRmB3KKnrhlabCVGSQU/n5zLYOE4Qdd0gCMOFtDXZBeZcZvtPbgDSjS1x91dvR0xf 9ud/BBgELkF4pZZ8RihhKm8iXwnAv+P2omohu/OsST216godIdIP99ngEx7UdrqXLHFlUT2oSiPTr ySfaV96w==; 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 1emR5V-0004j5-Id; Thu, 15 Feb 2018 21:29:05 +0000 Received: from mail-wm0-f68.google.com ([74.125.82.68]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1emQi5-0000X6-9Q for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2018 21:05:47 +0000 Received: by mail-wm0-f68.google.com with SMTP id k87so3314313wmi.0 for ; Thu, 15 Feb 2018 13:04:43 -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=3GXfGKNUqFobi9d3HQHD0fd1r65t8RaKej2jdp5JVpA=; b=f+ysyVmFY7UT3QYbSqFVDulEK/U1cLyfdK74/BlpbKCWz9QSMa0RSRgFRcK3FFlj3k 8XBrk17f0ym2x5fwSVlXtICq5h74DmPFOKr5R35+ht9YkjJSgK4IoOBZx95TffpGuxdT dFZoFikUhOY7FKi+Vr+U31Pt0eGpwManarNkk= 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=3GXfGKNUqFobi9d3HQHD0fd1r65t8RaKej2jdp5JVpA=; b=FHzX0Qg88WryJ2+CeTYKIn5MXLxFthw2zcFHMiMgqr/a4t3+w0LLieQKRAK9L0a+ps 1wgX+pYagpejfRJ1/izB+xGx5nU9vpA2tHmPxmI/LuXZ1IaMfisoB/RpboR0p1GCTIU6 L5J2od4Q6CZNx/lqWNyRdyhSN0deWvcUOd6Vj/dVaVjAyGqhvAimYTeKf4DkUmdw5PqL 4pZ3/SgK1Z2d7y0a8punSo3hc6r4FwrAkK8ZgG0N8LKLyTezrOrEw+TCgVPfnvXSRXjQ MnUjxAyLzW+EKtkT1qnnb4BVKQW2ZtKoiAegD8aLtPRisqGHZowUHhu2RpI1VJ0zQiK6 ROnw== X-Gm-Message-State: APf1xPA9y8QBMxjyv6ie0hUgz8x83Kqa+fqLjhaNdJlxdg5jjT02fI6w pXTNIo8uF6zgeQaYaFbaJ+eVBA== X-Google-Smtp-Source: AH8x225BdpYyW8K0z8dRDeVDlBgcCpvhquKyG7tdn36b2FaEdIP65hmtOE8NIXJ+zD/Yg8m1rkXtAA== X-Received: by 10.80.214.8 with SMTP id x8mr5029425edi.129.1518728681252; Thu, 15 Feb 2018 13:04:41 -0800 (PST) Received: from localhost.localdomain (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id p55sm8220030edc.15.2018.02.15.13.04.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Feb 2018 13:04:40 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v4 34/40] KVM: arm64: Cleanup __activate_traps and __deactive_traps for VHE and non-VHE Date: Thu, 15 Feb 2018 22:03:26 +0100 Message-Id: <20180215210332.8648-35-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180215210332.8648-1-christoffer.dall@linaro.org> References: <20180215210332.8648-1-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180215_130453_551464_474AC96A X-CRM114-Status: GOOD ( 13.86 ) 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 , Christoffer Dall , 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 To make the code more readable and to avoid the overhead of a function call, let's get rid of a pair of the alternative function selectors and explicitly call the VHE and non-VHE functions using the has_vhe() static key based selector instead, telling the compiler to try to inline the static function if it can. Signed-off-by: Christoffer Dall Reviewed-by: Andrew Jones --- arch/arm64/kvm/hyp/switch.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 5e94955b89ea..0e54fe2aab1c 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -85,7 +85,7 @@ static void __hyp_text __deactivate_traps_common(void) write_sysreg(0, pmuserenr_el0); } -static void __hyp_text __activate_traps_vhe(struct kvm_vcpu *vcpu) +static inline void activate_traps_vhe(struct kvm_vcpu *vcpu) { u64 val; @@ -97,7 +97,7 @@ static void __hyp_text __activate_traps_vhe(struct kvm_vcpu *vcpu) write_sysreg(kvm_get_hyp_vector(), vbar_el1); } -static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu) +static inline void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu) { u64 val; @@ -108,11 +108,7 @@ static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu) write_sysreg(val, cptr_el2); } -static hyp_alternate_select(__activate_traps_arch, - __activate_traps_nvhe, __activate_traps_vhe, - ARM64_HAS_VIRT_HOST_EXTN); - -static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) +static inline void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) { u64 hcr = vcpu->arch.hcr_el2; @@ -122,10 +118,13 @@ static void __hyp_text __activate_traps(struct kvm_vcpu *vcpu) write_sysreg_s(vcpu->arch.vsesr_el2, SYS_VSESR_EL2); __activate_traps_fpsimd32(vcpu); - __activate_traps_arch()(vcpu); + if (has_vhe()) + activate_traps_vhe(vcpu); + else + __activate_traps_nvhe(vcpu); } -static void __hyp_text __deactivate_traps_vhe(void) +static inline void deactivate_traps_vhe(void) { extern char vectors[]; /* kernel exception vectors */ write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2); @@ -133,7 +132,7 @@ static void __hyp_text __deactivate_traps_vhe(void) write_sysreg(vectors, vbar_el1); } -static void __hyp_text __deactivate_traps_nvhe(void) +static inline void __hyp_text __deactivate_traps_nvhe(void) { u64 mdcr_el2 = read_sysreg(mdcr_el2); @@ -147,11 +146,7 @@ static void __hyp_text __deactivate_traps_nvhe(void) write_sysreg(CPTR_EL2_DEFAULT, cptr_el2); } -static hyp_alternate_select(__deactivate_traps_arch, - __deactivate_traps_nvhe, __deactivate_traps_vhe, - ARM64_HAS_VIRT_HOST_EXTN); - -static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) +static inline void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) { /* * If we pended a virtual abort, preserve it until it gets @@ -162,7 +157,10 @@ static void __hyp_text __deactivate_traps(struct kvm_vcpu *vcpu) if (vcpu->arch.hcr_el2 & HCR_VSE) vcpu->arch.hcr_el2 = read_sysreg(hcr_el2); - __deactivate_traps_arch()(); + if (has_vhe()) + deactivate_traps_vhe(); + else + __deactivate_traps_nvhe(); } void activate_traps_vhe_load(struct kvm_vcpu *vcpu)