Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp27176lqb; Tue, 4 Jun 2024 04:08:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXDPzqHanuiXDfm+nLDx1KMNVrQ+D6vrAZkX1W4+oAbuYr9iv+IZn2WWT+XjynOAuiDYKwZK5Q7NuK+t6oBLi0y+6NYg3TlGy/jJqriZw== X-Google-Smtp-Source: AGHT+IHu2hmffaYJlok63fFtFIvOe/31rFVRfBWfeK/BGWhllcO1c9OccwdXLo3HOdaFDmRdeORI X-Received: by 2002:ac8:7d43:0:b0:43a:f578:23c6 with SMTP id d75a77b69052e-43ff54b03e6mr92267841cf.59.1717499319703; Tue, 04 Jun 2024 04:08:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717499319; cv=pass; d=google.com; s=arc-20160816; b=IZIKsr4Wo5H4ZJBEssp+gNybW/+MeGbtupokhDGL7gYr6r9mzWQXVrMdVXZagyCaU6 wcl9XdWRdXqt9AIB0gq+BA5Obguvrup3a51mI9tdj+tc23En6AqxRHlDe4njzFlb8XUg +/KLWETs7mGbRLZNMArX1fc19EqSP/YBUHprlyuTu+GA9SWjCTwFgPiLkoLPXeAcHQSJ JTFKoztjvCYmGEZowbyvLanY6JoF/O8hSlulEnTIqBRaHF9ufA0sZbsLJrjaY18DZTns EJO5RD2IgOR2tMpqFKP+2Y/PQBmce0Y+HHOLzJqMa3Aswwrxmaz8Y+MHzSezy13MgRas IRgA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date; bh=Kto+FR1FfRpT8M9yY1Kt6Bx+gIpf1YqdKC+9P/vnGxk=; fh=K4FoCp089992NyiAppFLM50urIsCobMvjRio8vx4BaM=; b=JHSZkK9MfFZag6VtXKWPiXUmI5h1KYv8hl2BEr/3eu10G9Y+E5Ee2IO1SWkl7xxsDx PUJiDJtAgC0Os65j7YjKbVjv3t9XuOtdifeGmb5T3Syfbbb+SlSKXiZFq5MEjO84MpyT vhdgFE6Z6j+IP58cUwVH8LsS4VdMNkWlyNMvJni/BZImx4/U7gXryysnyVqUxHMyeZ6E DU51VDqwXnUvdEQr5Kv3/LVIcs60XQca3BB8/CwdTcp54SDkn4AtWBxBE6rzqGIGAr+1 v778Rak9ea/UO/5a3jM7coiDsialua1VDEOH8XQPfceE5m/P4nPbcmUZ/jFK2HoulTOj CDSQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200489-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43ff257e78fsi11063151cf.451.2024.06.04.04.08.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 04:08:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-200489-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200489-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2E03E1C216FF for ; Tue, 4 Jun 2024 11:08:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49810145344; Tue, 4 Jun 2024 11:08:32 +0000 (UTC) Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBD654A07; Tue, 4 Jun 2024 11:08:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717499311; cv=none; b=B2ZL9wQk1FhVO8UDp4g6ph/5flM2Xx0vqsBQPcSrFRiPxpPsLNp/uhR2A8jm5pNVsb2YdTXdiL9RGErfF4Lhpv6SZp1Lne9D8VmFDYmrkTeNhDs2VfCGLaPVxaNUIGZ1I9fXJHd01gNfWVLWV4/3UQCbGg/wAGNU2wUObpGYPoo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717499311; c=relaxed/simple; bh=O/y6u8vfxnyc9M0sYToQE9eckbW/BoNY61LnLEuAsXQ=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YM18s0GC1sZyN5/PEdUB+3SyM8qKJCbK/+7DV30y7RJAC15cpjixI6g6vBY8IFxQ/xZIkPU6Zj2/lHPOggtcDL1fSYUrFGtmuEHUbRXBgRNGmpzdY4BUh7Wficv2l6sLxKzZ1ulWBYk0bI5W9/RKOhjgZwNYLiBQ0MCpvHOMRPw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94E82C2BBFC; Tue, 4 Jun 2024 11:08:27 +0000 (UTC) Date: Tue, 4 Jun 2024 07:08:26 -0400 From: Steven Rostedt To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , "Liam R. Howlett" , Vlastimil Babka , Lorenzo Stoakes , linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Kees Cook , Tony Luck , "Guilherme G. Piccoli" , linux-hardening@vger.kernel.org, Guenter Roeck , Ross Zwisler , wklin@google.com, Vineeth Remanan Pillai , Joel Fernandes , Suleiman Souhlal , Linus Torvalds , Catalin Marinas , Will Deacon , Mike Rapoport Subject: Re: [PATCH 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up Message-ID: <20240604070826.030c5202@gandalf.local.home> In-Reply-To: References: <20240603233330.801075898@goodmis.org> <20240603233631.452433539@goodmis.org> X-Mailer: Claws Mail 3.20.0git84 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 4 Jun 2024 08:03:54 +0200 Ard Biesheuvel wrote: > On Tue, 4 Jun 2024 at 01:35, Steven Rostedt wrote: > > > > From: "Steven Rostedt (Google)" > > > > In order to allow for requesting a memory region that can be used for > > things like pstore on multiple machines where the memory layout is not the > > same, add a new option to the kernel command line called "reserve_mem". > > > > The format is: reserve_mem=nn:align:name > > > > Where it will find nn amount of memory at the given alignment of align. > > The name field is to allow another subsystem to retrieve where the memory > > was found. For example: > > > > reserve_mem=12M:4096:oops ramoops.mem_name=oops > > > > Where ramoops.mem_name will tell ramoops that memory was reserved for it > > via the reserve_mem option and it can find it by calling: > > > > if (reserve_mem_find_by_name("oops", &start, &size)) { > > // start holds the start address and size holds the size given > > > > Link: https://lore.kernel.org/all/ZjJVnZUX3NZiGW6q@kernel.org/ > > > > Suggested-by: Mike Rapoport > > Signed-off-by: Steven Rostedt (Google) > > You failed to point out in the commit message that the assumption here > is that this memory will retain its contents across a soft reboot. Or > am I misunderstanding this? Yes that is the intention. I should update the commit message. > > In any case, as I pointed out before, playing these games unilaterally > from the kernel side, i.e., without any awareness whatsoever from the > firmware and bootloader (which will not attempt to preserve RAM > contents), is likely to have a rather disappointing success ratio in > the general case. I understand this may be different for vertically > integrated software stacks like ChromeOS so perhaps it should live > there as a feature. I have been using this on two different test machines, as well as a chromebook, and it appears to work on all ofthem. As well as for VMs. I plan on adding this to my workstation and server too (they use EFI). > > Then, as Kees points out, there is also the risk that the kernel > itself may be stepping on this memory before having realized that it > is reserved. At least ARM and x86 have decompressors with a > substantial amount of non-trivial placement logic that would need to > be made aware of this reservation. Note that EFI vs. non-EFI boot also > makes a difference here. Agreed. Note, it should definitely state that this is not 100% reliable, and depending on the setup it may not be reliable at all. Whatever uses it should add something to confirm that the memory is the same. If corner cases become an issue, this could be extended to work with them. We could update KASLR to be aware of this allocation. The documentation update to kernel-parameters.txt on this usage should definitely stress that this can be unreliable, and use should be tested to see if it works. And also stress that if it does work, it may not work all the time. The best usage for this is for statistical debugging. For instance, in our use case, we have 1000s of crashes that we have no idea why. If this worked only 10% of the time, the data retrieved from 100 of those crashes would be very valuable. -- Steve