Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3127035pxb; Mon, 25 Jan 2021 07:38:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJzRoHqfi8Wqh1cRgc4imWvNI0pM4ZuRS2AQVEQcbyGsDgsi03rh2iQYI4mkleaJwSH7C701 X-Received: by 2002:a17:907:d27:: with SMTP id gn39mr719920ejc.152.1611589096527; Mon, 25 Jan 2021 07:38:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611589096; cv=none; d=google.com; s=arc-20160816; b=SD0cxFcsxMm+QVu6FH3xtKaRNaXnwqcERmwuarOiNRo+vpVXA99ihxJLBaUCJUZbZp lOYmV9aB9WOMDBRc0RPoxj0fvovQyctT/YyU9qLpE6uPFJnIPxF366VsLdCnaDYJHNpJ mrNrbZwvQZ3ByOaLN7r35JI5JC1JTkq4Aags7ICAlrWNbC9fv2QGSbbBYV8NcanZ5/8t Pa6GSQ4nmIv6rABJOBCCAm4+QuNyr0Rr12ClQuJPzs6LByHTZHBVCWBTGABIyzm57DPF vUp4Q6WY8NpIgPgUEnypQPUR83FdoOoX7sHkjpIPtzCtZo9t7pTKkoVrooKwMBKs5wuR NlmQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=lWUqF+3JpJB9cx2H4gYT2MJct82eXG9nrGA0uRP6xAQ=; b=d1vMwAk5SXv1TbGCFTlqDjQhxE7cih2KMYA7r7RSmoriOyEmEowHaUZAaWY5UpBD/8 TnUu6p4IF+zK9ZjbRWTaM60yHSdeiDyD34LWuJnCZWH5inxpG9v5KI44N8eeSwVxDX42 1yAgk/ZB2Wx39pRIpLVD++Ji9EKvii3gKj4SAeJe8G82ZCuunb3SkyN2lyAfZ4aMWnXm OBqrHNDJeKZyrYBcCOHO44jMTa9RSS4OQadwENrborMeIPZtMxWqSti+QyaeuY/NFpok B7TE1VR8919imFUSubsrmcXr622uIjMTzHIkZDMzgwUMo7CpHEiG7GmC1lX9vCYk+GfY 9ZCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jAIjljpR; 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 c14si7308792edv.132.2021.01.25.07.37.51; Mon, 25 Jan 2021 07:38:16 -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=jAIjljpR; 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 S1729893AbhAYPfg (ORCPT + 99 others); Mon, 25 Jan 2021 10:35:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:37862 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729869AbhAYPdo (ORCPT ); Mon, 25 Jan 2021 10:33:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9DC8423B70; Mon, 25 Jan 2021 15:31:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611588682; bh=qjqOOxZHKUNkJrWJLLIv5ELWV/kMvv5CYzw1+xODwS0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jAIjljpRC9HZtZNqGk1TAWWiZm0+mJJBd9Cqz1brf/HrRlTH3LnsgjuoyIlO0NH2K tAL2IGsS6H92+0RRFMP59nK7k6ZzMd8lCdCYrRMdFLAE+9tOUopdi9P9kTQY3fw16M l0pQ9luW5RcK21IceGedE4jzyKw6624rhQaJq7uqe4miZ1PFToGe0PaYqCXjoJamwW F3j+zMU4FJM796dn28MGcq81vHzqF3a0zEN/T3eAeHDdYB9FRdtsQAjrh7YzysuA9n APsvKnhcdqxxG6d/q9lPg8myw7RX5B3BJKCik7ZRG4meBfCABC9vc/wqRlIrbl3nbv qH+4ravqCopLA== Date: Mon, 25 Jan 2021 17:31:14 +0200 From: Mike Rapoport To: Borislav Petkov Cc: Andrew Morton , Andrea Arcangeli , Baoquan He , David Hildenbrand , "H. Peter Anvin" , Ingo Molnar , Mel Gorman , Michal Hocko , Mike Rapoport , Qian Cai , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org Subject: Re: [PATCH 1/2] x86/setup: consolidate early memory reservations Message-ID: <20210125153114.GH6332@kernel.org> References: <20210115083255.12744-1-rppt@kernel.org> <20210115083255.12744-2-rppt@kernel.org> <20210125145041.GD23070@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210125145041.GD23070@zn.tnic> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2021 at 03:50:41PM +0100, Borislav Petkov wrote: > On Fri, Jan 15, 2021 at 10:32:54AM +0200, Mike Rapoport wrote: > > From: Mike Rapoport > > > > The early reservations of memory areas used by the firmware, bootloader, > > kernel text and data are spread over setup_arch(). Moreover, some of them > > happen *after* memblock allocations, e.g trim_platform_memory_ranges() and > > trim_low_memory_range() are called after reserve_real_mode() that allocates > > memory. > > > > We did not observe corruption of these memory regions because memblock > > Make that "We" impersonal, passive voice pls. Ok. > > always allocates memory either from the end of memory (in top-down mode) or > > above the kernel image (in bottom-up mode). However, the bottom up mode is > > going to be updated to span the entire memory [1] to avoid limitations > > caused by KASLR. > > > > Consolidate early memory reservations in a dedicated function to improve > > robustness against future changes. Having the early reservations in one > > place also makes it clearer what memory must be reserved before we allow > > memblock allocations. > > Would it make sense to have a check with a WARN or so to catch early > reservations which get added after memblock allocations have been > allowed? To catch people who don't pay attention... This would make sense but it's tricky. From memblock perspective, allocations are always allowed and it is the user responsibility to ensure all the early reservations are done before allocating memory. So adding such a WARN would require a new memblock API and it's adoption by all architectures, which is way beyond the scope of this series :) -- Sincerely yours, Mike.