From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DC4CC433E2 for ; Mon, 25 May 2020 15:58:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 20F312078B for ; Mon, 25 May 2020 15:58:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="aJELzVEP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20F312078B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BD1EC80051; Mon, 25 May 2020 11:58:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BAA4C8E0008; Mon, 25 May 2020 11:58:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A97AA80051; Mon, 25 May 2020 11:58:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0211.hostedemail.com [216.40.44.211]) by kanga.kvack.org (Postfix) with ESMTP id 902848E0008 for ; Mon, 25 May 2020 11:58:35 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 5842F5003 for ; Mon, 25 May 2020 15:58:35 +0000 (UTC) X-FDA: 76855698990.05.ocean83_2dd4fc700fb10 X-HE-Tag: ocean83_2dd4fc700fb10 X-Filterd-Recvd-Size: 5193 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 May 2020 15:58:34 +0000 (UTC) Received: from kernel.org (unknown [87.70.212.59]) (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 1635F2071A; Mon, 25 May 2020 15:58:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590422313; bh=wiDKEyw484GXmzSpZVclCFGRQEPFTvq5irNs419nfE4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aJELzVEPKY+5KMeo8hwIzuqSdQOIGJRHj/t/iF3JINZEsAtYxfFOUSrWPkz21CKEb B3vg9eQI7Das73bdaUmYck2p+l4ymM+jeed8WASz0bR5SGfs0HEDOf2iFB+RvIlCur jJA4oOH7cASC0Bl1E46qbLND7ovDEJmEy0zytSs4= Date: Mon, 25 May 2020 18:58:25 +0300 From: Mike Rapoport To: "Kirill A. Shutemov" Cc: "Kirill A. Shutemov" , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Dan Williams , Tony Luck , x86@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dave Hansen , stable@vger.kernel.org Subject: Re: [PATCH] x86/mm: Fix boot with some memory above MAXMEM Message-ID: <20200525155825.GB13247@kernel.org> References: <20200511191721.1416-1-kirill.shutemov@linux.intel.com> <20200525044902.rsb46bxu5hdsqglt@box> <20200525145943.GA13247@kernel.org> <20200525150820.zljiamptpzi37ohx@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200525150820.zljiamptpzi37ohx@box> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, May 25, 2020 at 06:08:20PM +0300, Kirill A. Shutemov wrote: > On Mon, May 25, 2020 at 05:59:43PM +0300, Mike Rapoport wrote: > > On Mon, May 25, 2020 at 07:49:02AM +0300, Kirill A. Shutemov wrote: > > > On Mon, May 11, 2020 at 10:17:21PM +0300, Kirill A. Shutemov wrote: > > > > A 5-level paging capable machine can have memory above 46-bit in the > > > > physical address space. This memory is only addressable in the 5-level > > > > paging mode: we don't have enough virtual address space to create direct > > > > mapping for such memory in the 4-level paging mode. > > > > > > > > Currently, we fail boot completely: NULL pointer dereference in > > > > subsection_map_init(). > > > > > > > > Skip creating a memblock for such memory instead and notify user that > > > > some memory is not addressable. > > > > > > > > Signed-off-by: Kirill A. Shutemov > > > > Reviewed-by: Dave Hansen > > > > Cc: stable@vger.kernel.org # v4.14 > > > > --- > > > > > > Gentle ping. > > > > > > It's not urgent, but it's a bug fix. Please consider applying. > > > > > > > Tested with a hacked QEMU: https://gist.github.com/kiryl/d45eb54110944ff95e544972d8bdac1d > > > > > > > > --- > > > > arch/x86/kernel/e820.c | 19 +++++++++++++++++-- > > > > 1 file changed, 17 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c > > > > index c5399e80c59c..d320d37d0f95 100644 > > > > --- a/arch/x86/kernel/e820.c > > > > +++ b/arch/x86/kernel/e820.c > > > > @@ -1280,8 +1280,8 @@ void __init e820__memory_setup(void) > > > > > > > > void __init e820__memblock_setup(void) > > > > { > > > > + u64 size, end, not_addressable = 0; > > > > int i; > > > > - u64 end; > > > > > > > > /* > > > > * The bootstrap memblock region count maximum is 128 entries > > > > @@ -1307,7 +1307,22 @@ void __init e820__memblock_setup(void) > > > > if (entry->type != E820_TYPE_RAM && entry->type != E820_TYPE_RESERVED_KERN) > > > > continue; > > > > > > > > - memblock_add(entry->addr, entry->size); > > > > + if (entry->addr >= MAXMEM) { > > > > + not_addressable += entry->size; > > > > + continue; > > > > + } > > > > + > > > > + end = min_t(u64, end, MAXMEM - 1); > > > > + size = end - entry->addr; > > > > + not_addressable += entry->size - size; > > > > + memblock_add(entry->addr, size); > > > > + } > > > > + > > > > + if (not_addressable) { > > > > + pr_err("%lldGB of physical memory is not addressable in the paging mode\n", > > > > + not_addressable >> 30); > > > > + if (!pgtable_l5_enabled()) > > > > + pr_err("Consider enabling 5-level paging\n"); > > > > Could this happen at all when l5 is enabled? > > Does it mean we need kmap() for 64-bit? > > It's future-profing. Who knows what paging modes we would have in the > future. Than maybe pr_err("%lldGB of physical memory is not addressable in %s the paging mode\n", not_addressable >> 30, pgtable_l5_enabled() "5-level" ? "4-level"); "the paging mode" on its own sounds a bit awkward to me. > -- > Kirill A. Shutemov -- Sincerely yours, Mike.