2023-09-12 12:08:18

by Will Deacon

[permalink] [raw]
Subject: Re: [REBASE PATCH v5 08/17] arm64: mm: Add dynamic ramoops region support through command line

On Mon, Sep 11, 2023 at 04:23:50PM +0530, Mukesh Ojha wrote:
> The reserved memory region for ramoops is assumed to be at a fixed
> and known location when read from the devicetree. This may not be
> required for something like Qualcomm's minidump which is interested
> in knowing addresses of ramoops region but it does not put hard
> requirement of address being fixed as most of it's SoC does not
> support warm reset and does not use pstorefs at all instead it has
> firmware way of collecting ramoops region if it gets to know the
> address and register it with apss minidump table which is sitting
> in shared memory region in DDR and firmware will have access to
> these table during reset and collects it on crash of SoC.
>
> So, add the support of reserving ramoops region to be dynamically
> allocated early during boot if it is request through command line
> via 'dyn_ramoops_size=' and fill up reserved resource structure and
> export the structure, so that it can be read by ramoops driver.
>
> Signed-off-by: Mukesh Ojha <[email protected]>
> ---
> arch/arm64/mm/init.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++

Why does this need to be in the arch code? There's absolutely nothing
arm64-specific here.

Will


2023-09-13 10:06:57

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [REBASE PATCH v5 08/17] arm64: mm: Add dynamic ramoops region support through command line

Thanks for the response.

On 9/12/2023 3:48 PM, Will Deacon wrote:
> On Mon, Sep 11, 2023 at 04:23:50PM +0530, Mukesh Ojha wrote:
>> The reserved memory region for ramoops is assumed to be at a fixed
>> and known location when read from the devicetree. This may not be
>> required for something like Qualcomm's minidump which is interested
>> in knowing addresses of ramoops region but it does not put hard
>> requirement of address being fixed as most of it's SoC does not
>> support warm reset and does not use pstorefs at all instead it has
>> firmware way of collecting ramoops region if it gets to know the
>> address and register it with apss minidump table which is sitting
>> in shared memory region in DDR and firmware will have access to
>> these table during reset and collects it on crash of SoC.
>>
>> So, add the support of reserving ramoops region to be dynamically
>> allocated early during boot if it is request through command line
>> via 'dyn_ramoops_size=' and fill up reserved resource structure and
>> export the structure, so that it can be read by ramoops driver.
>>
>> Signed-off-by: Mukesh Ojha <[email protected]>
>> ---
>> arch/arm64/mm/init.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
>
> Why does this need to be in the arch code? There's absolutely nothing
> arm64-specific here.

Current clients of this cmdline would be only arm64, and that is the
reason of putting this here.

