Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp63860lqp; Tue, 11 Jun 2024 14:58:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV2+d1vZz+SmwTWQHpKP81o6Tk7aLbbyXEDxvMhnY7q1tsV2FGJUONQkhKwJvtmecvfSGqbxxuhuiMevlOcQwJASq/ttktCBgU+Q9oXHw== X-Google-Smtp-Source: AGHT+IGV5VT++eihDD09sjJQbzTJfIGsYUAcQJG/RQdj/xcKLn4+Wo+2cxKrrVvQrLUJIR1QYacv X-Received: by 2002:a05:622a:1390:b0:440:5ac6:511a with SMTP id d75a77b69052e-4405ac653eemr158267011cf.5.1718143086489; Tue, 11 Jun 2024 14:58:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718143086; cv=pass; d=google.com; s=arc-20160816; b=TRyrBpCHswEhJsQD7DgkoHKNAsutQYfVq0Yuh42qD4/cHyAgLmrSd+dU3pXoCwItNB Ad7ZrNE5kpbIc0X/LPNUuJWqUSnTUyqtRawYXp17tx3fLgOxO8FwbH+sDlnymnguztFv pgddhdt9/cTXhjt649V6pO1L4IhnsuLYgDUBDTfH972EpVae229j/EzFKmfaQX1p02xO mEUjlfDfsEa+KzJ9DqAB8c7MoPe9x1SMLOpgxjulrFgJ3mXNUVbHN3gm8ijKmKnqYw3d vXJwTfar6vNgI10h2TqShdpqmeS1MLgA1JqqF/jGcuFVTwtJfSJUK77BQCTQb1i37g5H 6ygQ== 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=wNHrip7Acg7RXDhGz073bCFMh8j39WHtPzy1FVePtJE=; fh=QORXSiDV/x9VWq4RcqWjO5bZNJ5t7To8OgD4cz5pN8M=; b=GGzUb5k3plF4SfD1uRHJcNd4H++imURZztwkWOi9NX9InMTTJ7l4QTAaye8IttJC+/ TAFXbDV4ja4gu3jfPh8vjbi8+8Hwb6bPZAcWB/SWD6P2PdXI2l++tSYs1n55/Z21Jj46 sMHgk441SpepkahxeIYYXxgJz93BWCYALOUjYdtsWh3jJaSV8z0jYxS66cH0q7KRg0YZ 2o4+B3gEy6TnjOnsvy5GCpMxpHH+s4+h6IwAzKd0z0K3ZHX0UKhf2pJ8PJo5c85IWbun HyY6RqQNEzlqQVybsBQPTc+vPWSg95aLRUAgfBF9E4R5ID8w4BSl0opPRDBE1LPghpks KKpg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-210640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210640-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-4411f46a75dsi38740091cf.240.2024.06.11.14.58.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 14:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210640-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-210640-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210640-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 17E3E1C23625 for ; Tue, 11 Jun 2024 21:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 238711552E3; Tue, 11 Jun 2024 21:57:46 +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 48C03150991; Tue, 11 Jun 2024 21:57:45 +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=1718143065; cv=none; b=nK4jMs+XzS6FKNYw/PArmtH9+kbgn0EIPCiUoQbyyqLCTat7cF8tE4RkDg74rN1xrmQiFfEx5eaUbcrEJlOpV2CoAvtCkgfscfCzNIk6JY+zuj6HDBcgisCbJy1BsGZSoBnzW/p2SSmN2/al5umHuIzx52VcmLry+9t0urmoZ0k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718143065; c=relaxed/simple; bh=z+rUOow7P2VMVh1duvslZOi1Nbne+Yl+f5wz9pzx3G0=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=YUio2UWi2+4CyOFNSkPAgDQ8r4A6m3JK3RJeAAgst1GtkxL3XNh640JUpL7pkLaYxA469YXXArAfbMIadmwf4Pup0IwosrNhvkcORsQ87LKDx0uZkcrBp2sg5YH8FJLcpuk8peVaxIboQSVAZJSoCLujaytMqnsBD+wRCxT01s8= 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 E4B85C4AF50; Tue, 11 Jun 2024 21:57:44 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sH9VB-00000001VTR-2SZL; Tue, 11 Jun 2024 17:58:01 -0400 Message-ID: <20240611215801.443593152@goodmis.org> User-Agent: quilt/0.68 Date: Tue, 11 Jun 2024 17:56:11 -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 v4 1/2] mm/memblock: Add "reserve_mem" to reserved named memory at boot up References: <20240611215610.548854415@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 Signed-off-by: Steven Rostedt (Google) --- Changes since v3: https://lore.kernel.org/linux-trace-kernel/20240606150316.751642266@goodmis.org - Changed table type of start and size from unsigned long to phys_addr_t (as well as the parameters to the functions that use them) - Changed old reference to "early_reserve_mem" to "reserve_mem" - Check before reservering memory: o Size is non-zero o name has text in it - If align is less than SMP_CACHE_BYTES, make it SMP_CACHE_BYTES - Remove the silly check of testing *p == '\0' after a p += strlen(p) .../admin-guide/kernel-parameters.txt | 20 +++ include/linux/mm.h | 2 + mm/memblock.c | 115 ++++++++++++++++++ 3 files changed, 137 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]::