Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp207798pxb; Fri, 15 Jan 2021 00:48:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsOwdb3dQj/5hdaVuWVRiBu0zJFHBDZPEdki+QPhc0IzZ6BqpNW/J9h7LJTpf3q5pAhd/q X-Received: by 2002:a50:bf4a:: with SMTP id g10mr8482586edk.201.1610700530295; Fri, 15 Jan 2021 00:48:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610700530; cv=none; d=google.com; s=arc-20160816; b=SW3DE6+jres+wPgC5AhGMv/2H393LXtHUCvW2bnF/n8oS3Ilf/eGLdO2FActOLjLOt JRBuM7rtecI5ZQFzw7+C5VNNoR2dlZjy/YeomEjSiHd+dfpaJwRTXI6HEpBnrdcubAR2 et2UP7/DueMVKsPoG8CzgwAcP3Z+0dkW3ialjOdXgxIwaoUgnkX5kM+t3SJZBEXXQSFs PDN6D7adWJ/tt/a6L/a18bawbYGxRgX6QxT3fi+rR3tBT8FYKLOiy2foEmirKcUiChOS IXWrtUs4BG5FiTN5bkWrOURxzfTsJA8xQOO0SrIrkp9XopF/EuAIR3zmVEGU5dK6CE0r FLEg== 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=I7c0DcqRLWtcxtdg2kZYE3j1Uu4pcGfbF6yK9qfzigI=; b=PPmoEpwWIhc2zEtWSOG15Yxfl7RoAr7+rr9rcY1vzUMMjMbroJ/lqq7QPCPDg6lFQL nR70Jft5ZahgH7FPmvMJLIPWuJMlJ0vhb6aCsespBWHunRYNQMZ8v9tU4N3y6HQwtEAw A1r0zKgIzGI4yVhNaozphwiM1kev3GHEEBjjdY8kIS0XW1ckrgsvj4ZRzAb84VGSVOkG OaEBiI0udWnic3aLoagqI1DfGMFYXbamtP1DsvDbtEcl1mIAU7vcrX15fZtAfrvTv9zF mlRkNe7VPaZTAoUu3dB9XIGnBy6q+fR5V7yOdlJ6BryH+d/XcrQ/X/8aZls2XrMNqUFd QZ1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SW/g2dTW"; 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 v26si3960574edw.486.2021.01.15.00.48.27; Fri, 15 Jan 2021 00:48:50 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="SW/g2dTW"; 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 S1726439AbhAOIeB (ORCPT + 99 others); Fri, 15 Jan 2021 03:34:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:57284 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725880AbhAOIeB (ORCPT ); Fri, 15 Jan 2021 03:34:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8017522597; Fri, 15 Jan 2021 08:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610699600; bh=KpXmcXL6FYc320RhBuERzath9qSEZFkBf2bJF4H4cmc=; h=From:To:Cc:Subject:Date:From; b=SW/g2dTWKGHibp7GcZoc7RanuaeEfvCGzUkMd2N28NQnlLJpd21DXiKc+XHf8fh8I xo3OBIE5Vdj31zcF/CR2c2TE2vijLaJb0ipZGQMTgENBPS79Hh3J/W4eX41XpWh1Q7 MFTK5UQvdchPjerlzxb5j+EtLXFpulrVGXTYtlfTEkleyvB+x1BHxUEgt6g9PgPO5P 4YchAEcLGJamFPM4LH6yfLPxCGMDVR6+ep8jsTXJWiztRpiFJOLEIntGHZIOP+hHaO LriShka04lSjY7Ny1aZ8GmGlyNI2eTUMMFFkvURjmf8D2gWY/36k5FDT5A4iYejy7x MqaCavw9ej1hg== From: Mike Rapoport To: Andrew Morton Cc: Andrea Arcangeli , Baoquan He , Borislav Petkov , David Hildenbrand , "H. Peter Anvin" , Ingo Molnar , Mel Gorman , Michal Hocko , Mike Rapoport , Mike Rapoport , Qian Cai , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: [PATCH 0/2] x86/setup: consolidate early memory reservations Date: Fri, 15 Jan 2021 10:32:53 +0200 Message-Id: <20210115083255.12744-1-rppt@kernel.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Rapoport Hi, David noticed that we do some of memblock_reserve() calls after allocations are possible: https://lore.kernel.org/lkml/6ba6bde3-1520-5cd0-f987-32d543f0b79f@redhat.com For now there is no actual problem because in top-down mode we allocate from the end of the memory and in bottom-up mode we allocate above the kernel image. But there is a patch in the mm tree that allow bottom-up allocations below the kernel: https://lore.kernel.org/lkml/20201217201214.3414100-2-guro@fb.com and with this change we may get a memory corruption if an allocation steps on some of the firmware areas that are yet to be reserved. The below patches consolidate early memory reservations done during setup_arch() so that memory used by firmware, bootloader, kernel text/data and the memory that should be excluded from the available memory for whatever other reason is reserved before memblock allocations are possible. The patches are vs v5.11-rc3-mmots-2021-01-12-02-00 as I think they are prerequisite for the memblock bottom-up changes, but if needed I can rebase then on another tree. Mike Rapoport (2): x86/setup: consolidate early memory reservations x86/setup: merge several reservations of start of the memory arch/x86/kernel/setup.c | 85 +++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 42 deletions(-) -- 2.28.0