Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1484510pxb; Fri, 1 Apr 2022 15:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwq/kQOBx5AU7/pHzc2Ons/6cHYvuvVCZvE0UqACXuYVKTxFBJwXaYlKIeiINYnqjy3czuH X-Received: by 2002:a05:6402:26c8:b0:419:2e54:9262 with SMTP id x8-20020a05640226c800b004192e549262mr22723278edd.61.1648850874562; Fri, 01 Apr 2022 15:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648850874; cv=none; d=google.com; s=arc-20160816; b=fHiaAikRYb74qDVbXqQNH0Jf9E3a2n8OdKtwyAEkVqjI2G9KcPDntMcv4Gq8Im4jHV 86F0PA3zxau+AaiHTpmKo2N7Mdu9tkcRU7pD4IME47MghIH/xWf53wITH0x+NXkEfOdP 0aqNVKSVAUTHDD1K2sfzy3kocL7sQhpBJCUgXIfA/p7s9/IaadtPrR1lAqGjb2r+45+y 1AXBROiLiCay8SeJhpN6kB1OFbc8SXallLINfJ+OUDDdxB1d5WLkhqlED8e7b5eN6BKq CHMGV/M3W1ZTcAujGYXWKwT2zGphomGEWEBjyj6nKZOWjwnoAVYyEhhOX6d42slRuOGD fHAQ== 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=pG+lnJMCQBrxguNeyhYQMj3IVciA00Mjir9nm6UcVI4=; b=ySXdVHc9gRD7i1eirGTUk2CKy//Srz1jYZPYG7zA09Q6lcV9NzDrkmY6YUi5Q2jlxs U7eGE3WHkEVws06IWAoVyS6Q77fPCNrBZn+H7ZN30pX1hKVVlnLb32BbrKJv6UpVvtWH CiDjSuIsD9oGPArvftio6m1qskWdMmcS1Y9qs7JlEiCEM8EP5bDvOo+T5MC4hK6Spf44 Hpv0vvRw8tmJqIWlNbT3g8sQVcBQq+HPGSsvwqL0DJOH4/XamjFibVjUgO8LGR6uOiSm 2ZCvELEqnheZsLUgc0TEZDZQI7dlVyA7mgI0EYwjHlf+pLaViGnG5od+Hhya/BNlwL+x QXqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pRvy5Cd6; 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 dc26-20020a170906c7da00b006e4e1b3bb5bsi1261156ejb.124.2022.04.01.15.07.28; Fri, 01 Apr 2022 15:07:54 -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=pRvy5Cd6; 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 S233612AbiDAGjp (ORCPT + 99 others); Fri, 1 Apr 2022 02:39:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245607AbiDAGjC (ORCPT ); Fri, 1 Apr 2022 02:39:02 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09159262D53; Thu, 31 Mar 2022 23:37:08 -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 6531CB823E9; Fri, 1 Apr 2022 06:37:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C392DC2BBE4; Fri, 1 Apr 2022 06:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648795026; bh=tQJmZjaRSI8412zQh+u4HGkoB0Is7ytsCAD/kEHf0to=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pRvy5Cd6qNfNP3py/9pGbVNIPj7z246Zol9Za5Goy9fycQotCqO/6TtaUnnP+hFFX vMUugpMDZBD2XuM1Hpul+KoB0tM1GUdmmzvP/VEhraz39BT1IzXZ59Vmugr2wZh6lD GhKU4DhAaIgAZwB4vxx+0WF9Lot/u40U2CCII1sA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Catalin Marinas , James Morse Subject: [PATCH 4.14 17/27] arm64: entry: Allow the trampoline text to occupy multiple pages Date: Fri, 1 Apr 2022 08:36:27 +0200 Message-Id: <20220401063624.721541774@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 a9c406e6462ff14956d690de7bbe5131a5677dc9 upstream. Adding a second set of vectors to .entry.tramp.text will make it larger than a single 4K page. Allow the trampoline text to occupy up to three pages by adding two more fixmap slots. Previous changes to tramp_valias allowed it to reach beyond a single page. Reviewed-by: Catalin Marinas Signed-off-by: James Morse Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/fixmap.h | 6 ++++-- arch/arm64/include/asm/sections.h | 6 ++++++ arch/arm64/kernel/entry.S | 2 +- arch/arm64/kernel/vmlinux.lds.S | 2 +- arch/arm64/mm/mmu.c | 11 ++++++++--- 5 files changed, 20 insertions(+), 7 deletions(-) --- a/arch/arm64/include/asm/fixmap.h +++ b/arch/arm64/include/asm/fixmap.h @@ -59,9 +59,11 @@ enum fixed_addresses { #endif /* CONFIG_ACPI_APEI_GHES */ #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 - FIX_ENTRY_TRAMP_TEXT, + FIX_ENTRY_TRAMP_TEXT3, + FIX_ENTRY_TRAMP_TEXT2, + FIX_ENTRY_TRAMP_TEXT1, FIX_ENTRY_TRAMP_DATA, -#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT)) +#define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1)) #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ __end_of_permanent_fixed_addresses, --- a/arch/arm64/include/asm/sections.h +++ b/arch/arm64/include/asm/sections.h @@ -28,5 +28,11 @@ extern char __initdata_begin[], __initda extern char __inittext_begin[], __inittext_end[]; extern char __irqentry_text_start[], __irqentry_text_end[]; extern char __mmuoff_data_start[], __mmuoff_data_end[]; +extern char __entry_tramp_text_start[], __entry_tramp_text_end[]; + +static inline size_t entry_tramp_text_size(void) +{ + return __entry_tramp_text_end - __entry_tramp_text_start; +} #endif /* __ASM_SECTIONS_H */ --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1018,7 +1018,7 @@ alternative_else_nop_endif .endm .macro tramp_data_page dst - adr \dst, .entry.tramp.text + adr_l \dst, .entry.tramp.text sub \dst, \dst, PAGE_SIZE .endm --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -258,7 +258,7 @@ ASSERT(__hibernate_exit_text_end - (__hi <= SZ_4K, "Hibernate exit text too big or misaligned") #endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) == PAGE_SIZE, +ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE, "Entry trampoline text too big") #endif /* --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -532,6 +532,7 @@ early_param("rodata", parse_rodata); #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 static int __init map_entry_trampoline(void) { + int i; extern char __entry_tramp_text_start[]; pgprot_t prot = rodata_enabled ? PAGE_KERNEL_ROX : PAGE_KERNEL_EXEC; @@ -542,11 +543,15 @@ static int __init map_entry_trampoline(v /* Map only the text into the trampoline page table */ memset(tramp_pg_dir, 0, PGD_SIZE); - __create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE, - prot, pgd_pgtable_alloc, 0); + __create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, + entry_tramp_text_size(), prot, pgd_pgtable_alloc, + 0); /* Map both the text and data into the kernel page table */ - __set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot); + for (i = 0; i < DIV_ROUND_UP(entry_tramp_text_size(), PAGE_SIZE); i++) + __set_fixmap(FIX_ENTRY_TRAMP_TEXT1 - i, + pa_start + i * PAGE_SIZE, prot); + if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { extern char __entry_tramp_data_start[];