Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp733045ybc; Sat, 16 Nov 2019 07:45:26 -0800 (PST) X-Google-Smtp-Source: APXvYqzqDiHRE7xY3oUp8ncE79S2itJ98QOPZ5avkODvL0fhQhFi6rSZyyRrbjw536d6RBNRzI7P X-Received: by 2002:a17:906:6006:: with SMTP id o6mr10530761ejj.51.1573919125959; Sat, 16 Nov 2019 07:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919125; cv=none; d=google.com; s=arc-20160816; b=0X2tQQOY1PTc+natQH9bgPMg+ry87SHSR5nILJOUlHpCtzuOkizzxlYyYFfxic2lh3 ih3MOP9MNbofszN7dS8G7lr9MvYOd+rqrBEsCT6PYmNntfuJw+tWXNsJCN6GnCzFUUZO DHLHKDA6RWdT1dWTUJxfkXTdHJ4P1iEKAytDm19o3TfsxDadWAMiOIQcBGxTnJ72KPGY A/66zPJD7/DHmdCN0gejEREC8hRdJpt1C5gBq/RIHDKI8DaDWxfe+nuweSu6LdcnZyfg eZb9tcfEkBhgPb0wl1BEISEJG+zCOm9A6auXeDfVUDHPGjPs97AE+dIbQCM9ptnTEzAh XFWQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qRcqLeE7BD65Dx913TR+uyi0IB0F5wWdva9HgAT1ejA=; b=Av29vU8LOmp8U/NKcMexI2cGFr+irxn0e6oKgjbrJ374Er+boKs0+dcSOaY48iEc9B GOwU/AqSNJaftfBxBTr1wE47NUpN25vQEwmM3dmTVYL+1+4EHRqAhn0B6DBF225MPaF5 CgEeeatE3RIRNTQzmGHvQVSWIb4Yzrg6hUXNeyG524c8rb7cG1GZ1UF+h8kUKPl2UN4Q R18e6IKaemMekym1peZDsSJVugPv5WEmzg7fpWpsItCtASYp5EGHm9+V5tmbcmI6Ssg3 FIhksGmUHdTItpXZ9XnCWRrHLFTrOjan+Rr9a4B3HX+8Su3wvOQFA/ARzZyeNsVyXrOy iuhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wZHhtcws; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a9si10000614edm.231.2019.11.16.07.45.00; Sat, 16 Nov 2019 07:45:25 -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=wZHhtcws; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728631AbfKPPnO (ORCPT + 99 others); Sat, 16 Nov 2019 10:43:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:47044 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728594AbfKPPnK (ORCPT ); Sat, 16 Nov 2019 10:43:10 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 254E02072D; Sat, 16 Nov 2019 15:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918989; bh=xSTAfSAwQlR+mw6DZnVx2dvVH4DuAFNoVR9OKpY6MwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wZHhtcwsaQodyOzZDIbL4eA2D1A7AyfR5dOdQM74sdjWX+OsOXxxRzo4zeyIYUKPd LVAnGniTq8AHZ8LOTEeJYJwW9LtGuFCxbKWwzrYW2m4+7ShNobcSKQvx6IfOi/fC29 suo/kfW5xu1t30Hjx98BfiunKrvVvG/w89ZWY0cI= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 094/237] powerpc/mm/radix: Fix small page at boundary when splitting Date: Sat, 16 Nov 2019 10:38:49 -0500 Message-Id: <20191116154113.7417-94-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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