Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A102C35274 for ; Mon, 18 Dec 2023 14:59:32 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.656113.1024094 (Exim 4.92) (envelope-from ) id 1rFF5O-0003WT-2P; Mon, 18 Dec 2023 14:59:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 656113.1024094; Mon, 18 Dec 2023 14:59:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFF5N-0003WM-VL; Mon, 18 Dec 2023 14:59:13 +0000 Received: by outflank-mailman (input) for mailman id 656113; Mon, 18 Dec 2023 14:59:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rFF5M-0003V8-0J for xen-devel@lists.xenproject.org; Mon, 18 Dec 2023 14:59:12 +0000 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [2a00:1450:4864:20::42e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id ff7d9952-9db5-11ee-9b0f-b553b5be7939; Mon, 18 Dec 2023 15:59:09 +0100 (CET) Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-33666946422so924426f8f.1 for ; Mon, 18 Dec 2023 06:59:09 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id z8-20020adfec88000000b0033661255299sm5647133wrn.34.2023.12.18.06.59.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Dec 2023 06:59:08 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: ff7d9952-9db5-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1702911549; x=1703516349; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=cxP29n4VWgPdbNOCi1SlYHTP9cf3/4CPHpClqTi9kAg=; b=fAF1q2rmDLcaOsHbOtpfDbYfw1vL4yxLSDSsK2vWBtlbb6+bu6ZDWuIKZyDM95dRbY dIJQx+1ErsuOld+HmW/O3hb4yx24si3D39ACGYQBy/4r9DGfrZ/wbma8TxV8kSI+17wG chVQcKR39OgVTQYRk3wnh7AaChyVf/IHSuLPRw7zVE2V5wvOP5hFwvPW3A9/n4gqpeYr ayMQB19KB5yHgqSNWgd9YkvxynV2EJgHppWWiCLADFyB8Jcl9sCRPm57JmUaEyfgP7Rw qmd5Zwo+BZVDa1IX/FLma5L10a9l9te9dMiG7pCyT2MLiaNPQDbYKSJAb3GFLaLn0yil kScg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702911549; x=1703516349; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cxP29n4VWgPdbNOCi1SlYHTP9cf3/4CPHpClqTi9kAg=; b=esDCX2u6oCceXCyiyg60AKkji4G78bK9xEQ+K2K4xwVIcveljvsJbGWX6y+/DcDePh qqPqoifF2Ikipzyg9eku8lorSzxitEfyFuZmc3WT/RQ7Z12XrhJ1kXXUgOdaunkdOyFB WQ89wPqVnO0Z/xUWt8tM8xVtHItJGEuy5+7Cxl65S18ipz+vd4PYIXglD27gRqbLHXzL hoX6oyL0f2kgkxzKWHfwdewVbe7JObBu41jFvG4uKEm0Jv9soBFHhLgh5SyKWidDkMsq p40+AqChf99V5VM7KQiZpVSw2B/LZTk5yjghP/RB10fFimP8fVssDt+gpOz0Zyvud+S4 vokg== X-Gm-Message-State: AOJu0Yx2tPm1HeBQe11erOu58Lx3gXLvvMbneiiR8PIRV/gr/2HVZ26d KUH0D1hyemRvcfmIBkhtEQ+s X-Google-Smtp-Source: AGHT+IGhDOv82I4kXat8MLnocczdOTQWF2fMhWWRpM8tZovtLHu+LvYc2bPkkEUfxPo9sTaiv639ag== X-Received: by 2002:a5d:5f49:0:b0:336:6d62:763e with SMTP id cm9-20020a5d5f49000000b003366d62763emr604511wrb.7.1702911549174; Mon, 18 Dec 2023 06:59:09 -0800 (PST) Message-ID: Date: Mon, 18 Dec 2023 15:59:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] x86: allow non-BIGMEM configs to boot on >= 16Tb systems Content-Language: en-US To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: "xen-devel@lists.xenproject.org" , Andrew Cooper , Wei Liu References: <4b282f2f-bce8-4c98-897c-2866ec1b6dd0@suse.com> <3a41ab3a-c1e6-4371-bd71-26cd97baffd6@suse.com> From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBt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MpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 18.12.2023 12:13, Roger Pau Monné wrote: > On Mon, Dec 18, 2023 at 09:26:24AM +0100, Jan Beulich wrote: >> On 15.12.2023 15:54, Roger Pau Monné wrote: >>> On Wed, Jun 07, 2023 at 08:17:30AM +0200, Jan Beulich wrote: >>>> While frame table setup, directmap init, and boot allocator population >>>> respect all intended bounds, the logic passing memory to the heap >>>> allocator which wasn't passed to the boot allocator fails to respect >>>> max_{pdx,pfn}. This then typically triggers the BUG() in >>>> free_heap_pages() after checking page state, because of hitting a struct >>>> page_info instance which was set to all ~0. >>>> >>>> Of course all the memory above the 16Tb boundary is still going to >>>> remain unused; using it requires BIGMEM=y. And of course this fix >>>> similarly ought to help BIGMEM=y configurations on >= 123Tb systems >>>> (where all the memory beyond that boundary continues to be unused). >>>> >>>> Fixes: bac2000063ba ("x86-64: reduce range spanned by 1:1 mapping and frame table indexes") >>>> Signed-off-by: Jan Beulich >>> >>> Acked-by: Roger Pau Monné >> >> Thanks. >> >>>> --- a/xen/arch/x86/setup.c >>>> +++ b/xen/arch/x86/setup.c >>>> @@ -1722,15 +1722,16 @@ void __init noreturn __start_xen(unsigne >>>> >>>> if ( max_page - 1 > virt_to_mfn(HYPERVISOR_VIRT_END - 1) ) >>>> { >>>> - unsigned long limit = virt_to_mfn(HYPERVISOR_VIRT_END - 1); >>>> + unsigned long lo = virt_to_mfn(HYPERVISOR_VIRT_END - 1); >>>> + unsigned long hi = pdx_to_pfn(max_pdx - 1) + 1; >>> >>> Maybe use max_page to avoid the pdx_to_pfn() call? (And is also more >>> in context with the condition on the outside if). >> >> You mean >> >> unsigned long hi = min(pdx_to_pfn(max_pdx - 1) + 1, max_page); >> >> ? I could switch to that, yes. I wouldn't feel well switching to using >> just max_page, especially with me having nowhere to (reasonably) test. > > Isn't max_page derived from max_pdx (see setup_max_pdx()), and > hence we could avoid the pdx_to_pfn() conversion by just using it? > > max_page = pdx_to_pfn(max_pdx - 1) + 1; > > So hi == max_page in your proposed code. > > Maybe there are further restrictions applied to max_pdx that are not > propagated into max_page, the meaning of all those variables is very > opaque, and hard to follow in the source code. Looking more closely, the two appear to be properly in sync once setup_max_pdx() was called the first time. I guess I was in part mislead by e = (pdx_to_pfn(max_pdx - 1) + 1ULL) << PAGE_SHIFT; just a few lines past an update to both variables. I'll switch to max_page here, and I may also make a patch to tidy the line quoted above. Jan