Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1272618pxp; Thu, 17 Mar 2022 06:27:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZlIrtVBT232ee4FysMxLFRrsJ5jLll49eFEbX1SsRGJBa34LlTdEhRYXIuUrQXfPBl6v3 X-Received: by 2002:a17:906:3cb1:b0:6ce:2a97:5ade with SMTP id b17-20020a1709063cb100b006ce2a975ademr4313358ejh.728.1647523658698; Thu, 17 Mar 2022 06:27:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647523658; cv=none; d=google.com; s=arc-20160816; b=rVGZMhOHhyrjc0h+8UGAkULNMc72DwkQ0vJBVKDiXa9Hxa2yuaMY7VMRXhumv0hjYn WAbgbhALnvicu4NuTPMHfP8ECXVhr1BOBHbrW6BUCkbXrxqL/h+bhL/fBB7IvujeHFiK AhPYkWuETf0MrZ1qioUXtHlsU9uMFgc9vKJ7mYB4ewoRSoTQ0wDkn1xPA6ogsieEpvEF n0Et8SkrJOuU8hKQlCccBsRZ/8ispTDnaYW8c2jA9rjDU2ozxIDy1kYx2aeEM+t+ETL9 MG+X6DTeXtTDahCuATdei3rfAIFxHXQy5SvJXPzyilbYqd+noOOSDXoMpzQlx04cbwJm I70Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VwVoAAz83vEKedEj24kXtMG1mLNBDejmfBW0pw+BvpY=; b=XGp7/EUn3ZtPvz6Dur+mwccHWQJPO3I9V13pctRYXJBlr5UPIRN1SZE2WaLXlTvtWX ShYOqwdEPO/N15oOOQ24ny1Y6h2Fui+aU7JWnh1UhpuTwjX+k5jbeDxGePy23vJwh8L1 X2HMrlGviS+Eedb05mwwpKYsKJfdc3xlyQlwpAU1JuN2lFoPQrqZJOitJj8mIiL3HvX3 Hg1H5bGho0yGBezFB0G+wUc2OUWbob1hv7szhT6BcKnJhPJrTW+fB2u9PVIO8pGXC7f/ g7D2SLODZ74ApgjrVOqycc9sN6wRqzhJpK78V1ELVFEnyq1xHMypLeFgZX6YE6xVmro3 XuLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m9dLRKtL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g11-20020a170906538b00b006df8069efe7si2740379ejo.145.2022.03.17.06.27.13; Thu, 17 Mar 2022 06:27:38 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=m9dLRKtL; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233771AbiCQMsa (ORCPT + 99 others); Thu, 17 Mar 2022 08:48:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233767AbiCQMsY (ORCPT ); Thu, 17 Mar 2022 08:48:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F310C1EFE05; Thu, 17 Mar 2022 05:47:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5BD3761228; Thu, 17 Mar 2022 12:47:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D60BC340E9; Thu, 17 Mar 2022 12:47:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647521225; bh=3bMaeI7+Rq15Ziv8tKIkksUrHYjkAOm2PbvHHdnCRMA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m9dLRKtLbzx0CbCW6Qa/34dCDEriSo6kOEtQKqcn8tcfb2L1zFr6YlFj9Qdfuwz0c VFhf4fVZ4EZgfz4EUKa1D+UFmuCfxT5hyP4fL0qXjfUgTEWgCO/MIePPKomvEwLKla 9ba+8mMmsWMEB9LK6ZyE56/aSBwIQcLrV0EDnG9I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , James Morse , Sasha Levin Subject: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline Date: Thu, 17 Mar 2022 13:45:29 +0100 Message-Id: <20220317124528.180267687@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220317124527.672236844@linuxfoundation.org> References: <20220317124527.672236844@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 From: James Morse 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 Signed-off-by: James Morse Signed-off-by: Sasha Levin --- arch/arm64/kernel/entry.S | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 14351ee5e812..e4b5a15c2e2e 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1063,6 +1063,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 @@ -1093,13 +1102,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 alternative_if_not ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM prfm plil1strm, [x30, #(1b - \vector_start)] alternative_else_nop_endif @@ -1183,7 +1187,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 */ @@ -1310,13 +1319,7 @@ ENTRY(__sdei_asm_entry_trampoline) */ 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] -#ifdef CONFIG_RANDOMIZE_BASE - tramp_data_page x4 - add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler - ldr x4, [x4] -#else - ldr x4, =__sdei_asm_handler -#endif + tramp_data_read_var x4, __sdei_asm_trampoline_next_handler br x4 ENDPROC(__sdei_asm_entry_trampoline) NOKPROBE(__sdei_asm_entry_trampoline) @@ -1339,12 +1342,6 @@ ENDPROC(__sdei_asm_exit_trampoline) NOKPROBE(__sdei_asm_exit_trampoline) .ltorg .popsection // .entry.tramp.text -#ifdef CONFIG_RANDOMIZE_BASE -.pushsection ".rodata", "a" -__sdei_asm_trampoline_next_handler: - .quad __sdei_asm_handler -.popsection // .rodata -#endif /* CONFIG_RANDOMIZE_BASE */ #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ /* -- 2.34.1