Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp624106pxp; Sat, 19 Mar 2022 11:59:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH89/MNqOAUekC1GbsGxjjf1eQTbwwm+uacRZIrIenmayU0hwMXeEjP9z/q0rcwRYS+4pu X-Received: by 2002:a17:907:8688:b0:6d2:c19:e1a0 with SMTP id qa8-20020a170907868800b006d20c19e1a0mr13542206ejc.249.1647716342747; Sat, 19 Mar 2022 11:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647716342; cv=none; d=google.com; s=arc-20160816; b=qbwnbJ7rdmdOVVqz2dc42/7OD2Wx50iai5lxVT5ljYwp5tQFzSAVbxggsB5ANojWc7 +LD9Z1RyAs/Z2lR1Ja0q2UEbyGUf+men4xyPZpGvPeu6wDaG0DyYVYe1WYo5ePpq3gr+ V2jld+6ys285+pWaqfF1ZZHuwEg4bAdtIUdGSbKhO44RxlDfQZQbm8zXAYb8JeqFf2+D jdfC48Rlky/Rj54nVbdlRdVWThssi39y43uEZVD8f1GP0kO/ZC8+VMGBwOFpJFELaO95 N3Gmj4JR68SB1PC0YAfpt5eSi5UtRfvvTwR0aG0PjY2e3EtBT0WAhoQSNvMciA8lhxgR yFkQ== 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=x5uqInPrOudqs0SLNZEt1YP8gwnTQUN7sy4/Na0ISM8=; b=Q4p4XQvJn45fYdnQqXnrMD8t55ub2PEzgm/nFV0emYyA0HmPPcHvCO339AD4A6UPt1 WkiKL9Ef+PfyKEj9gKU28kTvJUQfVDfPBc01/VCIdsGs6y7ljHmeJuCv45YLHW5M/jsG IgLmkSFD+kKHaU4zz2h9w729a3tQdwMdMy7ehQVuWj9GnAnE+8AKv1CShtd8wthxE0ae A5g9z9bRK8/vGvng8obUiV2pn7XIC1nc3tvLY6JCO9Y3/MBbbe9J3Z00RDTAG7mxwSOY 1as7uOm5CzTCl/WrBAGJmtg1syqf5efftmGD6BZJHjAtq7550pdFbP3NmRCPyh1hnoCG iNvQ== 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 23-20020a170906011700b006df76385ba1si3755057eje.65.2022.03.19.11.58.17; Sat, 19 Mar 2022 11:59:02 -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 S239941AbiCRRvl (ORCPT + 99 others); Fri, 18 Mar 2022 13:51:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239838AbiCRRvH (ORCPT ); Fri, 18 Mar 2022 13:51:07 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA96317DC85; Fri, 18 Mar 2022 10:49:40 -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 875D91515; Fri, 18 Mar 2022 10:49:40 -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 DBC163F7B4; Fri, 18 Mar 2022 10:49:39 -0700 (PDT) From: James Morse To: stable@vger.kernel.org Cc: linux-kernel@vger.kernel.org, james.morse@arm.com, catalin.marinas@arm.com Subject: [stable:PATCH v4.19.235 08/22] arm64: entry: Allow tramp_alias to access symbols after the 4K boundary Date: Fri, 18 Mar 2022 17:48:28 +0000 Message-Id: <20220318174842.2321061-9-james.morse@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220318174842.2321061-1-james.morse@arm.com> References: <20220318174842.2321061-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 6c5bf79b69f911560fbf82214c0971af6e58e682 upstream. Systems using kpti enter and exit the kernel through a trampoline mapping that is always mapped, even when the kernel is not. tramp_valias is a macro to find the address of a symbol in the trampoline mapping. Adding extra sets of vectors will expand the size of the entry.tramp.text section to beyond 4K. tramp_valias will be unable to generate addresses for symbols beyond 4K as it uses the 12 bit immediate of the add instruction. As there are now two registers available when tramp_alias is called, use the extra register to avoid the 4K limit of the 12 bit immediate. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas Signed-off-by: James Morse --- arch/arm64/kernel/entry.S | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 1df718f53a1f..5d174c119563 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -135,9 +135,12 @@ .org .Lventry_start\@ + 128 // Did we overflow the ventry slot? .endm - .macro tramp_alias, dst, sym + .macro tramp_alias, dst, sym, tmp mov_q \dst, TRAMP_VALIAS - add \dst, \dst, #(\sym - .entry.tramp.text) + adr_l \tmp, \sym + add \dst, \dst, \tmp + adr_l \tmp, .entry.tramp.text + sub \dst, \dst, \tmp .endm // This macro corrupts x0-x3. It is the caller's duty @@ -362,10 +365,10 @@ alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 bne 4f msr far_el1, x29 - tramp_alias x30, tramp_exit_native + tramp_alias x30, tramp_exit_native, x29 br x30 4: - tramp_alias x30, tramp_exit_compat + tramp_alias x30, tramp_exit_compat, x29 br x30 #endif .else @@ -1265,7 +1268,7 @@ alternative_if_not ARM64_UNMAP_KERNEL_AT_EL0 alternative_else_nop_endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 - tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline + tramp_alias dst=x5, sym=__sdei_asm_exit_trampoline, tmp=x3 br x5 #endif ENDPROC(__sdei_asm_handler) -- 2.30.2