From patchwork Tue Sep 22 20:49:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11793085 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 28E63112E for ; Tue, 22 Sep 2020 20:50:31 +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 E5E12235FD for ; Tue, 22 Sep 2020 20:50:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="IY74UzYu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="KYMM1B96" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5E12235FD 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=J+0xTlLYPjeirw467Zl7PWEYmlBDUbWFhYLerrPmQ5E=; b=IY74UzYuT1HwggSwdTB38CgKb th1yK/8Vl+DxZ7miu04jfbdVuaBEf3RU1ozoV8GDjZuSnG48bJinyFSsO/ieVHkXy9VsHAF4xC5nf UIafomllpZvUy7899rcFAncun2OyLlFM4eS2JTISIVfe327dOKPGAFr8o4RL9z/xj7VUoq1uo9c5U W/3p5AUDOJdCKKdH669mZCwzPlpERHwulA/mIUIaaM/hwJqmT0zG4KOoEDcFXy9DnstudWo932aPr VObljZ+IBQIrtuY7KVXFxXH9mXEFWrKhhm6+jrAfBML0vsgBttTJ3zBkmD1MxNG68uTqdUpxnpOIB CTifCwo5A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKpEn-00062d-BI; Tue, 22 Sep 2020 20:50:09 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKpE3-0005re-37 for linux-arm-kernel@lists.infradead.org; Tue, 22 Sep 2020 20:49:24 +0000 Received: by mail-wr1-x444.google.com with SMTP id w5so18577052wrp.8 for ; Tue, 22 Sep 2020 13:49:22 -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=4owpoQA0YZkU55g3xZqB0P4GXzrY6zfnXz2TqZZIyZ0=; b=KYMM1B96Jv7z2OSW2J1SxoT0oCmfO8gzdOG3M1m8MGUzXriMClxvjHa/SFXuKswpCm RXSDpcMVpydS7yQvsSinqKRB4luwMTtxl9yqngeD3k1qPCwL1tyaO6lZDQwcOBnmvohX u3CxFJrBb5HXhwlotYXSVREXOiEaAsCN8mVf/eDVM2sXPVh5UmS3JoU8JdJtDXU9b8y/ yIzBCfYtb7WXokc+pb7TdoScbplDeCH0U9QuIDyYx2LfgAkMx9l7SpOD6T0AUzSp2jj0 jPoMAfE1qHyVwF5n11jwIJ2KZ0DPEPFe37y2qMCLi5Mq5zD5r7MgYvB3/9Ocys280cNY VrnQ== 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=4owpoQA0YZkU55g3xZqB0P4GXzrY6zfnXz2TqZZIyZ0=; b=DcEVwCYKXFb6FN7dyLm/1ksbMaQKlf3SOlzMV97bfGUzhpmOO+Se84Vc3XJRvilzzK BNkypN4f5akohM8d/087y589KU0adL/lkzHYz5Lbbs3Fzzov1Y6x6BKB1sNYRtmLiUCQ Icb7a7Ciwgqy8ujWEZE/Z3s3IGYT27BbeZTkcVgUlM6XJ2oftYfktpmAYln4q+pWr3mz RHnlFRHNq7a7yKgILgoIsDDczvVmYEiDwZ5/+FE/0tViOlbq+/D+lnKBTW0GmEH3pgsW /jFsOWuRXLC4tYIOU3bBLDRmDZkCPALpMFqaE3kyY3t8x94/3AV0snobMAJSZsiQWeyJ Nv1w== X-Gm-Message-State: AOAM530Mc3E2E337LbsI540H5MnhZoJxyScUkO2D288D9eZlY3QZnqcF qCJE/dfqaHlhzhel+GDAl4YHbQ== X-Google-Smtp-Source: ABdhPJxX9uBzSAKnJBAmtj/fHGztbwr3USOr+K3MXcKDIWkd6igzfbo8A1qOGNiBRh7RnslToVGEkg== X-Received: by 2002:a5d:4dcb:: with SMTP id f11mr5757666wru.163.1600807761459; Tue, 22 Sep 2020 13:49:21 -0700 (PDT) Received: from localhost ([2a01:4b00:8523:2d03:1105:630f:e990:272f]) by smtp.gmail.com with ESMTPSA id y207sm6365851wmc.17.2020.09.22.13.49.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 22 Sep 2020 13:49:20 -0700 (PDT) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [PATCH v4 05/10] kvm: arm64: Remove hyp_adr/ldr_this_cpu Date: Tue, 22 Sep 2020 21:49:05 +0100 Message-Id: <20200922204910.7265-6-dbrazdil@google.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200922204910.7265-1-dbrazdil@google.com> References: <20200922204910.7265-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200922_164923_295667_C9457F3E X-CRM114-Status: GOOD ( 14.83 ) 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:444 listed in] [list.dnswl.org] -7.5 USER_IN_DEF_SPF_WL From: address is in the default SPF white-list -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -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_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 trust 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 Acked-by: Will Deacon Signed-off-by: David Brazdil --- arch/arm64/include/asm/assembler.h | 29 +++++++++++++++++++---------- arch/arm64/include/asm/kvm_asm.h | 14 +------------- arch/arm64/kvm/hyp/hyp-entry.S | 2 +- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 54d181177656..86e0ef79a799 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -218,6 +218,23 @@ lr .req x30 // link register str \src, [\tmp, :lo12:\sym] .endm + /* + * @dst: destination register (32 or 64 bit wide) + */ +#if defined(__KVM_NVHE_HYPERVISOR__) || defined(__KVM_VHE_HYPERVISOR__) + .macro this_cpu_offset, dst + mrs \dst, tpidr_el2 + .endm +#else + .macro this_cpu_offset, dst +alternative_if_not ARM64_HAS_VIRT_HOST_EXTN + mrs \dst, tpidr_el1 +alternative_else + mrs \dst, tpidr_el2 +alternative_endif + .endm +#endif + /* * @dst: Result of per_cpu(sym, smp_processor_id()) (can be SP) * @sym: The name of the per-cpu variable @@ -226,11 +243,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 +254,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