Received: by 2002:ab2:784b:0:b0:1fd:adc2:8405 with SMTP id m11csp493631lqp; Mon, 10 Jun 2024 10:02:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWUbInRQCU1jk44gDWWwDa+ikWnz36Ybu5J8Qw2x+ywoqFtIPNleyoeJCFn7yJO55HbzHUxzPYy0MCR8HDRLLWPVdazU56UgIshA/K+Zw== X-Google-Smtp-Source: AGHT+IFKcaiSKU+jpsUcFILDZ5MIpc85KeEOurEGIRtNEKydYQwfjy8pjPZNpT29av5T7u2rTIxw X-Received: by 2002:a05:6a20:7f8c:b0:1b1:ec17:ad81 with SMTP id adf61e73a8af0-1b2f9a4d876mr13169963637.29.1718038935148; Mon, 10 Jun 2024 10:02:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718038935; cv=pass; d=google.com; s=arc-20160816; b=kvGMQ/4yjWApLapcWWfdX5yjLdOR5SH9D2BNVL3emRPbchnFt3D4n2RogMPP2Bwgu3 RO/D0FhfIJ3mehiUXoDXcI4LaDnOoIBxBs8OOs+CMx+weZeSeIRHTpB8j0bt+ajT/UVq q0G7463UHi245HaWvQ5dBHsPlzpiq/vpkn1Q4N6mT+7gjb8y0nEWBLYkyPN+4XDyXKxT CYvS74Ly9VdHi+6+GAstT6vh/4GJxpgg64BTreedDMYM4DFPeKsuVBnNF8vT1F95qBiz +RIqkRGplIPP+QfDSQMhEc/tmlUx3cr3bReftI5pbyR2ffpkoRiUcIFiN6aBniuvaEvW NlmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eVlEcHfF80iKfLaqatoE33k/NEhsBfjLtQ95b6hAHFA=; fh=P2+5tRJ4DFiBXZAD6NPb9ulwNXqhYzwC4gyu4mfNXnA=; b=KVM8OeCrXmX3vwronlTM2u+erQqUYkuZeq8RPXQxmueiBwvAJCyBXY8WtiFApBHy9Q ik0hxHt3xc31nQiLJMQNHSEpUnKekveD2rSLHtLIP4g4Wl1Av6LSsT0rcwnfxfj4UO6Y 3fzimYevDggn5VZQrbu0NqQR8SmkjhCbK5sPGAED/ihSexSQ4WRN/WrbMMJPysLyiUIX wQkdug9n6DuotEGF+7z8tZ8SOjNQd4SebzhztXLFQNAbc3jggAKbI1D+lf2Kd6gNnh/G rjyOEhnCf7lrg42G8+uznsVIeOEFCgqpxEzaVryX6MaZuGv/a5b1NqiQcWAcmQtBlfl7 14YA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ti3YrOvh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208633-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208633-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de261cadacsi5356827a12.260.2024.06.10.10.02.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 10:02:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208633-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ti3YrOvh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-208633-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208633-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 403AA28971E for ; Mon, 10 Jun 2024 17:02:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B846144D19; Mon, 10 Jun 2024 17:02:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ti3YrOvh" 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 B502D1EA6F; Mon, 10 Jun 2024 17:02:06 +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=1718038926; cv=none; b=D13GHqW+hqVBrxmgP87LogMWHuwVKCNrsJOEXpU2q/fpuulY0SZ1D48eXVBapQ2aPSLaEJ1lpbWeEMj/txE+f/zoqwmHZVlU1nhNQvNxWZqhIb9jvXL22PZ9ykYgMtupb84KtawluHjR6s0YXGwvlxUcaLOq+lS5hHrOW/jwt7Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718038926; c=relaxed/simple; bh=WFeffItMXMcz+XG1+wQHxMIyeQdKyjz6JLP3Gz+RuNw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nWU4H/iXSNHiZmjRBFCh7p7sjVWaoVlANLr07adgarlHfFA/FZGdF9T9i/0l97RGZJFmYNlv6nvLzvPQ4hDAjDoSebjCDFYc3EYEWOBHCuM22OsWbj8DnEbWcjcL8IgJPqCePbU0hu6T3GvRYULyoHFZzZa0VzNHbL4+i5Cc/ug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ti3YrOvh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33F37C2BBFC; Mon, 10 Jun 2024 17:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718038926; bh=WFeffItMXMcz+XG1+wQHxMIyeQdKyjz6JLP3Gz+RuNw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ti3YrOvh6kr5L5/NEmkjAc5sZJGS2uB9eaN9LfnQmvR7CYr1QvL70SPO1fFt+U3b+ doxRofUpDLlm82KDuIFhpGfxLe1vkjZjOSUgNJ0+fLX2LXO7StMGCMkXufzn8drQN0 6OiNHM6Uf/ryvFLlmDbEEHSfOU8ryT/2wjZqzX6aV4iZP3D7Gd78TistJY9yFMMTF4 UEcLNDRf5z0B0KLJWltETSvBp/o3kbaYzMNKlw8C8TXulzA6FAytCGJHVjUX+b1oWu UeSi5LdyRoEd5kDGRZlhTAcaT5HWBWlYEdD+5IdM7uZStDBCz/CJGdxOi9VuvbLqOD 9AOlEQ2ImzyDw== Date: Mon, 10 Jun 2024 10:02:05 -0700 From: Kees Cook To: "Guilherme G. Piccoli" Cc: Steven Rostedt , 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 , Tony Luck , 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 , Ard Biesheuvel Subject: Re: [PATCH v2 0/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up Message-ID: <202406101001.D469C9A@keescook> References: <20240606150143.876469296@goodmis.org> 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-Disposition: inline In-Reply-To: On Fri, Jun 07, 2024 at 04:54:41PM -0300, Guilherme G. Piccoli wrote: > On 06/06/2024 12:01, Steven Rostedt wrote: > > Reserve unspecified location of physical memory from kernel command line > > [...] > > Solution: > > > > The solution I have come up with is to introduce a new "reserve_mem=" kernel > > command line. This parameter takes the following format: > > > > reserve_mem=nn:align:label > > > > Where nn is the size of memory to reserve, the align is the alignment of > > that memory, and label is the way for other sub-systems to find that memory. > > This way the kernel command line could have: > > > > reserve_mem=12M:4096:oops ramoops.mem_name=oops > > > > At boot up, the kernel will search for 12 megabytes in usable memory regions > > with an alignment of 4096. It will start at the highest regions and work its > > way down (for those old devices that want access to lower address DMA). When > > it finds a region, it will save it off in a small table and mark it with the > > "oops" label. Then the pstore ramoops sub-system could ask for that memory > > and location, and it will map itself there. > > > > This prototype allows for 8 different mappings (which may be overkill, 4 is > > probably plenty) with 16 byte size to store the label. > > > > I have tested this and it works for us to solve the above problem. We can > > update the kernel and command line and increase the size of pstore without > > needing to update the firmware, or knowing every memory layout of each > > board. I only tested this locally, it has not been tested in the field. > > > > Hi Steve, first of all, thanks for this work! This is much appreciated. > The kdumpst tooling (Arch Linux) makes use of pstore when available, and > the recommendation so far was to reserve memory somehow, like "mem=" or > use kdump instead, if no free RAM area was available. > > With your solution, things get way more "elegant". Also, I think we all > know pstore is not 100% reliable, specially the RAM backend due to > already mentioned reasons (like FW memory retraining, ECC memory, etc), > but it's great we have a mechanism to **try it**. If it works, awesome - > for statistical analysis, this is very useful; pstore has been used with > success in the Steam Deck, for example. > > With all that said, I've tested your patches on top of 6.10-rc2 in 2 > qemu VMs (one running legacy BIOS - seabios - and the other UEFI - using > ovmf) and on Steam Deck, and it's working flawlessly. I've tested only > using ramoops as module. > > Some code review in the patches themselves (like a missing > EXPORT_SYMBOL_GPL), but all in all, that's a great addition! Feel free > to add my: > > Tested-by: Guilherme G. Piccoli Yeah, I think this looks good as long as it's understood to be a "best effort", and will radically simplify doing qemu testing, etc. I expect I can take v3 into -next with the fixes Guilherme noted. -Kees -- Kees Cook