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: 10244921 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 496BF60208 for ; Tue, 27 Feb 2018 11:40:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D62328845 for ; Tue, 27 Feb 2018 11:40:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 321FC28852; Tue, 27 Feb 2018 11:40: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 A0A8F28845 for ; Tue, 27 Feb 2018 11:40: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=hIapgpYh4anIh4DI4YNOW/O7tz+QxIE8yNq1KbE7P3w=; b=No9ke2Vig1qx3RYMyrmHsJi3tE gXYIEbeTcnfbrXYT8LztGZKx3+AvM4YJKaFUTMoPlIZ6WpwchSkwYGFDkcoXqu45LLmIe30+RX7hl 3YM2Vxte19czl0OOTP0YQKrkJY9v4mkXSBCO3F45c/1gDntjCjgawdyAWAtZpsBfMhtiU+8+fvyDz Cam4pSacTAIlVK4Ovex+gFvu2jmcw6maAMRm03X2HPSBk1d7t1QcASbUSuAZuRkpaG6IxSqZrLz4o Src8zNLXL/LzNx5/ywmnXUJBFjwD0hp76kpsqh9SKea6uXRx+Al0LKCQ/sCkqRdczL/RFsQyT+k08 CI6IIMug==; 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 1eqdcV-00037N-GF; Tue, 27 Feb 2018 11:40:31 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqdXf-0007U4-EM for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 11:35:47 +0000 Received: by mail-wm0-x242.google.com with SMTP id z9so23020235wmb.3 for ; Tue, 27 Feb 2018 03:35:21 -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=PaBlCl29SJXbHDmhgrXhd8zT8TPGhxgjS9pBc9MwvZ/y8y/jEAjO3t71TXRyWwsLTz BrgD91apgEKRi3eOOxjLCP7uU25pbx5l/MLuGJyy1pKAgHluGicf0Y7pQPBEa1tss7sa NFIfe8cKil9LJZFT0tQjIJIqbz1snMSymmEJ6EGk9H/2ZWbYklfOd1oenTYESKMMKmVh wZ8aBhPYm94wOyC4MecsA7ABY6taR+8/E14fHWs4VIR3L0tT1gx73IqEMxQKNDANGkAU +2PBn/Q6Lu5cSG12XfBrBQyFdwkYx3ACUfNLhLqc0yRkoyj5+H4GykkKOPdOteCXfxht DRKA== X-Gm-Message-State: APf1xPCZTSisH/R+ZN/FzyDPcU4Mp0tN/WYXZzRVvQcdAW5BpSYipLAw 2aHBYXuwaZl42j1OzqEvCWSQCw== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180227_033532_205543_12B85733 X-CRM114-Status: GOOD ( 14.68 ) 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 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)