Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1233388pxb; Fri, 1 Apr 2022 08:03:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXMupGBP80T2Q82icoc6DGppdP7BxWfnB/dPmdciJ4A8YtxVbQcKuH+9qz0Q9sIfUKdu1h X-Received: by 2002:a17:907:7f18:b0:6e4:c15e:772d with SMTP id qf24-20020a1709077f1800b006e4c15e772dmr164295ejc.511.1648825417501; Fri, 01 Apr 2022 08:03:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648825417; cv=none; d=google.com; s=arc-20160816; b=ylmrL73UXrqxjdI/4idqRVfRrp+3xi/yNrSz42pz7eiNpurC6LJuqDWgU2U/odJMys lhqQlEPIPn2GqhZxkbsA4xvpzwd0bFPtFpcBASAkX7Ak9M/NJaMxJ4VinR7HN9jft9kw Yce3ujlec7PkAC4NNUC0lKgOEg+XB4rPrVe4sFiqIolAXLYCQdGynNhp3j0UEREwhrfx g0B/7SVk/qRY9IMFyvqE4SPhmUUdtddK9CY7RUI0UDO8ZAuBZbBdRS1QGOtBp9F03UoM 74ZE8YlzdD/cJ3vRMorZHMtRjp+JVx+HAGnRpAmWeh5BUIDpZFk5p0zhaJijx0F1DDPG nx9Q== 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=TLco1FYZta70ZL71YtWEETN/5IHot+s/U8Am6GaYmt0=; b=Ulq5C+94689Plgk070qZdfQ9RBu/dGcRj4gWrAPUqljPvo9ygwjwPzQHltKo22lhxF Sd6TyMx3qBbbOOwAFZBokA8ByGKzaytWnu2/waqd8nldOoXk42LhPDeTHAw0VrONYWLO YASGtddWMSaEjSc1aQVzFPJcyhZpUdTKjpu9pVnz/HDXitid5lswwHqgZ9tG80eHwT0D X/CAHmZeos0xMijezZlJR4ZHpGVPNEmQB8bLNA0Y/oaIgEZZoUmyERdV+EQHUV6SFDw5 BcmXoUydM1x2CRWBt+BJsu4n9W0apqA9O91O4/2OroXdK4X+88DzeAnGVprpc3PA4SfX 68AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fhx0DSGs; 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 a15-20020a170906190f00b006df76385cf2si1119213eje.402.2022.04.01.08.03.08; Fri, 01 Apr 2022 08:03:37 -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=Fhx0DSGs; 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 S1343491AbiDAGll (ORCPT + 99 others); Fri, 1 Apr 2022 02:41:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343540AbiDAGkq (ORCPT ); Fri, 1 Apr 2022 02:40:46 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46D8726240C; Thu, 31 Mar 2022 23:37:53 -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 ams.source.kernel.org (Postfix) with ESMTPS id CB9EDB82273; Fri, 1 Apr 2022 06:37:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28D55C340EE; Fri, 1 Apr 2022 06:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648795070; bh=QoMA7WPqOL3wnygAOdmogxeiODTKbXXHaNER5vUfwAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fhx0DSGsAFNF9XAWmBj2kJGg3fM4O8InH+0WGvLIenmqGQsQWuhPlEDpW6bK+eiqO ypxzZJv5UdC1aC5ZL3OnTodXG7xPL3bE5OTs5pmu9Hp3ffri3L1gvGWPSqxRG961zF Cjap3ux2od5R9K2/b2xmN4lYpOw9zIfclyTULgco= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Russell King (Oracle)" , Catalin Marinas , James Morse Subject: [PATCH 4.14 12/27] arm64: entry: Move the trampoline data page before the text page Date: Fri, 1 Apr 2022 08:36:22 +0200 Message-Id: <20220401063624.581102144@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220401063624.232282121@linuxfoundation.org> References: <20220401063624.232282121@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=-7.1 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 c091fb6ae059cda563b2a4d93fdbc548ef34e1d6 upstream. The trampoline code has a data page that holds the address of the vectors, which is unmapped when running in user-space. This ensures that with CONFIG_RANDOMIZE_BASE, the randomised address of the kernel can't be discovered until after the kernel has been mapped. If the trampoline text page is extended to include multiple sets of vectors, it will be larger than a single page, making it tricky to find the data page without knowing the size of the trampoline text pages, which will vary with PAGE_SIZE. Move the data page to appear before the text page. This allows the data page to be found without knowing the size of the trampoline text pages. 'tramp_vectors' is used to refer to the beginning of the .entry.tramp.text section, do that explicitly. Reviewed-by: Russell King (Oracle) Reviewed-by: Catalin Marinas [ removed SDEI for backport ] Signed-off-by: James Morse Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/fixmap.h | 2 +- arch/arm64/kernel/entry.S | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -59,8 +59,8 @@ enum fixed_addresses { #endif /* CONFIG_ACPI_APEI_GHES */ #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 - FIX_ENTRY_TRAMP_DATA, FIX_ENTRY_TRAMP_TEXT, + FIX_ENTRY_TRAMP_DATA, #define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT)) #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ __end_of_permanent_fixed_addresses, --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1019,6 +1019,11 @@ alternative_else_nop_endif */ .endm + .macro tramp_data_page dst + adr \dst, .entry.tramp.text + sub \dst, \dst, PAGE_SIZE + .endm + .macro tramp_ventry, regsize = 64 .align 7 1: @@ -1035,7 +1040,7 @@ alternative_else_nop_endif 2: tramp_map_kernel x30 #ifdef CONFIG_RANDOMIZE_BASE - adr x30, tramp_vectors + PAGE_SIZE + tramp_data_page x30 alternative_insn isb, nop, ARM64_WORKAROUND_QCOM_FALKOR_E1003 ldr x30, [x30] #else