From patchwork Wed Sep 16 17:34:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11780265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 344FF14F6 for ; Wed, 16 Sep 2020 17:35:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED56B206A4 for ; Wed, 16 Sep 2020 17:35:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jMemZjWl"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qMakas/E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ED56B206A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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=hi+0kd2rMxa6788csJRYwSenAeBlPrlzXhRLVyjd8CA=; b=jMemZjWlqtJLnwIYcT5H2LVtp I5ktvBupY8yFg4CFz8s51Yj6MyeoeoolZnI1owkBq1xDIuOGsfH8Wy1ki1K2YwmEcSsC9UR8HrBty a+6Os2lr4XqS4yCJ7n5SztF8mpJIlIzcK0ItGI9bCbsFjlG+qWq8CadrTwUUPYbbZ4Y7mOwlrKOwr X8KA+S3dpNiFASQ5Uu78a2Bp4rESo0vEjmOATGGTGW48Vk8ktnHSz3w+Iu2YBRJBzHoqKIzTKA6ij 53ZGsoCKtHM3sSu4QD5/CsWu61Y4wio87bJnv8/DEv7gxW/HCmhjKPFf8dQo1xFtOPJRPcu9c2sU0 OXZo4Sb9g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIbKz-000115-KT; Wed, 16 Sep 2020 17:35:21 +0000 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIbKa-0000tQ-Ff for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 17:34:57 +0000 Received: by mail-wm1-x343.google.com with SMTP id b79so3886094wmb.4 for ; Wed, 16 Sep 2020 10:34:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9sgzGfpFFC64RJRg+974gui8xymUAlAMqzcpem+/CSY=; b=qMakas/EqU8sthwlgBLnrwvnZRAraVI8Sv8JwWPnUfgEnVzZJSdrtVHvMt1ezF7z7H A/CJWmbIe4J9dCW8b0LTLe7Heh9CPHI643HmQCBrpkULf8M+cEXiyc0+aQbcTDAsf1v2 +n07zinh1/QDVCzCcP9y2XRmwPgdEs1CXndG+Zomxw2gl8eA2cp9tt2bxanJ+/59hf2A /m/n28TEXQlZYX3OIhG9T3Sixf56usD+TjQZ/+zNIZJNqfbTjzC6ijgK3F9kXhjOrOS3 4yT1Toi0Q6lOvmlLPznvI5ROFnBl/KAiCFVY5WND4p3AsI8mQUEIZDynexktrozfT8Lx 0RGA== 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:mime-version:content-transfer-encoding; bh=9sgzGfpFFC64RJRg+974gui8xymUAlAMqzcpem+/CSY=; b=sp54GnpdpQN36FH2OLOljji7o0tylNaSkkhy3p9DsE6100e+SkEoktRh1gSnvStnQ7 /CRhHH9kUidYpGWRzRUmkVkc40aH3ICKXweGUYdEcVW+kHcEN5tF5KMB0K4gHIMOov2q HAd43nvkNVaCzqOAFSPI2+11InTcicue7RoXav680LR1bz532EnMNq/yAwx3kVgc2uT1 9MyLpj/wBqDxiW/ZGo49N68c+XzPSKJORcEfPOM2PXvgM2OJQbPBOEh9BR7eAiLbrPrw X9SeDzi1eGrA439cTsnMao1J0KbPBFsmkROcyWu7pjQ9VySaSIbNJBPkIU5/1ZUWl5Q6 fxaw== X-Gm-Message-State: AOAM533YfjL8y72raktv/u4xu03BDy8SKXvIWs7YU/mIEKy7fJUzsO6q RLZVZmnZxPAOaYB3qQO/6q4hpw== X-Google-Smtp-Source: ABdhPJxFj6X/hCuUE/N+733RQjEZLOd7n2vySf2bWA+cMRMhZxuMBy1BHCIG9TmmZ1mKvjjqjdC8yA== X-Received: by 2002:a7b:c192:: with SMTP id y18mr5703981wmi.108.1600277695176; Wed, 16 Sep 2020 10:34:55 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:e49d:f6be:d31b:ad3c]) by smtp.gmail.com with ESMTPSA id m1sm6108804wmc.28.2020.09.16.10.34.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 10:34:54 -0700 (PDT) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v3 05/11] kvm: arm64: Remove hyp_adr/ldr_this_cpu Date: Wed, 16 Sep 2020 18:34:33 +0100 Message-Id: <20200916173439.32265-6-dbrazdil@google.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916173439.32265-1-dbrazdil@google.com> References: <20200916173439.32265-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_133456_590698_DE3CBB1D X-CRM114-Status: GOOD ( 14.82 ) X-Spam-Score: -15.7 (---------------) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-15.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:343 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF white-list -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.5 ENV_AND_HDR_SPF_MATCH Env and Hdr From used in default SPF WL Match -0.0 DKIMWL_WL_MED DKIMwl.org - Medium sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-team@android.com, Suzuki K Poulose , Catalin Marinas , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Marc Zyngier , Tejun Heo , Dennis Zhou , Christoph Lameter , David Brazdil , Will Deacon , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The hyp_adr/ldr_this_cpu helpers were introduced for use in hyp code because they always needed to use TPIDR_EL2 for base, while adr/ldr_this_cpu from kernel proper would select between TPIDR_EL2 and _EL1 based on VHE/nVHE. Simplify this now that the hyp mode case can be handled using the __KVM_VHE/NVHE_HYPERVISOR__ macros. Acked-by: Andrew Scull Signed-off-by: David Brazdil Acked-by: Will Deacon --- arch/arm64/include/asm/assembler.h | 27 +++++++++++++++++---------- arch/arm64/include/asm/kvm_asm.h | 14 +------------- arch/arm64/kvm/hyp/hyp-entry.S | 2 +- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 54d181177656..f79231a0f949 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -218,6 +218,21 @@ lr .req x30 // link register str \src, [\tmp, :lo12:\sym] .endm + /* + * @dst: destination register (32 or 64 bit wide) + */ + .macro this_cpu_offset, dst +#if defined(__KVM_NVHE_HYPERVISOR__) || defined(__KVM_VHE_HYPERVISOR__) + mrs \dst, tpidr_el2 +#else +alternative_if_not ARM64_HAS_VIRT_HOST_EXTN + mrs \dst, tpidr_el1 +alternative_else + mrs \dst, tpidr_el2 +alternative_endif +#endif + .endm + /* * @dst: Result of per_cpu(sym, smp_processor_id()) (can be SP) * @sym: The name of the per-cpu variable @@ -226,11 +241,7 @@ lr .req x30 // link register .macro adr_this_cpu, dst, sym, tmp adrp \tmp, \sym add \dst, \tmp, #:lo12:\sym -alternative_if_not ARM64_HAS_VIRT_HOST_EXTN - mrs \tmp, tpidr_el1 -alternative_else - mrs \tmp, tpidr_el2 -alternative_endif + this_cpu_offset \tmp add \dst, \dst, \tmp .endm @@ -241,11 +252,7 @@ alternative_endif */ .macro ldr_this_cpu dst, sym, tmp adr_l \dst, \sym -alternative_if_not ARM64_HAS_VIRT_HOST_EXTN - mrs \tmp, tpidr_el1 -alternative_else - mrs \tmp, tpidr_el2 -alternative_endif + this_cpu_offset \tmp ldr \dst, [\dst, \tmp] .endm diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index c196eec25498..cf9456663289 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -173,20 +173,8 @@ extern char __smccc_workaround_1_smc[__SMCCC_WORKAROUND_1_SMC_SZ]; #else /* __ASSEMBLY__ */ -.macro hyp_adr_this_cpu reg, sym, tmp - adr_l \reg, \sym - mrs \tmp, tpidr_el2 - add \reg, \reg, \tmp -.endm - -.macro hyp_ldr_this_cpu reg, sym, tmp - adr_l \reg, \sym - mrs \tmp, tpidr_el2 - ldr \reg, [\reg, \tmp] -.endm - .macro get_host_ctxt reg, tmp - hyp_adr_this_cpu \reg, kvm_host_data, \tmp + adr_this_cpu \reg, kvm_host_data, \tmp add \reg, \reg, #HOST_DATA_CONTEXT .endm diff --git a/arch/arm64/kvm/hyp/hyp-entry.S b/arch/arm64/kvm/hyp/hyp-entry.S index 46b4dab933d0..fba91c2ab410 100644 --- a/arch/arm64/kvm/hyp/hyp-entry.S +++ b/arch/arm64/kvm/hyp/hyp-entry.S @@ -132,7 +132,7 @@ alternative_cb_end str x0, [x2, #VCPU_WORKAROUND_FLAGS] /* Check that we actually need to perform the call */ - hyp_ldr_this_cpu x0, arm64_ssbd_callback_required, x2 + ldr_this_cpu x0, arm64_ssbd_callback_required, x2 cbz x0, wa2_end mov w0, #ARM_SMCCC_ARCH_WORKAROUND_2