Received: by 2002:ab2:6f44:0:b0:1fd:c486:4f03 with SMTP id l4csp76411lqq; Wed, 12 Jun 2024 17:35:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWBXq93B/61S6e7nhajzt+dZWRz8BlfwDuj1m+V7dsXfEzq+62lLmSN4y31dWTciJhyzfbJHHpDkBZtVluAbKLZJDd9+mS2xwDQrBt/qw== X-Google-Smtp-Source: AGHT+IHRqwUmi1InLzVPD/CcfDDMDSptw2wA3iKJ2wruABHvsfjEfRHqqTe5boDLR5TXk43ha2NI X-Received: by 2002:ac8:5d8c:0:b0:43a:ed9c:36f3 with SMTP id d75a77b69052e-4415ac5bc27mr44277651cf.42.1718238909666; Wed, 12 Jun 2024 17:35:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718238909; cv=pass; d=google.com; s=arc-20160816; b=VKs9tjm+1YkLY62OjN9eh4u2SFHZn2o8VlM+fHMmx5Vl3PxaKjdsjKH7XgJv2RAj90 8qQLu8mfNqSxOy2dHtkb/pIZKMN+nQ+lsVSlLr55A2aOQ7ovlU556Zu0kTPH2N/TGZXX MGurdZ3dMXKTaxfKxYXHeqvL9j7EPiSFYujq1fS7rojjR+d6IK5ZafvZ9234Mswl9Qm9 8CXJmhAjZL+pcQU06bvH7j9OJrCRAEpu5Ml4hkL//v5JpWGBxl952q6sKPA4TGbRSBvs iMqzfDIZMnkBPJzLvQHr9wRBG+4zrpqm3F5Xw09e3y6Xdze293blr3oo2pzqdq6ilS27 Z6Sw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:subject:cc:to:from:date:user-agent:message-id; bh=QzN3YGRkVyxpLqEbfzy/POyX0V7EbVZAm324ZBlI6DY=; fh=QORXSiDV/x9VWq4RcqWjO5bZNJ5t7To8OgD4cz5pN8M=; b=K69jBK2XgtnOZVjz/eZRY8m+CVMpzBNnEmHGqQfaL5UOI+MevQUhafy5p+lySXRoUH 80ozjOQ3IUEsBoWt+wefUekPYLLk8i6E3Bgkn1HqxCEmsfnINAfDtYgbK2zbJp4JRyLm 3ESstUWOSaDgT2dG2tVRVjhFvDvjsm/si4HsNIU12C9AUMHJP+HNyluygPPwM+0aFBHU DsHSUyG6n5kaoOZHh74tmOfqC1bHp0o447Ubm1dP4w7eH1OTjW9EADx6RBP1c6ClGMkl MRiKUCWZLEWeVp/NeYwT5mIYvF3249cNezs1/ZzW07EPKHAjkddRd4qJcA/F42wLI4rx 9v2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-212406-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212406-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-441ef3dcd23si3692131cf.223.2024.06.12.17.35.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 17:35:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-212406-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-212406-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-212406-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 55DC71C212E9 for ; Thu, 13 Jun 2024 00:35:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15A89B644; Thu, 13 Jun 2024 00:34:54 +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 4E85F63A5; Thu, 13 Jun 2024 00:34:53 +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=1718238893; cv=none; b=an4CZBk4rnrtxPHWg5yEYJo9wY7lvvDKS/pIa4PZbI5NnsSalqoo2nF5Sw6mTaFFV237AJWWkMffoX3wsFmJ5s3Y8w7NLW76DeM2FsbIsfYa1l5ME7xYCoqwcgKCC8t3ZGEKSUHVfrNDYEqWAfbvhNHxUgz+6A1YmxolQW8edNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718238893; c=relaxed/simple; bh=uhP9G8bT8fUmRQ2ghs8UzgPprc3W3L4JLL0dPpaSGH8=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=IjJswwRxQ4PomoJjTaOJ0AcbM2fzrJpZ2pBPhdOQlJrRVAyv/5hsjVU1vN/Zuc3KdiVZom9R5aEh9fq+TuUNe1HLZ5afheOMglL9aQV2g6phMTtShxAB7GfdJoQ9bCzeLNaUe6dnPSvmNt4kyXAEavgOhy5kfnYpGjV2PjYZxDk= 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 95BCCC32786; Thu, 13 Jun 2024 00:34:52 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sHYQm-00000001eN3-3lZi; Wed, 12 Jun 2024 20:35:08 -0400 Message-ID: <20240613003508.752963299@goodmis.org> User-Agent: quilt/0.68 Date: Wed, 12 Jun 2024 20:34:36 -0400 From: Steven Rostedt To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Cc: 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 , Ard Biesheuvel , Mike Rapoport Subject: [PATCH v5 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up References: <20240613003435.401549779@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=UTF-8 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 This is typically used for systems that do not wipe the RAM, and this command line will try to reserve the same physical memory on soft reboots. Note, it is not guaranteed to be the same location. For example, if KASLR places the kernel at the location of where the RAM reservation was from a previous boot, the new reservation will be at a different location. Any subsystem using this feature must add a way to verify that the contents of the physical memory is from a previous boot, as there may be cases where the memory will not be located at the same location. Not all systems may work either. There could be bit flips if the reboot goes through the BIOS. Using kexec to reboot the machine is likely to have better results in such cases. Link: https://lore.kernel.org/all/ZjJVnZUX3NZiGW6q@kernel.org/ Suggested-by: Mike Rapoport Tested-by: Guilherme G. Piccoli Signed-off-by: Steven Rostedt (Google) --- Changes since v4: https://lore.kernel.org/linux-trace-kernel/20240611215801.443593152@goodmis.org - Add all checks about reserve_mem before allocation. This means reserved_mem_add() is now a void function. - Check for name duplications. - Fix compare of align to SMP_CACHE_BYTES ("<" instead of "<=") .../admin-guide/kernel-parameters.txt | 20 +++ include/linux/mm.h | 2 + mm/memblock.c | 117 ++++++++++++++++++ 3 files changed, 139 insertions(+) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index b600df82669d..ce7de8136f2f 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -5710,6 +5710,26 @@ them. If is less than 0x10000, the region is assumed to be I/O ports; otherwise it is memory. + reserve_mem= [RAM] + Format: nn[KNG]::