Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10387286rwd; Wed, 21 Jun 2023 22:23:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bT9KLDd0+jfvGa8RFC1HlWWi5JVBjQaPPkR2Z8m0PxU1RN63nr0MsFTU+XmQiHb5aZ5ZF X-Received: by 2002:a05:6a00:c86:b0:66a:56ea:2b5b with SMTP id a6-20020a056a000c8600b0066a56ea2b5bmr1271062pfv.34.1687411395143; Wed, 21 Jun 2023 22:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687411395; cv=none; d=google.com; s=arc-20160816; b=wvWq3cD3zmhRXgH3Z4ip9CQFzsiJSHoJ4ZeVDv55Fh1ROd7rgRUbbRAs1PM8eGGBus rdjibYJDHMQaeJjmHjgpb7ltonWDp4jMEeCGrFwvcrfA17fwvLJI9cEsGncdjMVtw+09 nKJCsYGyV/qhqo3UQsCJYrcbMhZcKo1SbJIpoOx8OU9DhL/h+1lqX5sclA61Cwv9u2K1 D1BM9y0pgwGplgHUaJ6keRiA4RCNQMm75IGyp0febhj4HlASrTOrOSrkqD/8OHv2Tv3I p/Yi6DXyREyStv81D6f6qXRFw4l+XTdExiAVjw6EpFlNkr9UJyrVzVl0fDd3zXWwVBa9 ck+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=RswzDNbUeMUjbPFYG+iZxviTZ/WORDfOHoGv7gqMsGc=; b=fFcX/pdDN5dzj9OCDC8PX+tzf7ZKtSqWTy4WxhznX/6mTZxkVwn5j1hb8/v4oljK6n 9G6v7K92u8blbQNPPTGauMM5OJigI03+sWnY58yPtrA7vZi1VnfXbaOzHe4tiFvaeeNT LFRsk6XtOJg1dZFfG2/13rz9XKZqFrEf+BxrBTSZF9/aerEXjmygWq6yKHW6OpJNaxTr FktFePja7JZBSed4hRxBH54ZZDeRKa3T2qz+BqmZUs3UHTOKsf6LhAQwE5vj7xF80/0C i6iqbpkJrLz2GU3cHGF3X1M5Z3TZBSiGU5UkRfnbR51mIdAQ4fTMNB8RnrLGdYGdrU2z wzOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=DNCJ+vgC; 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 z2-20020aa79f82000000b0064f735aef04si5829251pfr.209.2023.06.21.22.23.00; Wed, 21 Jun 2023 22:23:15 -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=DNCJ+vgC; 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 S230484AbjFVErk (ORCPT + 99 others); Thu, 22 Jun 2023 00:47:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbjFVErj (ORCPT ); Thu, 22 Jun 2023 00:47:39 -0400 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C47931992 for ; Wed, 21 Jun 2023 21:47:37 -0700 (PDT) Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-33d928a268eso204965ab.0 for ; Wed, 21 Jun 2023 21:47:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687409257; x=1690001257; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RswzDNbUeMUjbPFYG+iZxviTZ/WORDfOHoGv7gqMsGc=; b=DNCJ+vgCu1f/LA+QlmAzQIbDaMNrX+aHSF7SCwGIQ6Hz6Ed/4Mh7KJj+oHBax1fZrd rK8BDTnVh6+IkfvyIiuSYF52FywsD5vTIvvDS0gMfUvGkIPf12JscQufegjK2WTSac8B bCQw0bGcqship4RGxusgz/H0tWJO/NhRhKpvSiTiNLPenLguAu3XOjF87v0XDJY9pEMP f0A9IFwtDC5M5lnpI+fBQ2uywRIyiScg8bu3qJnr+byx3uT9ULkORAg7El7b+WqqOQx9 NQxiJXFVvFResRpZmbfTmsP4lWqU3W04tKHe1QhJJ0QXvH94r5zFCwEJa5q5ZYwQ9kuL +AlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687409257; x=1690001257; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RswzDNbUeMUjbPFYG+iZxviTZ/WORDfOHoGv7gqMsGc=; b=jdTW8LGbX8hWJhqhRyJq7ESSnB44wWnVL6WfAP2kBrZO5BnK5zJ71YtCHRDX4J0Xx8 +9nG1rQ9mftWICeeyZ0ycONaWI0afaPJWp1nb2sEYirMHMqwrmW+0oK2dM8EwoMlW6IX d30AbQaR+iTRd/xGdNoNZapGjFIUwCdlGT74+8j5TirAXLPTaKs2DXyUWmvSElAOC7Bb vn6NZoor77X+W10lVNhBEM6ure2tXXl7MbkviWoGr3rvuFdKZyQkmzWnXeDJcfsfHEHt gFD+lDXyBSpIRu+ktyNREQs7hB8WxkICmdhV/6PgKMm18oE+nk8Mb9cHPDeanyBnCcf/ qL/g== X-Gm-Message-State: AC+VfDyvtgjTZEgjLezXH9llA31nVBeCMhlCH75uGKFKTumgZD4LOFs/ cJaeFj806LFP+3NnlA7sBBa5ll2X/DeYN4+Cf8fv X-Received: by 2002:a05:6e02:1e01:b0:33e:549a:78c2 with SMTP id g1-20020a056e021e0100b0033e549a78c2mr2072301ila.5.1687409256992; Wed, 21 Jun 2023 21:47:36 -0700 (PDT) MIME-Version: 1.0 References: <20230622005213.458236-1-isaacmanjarres@google.com> In-Reply-To: <20230622005213.458236-1-isaacmanjarres@google.com> From: John Stultz Date: Wed, 21 Jun 2023 21:47:26 -0700 Message-ID: Subject: Re: [PATCH] pstore/ram: Add support for dynamically allocated ramoops memory regions To: "Isaac J. Manjarres" Cc: Kees Cook , Tony Luck , "Guilherme G. Piccoli" , "Isaac J. Manjarres" , Mukesh Ojha , Prasad Sodagudi , kernel-team@android.com, linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Wed, Jun 21, 2023 at 5:52=E2=80=AFPM 'Isaac J. Manjarres' via kernel-tea= m wrote: > > 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). > Thanks for sending this out, Isaac! Apologies, I've forgotten much of the details around dt bindings here, so forgive my questions: If the memory is dynamically allocated from a specific range, is it guaranteed to be consistently the same address boot to boot? > 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. I think this is answering my question above, but it's a little opaque, so I'm not sure. > 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 *p= dev, > { > struct device_node *of_node =3D 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 =3D platform_get_resource(pdev, IORESOURCE_MEM, 0); > if (!res) { > - dev_err(&pdev->dev, > - "failed to locate DT /reserved-memory resource\n"= ); > - return -EINVAL; > + rmem =3D of_reserved_mem_lookup(of_node); Nit: you could keep rmem scoped locally here. Otherwise the code looks sane, I just suspect the commit message could be more clear in explaining the need/utility of the dts entry using alloc-ranges. thanks -john