Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1211582pxb; Wed, 6 Apr 2022 11:26:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzElonS361RQCilNCbMhBR1vSnqwmctdoLXylA+cyTPunuxwe1vAPj1zDHxNVsmp3aAu7Fz X-Received: by 2002:a62:e215:0:b0:4fa:87f1:dc16 with SMTP id a21-20020a62e215000000b004fa87f1dc16mr10254898pfi.19.1649269574755; Wed, 06 Apr 2022 11:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649269574; cv=none; d=google.com; s=arc-20160816; b=V9HmIi9B0ep8FTN6pzW7iB8cbDswdAbvAYIPa2YRxwAGRXXkeFPfpcmQqy+uTMZfvp owNcMvsTy17jibwI7sGxIk6OFLZ1tQUS0Kc5xAEGN3Vwwvo7SYfLFm0JmYURF8iEy5x1 YqLIj6GfDtbBzfb39vnZWn4ncAo7xaZ5t9uOUeFQCWtBmiSMGeHC2TUB0yGnTeD8olX1 MtTEFwgyEruc3wS702brfmQg9u8SWHRPuoxgubr0iCnxS7iVcYOzi8bsilSq/kNZZLA6 RH+PsxA/oaEYdzz1Hk181epw2QM8Y5eKiEJ7Q6sj/yw2UeDJMbojZT6bFh9H2msDYeWz BiUA== 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=txOR2tA/7VQY5O+N7ksLWYoMvn8Nb2QChYcNoHWyYro=; b=M2WDYcm2kH8Y+E+nmQHhUwRvhkYI0oaoW4/6iHMRo9tOgveQTMa1lZDZ4x0u376xSY g9RUFWPdXGml8BLxvKXd25SlvHhvG6xjfo67yedXOzYVb1COtJGE0oEGbqrSWjwKk9oU PDWUAEmWJmXphjKaTccj5mJShIK4Myf2PZIxSvz26ESbyxRiBbcrcokFZUowBfPhAhkT uzXkn9PO8tdeaCdw3DNHeJgowYKE7tfkK/fcC0EOEmPeT237+nMjVljNWedzS3ivYMLR YRpoAqciE7EzOdaagl4cQPif/4SjvFA/CdByf0VAszisg2fufxyBEUElEFg6lMC4vprY Srjg== 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 w3-20020a634743000000b003816043eff7si16768886pgk.492.2022.04.06.11.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 11:26:14 -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 53AF42364CA; Wed, 6 Apr 2022 11:09:28 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240376AbiDFSKV (ORCPT + 99 others); Wed, 6 Apr 2022 14:10:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240544AbiDFSII (ORCPT ); Wed, 6 Apr 2022 14:08:08 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68FCD194FDC; Wed, 6 Apr 2022 09:46:27 -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 321CE1516; Wed, 6 Apr 2022 09:46:27 -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 851C53F73B; Wed, 6 Apr 2022 09:46:26 -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 28/43] arm64: entry: Move the trampoline data page before the text page Date: Wed, 6 Apr 2022 17:45:31 +0100 Message-Id: <20220406164546.1888528-28-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 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 --- arch/arm64/include/asm/fixmap.h | 2 +- arch/arm64/kernel/entry.S | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h index d8e58051f32d..feee38303afe 100644 --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -53,8 +53,8 @@ enum fixed_addresses { FIX_TEXT_POKE0, #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, diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 40647b5e279e..d665714cdca6 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -918,6 +918,11 @@ __ni_sys_trace: */ .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: @@ -934,7 +939,7 @@ __ni_sys_trace: 2: tramp_map_kernel x30 #ifdef CONFIG_RANDOMIZE_BASE - adr x30, tramp_vectors + PAGE_SIZE + tramp_data_page x30 isb ldr x30, [x30] #else -- 2.30.2