From patchwork Wed Mar 9 11:32:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Richter X-Patchwork-Id: 8545631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0CF4CC0553 for ; Wed, 9 Mar 2016 11:34:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DD29220121 for ; Wed, 9 Mar 2016 11:34:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D22832010E for ; Wed, 9 Mar 2016 11:34:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1adcM8-000396-6S; Wed, 09 Mar 2016 11:32:44 +0000 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1adcM3-000301-NP for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2016 11:32:41 +0000 Received: by mail-wm0-x241.google.com with SMTP id p65so9454157wmp.1 for ; Wed, 09 Mar 2016 03:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=o9y1NGZjKbM3I0kOnxk4IzpCz+GARKhSb3amcg9RGEY=; b=q+1FyNlYQ487HWE/L1uJs7+RYcnyUySx3yGt2QsmSZfpugNBNPEli2dUaey4Njhu1t HTkfQfY6r/pKXZB3eky3v1c+uq2l6pOsqM8rDcGBVwrcdi213g2O+yg8sjv38BZMfIOS WwHunX6Oy4Txa4bnBa+juwM9MH3oBuqqd2wC6KyDV3f06avaRa5Hoo0JcLc7Cq/4Zb5O Xtq3Nmput6KJFNZuwBRVM0GB+5zom3SpxrURcaKoxEkHiLKCqE2OXcYyne2A6sod2EVJ rxf5lHnh37cLBLdpG+NOtLdP4VrP65ARb0XOQbE7ZlWsQMY7nYlU+5lF4JRqo7qi9RpP KF6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=o9y1NGZjKbM3I0kOnxk4IzpCz+GARKhSb3amcg9RGEY=; b=mwpURlDr+8Ab7jZ7AMK668ylQFIS5EDGRhPT8Q4LKbAEaXWt4xjIKx2vYpKIBYy5Lq /ywOF3a7+Mlhvx5xhkSxiwf5vM8b/OjbZiQg8wfwtXTjMdVRgw+d5jY9F1/MRs+ii5Jj f0wY/2p++wlhK3K9S/Tfioyyf9OqJk1XrnUQl2wXtDcMMI+C1UcK1H83G8gFGMAUD9zA WmYEIY7OBsTV88mfZHtMgB7Wc4HpITkHp+663bSEX8WEBstsw3HzUlfW5svfcVy1aELf 2VKn1EM40LjPxMREGem+20D7qCyPdkDOVZI0id2LBkodC9+NUfllSXdf3jt3c6Ctc+fs pFgQ== X-Gm-Message-State: AD7BkJJCnQMxLwKUXmzqu7rvJ+dgTEKyXtNlrP1OvOoYy0OII1v8otTcDWbM3WzMJpPjPw== X-Received: by 10.28.105.136 with SMTP id z8mr25241773wmh.71.1457523137826; Wed, 09 Mar 2016 03:32:17 -0800 (PST) Received: from rric.localdomain (x5ce0c240.dyn.telefonica.de. [92.224.194.64]) by smtp.gmail.com with ESMTPSA id bg1sm7507021wjc.27.2016.03.09.03.32.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Mar 2016 03:32:16 -0800 (PST) Date: Wed, 9 Mar 2016 12:32:14 +0100 From: Robert Richter To: Ard Biesheuvel Subject: Re: [PATCH v2 1/2] arm64: vmemmap: use virtual projection of linear region Message-ID: <20160309113214.GB1535@rric.localdomain> References: <1456505834-8638-1-git-send-email-ard.biesheuvel@linaro.org> <1456505834-8638-2-git-send-email-ard.biesheuvel@linaro.org> <56DE25DD.4010401@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160309_033239_941325_E7D7DBEC X-CRM114-Status: GOOD ( 30.33 ) X-Spam-Score: -2.4 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Mark Langsdorf , Catalin Marinas , Will Deacon , David Daney , "linux-arm-kernel@lists.infradead.org" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 08.03.16 17:31:05, Ard Biesheuvel wrote: > On 8 March 2016 at 09:15, Ard Biesheuvel wrote: > > > > > >> On 8 mrt. 2016, at 08:07, David Daney wrote: > >> > >>> On 02/26/2016 08:57 AM, Ard Biesheuvel wrote: > >>> Commit dd006da21646 ("arm64: mm: increase VA range of identity map") made > >>> some changes to the memory mapping code to allow physical memory to reside > >>> at an offset that exceeds the size of the virtual mapping. > >>> > >>> However, since the size of the vmemmap area is proportional to the size of > >>> the VA area, but it is populated relative to the physical space, we may > >>> end up with the struct page array being mapped outside of the vmemmap > >>> region. For instance, on my Seattle A0 box, I can see the following output > >>> in the dmesg log. > >>> > >>> vmemmap : 0xffffffbdc0000000 - 0xffffffbfc0000000 ( 8 GB maximum) > >>> 0xffffffbfc0000000 - 0xffffffbfd0000000 ( 256 MB actual) > >>> > >>> We can fix this by deciding that the vmemmap region is not a projection of > >>> the physical space, but of the virtual space above PAGE_OFFSET, i.e., the > >>> linear region. This way, we are guaranteed that the vmemmap region is of > >>> sufficient size, and we can even reduce the size by half. > >>> > >>> Signed-off-by: Ard Biesheuvel > >> > >> I see this commit now in Linus' kernel.org tree in v4.5-rc7. > >> > >> FYI: I am seeing a crash that goes away when I revert this. My kernel has some other modifications (our NUMA patches) so I haven't yet fully tracked this down on an unmodified kernel, but this is what I am getting: > >> > > > > I managed to reproduce and diagnose this. The problem is that vmemmap > is no longer zone aligned, which causes trouble in the zone based > rounding that occurs in memory_present. The below patch fixes this by > rounding down the subtracted offset. Since this implies that the > region could stick off the other end, it also reverts the halving of > the region size. I have seen the same panic. The fix solves the problem. See enclosed Tested-by: Robert Richter diff for reference as there was some patch corruption of the original. Thanks, -Robert From 562760cc30905748cb851cc9aee2bb9d88c67d47 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 8 Mar 2016 17:31:05 +0700 Subject: [PATCH] arm64: vmemmap: Fix use virtual projection of linear region Signed-off-by: Robert Richter --- arch/arm64/include/asm/pgtable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index d9de87354869..98697488650f 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -40,7 +40,7 @@ * VMALLOC_END: extends to the available space below vmmemmap, PCI I/O space, * fixed mappings and modules */ -#define VMEMMAP_SIZE ALIGN((1UL << (VA_BITS - PAGE_SHIFT - 1)) * sizeof(struct page), PUD_SIZE) +#define VMEMMAP_SIZE ALIGN((1UL << (VA_BITS - PAGE_SHIFT)) * sizeof(struct page), PUD_SIZE) #ifndef CONFIG_KASAN #define VMALLOC_START (VA_START) @@ -52,7 +52,7 @@ #define VMALLOC_END (PAGE_OFFSET - PUD_SIZE - VMEMMAP_SIZE - SZ_64K) #define VMEMMAP_START (VMALLOC_END + SZ_64K) -#define vmemmap ((struct page *)VMEMMAP_START - (memstart_addr >> PAGE_SHIFT)) +#define vmemmap ((struct page *)VMEMMAP_START - ((memstart_addr >> PAGE_SHIFT) & PAGE_SECTION_MASK)) #define FIRST_USER_ADDRESS 0UL