I was checking the places where memblock_phys_alloc_range() gets called
and found either it is arch/*/ and drivers/of/of_reserved_mem.c .

Since, this is not related to device tree, did not find a proper place
than this, i took the reference of this place from
reserve_crashkernel(). Also, not sure how could it be of help to other
non-arch64 users at this point.

-Mukesh
>
> Will

2023-09-13 10:37:59

by Will Deacon

[permalink] [raw]
Subject: Re: [REBASE PATCH v5 08/17] arm64: mm: Add dynamic ramoops region support through command line

On Wed, Sep 13, 2023 at 12:32:54PM +0530, Mukesh Ojha wrote:
> Thanks for the response.
>
> On 9/12/2023 3:48 PM, Will Deacon wrote:
> > On Mon, Sep 11, 2023 at 04:23:50PM +0530, Mukesh Ojha wrote:
> > > The reserved memory region for ramoops is assumed to be at a fixed
> > > and known location when read from the devicetree. This may not be
> > > required for something like Qualcomm's minidump which is interested
> > > in knowing addresses of ramoops region but it does not put hard
> > > requirement of address being fixed as most of it's SoC does not
> > > support warm reset and does not use pstorefs at all instead it has
> > > firmware way of collecting ramoops region if it gets to know the
> > > address and register it with apss minidump table which is sitting
> > > in shared memory region in DDR and firmware will have access to
> > > these table during reset and collects it on crash of SoC.
> > >
> > > So, add the support of reserving ramoops region to be dynamically
> > > allocated early during boot if it is request through command line
> > > via 'dyn_ramoops_size=' and fill up reserved resource structure and
> > > export the structure, so that it can be read by ramoops driver.
> > >
> > > Signed-off-by: Mukesh Ojha <[email protected]>
> > > ---
> > > arch/arm64/mm/init.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
> >
> > Why does this need to be in the arch code? There's absolutely nothing
> > arm64-specific here.
>
> Current clients of this cmdline would be only arm64, and that is the
> reason of putting this here.

I don't think that's a strong enough justification, tbh. We should at
least be able to compile this for other architectures using TEST_COMPILE
and so somewhere under drivers/ makes more sense to me.

Will

2023-09-14 02:23:44

by Kees Cook

[permalink] [raw]
Subject: Re: [REBASE PATCH v5 08/17] arm64: mm: Add dynamic ramoops region support through command line

On Tue, Sep 12, 2023 at 11:18:20AM +0100, Will Deacon wrote:
> On Mon, Sep 11, 2023 at 04:23:50PM +0530, Mukesh Ojha wrote:
> > The reserved memory region for ramoops is assumed to be at a fixed
> > and known location when read from the devicetree. This may not be
> > required for something like Qualcomm's minidump which is interested
> > in knowing addresses of ramoops region but it does not put hard
> > requirement of address being fixed as most of it's SoC does not
> > support warm reset and does not use pstorefs at all instead it has
> > firmware way of collecting ramoops region if it gets to know the
> > address and register it with apss minidump table which is sitting
> > in shared memory region in DDR and firmware will have access to
> > these table during reset and collects it on crash of SoC.
> >
> > So, add the support of reserving ramoops region to be dynamically
> > allocated early during boot if it is request through command line
> > via 'dyn_ramoops_size=' and fill up reserved resource structure and
> > export the structure, so that it can be read by ramoops driver.
> >
> > Signed-off-by: Mukesh Ojha <[email protected]>
> > ---
> > arch/arm64/mm/init.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
>
> Why does this need to be in the arch code? There's absolutely nothing
> arm64-specific here.

I would agree: this needs to be in ramoops itself, IMO. It should be a
ramoops module argument, too.

It being unhelpful for systems that don't have an external consumer is
certainly true, but I think it would still make more sense for this
change to live entirely within ramoops. Specifically: you're
implementing a pstore backend behavioral change. In the same way that
patch 10 is putting the "output" side of this into pstore/, I'd expect
the "input" side also in pstore/

More comments there, though.

--
Kees Cook

2023-10-05 14:42:11

by Mukesh Ojha

[permalink] [raw]
Subject: Re: [REBASE PATCH v5 08/17] arm64: mm: Add dynamic ramoops region support through command line

Sorry for the late reply, was on a long vacation.

On 9/14/2023 4:47 AM, Kees Cook wrote:
> On Tue, Sep 12, 2023 at 11:18:20AM +0100, Will Deacon wrote:
>> On Mon, Sep 11, 2023 at 04:23:50PM +0530, Mukesh Ojha wrote:
>>> The reserved memory region for ramoops is assumed to be at a fixed
>>> and known location when read from the devicetree. This may not be
>>> required for something like Qualcomm's minidump which is interested
>>> in knowing addresses of ramoops region but it does not put hard
>>> requirement of address being fixed as most of it's SoC does not
>>> support warm reset and does not use pstorefs at all instead it has
>>> firmware way of collecting ramoops region if it gets to know the
>>> address and register it with apss minidump table which is sitting
>>> in shared memory region in DDR and firmware will have access to
>>> these table during reset and collects it on crash of SoC.
>>>
>>> So, add the support of reserving ramoops region to be dynamically
>>> allocated early during boot if it is request through command line
>>> via 'dyn_ramoops_size=' and fill up reserved resource structure and
>>> export the structure, so that it can be read by ramoops driver.
>>>
>>> Signed-off-by: Mukesh Ojha <[email protected]>
>>> ---
>>> arch/arm64/mm/init.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++
>>
>> Why does this need to be in the arch code? There's absolutely nothing
>> arm64-specific here.
>
> I would agree: this needs to be in ramoops itself, IMO. It should be a
> ramoops module argument, too.
>
> It being unhelpful for systems that don't have an external consumer is
> certainly true, but I think it would still make more sense for this
> change to live entirely within ramoops. Specifically: you're
> implementing a pstore backend behavioral change. In the same way that
> patch 10 is putting the "output" side of this into pstore/, I'd expect
> the "input" side also in pstore/

How do we reserve memory? are you suggesting to use dma api's for
dynamic ramoops ?

-Mukesh
>
> More comments there, though.
>