Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211777pxb; Wed, 6 Apr 2022 11:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy6ZncOfDD76KmJdxOBfx1XKNwUGeVd9Rb5bnIKMiYnP4EkxWtJ177SAbOHVlL83z+Jq47v X-Received: by 2002:a65:694c:0:b0:398:fd64:7422 with SMTP id w12-20020a65694c000000b00398fd647422mr7988279pgq.503.1649269593295; Wed, 06 Apr 2022 11:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269593; cv=none; d=google.com; s=arc-20160816; b=hzDdQ/z+HRF0bBf1jPfIDgfZVajU9677JHJSuhMb3iczY4UJdOKL9XueuP2hXu5L/+ zuzBC352QzJE9EQLjXlXRf3tWbJyDe0Obo+NZree83wXo+2+YQjqTnw9VsDMOnmtBA/d pbDxeB/eQlpzyVU7j+3qgRndfa+MAHncfuob2XdsL6lMijOQ+qKrfw97p6PXTRPJq9Ov fnRjHwkUyag8DSJjIJD3mBDTSqHqiZ34Z1z4y2kAMRjeCbqGL1Nap/ldbkAcvpSsg7R+ dcSoQXMdrAKEoirtnhLzMarThj7jRArxS+ZLl0qc4K+g2SFqQM5dn6tXbt0+99DrZzkp IbfQ== 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=qYSqJIOxazqe8mHnf4EYNLOhUW0aktT62W5mTUwjpn4=; b=FdpEDXuTBOjyViNFSPsQQRTMwEt3fP4PB8o+05EJ0uNinMChY7lLz1nU0rpiIsPrTv Rc7eqfRcaabiopruQCz/7Zbn2DAL0i6d5n/AhVxiU+UGmm0OI8NxVlO6WNA0oTd9Gt2t rRW/zHai36ZhaCxYxNahzkc+k1S8bsbVRACogRZMUqAUzOqufjbPaPt4Gn7r1eSS9TKk 1IC3ATEVCbzvtKCmsJJJEnwTODmqrsgk2y4BjAO+94b7psLCpi4nkvnLMzZy5t/nZIcT +hZC/KHkpVOHY/JEG79cx3Qk6v2eqtowQa+TwpqHTjVVWwfH00Yn9FEOh/d4QxxtSd7f etjQ== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b2-20020a170902b60200b001540e087684si16356949pls.24.2022.04.06.11.26.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:26:33 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 285D41BA44E; Wed, 6 Apr 2022 11:09:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240291AbiDFSLI (ORCPT + 99 others); Wed, 6 Apr 2022 14:11:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240109AbiDFSIW (ORCPT ); Wed, 6 Apr 2022 14:08:22 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 303FB1FCF7; Wed, 6 Apr 2022 09:46:35 -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 1754923A; Wed, 6 Apr 2022 09:46:35 -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 6A3FD3F73B; Wed, 6 Apr 2022 09:46:34 -0700 (PDT) From: James Morse To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: James Morse , Catalin Marinas Subject: [stable:PATCH v4.9.309 37/43] arm64: entry: Add macro for reading symbol addresses from the trampoline Date: Wed, 6 Apr 2022 17:45:40 +0100 Message-Id: <20220406164546.1888528-37-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406164546.1888528-1-james.morse@arm.com> References: <0220406164217.1888053-1-james.morse@arm.com> <20220406164546.1888528-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,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 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 | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 6e637315fd80..ec46c89759a8 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -921,6 +921,15 @@ __ni_sys_trace: 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 @@ -951,13 +960,7 @@ __ni_sys_trace: b . 2: tramp_map_kernel x30 -#ifdef CONFIG_RANDOMIZE_BASE - tramp_data_page x30 - isb - 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 @@ -1037,7 +1040,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