From patchwork Tue Feb 27 11:34: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: 10244863 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 EFB8460208 for ; Tue, 27 Feb 2018 11:35:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4C7928833 for ; Tue, 27 Feb 2018 11:35:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D939928846; Tue, 27 Feb 2018 11:35:29 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D89928833 for ; Tue, 27 Feb 2018 11:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753150AbeB0Lf1 (ORCPT ); Tue, 27 Feb 2018 06:35:27 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:37110 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753120AbeB0LfV (ORCPT ); Tue, 27 Feb 2018 06:35:21 -0500 Received: by mail-wm0-f67.google.com with SMTP id 139so10000003wmn.2 for ; Tue, 27 Feb 2018 03:35:20 -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=t8ZWB/byuwIgOXivDRrGW6RtqjO9Zci4wmnd1SUt5ww=; b=GLlLEkTbf1PNwifYChMet7S8SVHxihHNbJIsh8069rASiXv7sdeYbwz9THG6gDTePC revJTSNR1bWvm9zaKXFNt8wx1qt4Y8O/Z/K53fJtl7eMkb7of8zrEgMFFDc2pXjw5ACe dwj4o1NvDFFde9gxutC4+itLCF5vN7JSmHfY+kjxw6W9Bt6PhFq1KX1arnAKrg+u4Q0q RzndaJlC9uQ/J9D8r9FBoKnAStwwgJdY3eVSQIkRlaPcn3xy7KrVUA19wOy+Zp5AMLFr 6KsXeZFvaVPHqpufuUH4lAg7pB1qdNS1uYLXnqmrKy5hRRUDgTf26Ufd+2X9aSrY4q/R 2hWw== 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=t8ZWB/byuwIgOXivDRrGW6RtqjO9Zci4wmnd1SUt5ww=; b=LsY6dyaQqAevaG0jZQme+dlXtgthoacE3gkx8yPjg+wjrAoV/nZy/N5vsUPEeUZmqG dsZ4CACMfIDmVFUe3i14UMBJ8qQo/1Kz7ufgx/4Ylak9YCCJpItNHdxTmdRzW3uOyG6I L7EGoe/xyqSfhxUHx60lTD8eNYS5GSy/mT0344+hrJRIXxL/DU/wjGymGr7ap+m0w/TM exESeaBWElvG29jaqHzqByfmo/wSDo0OcJVL9dXJ7XVBnPGwSBMAqMsstZWW5UcdoSPX YxgUyqv0+oncpuCoMptnaLQeVealIPN7wpYfReHe1O8WehOisyaFTMwsM2KWWBe/amwg m98Q== X-Gm-Message-State: APf1xPA0iLyG//9su5N0R4brc2kOjmo10D575qVcmuA0QVQf6Ozvb4ps /zUVD8YRWP1dVBc59I4h+GUuzg== X-Google-Smtp-Source: AH8x226Pjn3e7D4i8oGbNXX9qrqPw9qAfzJUVKyR+iXmCfDGwwabxDbZZWZiKgf9GwiKbrmZaGNqwg== X-Received: by 10.80.140.184 with SMTP id q53mr18338654edq.17.1519731319961; Tue, 27 Feb 2018 03:35:19 -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.35.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 27 Feb 2018 03:35:18 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: kvm@vger.kernel.org, Marc Zyngier , Andrew Jones , Shih-Wei Li , Dave Martin , Julien Grall , Tomasz Nowicki , Yury Norov Subject: [PATCH v5 34/40] KVM: arm64: Cleanup __activate_traps and __deactive_traps for VHE and non-VHE Date: Tue, 27 Feb 2018 12:34:23 +0100 Message-Id: <20180227113429.637-35-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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoffer Dall 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. Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall --- Notes: Changes since v4: - Removed inline attributes from static functions in arch/arm64/kvm/hyp/switch.c arch/arm64/kvm/hyp/switch.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index eab433fa1442..67c66b4e237e 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -86,7 +86,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 void activate_traps_vhe(struct kvm_vcpu *vcpu) { u64 val; @@ -109,10 +109,6 @@ 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) { u64 hcr = vcpu->arch.hcr_el2; @@ -123,10 +119,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 void deactivate_traps_vhe(void) { extern char vectors[]; /* kernel exception vectors */ write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2); @@ -148,10 +147,6 @@ 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) { /* @@ -163,7 +158,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)