Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10182190rwd; Wed, 21 Jun 2023 18:07:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7d4mbb4e5UK+Y4S7m4l6e8fCY/g0ou1kCnsCsCeNKYh5kEHROn1AtL1JOsw/ZXn9nz2uDr X-Received: by 2002:a54:400c:0:b0:3a0:5800:389f with SMTP id x12-20020a54400c000000b003a05800389fmr1425899oie.10.1687396070843; Wed, 21 Jun 2023 18:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687396070; cv=none; d=google.com; s=arc-20160816; b=DZIOMZeH09joLOteHuvzdbobkLzRcFpswMhhIYQcn8c0iOMGDtHtqDztqVqVOHpg/Z 9KYzBAIvMGeZC3xBT/FB3JiXy/8gC76fLXmf+qVyYuE4pKei0cwdvW2Jq8hLDZm2v6k7 kz1mnCzuhvZDzRXAThV/Nr0xhDeLyLM9v6Wt9qrNyjNB7ASMDmeW7/D0DEVECxJNyBGc gASpwFehSlkSrH7BHJpI8WsqCAy+o+4nYGI8Z0t8M6OqZrPXausV/ou52MEV452OKxQ4 4VwOB4NnGY4CPyl/27LRBME2judTbqnu9EfgsNS6m9xDTgs1YHZhA8QL47fKZCkDCY/2 ml8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=udHRmMpy+xwUknnQXeH45s8WH+sOsn0OoP200LprEk8=; b=Q1a1r4owpmiNiWnGa3FWRezYW1yW17gdf754p+PlBVI/erkNJ2YR89fwKL+X9x2vps hG1evd2Az6L+vyL4LGS7LPE2p/02oAF+Bj/oXGT+Qg2GlZdrnHnVkbOVEMOBcqqKyLx9 oxUi6pV21pl9xI5qK5fw0Ov2xEVgROhKbDoK2dRtGKlV5NGH87GEeuI8hESnrEVAAwbE T0jU57UvjPs2qvod1iMSdTIHnyAhWxwLA5U56LhVLxNapRy5krJs9Z1u1mwH+sHEF9tC oH9uaqhVhTv4feJPcvFy+xSxoIMipmDPkjJ+HA7YLIq3KQopWevv3brtdlJ4jM5hrMlV mSOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=GAJEjs2Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e23-20020a63db17000000b0053f0d8ac4b0si5040417pgg.825.2023.06.21.18.07.38; Wed, 21 Jun 2023 18:07:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=GAJEjs2Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229530AbjFVAwW (ORCPT + 99 others); Wed, 21 Jun 2023 20:52:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229839AbjFVAwT (ORCPT ); Wed, 21 Jun 2023 20:52:19 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A18E198 for ; Wed, 21 Jun 2023 17:52:18 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-57320c10635so60051137b3.3 for ; Wed, 21 Jun 2023 17:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687395137; x=1689987137; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=udHRmMpy+xwUknnQXeH45s8WH+sOsn0OoP200LprEk8=; b=GAJEjs2YZoM/GNZOZEMFVk5T7kspISkVDy/DFO4zdDGLHaO58YIs0C+goCRA6w7FzX XsoR4zIwn2U7KXr86Epk78qLKvDKcmlmwzgG8YJt+IFdU5RbFzDfU6LU9T4QK7rt6lOK SqOu2GTA7iNSkTXAecvssfTivjwu0eJx57ddopDEq5TgWfb9mUIsSvlzWrm0JkHiaE2k tH69P30RnQ6ejx7AwVF6sbLpZEyMoc6/D3ZSNhCqi6rEytTLWhmqclLEdLEQcD3pJEzl 6SW0KfpS74Qxf7bfjYh972DHh5xr9NNZl83oQhXq2R4dEBPMaSJIw+unH7T+ZD8Qq81U 7Imw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687395137; x=1689987137; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=udHRmMpy+xwUknnQXeH45s8WH+sOsn0OoP200LprEk8=; b=CRzxAjzZtq6/txdkJJYEYbEH3fX49TAChhED/ilPx7KyW8GEbmrwz49fJsiiAyOf0S LeLgkAnRVt2Z223KCtep+Z6bqNjlxO+lFrOESnYaPTWhCiRMyfoQCmCo39iP8N1ZuDzt 4IIwOVgrdrG0uKfFwMT66Snpo+fXSyjleJ3GKfCelCjDGYLHKfhStB3Z6qhK0nYqkAns Np3eQywfdsXH0GYvojXtvtJoXx52jhkgaf0sCudzuz3h1YShIxkUfLd0B8GVXQiB2Ex+ q5SKONWa9R/HXw8yLKih2Xh2sEHNHqRZwz5DYTVQVFe390+7hS5VppcNpebmjOW5qN/4 mE7w== X-Gm-Message-State: AC+VfDzb6MV0iYtmDm5ziwrribUIu1cozweDrVRgsg1Sdwb7qFhM1GTq OA2NgrOjXp+ewNkm9XrBkS/lAJlzj79HFhG4cuf7Bw== X-Received: from isaacmanjarres.irv.corp.google.com ([2620:15c:2d:3:e855:b0d7:44f2:fbb7]) (user=isaacmanjarres job=sendgmr) by 2002:a81:af46:0:b0:56c:e6fa:6ce9 with SMTP id x6-20020a81af46000000b0056ce6fa6ce9mr7022607ywj.8.1687395137684; Wed, 21 Jun 2023 17:52:17 -0700 (PDT) Date: Wed, 21 Jun 2023 17:52:13 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.178.g377b9f9a00-goog Message-ID: <20230622005213.458236-1-isaacmanjarres@google.com> Subject: [PATCH] pstore/ram: Add support for dynamically allocated ramoops memory regions From: "Isaac J. Manjarres" To: Kees Cook , Tony Luck , "Guilherme G. Piccoli" Cc: "Isaac J. Manjarres" , Mukesh Ojha , Prasad Sodagudi , "Isaac J . Manjarres" , kernel-team@android.com, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Isaac J. Manjarres" The reserved memory region for ramoops is assumed to be at a fixed and known location when read from the devicetree. This is not desirable in environments where it is preferred for the region to be dynamically allocated early during boot (i.e. the memory region is defined with the "alloc-ranges" property instead of the "reg" property). If the location of the ramoops region is not fixed via the "reg" devicetree property, the call to platform_get_resource() will fail because resources of type IORESOURCE_MEM must be described with the "reg" property. Since ramoops regions are part of the reserved-memory devicetree node, they exist in the reserved_mem array. This means that the of_reserved_mem_lookup() function can be used to retrieve the reserved_mem structure for the ramoops region, and that structure contains the base and size of the region, even if it has been dynamically allocated. Thus invoke of_reserved_mem_lookup() in case the call to platform_get_resource() fails in order to support dynamically allocated ramoops memory regions. Signed-off-by: Isaac J. Manjarres Signed-off-by: Mukesh Ojha Signed-off-by: Prasad Sodagudi Signed-off-by: Isaac J. Manjarres --- fs/pstore/ram.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index ade66dbe5f39..e4bbba187011 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "internal.h" #include "ram_internal.h" @@ -643,6 +644,7 @@ static int ramoops_parse_dt(struct platform_device *pdev, { struct device_node *of_node = pdev->dev.of_node; struct device_node *parent_node; + struct reserved_mem *rmem; struct resource *res; u32 value; int ret; @@ -651,13 +653,20 @@ static int ramoops_parse_dt(struct platform_device *pdev, res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { - dev_err(&pdev->dev, - "failed to locate DT /reserved-memory resource\n"); - return -EINVAL; + rmem = of_reserved_mem_lookup(of_node); + if (rmem) { + pdata->mem_size = rmem->size; + pdata->mem_address = rmem->base; + } else { + dev_err(&pdev->dev, + "failed to locate DT /reserved-memory resource\n"); + return -EINVAL; + } + } else { + pdata->mem_size = resource_size(res); + pdata->mem_address = res->start; } - pdata->mem_size = resource_size(res); - pdata->mem_address = res->start; /* * Setting "unbuffered" is deprecated and will be ignored if * "mem_type" is also specified. -- 2.41.0.178.g377b9f9a00-goog