Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp476455lqs; Thu, 13 Jun 2024 16:36:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNADXiXwm2UeGPdsD6zSAnIzz82L41eDFpkQDAj08ys+WYfPThs7lPOhoZwzfB4JLmrBFCCdnaHQsS2+YM2Bzpe1ddbhEytBvW1tj2fQ== X-Google-Smtp-Source: AGHT+IEb4syLRY3oex/RFRxAXaQOChDd0cgGGUBNc/1wSZXFF2nKGY345namKQWg19VMSYoPy/G9 X-Received: by 2002:a17:902:ecd0:b0:1f6:fbde:9ba0 with SMTP id d9443c01a7336-1f8625c0521mr16218135ad.10.1718321766297; Thu, 13 Jun 2024 16:36:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718321766; cv=pass; d=google.com; s=arc-20160816; b=xniEPUi1guxiajrn513NuH3G2GkpVSETLwvUdPS7mxploYoAUQEiy5Nh8tz0AotwPU Ryd53O/BET6xSIprEQuuv9iKbTck5H/P/qK+85v/8yZdJ3byR7nPR7Uhn5Q3DpcnEyn1 sRZKDOpleOyPuxOeq8g164hZ+XnaQkUirA6aGh9TUqjpDQs0+2rxCGFQ2v+RApFw+zGA Y+81cWN4OIbks2V6QWatyWuuEIoFP0N8PXpxKw4fl+29Brn21x8OvfwVm588rJUQudqN Lprcdu7H+YNy7kIBDIczy8yJ+iX/yBx+Rf5QdwNO7RRHrpCEae/Qooap3vOvP1QJtGf3 asmA== 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=tweR4O1Z1XEBw2QUHCfwn4PGEwMytD+PIK9SmL2ZTcw=; fh=utmKxJnE0qV2HUjB57CT0YlCxA/Y7V1+mXeSYrRW87A=; b=NSe/RzO3LE8UdRdKvQJ2dWLKoPVCg5f+JYd6/83TEvBj4RBk/3SdhO7VVg5FuTyDRg 4Tfh+Tv86OqC/FOPX30g4Tdotu59sSSBT4PSBrORcPW4/Xwe+UtPOx0lZGU/5r49DmK4 FUgWqRypAjy4DBuVMVcMEtF4e/GPxVAgBdAULVMusEg8QbDSh9TdwMRKMw8bF9sDcKCd T16ZWULhttlzzc8GsA6IR5FzfFrsn63jQkcGoCNqAJGPHJCgmSXlxvVufrYJjh8s8497 mT0gFRinVkVDtkIkwR7zeBxy33W45Etv0fcvKGNFxROYM9t40Ub6VV0x/75JaWVdg7Pu ST0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-214110-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214110-linux.lists.archive=gmail.com@vger.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 d9443c01a7336-1f855ee2c33si22632575ad.380.2024.06.13.16.36.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 16:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214110-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; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-214110-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214110-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E6649285C08 for ; Thu, 13 Jun 2024 23:36:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D842156C77; Thu, 13 Jun 2024 23:34:26 +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 59E6914F134; Thu, 13 Jun 2024 23:34:25 +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=1718321665; cv=none; b=M8+6jJR84ZAY8UcukgPAdsGLQNOJD5UXrSYRfrb0IvPcnlvPLibxiYcOpzay0VlrR3Zhc7cU1gpL+EhQEyQDpwLxYsrG9K6UMvJ0PNK/DeWjOnPrk9ulbUFWLJxw8RtWEnbz2Abr487LIgWlqeyl/0lRMxe9Xp6YS7xM7VaPp0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718321665; c=relaxed/simple; bh=8moigw637ieHT33YXV/AkKxkbGL72rg/LRp0HyYUdIQ=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=GNFgYVvry5m5tdRJJub+cDofrp8pkwE/usG3J2YL69hbHqEW8/DElYyp4soqurQ56aHakvjoNOM5dQKtUmjG7tZCb7TGOvDT74aizpmnXNoxPy94kcp5UBedrYiix+TAfoZIQEeOEf2s+nqpwXBD1XJQsJPyQMcVFgPLysJFSUE= 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 0A314C4AF51; Thu, 13 Jun 2024 23:34:25 +0000 (UTC) Received: from rostedt by gandalf with local (Exim 4.97) (envelope-from ) id 1sHtxu-00000001m5X-1mhV; Thu, 13 Jun 2024 19:34:46 -0400 Message-ID: <20240613233446.283241953@goodmis.org> User-Agent: quilt/0.68 Date: Thu, 13 Jun 2024 19:34:17 -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 , Vincent Donnefort , Joel Fernandes , Daniel Bristot de Oliveira , Ingo Molnar , Peter Zijlstra , suleiman@google.com, Thomas Gleixner , Vineeth Pillai , Youssef Esmat , Beau Belgrave , Alexander Graf , Baoquan He , Borislav Petkov , "Paul E. McKenney" , David Howells , Mike Rapoport , "Guilherme G. Piccoli" Subject: [PATCH v7 2/2] pstore/ramoops: Add ramoops.mem_name= command line option References: <20240613233415.734483785@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)" Add a method to find a region specified by reserve_mem=nn:align:name for ramoops. Adding a kernel command line parameter: reserve_mem=12M:4096:oops ramoops.mem_name=oops Will use the size and location defined by the memmap parameter where it finds the memory and labels it "oops". The "oops" in the ramoops option is used to search for it. This allows for arbitrary RAM to be used for ramoops if it is known that the memory is not cleared on kernel crashes or soft reboots. Tested-by: Guilherme G. Piccoli Signed-off-by: Steven Rostedt (Google) --- Documentation/admin-guide/ramoops.rst | 13 +++++++++++++ fs/pstore/ram.c | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/Documentation/admin-guide/ramoops.rst b/Documentation/admin-guide/ramoops.rst index e9f85142182d..2eabef31220d 100644 --- a/Documentation/admin-guide/ramoops.rst +++ b/Documentation/admin-guide/ramoops.rst @@ -23,6 +23,8 @@ and type of the memory area are set using three variables: * ``mem_size`` for the size. The memory size will be rounded down to a power of two. * ``mem_type`` to specify if the memory type (default is pgprot_writecombine). + * ``mem_name`` to specify a memory region defined by ``reserve_mem`` command + line parameter. Typically the default value of ``mem_type=0`` should be used as that sets the pstore mapping to pgprot_writecombine. Setting ``mem_type=1`` attempts to use @@ -118,6 +120,17 @@ Setting the ramoops parameters can be done in several different manners: return ret; } + D. Using a region of memory reserved via ``reserve_mem`` command line + parameter. The address and size will be defined by the ``reserve_mem`` + parameter. Note, that ``reserve_mem`` may not always allocate memory + in the same location, and cannot be relied upon. Testing will need + to be done, and it may not work on every machine, nor every kernel. + Consider this a "best effort" approach. The ``reserve_mem`` option + takes a size, alignment and name as arguments. The name is used + to map the memory to a label that can be retrieved by ramoops. + + reserve_mem=2M:4096:oops ramoops.mem_name=oops + You can specify either RAM memory or peripheral devices' memory. However, when specifying RAM, be sure to reserve the memory by issuing memblock_reserve() very early in the architecture code, e.g.:: diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index b1a455f42e93..4311fcbc84f2 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -50,6 +50,10 @@ module_param_hw(mem_address, ullong, other, 0400); MODULE_PARM_DESC(mem_address, "start of reserved RAM used to store oops/panic logs"); +static char *mem_name; +module_param_named(mem_name, mem_name, charp, 0400); +MODULE_PARM_DESC(mem_name, "name of kernel param that holds addr"); + static ulong mem_size; module_param(mem_size, ulong, 0400); MODULE_PARM_DESC(mem_size, @@ -914,6 +918,16 @@ static void __init ramoops_register_dummy(void) { struct ramoops_platform_data pdata; + if (mem_name) { + phys_addr_t start; + phys_addr_t size; + + if (reserve_mem_find_by_name(mem_name, &start, &size)) { + mem_address = start; + mem_size = size; + } + } + /* * Prepare a dummy platform data structure to carry the module * parameters. If mem_size isn't set, then there are no module -- 2.43.0