Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp861647pxb; Tue, 1 Feb 2022 11:59:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYpN8Z4queFfFG3agLGDg4kj1SHewPSVLqaXTmllaBkzjaibnDQkMDO1cV/sEp8vrQMISr X-Received: by 2002:a17:902:a98b:: with SMTP id bh11mr13398827plb.49.1643745581953; Tue, 01 Feb 2022 11:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643745581; cv=none; d=google.com; s=arc-20160816; b=IQZrCunenD2GDyc0gjl1A8EZn4Il5iNMJ0glyHSefFEvdVJ+GK+HvKZe75XkXr7nFG MD7Zzx0sNAyT7ef54GuHWEe5MyFxkvxUYVQi2qrLP+37Sm35AwrkKDQXE6maCZ6Rd8Q5 iUoGlEC8W17Czmzb5jDxObZ6FXngFcF5ZjGgVHeWZ4ujDLUsfwnjt57aKPU5jwcVqdhb AvzXEM3cTU1P0N5JsQr3wMr3LVrC+WHlyj/8kng09/FIAH2uI/E1cDSGInDkDK/Btq0J 7p2+GgmWaWp67i4XjISsfB9Y41lrtU6vhIfRApufga7WoQWAerw4HXN68PCqkJdJHygN rn5w== 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=iUltvUP11TU0gG4p2bMFpq8EOiFye1KN3v67qmxMFXE=; b=av1zPFpYZ9B2AyAs7TY8kqk1F2w53inW7x6j6dBmW059x67vcmywWTQYJ6gmgxq5Cq gfzQEJhUxU30lkxnaY1pQ8Bgxfgk2a+wlp4wbGJQIHKMbInTUr0A82ywL36Lt4QHMygN WkW4HyTL1CDrVYv99zXpYPSOb41ZY8FAa89yI01M4lPxcpIzuMmc1i3LVJ6y42EyiI3r NU8FXvPDGC6JnUN02YzPFiaCcWm+lH/EBr0uQi3y0LzVZm5E+Bq37slQ28NSOaLEq8vi kCNIQwWr8PRq8ffNlxm6APqsu82Tf7qOv5+ovsHLDnAcxDadmPHvAa5oGsIaBNRSS7lO Bqsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i4bIEQcZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j3si19801723plr.559.2022.02.01.11.59.30; Tue, 01 Feb 2022 11:59:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=i4bIEQcZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1376366AbiAaLIS (ORCPT + 99 others); Mon, 31 Jan 2022 06:08:18 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:39418 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359278AbiAaLEy (ORCPT ); Mon, 31 Jan 2022 06:04:54 -0500 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 C413E60EFE; Mon, 31 Jan 2022 11:04:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BDBEC36AE7; Mon, 31 Jan 2022 11:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643627093; bh=bh57M7kPGJHMCFswNDB0rtNduQxQs1+ujCn7yAjpzDo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i4bIEQcZxiU+WeYUkqEOFVCW+TeNaWC4IxvR0T6yGaZRZfEMWJJrpzXOo2ez+xpM6 T74tK1wElVGR2hCoJh8JqUOn6oBF3YQMnduAxXEbKIL6rMxtLGQjwXN70SpPcpiY5m ClI5rw6hAJGPn6xpOzuhyCEO9bmONk1t5PmQcgyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Michael Ellerman Subject: [PATCH 5.10 039/100] powerpc/32s: Allocate one 256k IBAT instead of two consecutives 128k IBATs Date: Mon, 31 Jan 2022 11:56:00 +0100 Message-Id: <20220131105221.758203839@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105220.424085452@linuxfoundation.org> References: <20220131105220.424085452@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy commit 37eb7ca91b692e8e49e7dd50158349a6c8fb5b09 upstream. Today we have the following IBATs allocated: ---[ Instruction Block Address Translation ]--- 0: 0xc0000000-0xc03fffff 0x00000000 4M Kernel x m 1: 0xc0400000-0xc05fffff 0x00400000 2M Kernel x m 2: 0xc0600000-0xc06fffff 0x00600000 1M Kernel x m 3: 0xc0700000-0xc077ffff 0x00700000 512K Kernel x m 4: 0xc0780000-0xc079ffff 0x00780000 128K Kernel x m 5: 0xc07a0000-0xc07bffff 0x007a0000 128K Kernel x m 6: - 7: - The two 128K should be a single 256K instead. When _etext is not aligned to 128Kbytes, the system will allocate all necessary BATs to the lower 128Kbytes boundary, then allocate an additional 128Kbytes BAT for the remaining block. Instead, align the top to 128Kbytes so that the function directly allocates a 256Kbytes last block: ---[ Instruction Block Address Translation ]--- 0: 0xc0000000-0xc03fffff 0x00000000 4M Kernel x m 1: 0xc0400000-0xc05fffff 0x00400000 2M Kernel x m 2: 0xc0600000-0xc06fffff 0x00600000 1M Kernel x m 3: 0xc0700000-0xc077ffff 0x00700000 512K Kernel x m 4: 0xc0780000-0xc07bffff 0x00780000 256K Kernel x m 5: - 6: - 7: - Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/ab58b296832b0ec650e2203200e060adbcb2677d.1637930421.git.christophe.leroy@csgroup.eu Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/mm/book3s32/mmu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/arch/powerpc/mm/book3s32/mmu.c +++ b/arch/powerpc/mm/book3s32/mmu.c @@ -201,18 +201,17 @@ void mmu_mark_initmem_nx(void) int nb = mmu_has_feature(MMU_FTR_USE_HIGH_BATS) ? 8 : 4; int i; unsigned long base = (unsigned long)_stext - PAGE_OFFSET; - unsigned long top = (unsigned long)_etext - PAGE_OFFSET; + unsigned long top = ALIGN((unsigned long)_etext - PAGE_OFFSET, SZ_128K); unsigned long border = (unsigned long)__init_begin - PAGE_OFFSET; unsigned long size; - for (i = 0; i < nb - 1 && base < top && top - base > (128 << 10);) { + for (i = 0; i < nb - 1 && base < top;) { size = block_size(base, top); setibat(i++, PAGE_OFFSET + base, base, size, PAGE_KERNEL_TEXT); base += size; } if (base < top) { size = block_size(base, top); - size = max(size, 128UL << 10); if ((top - base) > size) { size <<= 1; if (strict_kernel_rwx_enabled() && base + size > border)