Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp897798pxb; Thu, 28 Jan 2021 03:09:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6InFeeBysD2Qo3EGJP6GhqvoG+P/T8iYaedQvTLvFCouZ8DW+wrvQUkg6q4enCDpGP5Aj X-Received: by 2002:a17:906:8609:: with SMTP id o9mr10431373ejx.241.1611832159783; Thu, 28 Jan 2021 03:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611832159; cv=none; d=google.com; s=arc-20160816; b=FGxKfqP1TeOGDcjeq4UaBw8q2PRvcWqgYgV6KafeNkjP+A/jh3IRk+yNGQ0VZEVphw JZGTfg3/mn/BfuSQDuNoPW5rbVK394+9ZjuPYisAWrKet39+zo6FM6bJ/f1rUB5OjocT 7V+ve11mGFKpSMUsfqLPYMj12g+ycFpPIzDaM9u86f1TuhOuPpo46nIb3HEwZCgCd28E J5ih7FFFjnKDdF/eysOIs66HwajkYHXC83wXI89MT+QLpplBysUJaQkqS95Bu50Lfxbb P7fyH7q3VuyCPWCJU6BP6DOaUmTQp3FSm74Nrc9+THQ+wkYBhMo4uQNC9gEJU/wcYFr3 K+Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:authorized-sender; bh=IPAUsIeX7dZmH9XleMAYtkKaPqzbkXF48sOBb+EUA6k=; b=Ws5CArzeGJJQk0A/AgVXgyTwXeVVm5UudRSrmhMVuZWzNWM8KyiNjiugrp1wQbSBEh sF9uhe+8YEMZZoPfWk4yCEBh78ZI/0GrNvLiVzmMojoCF5cLw6ElN+7sR66OUjsqoreE 2dhuXunPf9B3VsZGtmTpNE2IvaedwQ4BiOkWdMbFWqboxHcO9DBSk2vOB6zFy9y5sPkE CmmD+UiVh4mBctiz1fEI+OJP8CyRG4KD9qsVShT8+Y4T/wr9bLn1CRTD5dwjDvVc3Dro EQnzD6xOsfLqo+pSiUYBnKdy9DZ4a40vlOiFsDcnYWnXqo6a18yu08jGld4Tf7GgACOt pL2Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l18si2246233eji.492.2021.01.28.03.08.54; Thu, 28 Jan 2021 03:09:19 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231187AbhA1LGV (ORCPT + 99 others); Thu, 28 Jan 2021 06:06:21 -0500 Received: from bin-mail-out-05.binero.net ([195.74.38.228]:54069 "EHLO bin-mail-out-05.binero.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbhA1LGR (ORCPT ); Thu, 28 Jan 2021 06:06:17 -0500 X-Halon-ID: bac96e9c-6158-11eb-b73f-0050569116f7 Authorized-sender: andreas@gaisler.com Received: from andreas.got.gaisler.com (h-98-128-223-123.na.cust.bahnhof.se [98.128.223.123]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id bac96e9c-6158-11eb-b73f-0050569116f7; Thu, 28 Jan 2021 12:05:33 +0100 (CET) Subject: Re: sparc32: boot fails with > 256 MB memory after switch to NO_BOOTMEM To: Mike Rapoport Cc: Sparc kernel list , linux-mm@kvack.org, Mike Rapoport , Linux Kernel Mailing List , "David S. Miller" , Sam Ravnborg , Michal Hocko References: <5adb7c41-ad71-b904-6b73-35aef4dfcafe@gaisler.com> <20210128093541.GC299309@linux.ibm.com> From: Andreas Larsson Message-ID: Date: Thu, 28 Jan 2021 12:05:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20210128093541.GC299309@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-28 10:35, Mike Rapoport wrote: > On Wed, Jan 27, 2021 at 04:03:00PM +0100, Andreas Larsson wrote: >> >> >> Commit cca079ef8ac29a7c02192d2bad2ffe4c0c5ffdd0 makes sparc32 use >> memblocks instead of the previous bootmem solution. Unfortunately, due >> to this: >> >> #define PAGE_OFFSET 0xf0000000 >> #define __va(x) ((void *)((unsigned long) (x) - phys_base + >> PAGE_OFFSET)) >> #define phys_to_virt __va >> >> it makes physical addresses >= 0x10000000 past phys_base wrap around the >> 32-bit memory space when converted to virtual addresses, e.g. in >> memblock_alloc_try_nid. Physical memory exactly 0x10000000 past >> phys_base is returned as an unintended NULL pointer, leading to a panic >> in my boot when percpu memory allocation fails due to it. >> >> Unfortunately I have had 256 MB memory or less in a lot of my testing, >> so this old one has slipped by me. >> >> Does anyone has any ideas or pointers on how to resolve this? > > I think the simplest way to work around this is to limit early allocations > to 256M with addition of > > memblock_set_current_limit(SZ_256M); > > somewhere at setup_arch(). > > The page allocator will anyway see the entire memory, so I cannot think of > any downside here. That works like a charm! Thank you! I'll submit a patch. -- Andreas Larsson Cobham Gaisler