From nobody Mon Apr 29 02:31:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1632139487; cv=none; d=zohomail.com; s=zohoarc; b=LgtQ1easLctELvlB9HNPiYwDTfd68P4RIom7viy03BcVuCVeBDg72otresQW4TUcYtmjIPibDExvjeaXei0nNNKnTNpY62+k7w3ZSGf4fgmZTR36xKLWiOivw4okDJImNy8F6iC8jCMNJOUEKWp7vqpwDa1vsY8u+hECnYgf2Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632139487; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ZubaKTTsXgUFZeDqZBtaX0Nm6q+Zb0+QJDfKEe2ZOB0=; b=VKfWGGZgNyfOfUn4lh6SRWd2GYRGxKI3GwORW+SpW3uT4H8K2xkpKVuRPsEn73A1JuEarUtwhAByhPNTck5PQxWDKcVVS+SoBqwSUadZqjY1ivE2IMKTc0bqNCMjGemcWqvNgjAU2aPN63F61SV8EBxqfyNuij3uDE4vU89j2CQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 163213948708696.40449889437309; Mon, 20 Sep 2021 05:04:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.190828.340616 (Exim 4.92) (envelope-from ) id 1mSI26-0007cY-TC; Mon, 20 Sep 2021 12:04:26 +0000 Received: by outflank-mailman (output) from mailman id 190828.340616; Mon, 20 Sep 2021 12:04:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSI26-0007cR-QD; Mon, 20 Sep 2021 12:04:26 +0000 Received: by outflank-mailman (input) for mailman id 190828; Mon, 20 Sep 2021 12:04:25 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mSI25-0007cL-89 for xen-devel@lists.xenproject.org; Mon, 20 Sep 2021 12:04:25 +0000 Received: from smtp-out2.suse.de (unknown [195.135.220.29]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e4ef18d8-1a0a-11ec-b86f-12813bfff9fa; Mon, 20 Sep 2021 12:04:24 +0000 (UTC) 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-out2.suse.de (Postfix) with ESMTPS id 350D92004D; Mon, 20 Sep 2021 12:04:23 +0000 (UTC) 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 DD4E513483; Mon, 20 Sep 2021 12:04:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qQejNMZ4SGFcIAAAMHmgww (envelope-from ); Mon, 20 Sep 2021 12:04:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version 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: e4ef18d8-1a0a-11ec-b86f-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1632139463; 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=ZubaKTTsXgUFZeDqZBtaX0Nm6q+Zb0+QJDfKEe2ZOB0=; b=TRbibNaBw9G4ffLO9IpRWu3FotMcA752oAO1A9dRbotpmFyTBVpvcurZUpUiTsjus4WhAX p5bgN1t3WNH9uKH9AtdSTbqZYYGBh0IilObJrSuGDgMRJ+586GNI7L3a+B0HartVxBcRI0 2TvIh5lA5Lr5tp6fC757ZhZnP4jql9E= From: Juergen Gross To: xen-devel@lists.xenproject.org, x86@kernel.org, linux-kernel@vger.kernel.org Cc: efault@gmx.de, 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 v2] x86/setup: call early_reserve_memory() earlier Date: Mon, 20 Sep 2021 14:04:21 +0200 Message-Id: <20210920120421.29276-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: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1632139488927100001 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=C3=B3recki Signed-off-by: Juergen Gross Tested-by: Marek Marczykowski-G=C3=B3recki 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) =20 x86_init.oem.arch_setup(); =20 + /* + * 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 =3D (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) =20 parse_early_param(); =20 - /* - * 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 --=20 2.26.2