Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3325851rwa; Tue, 23 Aug 2022 02:54:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR4rApgIYwa7uQAIF09f940WlT67fP5DrIfZx9yaPd0l097t1Lviasca0GZ1zcsDmKAduc/W X-Received: by 2002:a63:5912:0:b0:42a:dcc6:210d with SMTP id n18-20020a635912000000b0042adcc6210dmr3715630pgb.50.1661248443591; Tue, 23 Aug 2022 02:54:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248443; cv=none; d=google.com; s=arc-20160816; b=GDhP0hr06pqZhYVpmEYhAZbAZfhwVD5n7rSeE+pGAybB4BftiPUo/HL0niqx9SeeFR BKhr8LIKMix/ZlDCULYKUCzrDsra8mvzppJgXTt+yayefRwCXdGIteboxxI+vFIXuczM 86rMieguxZMvqCQ7Smga1eexd3QIg1O8Rt45pXMBrAJs6XG3AyaTJU7n+omsRAbY33Uu SHbQD1/lWlskl1jemNCOtLJ/H3XpGQEoADio1ugwl4bL3sAxbjOXTCAtph2ys2CEyxY6 8vMYvVWfIqZIkPBlO0qtomyPl0f36IMr5Bpu2VLm1xS+vFZEiHqXHY4OA+hOLWd/Ayjq 6h8w== 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=pWtbVGnlsV0wyW2bPewC6vP6IxElnviTskx7wg0fWkg=; b=D0sXl2GlRxINz2Gv5ywP8dLLRRoYgiDDtDrhJg4PLL5QsZvnhM4FW9LJpA8R1y1/iH 1lMASKsckCk+6qMz2L+n2CFf4/a4WT5wJSHKG569lTtABM5ADNx1hrT3OFDvgDcntgsv O4/S2BOuwNHCavQWpWpmZ3JNHm38J8/e65elcAKq6z6Mx7jVShqP6r0tRgcP981qRsam AHpSYKMro4kY4wZbkmjuiX78LqWeyPQr+OAlYx/LCIXKePVOs8IB4lTby2z7ypW0GTif R2j/5MCh8u10f75NtwYjGt/6VzF1M3FEAke3XYf3vuu0fnT5lG5OAB3ua4CFo0WMffDe Etzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mDCllxJ+; 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 c25-20020aa78e19000000b0052dfe17ce46si14259968pfr.285.2022.08.23.02.53.51; Tue, 23 Aug 2022 02:54:03 -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=mDCllxJ+; 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 S1349918AbiHWJYz (ORCPT + 99 others); Tue, 23 Aug 2022 05:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235543AbiHWJWP (ORCPT ); Tue, 23 Aug 2022 05:22:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE4838E9A6; Tue, 23 Aug 2022 01:35:15 -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 3A6086148E; Tue, 23 Aug 2022 08:34:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 425ACC433D7; Tue, 23 Aug 2022 08:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243653; bh=txqmN+YAfMMR2TvIi5EB/XRuqWPGhCXHEhadMv2AIf8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mDCllxJ+0uZO/rcCKfk6l0vTbXNl0WUnoxc5H3Wr2bxU8ws0VB6Y37u0m8vlkjdrI 0bMDWvALDiUMx3JVH6hAwa7tya3M6N4becFsCw5Z95wh//mIOzww99lDIiP5SzBwNT 9ALpxysI8xqQw+hx57RZbhVNo41w/4xYnQIxa+dU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxime Bizon , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.19 346/365] powerpc/32: Set an IBAT covering up to _einittext during init Date: Tue, 23 Aug 2022 10:04:07 +0200 Message-Id: <20220823080132.723879155@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 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: Christophe Leroy [ Upstream commit 2a0fb3c155c97c75176e557d61f8e66c1bd9b735 ] Always set an IBAT covering up to _einittext during init because when CONFIG_MODULES is not selected there is no reason to have an exception handler for kernel instruction TLB misses. It implies DBAT and IBAT are now totaly independent, IBATs are set by setibat() and DBAT by setbat(). This allows to revert commit 9bb162fa26ed ("powerpc/603: Fix boot failure with DEBUG_PAGEALLOC and KFENCE") Reported-by: Maxime Bizon Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/ce7f04a39593934d9b1ee68c69144ccd3d4da4a1.1655202804.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/head_book3s_32.S | 4 ++-- arch/powerpc/mm/book3s32/mmu.c | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/head_book3s_32.S b/arch/powerpc/kernel/head_book3s_32.S index 6c739beb938c..519b60695167 100644 --- a/arch/powerpc/kernel/head_book3s_32.S +++ b/arch/powerpc/kernel/head_book3s_32.S @@ -418,14 +418,14 @@ InstructionTLBMiss: */ /* Get PTE (linux-style) and check access */ mfspr r3,SPRN_IMISS -#if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KFENCE) +#ifdef CONFIG_MODULES lis r1, TASK_SIZE@h /* check if kernel address */ cmplw 0,r1,r3 #endif mfspr r2, SPRN_SDR1 li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC | _PAGE_USER rlwinm r2, r2, 28, 0xfffff000 -#if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KFENCE) +#ifdef CONFIG_MODULES bgt- 112f lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */ li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c index 49a737fbbd18..40029280c320 100644 --- a/arch/powerpc/mm/book3s32/mmu.c +++ b/arch/powerpc/mm/book3s32/mmu.c @@ -159,7 +159,10 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top) { unsigned long done; unsigned long border = (unsigned long)__init_begin - PAGE_OFFSET; + unsigned long size; + size = roundup_pow_of_two((unsigned long)_einittext - PAGE_OFFSET); + setibat(0, PAGE_OFFSET, 0, size, PAGE_KERNEL_X); if (debug_pagealloc_enabled_or_kfence() || __map_without_bats) { pr_debug_once("Read-Write memory mapped without BATs\n"); @@ -245,10 +248,9 @@ void mmu_mark_rodata_ro(void) } /* - * Set up one of the I/D BAT (block address translation) register pairs. + * Set up one of the D BAT (block address translation) register pairs. * The parameters are not checked; in particular size must be a power * of 2 between 128k and 256M. - * On 603+, only set IBAT when _PAGE_EXEC is set */ void __init setbat(int index, unsigned long virt, phys_addr_t phys, unsigned int size, pgprot_t prot) @@ -284,10 +286,6 @@ void __init setbat(int index, unsigned long virt, phys_addr_t phys, /* G bit must be zero in IBATs */ flags &= ~_PAGE_EXEC; } - if (flags & _PAGE_EXEC) - bat[0] = bat[1]; - else - bat[0].batu = bat[0].batl = 0; bat_addrs[index].start = virt; bat_addrs[index].limit = virt + ((bl + 1) << 17) - 1; -- 2.35.1