Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp876421pxb; Thu, 31 Mar 2022 21:17:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx791VAm2Lg+2M37QuzZrdnhTctdihQG9DHoI8oKAzhXLPOL5+7yAFw4p/cEwdXg5pPoy7i X-Received: by 2002:a17:907:9495:b0:6da:9602:3ec6 with SMTP id dm21-20020a170907949500b006da96023ec6mr7643261ejc.589.1648786628927; Thu, 31 Mar 2022 21:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648786628; cv=none; d=google.com; s=arc-20160816; b=pIrLB4BhSbIYIsWWnXS/b4FcPdEWA4in6GK1PKKF15ltLkpbvBtc2vOxscEWnoe3/W wItz7uhXMIdNMQF2mR07mXd9bkLbrNOpMzWLrnIWW79ftABvRraUMEDIzgQKfL5eD/q2 GCKPKuAzNZ7EYhg9ncy8XGLESGuMTh+QrIHdPfCfm9pGuSXcIxJmO8VVpNRto4VBr4kA b5p7VxLEVR3btHavLVARf5ASeZRjbNXdPqrTFkzfDBsG/+5hU7xKYa2Z+Itl8HOt0gZD dQXS1Z+f4vqpb1Sw52GgKsdwIC8PiAnI4cVPDEZwOdG8sY3U4pr6iF1bhQEchiT+qqdc 9Xyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=q/A+wI/NZTn3H0wfAYMgx9HBl9K9e0GlWESwyeKIpkI=; b=uNThkX7DxjJWVmL6JCg+qeuYzpUHPJeebUXDOGhzGAYPtmKjmTBBG3fuUdGcO/E0/r oOvF4NubvW6zosrcFhqGx4avKvTvHT4At3nZvG/zmZ0mu6GEC1rsZ8F/N13y/eGCrqbJ lS0mkp1U+nyHPyOOBasSLwv0s2R9p0oJDm16hdCs+IEBGIcYTtErTsg3sYnwfYhpgnLf VpH6xzkl0RM82Iqrxb9zjHfPDktz1MJPpK6ro9Uf2z0ahRr9MeUSD8TQpQPr0uhafa/E 2js9vC4XEzTswHzr4C4ROsxgeWEBg3Fi1WLe7wGibEGsXs4HRSCoVzyEswbh752n06aJ hX0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z8-20020a05640240c800b00418c2b5bdb2si996231edb.148.2022.03.31.21.16.31; Thu, 31 Mar 2022 21:17:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237600AbiCaShz (ORCPT + 99 others); Thu, 31 Mar 2022 14:37:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235565AbiCaSgf (ORCPT ); Thu, 31 Mar 2022 14:36:35 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2769521046D; Thu, 31 Mar 2022 11:34:47 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E580513D5; Thu, 31 Mar 2022 11:34:46 -0700 (PDT) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4818A3F718; Thu, 31 Mar 2022 11:34:46 -0700 (PDT) From: James Morse To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.14.274 20/27] arm64: entry: Add macro for reading symbol addresses from the trampoline Date: Thu, 31 Mar 2022 19:33:53 +0100 Message-Id: <20220331183400.73183-21-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220331183400.73183-1-james.morse@arm.com> References: <20220331183400.73183-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit b28a8eebe81c186fdb1a0078263b30576c8e1f42 upstream. The trampoline code needs to use the address of symbols in the wider kernel, e.g. vectors. PC-relative addressing wouldn't work as the trampoline code doesn't run at the address the linker expected. tramp_ventry uses a literal pool, unless CONFIG_RANDOMIZE_BASE is set, in which case it uses the data page as a literal pool because the data page can be unmapped when running in user-space, which is required for CPUs vulnerable to meltdown. Pull this logic out as a macro, instead of adding a third copy of it. Reviewed-by: Catalin Marinas [ Removed SDEI for stable backport ] Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index caf6f9cb8fd6..4fe25954fbb0 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1022,6 +1022,15 @@ alternative_else_nop_endif sub \dst, \dst, PAGE_SIZE .endm + .macro tramp_data_read_var dst, var +#ifdef CONFIG_RANDOMIZE_BASE + tramp_data_page \dst + add \dst, \dst, #:lo12:__entry_tramp_data_\var + ldr \dst, [\dst] +#else + ldr \dst, =\var +#endif + .endm #define BHB_MITIGATION_NONE 0 #define BHB_MITIGATION_LOOP 1 @@ -1052,13 +1061,8 @@ alternative_else_nop_endif b . 2: tramp_map_kernel x30 -#ifdef CONFIG_RANDOMIZE_BASE - tramp_data_page x30 alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 - ldr x30, [x30] -#else - ldr x30, =vectors -#endif + tramp_data_read_var x30, vectors prfm plil1strm, [x30, #(1b - \vector_start)] msr vbar_el1, x30 isb @@ -1138,7 +1142,12 @@ END(tramp_exit_compat) .align PAGE_SHIFT .globl __entry_tramp_data_start __entry_tramp_data_start: +__entry_tramp_data_vectors: .quad vectors +#ifdef CONFIG_ARM_SDE_INTERFACE +__entry_tramp_data___sdei_asm_trampoline_next_handler: + .quad __sdei_asm_handler +#endif /* CONFIG_ARM_SDE_INTERFACE */ .popsection // .rodata #endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ -- 2.30.2