Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2284157pxp; Mon, 21 Mar 2022 15:52:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe7DHyaDVhqsRRcKPR9sXUBQ1XQ/yFWsLRJA+yMCRlQ6JX3uKr/Jz/KGkItd7m629M6aVD X-Received: by 2002:a63:451b:0:b0:380:b9f8:13f4 with SMTP id s27-20020a63451b000000b00380b9f813f4mr20138821pga.367.1647903126981; Mon, 21 Mar 2022 15:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647903126; cv=none; d=google.com; s=arc-20160816; b=UXFqimutmGilTd9vRJjCpIVyvO6EplBrs+Vy+jSJuARq8wGHke5H0bFRVNMhL4VHEj jR2kNB2WouOB/35pgvHBtclpSYzYkaCfMhA+am1y4yTODS5qLAZuI4+CenrzyN9JNgxN +H/qQYOnE1g9FH8IMaMl+G3r+HIoFX1grLL/mDwKQyk5seUiElX7502aavhsWfYPIhx+ t29xMZvMqXbnh/NIC1ZtVJIjJGTJJJvYN0S83GG2zMZnxULiqOxmcaMIY05SZJyCGvcz q1E8A6oxIJWKWhEuTrio8ItGAetoVX7v9vdPdWp5eTt6Jp3RzmkdH7nVTr2Dg5W9iopZ HFfQ== 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=K2RJ3JFavRJ3BE+/iBqdqr0ObLyh3k0llDJN0peUke0=; b=r0P61g9AIQKkOs+NeY6DkamnZFmB7gXutrXSLnOJJRMrWpbodaJagxlyOvluH0SwRs HxPm5VupLliqCLz0qj5377HIvGC/84ZAFPXWDD7ifz8CVWsSBeiCt2MS3c79rZYdn8/+ qvdxAzRp/cwevGifKW5UtvW2Aui8Tr06Lij6qItKX6KakUl8pnajlUMZ3s1gRW7QiwDk 6iLTJTYvVl/VE/lAxw3BJl92PoppTgRYNND83VNJAIlfP7jjnY0H4YuccRMY6MzkCoRp ARdMfoCcCUrnux38gnomiAFwPUuUgwhay5zKHiYAp9zPiM5ksk0YueldUQPnJTwTNcp+ o/9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GGJKbw/T"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id w19-20020a170902d71300b00153b2d165a4si11224114ply.428.2022.03.21.15.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:52:06 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GGJKbw/T"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 855CD3D480; Mon, 21 Mar 2022 14:59:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348498AbiCUOBG (ORCPT + 99 others); Mon, 21 Mar 2022 10:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348731AbiCUN6M (ORCPT ); Mon, 21 Mar 2022 09:58:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47828177D38; Mon, 21 Mar 2022 06:56:22 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 35F1D611F4; Mon, 21 Mar 2022 13:55:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AE19C340E8; Mon, 21 Mar 2022 13:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647870954; bh=Awlc6VWiACZ6yM2JV3UQLlzhaKrqPsfPUekWk3jViqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GGJKbw/TSA6nMS09CCktOQiCSeXeZ1AWsAx4rZEL2cxbsbyAB8BLK1/deOTH9Lux6 bdxQfhffOTjOp45uaZvKgNIThPbvo2orsBNMKS1+FIKet0vZft8o1iKFgGr0niGa8+ qtRo/iU5EvBPQHZCgntEeKQWLDw6j3UPReoMJ2zw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , "Russell King (Oracle)" , Catalin Marinas , James Morse Subject: [PATCH 4.19 29/57] arm64: entry: Move the trampoline data page before the text page Date: Mon, 21 Mar 2022 14:52:10 +0100 Message-Id: <20220321133222.837064918@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133221.984120927@linuxfoundation.org> References: <20220321133221.984120927@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=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Signed-off-by: James Morse Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/fixmap.h | 2 +- arch/arm64/kernel/entry.S | 9 +++++++-- 2 files changed, 8 insertions(+), 3 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 @@ -967,6 +967,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: @@ -983,7 +988,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 @@ -1131,7 +1136,7 @@ ENTRY(__sdei_asm_entry_trampoline) 1: str x4, [x1, #(SDEI_EVENT_INTREGS + S_ORIG_ADDR_LIMIT)] #ifdef CONFIG_RANDOMIZE_BASE - adr x4, tramp_vectors + PAGE_SIZE + tramp_data_page x4 add x4, x4, #:lo12:__sdei_asm_trampoline_next_handler ldr x4, [x4] #else