Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1676986pxp; Thu, 17 Mar 2022 14:16:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydP31H5g6RtM97u2qHYlCQVudg/SlSPPnlXtwYvaikfTy+2RWw9TwH4MFJUtwM0uJYlyic X-Received: by 2002:a63:511d:0:b0:381:7f41:a4f0 with SMTP id f29-20020a63511d000000b003817f41a4f0mr5175989pgb.265.1647551785634; Thu, 17 Mar 2022 14:16:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647551785; cv=none; d=google.com; s=arc-20160816; b=dyojgQOg1LjzxET4J0/eJRq59aSxsZRNdCJgwjvlPEEro6qFy4iJaL1fGqXghUCqD4 AYuXI/uH2XAhIdzQkjr3I8ISv4ThBb3RpsPMg3diNimCyTZPo3j9UhkOveDnD96Ogc3h 1+ALWnfH1JbuKbIGvbL979fJW2ydMbXnYylDYyYOFRlTu3TJdkhMrrnJ1suHRsnw4cth LkwT9JTiHNF2YVWt64jJlycEWLxfZRQGCiodFVXiyyUBTIfVIT548VGqr44Imz3xvbFU +xl1i8Ei03Ii4ix5fBv+eCFQje+tHHom9waVJ4uLgsW4z85yf1oW3/n6oz2tNKlvbUcE CMnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=njBL1mxoEng7tVDrEjek9QFtAEEhmO0f5Yln/xxwvDw=; b=cb/tHvi/tZMvZhfgW7BaW8n2s24iBrWPPr395LKsBC8F805V7KXK198hSUdHWpU5lB 4eFePufGzXLwaNbzmD494TOpzuPt73jihdQ4295qCKAUOwW7dcQoSQx6LOKTt5sOTpEh BLUBslohd0UuxthMFAcWFo2RhQDs6cG+WpmIW/RzMkM1Gh9M4yMd5v2O2NAp1WWhNMct gURiDjZdWCfcEqN/Nx8tIdwyXcE1zCEOsgHfNRMShiuWBXCeUvsImmepS1S7S8Y4xRt6 o71/dX6RKoaetwXBQ0OetfcT1h+f+DvUasU+yLHGbwYkjeQWModeJyCPM4KWFauXh0mX N0tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lXM8Orqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u27-20020a056a00099b00b004f75cf4036csi6350029pfg.15.2022.03.17.14.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 14:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lXM8Orqu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C74E11AF7F2; Thu, 17 Mar 2022 13:48:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbiCQUtZ (ORCPT + 99 others); Thu, 17 Mar 2022 16:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbiCQUtX (ORCPT ); Thu, 17 Mar 2022 16:49:23 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BCC41AA8E5; Thu, 17 Mar 2022 13:48:06 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id p8so7769404pfh.8; Thu, 17 Mar 2022 13:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=njBL1mxoEng7tVDrEjek9QFtAEEhmO0f5Yln/xxwvDw=; b=lXM8OrqufnEFzjbGiqqWqKBGx879TMVpq4VVaebGl/WM2lSF2X9FYJlXLdvfJKuQaG YQKdWFVaTCtyNLuDOpXLhyXgNeL5GJKiW8cIm4AT0q1TK4GU6owp6UQ2o+cZerBWC1jy fsit++BGImvQU2Qmyr5Zz85X7ZQgOLvB21OgXawVkuy8EGZfIP+yMqIrFGT7h4e5OTA9 20cy/iQaNLqpaUpw/KZuvTfvbh0pjAN0T1j1kBFQI9C/4et6L/d1bzIv5YW5u1HTM8Rl ew3NoNnSMhqh/+N5qJEDTqQLhpYpn68XZWKVP0NRXZRy/UqGG5tCbMwYApCJeQjm5Mz/ sseA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=njBL1mxoEng7tVDrEjek9QFtAEEhmO0f5Yln/xxwvDw=; b=5xaJ/H6Ywi1jFv+G4ejUV3mdCbqCwgexWHVVDgb4l/3E6/yXqt8d5MNEJQD1mG/f6p GRU3WgUxd8MeMReyEzYR2WdqNN8oQlouDFtlD2X5njd28zwMIbcQ8GiIST02qQODkGJ7 KZdAlVA7cr5SqDzM1hiOJwL4RqzXi3ghnvkfi1ljz9eCelu2bZHvz4Ma/Gt3LvmeGf0N W/3aAZVq0a/qbYBFm76CcMRPHtUa1pRU1sr/KDBCiRxMAI9lXW+Gn1NER29cqS1whu+K 3yrtBz4Z4f34OxYWp2S5Iw8OwYTWySiRNL64YdLhUh/gttF6IyNn/t3Yn7dc3ZB7iIYb lmlA== X-Gm-Message-State: AOAM531CJXMQ1EeY6u9jm6GTCYWT1vH2XrbGpN322qQ6P6HijdQ/ipZA UumARXnq+vOrIq93n8qwrjEHh8059tM= X-Received: by 2002:a63:7702:0:b0:382:24f1:b70f with SMTP id s2-20020a637702000000b0038224f1b70fmr1519933pgc.144.1647550086039; Thu, 17 Mar 2022 13:48:06 -0700 (PDT) Received: from [10.67.48.245] ([192.19.223.252]) by smtp.googlemail.com with ESMTPSA id oo17-20020a17090b1c9100b001bf0ccc59c2sm11038810pjb.16.2022.03.17.13.48.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 13:48:05 -0700 (PDT) Subject: Re: [PATCH 5.4 18/43] arm64: entry: Add macro for reading symbol addresses from the trampoline To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Catalin Marinas , James Morse , Sasha Levin References: <20220317124527.672236844@linuxfoundation.org> <20220317124528.180267687@linuxfoundation.org> From: Florian Fainelli Message-ID: <113e7675-4263-2a20-81d0-9634f03511d2@gmail.com> Date: Thu, 17 Mar 2022 13:48:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20220317124528.180267687@linuxfoundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 3/17/22 5:45 AM, Greg Kroah-Hartman wrote: > 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 This commit causes a linking failure with CONFIG_ARM_SDE_INTERFACE=y enabled in the kernel: LD .tmp_vmlinux.kallsyms1 /local/users/fainelli/buildroot/output/arm64/host/bin/aarch64-linux-ld: arch/arm64/kernel/entry.o: in function `__sdei_asm_exit_trampoline': /local/users/fainelli/buildroot/output/arm64/build/linux-custom/arch/arm64/kernel/entry.S:1352: undefined reference to `__sdei_asm_trampoline_next_handler' make[2]: *** [Makefile:1100: vmlinux] Error 1 make[1]: *** [package/pkg-generic.mk:295: /local/users/fainelli/buildroot/output/arm64/build/linux-custom/.stamp_built] Error 2 make: *** [Makefile:27: _all] Error 2 > --- > 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 */ > > /* > -- Florian