Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp510651pxb; Tue, 14 Sep 2021 02:42:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhgRB07KxJQpiyW3Ko3TgJNniq0Wl/9N701vYAXjVLrEF+j/PsEjPcGmt0bvLNol0pGx9P X-Received: by 2002:a6b:8d8a:: with SMTP id p132mr12476864iod.81.1631612542425; Tue, 14 Sep 2021 02:42:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631612542; cv=none; d=google.com; s=arc-20160816; b=bLzV4CQPFXmfZh/LxcLy/sCP+7hOM8RrCQ1YZbwIvDeU2XCSrySqXFyfi1oiMD4E7s njcNTIOShyOIdoBYA7cLpb/EW0w+dUOpi50HFQ1clIfZbAxE7l0XsO4Msn8wPcV1PlYP Z+uYFpk4RnaLVF1rLd5O6sRL3sTDAvl8W+iOjC1vyAPbOGlyYh3sUPCOVWYn0zY7D8gp IS55B8RVvYQlBiakbaFF19SkK0dqt3RBvYntnILH8FMQ7bD22tslX2tclc3N8JHziqpa kD45xWcD9laBKrM12TFB8Am0tfgkJN0Q3SKfDkOUu/DjH2zTsOrBa+W8PfZyIibElaLX 956g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=30u9QxljtHQChxZ06/YlGhJs1iq5r8Bx3qVFUI1IaBI=; b=v9+2JSmGEveiraGaNLzadeimnryoja/9hJzcONpZ5Cyd9BvP9WXP0jZKAvqEzKXodu Fo6xxJdVhtXxgnHQ0CZduY3bnWUfTQUqgZiRUbuaZAg6OAEv8TamMaruEiSwS8v0wxv0 OZS9okmlf7+kuOB4qKIi4MJk1z4douuRv0CveGHD5gfIsl1p3eejcBy8wNc50WK23I8w i3lalW5Oc/YdEpPFH6YgCrf6o8zOzpSnGHxpwZuqr2MuMIirnOm9b1lW6t+UjiEwzcNl wjPiXp8ieLAtPQZk8A3P5dsctosg8UV5tTXLIN5mQVzGrOekzl+rh+I5c9I5X6tU3nSs qZhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iyMgnQgH; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si9512397ili.46.2021.09.14.02.42.08; Tue, 14 Sep 2021 02:42:22 -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=@suse.com header.s=susede1 header.b=iyMgnQgH; 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=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229946AbhINJmc (ORCPT + 99 others); Tue, 14 Sep 2021 05:42:32 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:41326 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbhINJma (ORCPT ); Tue, 14 Sep 2021 05:42:30 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AF5EA220CC; Tue, 14 Sep 2021 09:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1631612472; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=30u9QxljtHQChxZ06/YlGhJs1iq5r8Bx3qVFUI1IaBI=; b=iyMgnQgHJFFJjFjFAPR5PynTg/uuBNPUBW7HSkJDvAHUqb2vI8NVwufZ9B8pw1W8RwbV21 sY9ZPbqzyYgOU8rd59OHmzpkABuHi4r4SbS2XZaPS0OidXTQJHOpHEsK3oqq72VAHugVPv X+5HfzQQuA8wHQ0cTH5y8G4eeOVFOdw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 61C0313E55; Tue, 14 Sep 2021 09:41:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 1VE8FjhuQGFuSwAAMHmgww (envelope-from ); Tue, 14 Sep 2021 09:41:12 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , stable@vger.kernel.org, =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Subject: [PATCH] x86/setup: call early_reserve_memory() earlier Date: Tue, 14 Sep 2021 11:41:08 +0200 Message-Id: <20210914094108.22482-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() to the beginning of setup_arch() 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 --- arch/x86/kernel/setup.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 79f164141116..f369c51ec580 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -757,6 +757,18 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p) void __init setup_arch(char **cmdline_p) { + /* + * 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_X86_32 memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); @@ -876,18 +888,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