Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1953016pxx; Sat, 31 Oct 2020 03:50:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9zxymWDOwKQCaPHHKFSxb/MhVFVN0q6NM2Lg593l+/Jm0GA0cbP3eW07fMcyq49quCNRD X-Received: by 2002:a05:6402:c8d:: with SMTP id cm13mr5120878edb.340.1604141442984; Sat, 31 Oct 2020 03:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604141442; cv=none; d=google.com; s=arc-20160816; b=zbO0BCgieArZZLduBXfZ7FUQjG01e+5tFqfGtFDj4bZoeIvNkjTayUZuctcI0G8AnQ G8ycOi/XMZdeZmirzCsv7vOSBwAPOLMDN33+/gRoTyZVpN7PQfwTZbcLhvu0HgUVo5JH wCbPaxi5HSR2NwCLcSRs4gwiLniSCXkENYQIJseFgUSTztv5fljlxNb7bMKe+fx69rvz XrF3H+ssBdCAbRKC2y5BSm1QODYoKq3xkliF9CsHOeDhyXnmJU3xMfi8p/wpzd92IvPO 7KW6/PEKnH6ZHzO7NtXrJYYXEXvPliSoJyeuUFKc9EnDdZJHjJoLmCMTgjhd4AVAv7tv Lmdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=puvwNAqu/9FHGR0Y5cWDL8KLMkc/B0jRgmE7LTNim60=; b=qnywEmswi17b0MnsXXRzi43NXLb/06ibsqQeCTHBi4Dg4bhQs12EIbGN1Q9IUaOnYP hDUP1xn2C4L4PbKnM0e0lLikoREJuOYOhNOkBLDAWhgfoozbs47CVQ1XPg1BoDPwuh3G 0qiriYxODnCmhZKnbCfPEIctpg80ptxj4fzLdsiXT/FhPEu/wkeHo5LBDeOCxGt0luqh dQlXsnC5jbbkJtk8wL9Rh6wLN4KAnPCrckZJEs29PX67/WyVsmyDv9hD69qimR+Lq2Qg RH06GYixGxyYLGuS1M7fB7X4pII9YcE+ag8x5RW4XFikg2YxLwpFL9GZTF5us+KQNSmt Ptiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="CNy1G/cA"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a9si6455757edt.50.2020.10.31.03.50.18; Sat, 31 Oct 2020 03:50:42 -0700 (PDT) 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=@kernel.org header.s=default header.b="CNy1G/cA"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726757AbgJaKrz (ORCPT + 99 others); Sat, 31 Oct 2020 06:47:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:33104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726697AbgJaKrz (ORCPT ); Sat, 31 Oct 2020 06:47:55 -0400 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 1023922246 for ; Sat, 31 Oct 2020 10:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604141274; bh=V1iu1KT8r8Cx0HsatLRzfzAoIca0ncRgqSMr23EZDgk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=CNy1G/cAYqP6E1o+YBmxY+iGiqgQV11YfyJmzdDQxMfsY7PBegI5lCu+VOSZ5knHX uz2VgKuBcSouDQBjUOaOE01v+ayog5oxpjDMJGEpbxC6RjOb8ji9mFksdWBaactAKX 3eEBKUBQ8LnRzaWzaeofi0AbQEqjDP23DKnWxI9E= Received: by mail-ot1-f54.google.com with SMTP id b2so7974081ots.5 for ; Sat, 31 Oct 2020 03:47:54 -0700 (PDT) X-Gm-Message-State: AOAM532w3U7Uh3EJEaemE3hAN+sLsalGAEcaL5XjIsN3LTG/w8LUXtUx DHEI77JQub0zvI1mYDFUFK3J70O5vDzIlJWPNLE= X-Received: by 2002:a05:6830:1f13:: with SMTP id u19mr4849702otg.108.1604141273335; Sat, 31 Oct 2020 03:47:53 -0700 (PDT) MIME-Version: 1.0 References: <20201031094345.6984-1-rppt@kernel.org> <20201031103312.GI1551@shell.armlinux.org.uk> In-Reply-To: <20201031103312.GI1551@shell.armlinux.org.uk> From: Ard Biesheuvel Date: Sat, 31 Oct 2020 11:47:42 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] ARM, xtensa: highmem: avoid clobbering non-page aligned memory reservations To: Russell King - ARM Linux admin Cc: Mike Rapoport , Linux ARM , linux-xtensa@linux-xtensa.org, Chris Zankel , Florian Fainelli , Linus Walleij , Max Filippov , Mike Rapoport , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 31 Oct 2020 at 11:33, Russell King - ARM Linux admin wrote: > > On Sat, Oct 31, 2020 at 11:43:45AM +0200, Mike Rapoport wrote: > > From: Ard Biesheuvel > > > > free_highpages() iterates over the free memblock regions in high > > memory, and marks each page as available for the memory management > > system. > > > > Until commit cddb5ddf2b76 ("arm, xtensa: simplify initialization of > > high memory pages") it rounded beginning of each region upwards and end of > > each region downwards. > > > > However, after that commit free_highmem() rounds the beginning and end of > > each region downwards, and we may end up freeing a page that is > > memblock_reserve()d, resulting in memory corruption. > > > > Restore the original rounding of the region boundaries to avoid freeing > > reserved pages. > > > > Fixes: cddb5ddf2b76 ("arm, xtensa: simplify initialization of high memory pages") > > Link: https://lore.kernel.org/r/20201029110334.4118-1-ardb@kernel.org/ > > Signed-off-by: Ard Biesheuvel > > Co-developed-by: Mike Rapoport > > Signed-off-by: Mike Rapoport > > --- > > > > Max, Russell, > > > > Please let me know how do you prefer to take it upstream. > > If needed this can go via memblock tree. > > > > v2: fix words order in the commit message > > I really don't understand what is going on here; there seems to be a > total disconnect of communication between yourself and Ard. Ard has > already submitted a different patch for this to the patch system > already, sent yesterday. > > https://www.armlinux.org.uk/developer/patches/viewpatch.php?id=9021/1 > > Please discuss between yourselves how you want to solve the problem, > and then submit an agreed and tested patch to those of us upstream; > please don't make it for those upstream to pick one of your patches > as you are at present. > Apologies for creating this confusion. I posted a patch and dropped it into the patch system when I found the bug. However, only when Florian asked about a 'fixes' tag, I went back to the history, and realized that the issue was introduced by Mike during the most recent merge window, and affects xtensa as well. I don't have a preference which patch gets applied, though, so please indicate your preference, and we will adapt accordingly. > > > > arch/arm/mm/init.c | 4 ++-- > > arch/xtensa/mm/init.c | 4 ++-- > > 2 files changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c > > index d57112a276f5..c23dbf8bebee 100644 > > --- a/arch/arm/mm/init.c > > +++ b/arch/arm/mm/init.c > > @@ -354,8 +354,8 @@ static void __init free_highpages(void) > > /* set highmem page free */ > > for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, > > &range_start, &range_end, NULL) { > > - unsigned long start = PHYS_PFN(range_start); > > - unsigned long end = PHYS_PFN(range_end); > > + unsigned long start = PFN_UP(range_start); > > + unsigned long end = PFN_DOWN(range_end); > > > > /* Ignore complete lowmem entries */ > > if (end <= max_low) > > diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c > > index c6fc83efee0c..8731b7ad9308 100644 > > --- a/arch/xtensa/mm/init.c > > +++ b/arch/xtensa/mm/init.c > > @@ -89,8 +89,8 @@ static void __init free_highpages(void) > > /* set highmem page free */ > > for_each_free_mem_range(i, NUMA_NO_NODE, MEMBLOCK_NONE, > > &range_start, &range_end, NULL) { > > - unsigned long start = PHYS_PFN(range_start); > > - unsigned long end = PHYS_PFN(range_end); > > + unsigned long start = PFN_UP(range_start); > > + unsigned long end = PFN_DOWN(range_end); > > > > /* Ignore complete lowmem entries */ > > if (end <= max_low) > > -- > > 2.28.0 > > > > > > -- > RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ > FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!