Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6018130ybc; Wed, 27 Nov 2019 13:29:59 -0800 (PST) X-Google-Smtp-Source: APXvYqwnps6cAlYMMtOhAemqw1i++NorZb2gYMpsJGmMId7ZnButMoVi4bJnXA1fySLIy8MzGH+i X-Received: by 2002:a05:6402:28d:: with SMTP id l13mr35045014edv.286.1574890199434; Wed, 27 Nov 2019 13:29:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890199; cv=none; d=google.com; s=arc-20160816; b=iOX01a+6Cm69ccf5muLwefYyLoFz5H+Pt2AaSKSFXCC8SjmSeE+YVqvtMGOCmspsd9 ovH8FoI1CtlhNpq0zhqJFDaCrxYfiIH3LJ2lpykwL4hFk4dG35JfDy/iVLT/KArXkB3Q U9sjSnnA4hsR8Hhd9TFR8C/+KbOb1041gljVOdWs954rrZ4HjjJ1DRBqOoUN9HJ28R8h LhQ1fmSYV5PEbE0fM7pKJMey9m/zdAWdU5r+Nq6wTOvcVJxN4bgJGzJ6sohSlbqZ8UvZ TYd5YNYWwX7QT7eEJsnyn6K19ebqViXJimslGoRb11v8p7N3dCaDfksPknTbCuqvdh05 B3wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qRcqLeE7BD65Dx913TR+uyi0IB0F5wWdva9HgAT1ejA=; b=Y1e7O36lE5w5Ih7wudl8LlWVgV/us6y7+95J6+dlvjMIRRyqGRESjI0D8oCmg3o1am DeRp2LKids4tqnPZeermfdzT2OJEdTI5CGSPIegghTVsnMV78WxgaWs3gRR/nz+kBg3+ 2VtN7SInFe47XnQGxiPJQX8hr9f9uc7H7HUjhN+EhZlLcD0YIwaEcOnpVoH65ubLkMcW Vgk+0pVXaTUCbymXxZR6Fvv0JwiH6T8A9bYlllcfmWqo6GhkdcofROLOwWHpt+5Gaomm RZhOnpZl9i+os6sz4OgwYAFGQjLhIsgsW+OzzdNybMpl4f5xZEmz5elitPEqg1G6+qhr fcjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P9d+fncS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cw24si884322edb.382.2019.11.27.13.29.35; Wed, 27 Nov 2019 13:29:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P9d+fncS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731225AbfK0V1Q (ORCPT + 99 others); Wed, 27 Nov 2019 16:27:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:51288 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731454AbfK0U7l (ORCPT ); Wed, 27 Nov 2019 15:59:41 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2B0920678; Wed, 27 Nov 2019 20:59:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888381; bh=xSTAfSAwQlR+mw6DZnVx2dvVH4DuAFNoVR9OKpY6MwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P9d+fncSRKmJU2Tlq16ekulf2lOtR/Fe7xlI8cwP9OGaPyxqkSAvMub9xj4E1ZOw1 5mZGYV4bxFvR2PoMIQn8YmqkYKI42Vo/Ra2+dM+YEUj7tV+QBja7F9rPH2EvOUYwFD sSbcehlKRSE4E0bskbjxWwgkL6RZ91Yqepv/+jSM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 113/306] powerpc/mm/radix: Fix small page at boundary when splitting Date: Wed, 27 Nov 2019 21:29:23 +0100 Message-Id: <20191127203123.465081644@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Ellerman [ Upstream commit 81d1b54dec95209ab5e5be2cf37182885f998753 ] When we have CONFIG_STRICT_KERNEL_RWX enabled, we want to split the linear mapping at the text/data boundary so we can map the kernel text read only. Currently we always use a small page at the text/data boundary, even when that's not necessary: Mapped 0x0000000000000000-0x0000000000e00000 with 2.00 MiB pages Mapped 0x0000000000e00000-0x0000000001000000 with 64.0 KiB pages Mapped 0x0000000001000000-0x0000000040000000 with 2.00 MiB pages This is because the check that the mapping crosses the __init_begin boundary is too strict, it also returns true when we map exactly up to the boundary. So fix it to check that the mapping would actually map past __init_begin, and with that we see: Mapped 0x0000000000000000-0x0000000040000000 with 2.00 MiB pages Mapped 0x0000000040000000-0x0000000100000000 with 1.00 GiB pages Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/mm/pgtable-radix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c index b387c7b917b7e..69caeb5bccb21 100644 --- a/arch/powerpc/mm/pgtable-radix.c +++ b/arch/powerpc/mm/pgtable-radix.c @@ -295,14 +295,14 @@ static int __meminit create_physical_mapping(unsigned long start, if (split_text_mapping && (mapping_size == PUD_SIZE) && (addr < __pa_symbol(__init_begin)) && - (addr + mapping_size) >= __pa_symbol(__init_begin)) { + (addr + mapping_size) > __pa_symbol(__init_begin)) { max_mapping_size = PMD_SIZE; goto retry; } if (split_text_mapping && (mapping_size == PMD_SIZE) && (addr < __pa_symbol(__init_begin)) && - (addr + mapping_size) >= __pa_symbol(__init_begin)) { + (addr + mapping_size) > __pa_symbol(__init_begin)) { mapping_size = PAGE_SIZE; psize = mmu_virtual_psize; } -- 2.20.1