From patchwork Thu Nov 19 16:25:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Brazdil X-Patchwork-Id: 11918213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12B4EC63697 for ; Thu, 19 Nov 2020 16:27:13 +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 83A9422240 for ; Thu, 19 Nov 2020 16:27:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PZY6gcEa"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="KQDbQtOp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83A9422240 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+linux-arm-kernel=archiver.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=od/5sQN3hNT0IDb+GtZT8JOrzMJy3zkNe0hcJk403xM=; b=PZY6gcEadS6iH7bRe//nUTmAS +R62QBT98PXvBQNZczOJWzGEVZMJGIgJ98P6zrwJa/W2nehQveusdTxYieSucc6CR8EuwXx2BXaFs 9knCWKvU99i2IiHw1cmLHLeBRlA8XUXo8xHMWtffJcTnrOsv6xZPHoHW10IANg7IkmFfsK0VjH60O f6ibYS57mCu243C8HFN2WMzOG7Oe2VEShtiRcsoht1EN8bw/EczQAsZ2u0FUQSZKuLdUac+T60tWV NP6gEicxncQbqv8nRPD/cD0v2aNO/xNIhNdMghs4ON7sGQCFap7V1W34HwJlTwzqe+IWxUUfvy52j 1cEpEIIDA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfmlc-0004RD-EW; Thu, 19 Nov 2020 16:26:40 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kfml1-0004Eq-Bp for linux-arm-kernel@lists.infradead.org; Thu, 19 Nov 2020 16:26:04 +0000 Received: by mail-ed1-x542.google.com with SMTP id d18so6452714edt.7 for ; Thu, 19 Nov 2020 08:26:02 -0800 (PST) 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=Du1A1iohvYOXikNEv0tYZPkKvUMheyRm10QbPuVgnlA=; b=KQDbQtOpKGlA/mJE+IKXYs3nd9nRJy91CRVZ6hpu8lHeREkppXMaTHfErgzVmjd00n dxVTRWsn03RgwIp78LSBRmbwGjQ0Ysta0qEqtCYxX/Aw42cycA7Z3Si83t/T84oP7OjE XP2QIW0IKzQuuONquwHYq1b0lhWu0F8Ay88R5bcwanmVfL8zloykzAmLPzj3sF9L3pEz ye/en7DDEy9JnRLeJJSxVudY00hpdsmd9QPnBwGIvMPDqvaIhTalqmtNxOviEicwP+0m zd38ISBAid8iqz+ug7DqkjTEAbtMSaK/O/5zumXsM/LELNGvleSwfa5n36uwsTaZJlTv GajA== 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=Du1A1iohvYOXikNEv0tYZPkKvUMheyRm10QbPuVgnlA=; b=gdjfhBBVnJqBQ133xNONExrzToPvJi7PxS3ZVBiG6KgwzTT99CIo67qgrbLrkYqPYK AOfhE7GitcZKVo47Ks+cHIuke55ZaFB9G/nYf4G6jAPEfG5Rf7LC4JobpMSdvnMpVE1T DkNaIGZ3e0E0PYVdGPiW9fdE5ccj8UwhFiTE759BlZmnWCHIInFkotMpT4MP8TGs+nPH FDklCc9CI7Feae7tkY3Dg2Z90RC1ER1EH30UhXEMEv285zVFlWImsZlrl0d8edP2crge ady34i0YmCdqeUczg7Ym4Alq6cc6t7WDhC16IVLfOLkGdYWiK47iYb27wtp/jpBzJ8US 4jUw== X-Gm-Message-State: AOAM532G7IKftZh/2FZiPWYgLpS/7nDcho9B6bN9u4BKTJhGQ5oiC8AT xwgudTfkksVL4saBVBJa/GvEHA== X-Google-Smtp-Source: ABdhPJz+hVLzImDN1eqY0j2SdIgTYsByI/xefUNdZgBEv9BhBBzOHOWikqW/5dwv0rlHb5NhMij5fA== X-Received: by 2002:a50:cd09:: with SMTP id z9mr32082700edi.152.1605803161427; Thu, 19 Nov 2020 08:26:01 -0800 (PST) Received: from localhost ([2a01:4b00:8523:2d03:9843:cd3f:f36b:d55c]) by smtp.gmail.com with ESMTPSA id rn2sm58104ejb.94.2020.11.19.08.26.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Nov 2020 08:26:00 -0800 (PST) From: David Brazdil To: kvmarm@lists.cs.columbia.edu Subject: [RFC PATCH 6/6] kvm: arm64: Remove hyp_symbol_addr Date: Thu, 19 Nov 2020 16:25:43 +0000 Message-Id: <20201119162543.78001-7-dbrazdil@google.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201119162543.78001-1-dbrazdil@google.com> References: <20201119162543.78001-1-dbrazdil@google.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201119_112603_482783_6F61D7CB X-CRM114-Status: GOOD ( 20.09 ) 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: Mark Rutland , kernel-team@android.com, Suzuki K Poulose , Marc Zyngier , linux-kernel@vger.kernel.org, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , David Brazdil , Will Deacon , Ard Biesheuvel , Julien Thierry , Andrew Scull Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The helper was used to force PC-relative addressing in hyp code because absolute addressing via constant-pools used to generate kernel VAs. This was cumbersome and required programmers to remember to use the helper whenever they wanted to take a pointer. Now that hyp relocations are fixed up, there is no need for the helper any logner. Remove it. Signed-off-by: David Brazdil Acked-by: Ard Biesheuvel --- arch/arm64/include/asm/kvm_asm.h | 20 -------------------- arch/arm64/kvm/hyp/include/hyp/switch.h | 4 ++-- arch/arm64/kvm/hyp/nvhe/hyp-smp.c | 4 ++-- arch/arm64/kvm/hyp/nvhe/psci-relay.c | 4 ++-- arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c | 2 +- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h index 1a86581e581e..1961d23c0c40 100644 --- a/arch/arm64/include/asm/kvm_asm.h +++ b/arch/arm64/include/asm/kvm_asm.h @@ -203,26 +203,6 @@ extern void __vgic_v3_init_lrs(void); extern u32 __kvm_get_mdcr_el2(void); -/* - * Obtain the PC-relative address of a kernel symbol - * s: symbol - * - * The goal of this macro is to return a symbol's address based on a - * PC-relative computation, as opposed to a loading the VA from a - * constant pool or something similar. This works well for HYP, as an - * absolute VA is guaranteed to be wrong. Only use this if trying to - * obtain the address of a symbol (i.e. not something you obtained by - * following a pointer). - */ -#define hyp_symbol_addr(s) \ - ({ \ - typeof(s) *addr; \ - asm("adrp %0, %1\n" \ - "add %0, %0, :lo12:%1\n" \ - : "=r" (addr) : "S" (&s)); \ - addr; \ - }) - #define __KVM_EXTABLE(from, to) \ " .pushsection __kvm_ex_table, \"a\"\n" \ " .align 3\n" \ diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h index 84473574c2e7..54f4860cd87c 100644 --- a/arch/arm64/kvm/hyp/include/hyp/switch.h +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h @@ -505,8 +505,8 @@ static inline void __kvm_unexpected_el2_exception(void) struct exception_table_entry *entry, *end; unsigned long elr_el2 = read_sysreg(elr_el2); - entry = hyp_symbol_addr(__start___kvm_ex_table); - end = hyp_symbol_addr(__stop___kvm_ex_table); + entry = &__start___kvm_ex_table; + end = &__stop___kvm_ex_table; while (entry < end) { addr = (unsigned long)&entry->insn + entry->insn; diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-smp.c b/arch/arm64/kvm/hyp/nvhe/hyp-smp.c index ceb427aabb91..6870d9f3d4b7 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-smp.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-smp.c @@ -33,8 +33,8 @@ unsigned long __hyp_per_cpu_offset(unsigned int cpu) if (cpu >= ARRAY_SIZE(kvm_arm_hyp_percpu_base)) hyp_panic(); - cpu_base_array = (unsigned long*)hyp_symbol_addr(kvm_arm_hyp_percpu_base); + cpu_base_array = (unsigned long*)(&kvm_arm_hyp_percpu_base[0]); this_cpu_base = kern_hyp_va(cpu_base_array[cpu]); - elf_base = (unsigned long)hyp_symbol_addr(__per_cpu_start); + elf_base = (unsigned long)&__per_cpu_start; return this_cpu_base - elf_base; } diff --git a/arch/arm64/kvm/hyp/nvhe/psci-relay.c b/arch/arm64/kvm/hyp/nvhe/psci-relay.c index 313ef42f0eab..f64380a49a72 100644 --- a/arch/arm64/kvm/hyp/nvhe/psci-relay.c +++ b/arch/arm64/kvm/hyp/nvhe/psci-relay.c @@ -147,7 +147,7 @@ static int psci_cpu_suspend(u64 func_id, struct kvm_cpu_context *host_ctxt) * point if it is a deep sleep state. */ ret = psci_call(func_id, power_state, - __hyp_pa(hyp_symbol_addr(__kvm_hyp_cpu_entry)), + __hyp_pa(__kvm_hyp_cpu_entry), __hyp_pa(cpu_params)); release_reset_state(cpu_state); @@ -182,7 +182,7 @@ static int psci_cpu_on(u64 func_id, struct kvm_cpu_context *host_ctxt) return PSCI_RET_ALREADY_ON; ret = psci_call(func_id, mpidr, - __hyp_pa(hyp_symbol_addr(__kvm_hyp_cpu_entry)), + __hyp_pa(__kvm_hyp_cpu_entry), __hyp_pa(cpu_params)); /* diff --git a/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c b/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c index 8f0585640241..87a54375bd6e 100644 --- a/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c +++ b/arch/arm64/kvm/hyp/vgic-v2-cpuif-proxy.c @@ -64,7 +64,7 @@ int __vgic_v2_perform_cpuif_access(struct kvm_vcpu *vcpu) } rd = kvm_vcpu_dabt_get_rd(vcpu); - addr = hyp_symbol_addr(kvm_vgic_global_state)->vcpu_hyp_va; + addr = kvm_vgic_global_state.vcpu_hyp_va; addr += fault_ipa - vgic->vgic_cpu_base; if (kvm_vcpu_dabt_iswrite(vcpu)) {