Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2392346pxb; Mon, 20 Sep 2021 21:10:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMo3f8LyVlgC8foGD3yrDVmj6a4VhGN+mEM7G7BCybmk4V9+7kEafLfyNkMbhF1NJlIj2Q X-Received: by 2002:a6b:ea11:: with SMTP id m17mr13909975ioc.186.1632197452070; Mon, 20 Sep 2021 21:10:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632197452; cv=none; d=google.com; s=arc-20160816; b=fb7RRQflMNHJJIjnEdpBOSkKoRaNGYtJ/d4paRZBaqCPaEmyxUokD95uN8byrhtdFn 9KAdq4fbLJEMwKX0ldLP4gRtJ4IJOF9J54mrQYVZpWybK2Z5NB+mzfUUZi9jzaYOPcQS cI1uVpVc7pkjygSUV3SHyRw4uIR+ewsaLyE5PpFBeLbAeTBzsSLqm8hZQbfiiTf6/7pS ZMj/7BpXYV3HwXAOots9wlWDrVRoHcaeZRPu5rBAZbZOpciA4lDAYJLUijb6KJJW3x4L a9TZQnMVRwCFWOBUmq465tbg+tHPOg0KfaSs8Jos5i+OG/f3le7evcJ529S1xhqyHzxD Sxmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qzcLuDzmGBNi2AkACvUs2XN/5jX8vwKS2+m7x//U/Rc=; b=Yk5wjXiDPENI5debMZ91fRQm5Tc9ubVEJ/QerqMSywqEGCBcfbeNxJtStSQG1qcZR1 tTK1JXuTFA1B7GJl/rEf5QJGsAkxf4W5jQn8CVjbMaLid2I/Le0L1L86HFzPb1DKsYKp wU7XcXc1S4u7ImVQHo2IX2VAI3T/qdKCmtXmq5Si9ITo6de+CNUQTh53nr8MuJYBPF+s 42yV1vB0RB7zTTkQh9TvJ1B1mZKYYRsg/pMguaIH2AlzHjaELfjm2QGb+QewGn6v/zUt vD4b9PaEfKkdkTqaJfRYXA55W/hpGVMQGngwhhPNc/YpMznfqgeFUkWJZzbTIXJyGKq/ 1+hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=n3XB9+ug; 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 a13si13094939ilv.48.2021.09.20.21.10.41; Mon, 20 Sep 2021 21:10:52 -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=k20201202 header.b=n3XB9+ug; 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 S231839AbhIUEBL (ORCPT + 99 others); Tue, 21 Sep 2021 00:01:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:40572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbhIUEBH (ORCPT ); Tue, 21 Sep 2021 00:01:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1516B611C5; Tue, 21 Sep 2021 03:59:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632196779; bh=7OFVjzBNfyXXNiMg++zl6W4YbQ+GkChXNDPM6C4fm5Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=n3XB9+ugrNqVsTPmuetwR6tFfbxIb+a2Z7toWMqN0Dy+j2Cbd7wAA1OEPwy8tAEbZ ZjOua8+cY72aS72AP8eojwewsPQkKUXi2TtXcnk2kUzalmAKD01uRtWYX+3OA8Gepk B87YzxW/IBbfeVyitYV3IaTEAdLqdcLDfGb17WGpYDIka9EhrHUme/0D12blfxBtCu eJPWLehJsL7qkqgkblKCHlkbCjcuZ/ek106F5zZEGKWvfpWeQoNGGFGljGLDpsIpv1 OlBIdUGF7H3tJPgr997lQ9+w/Fo16rZSiWOXwAFb2KxZM19MDil9rGz75CswVKOYZB 7O9rHggfmZiQA== Date: Mon, 20 Sep 2021 20:59:33 -0700 From: Nathan Chancellor To: Juergen Gross Cc: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org, efault@gmx.de, Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , stable@vger.kernel.org, Marek =?iso-8859-1?Q?Marczykowski-G=F3recki?= Subject: Re: [PATCH v2] x86/setup: call early_reserve_memory() earlier Message-ID: References: <20210920120421.29276-1-jgross@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210920120421.29276-1-jgross@suse.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 20, 2021 at 02:04:21PM +0200, Juergen Gross wrote: > Commit a799c2bd29d19c565 ("x86/setup: Consolidate early memory > reservations") introduced early_reserve_memory() to do all needed > initial memblock_reserve() calls in one function. Unfortunately the > call of early_reserve_memory() is done too late for Xen dom0, as in > some cases a Xen hook called by e820__memory_setup() will need those > memory reservations to have happened already. > > Move the call of early_reserve_memory() before the call of > e820__memory_setup() in order to avoid such problems. > > Cc: stable@vger.kernel.org > Fixes: a799c2bd29d19c565 ("x86/setup: Consolidate early memory reservations") > Reported-by: Marek Marczykowski-G?recki > Signed-off-by: Juergen Gross I had issues on an AMD Ryzen 3 4300G based system with v1. v2 does not trigger any boot issues on that same machine or an Intel i5-4210U based system that I also test with. Tested-by: Nathan Chancellor > --- > V2: > - update comment (Jan Beulich, Boris Petkov) > - move call down in setup_arch() (Mike Galbraith) > --- > arch/x86/kernel/setup.c | 26 ++++++++++++++------------ > 1 file changed, 14 insertions(+), 12 deletions(-) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 79f164141116..40ed44ead063 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -830,6 +830,20 @@ void __init setup_arch(char **cmdline_p) > > x86_init.oem.arch_setup(); > > + /* > + * Do some memory reservations *before* memory is added to memblock, so > + * memblock allocations won't overwrite it. > + * > + * After this point, everything still needed from the boot loader or > + * firmware or kernel text should be early reserved or marked not RAM in > + * e820. All other memory is free game. > + * > + * This call needs to happen before e820__memory_setup() which calls the > + * xen_memory_setup() on Xen dom0 which relies on the fact that those > + * early reservations have happened already. > + */ > + early_reserve_memory(); > + > iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1; > e820__memory_setup(); > parse_setup_data(); > @@ -876,18 +890,6 @@ void __init setup_arch(char **cmdline_p) > > parse_early_param(); > > - /* > - * Do some memory reservations *before* memory is added to > - * memblock, so memblock allocations won't overwrite it. > - * Do it after early param, so we could get (unlikely) panic from > - * serial. > - * > - * After this point everything still needed from the boot loader or > - * firmware or kernel text should be early reserved or marked not > - * RAM in e820. All other memory is free game. > - */ > - early_reserve_memory(); > - > #ifdef CONFIG_MEMORY_HOTPLUG > /* > * Memory used by the kernel cannot be hot-removed because Linux > -- > 2.26.2 > >