2018-02-23 00:43:04

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH] riscv: Implement free_initrd_mem.

On Tue, 20 Feb 2018 05:50:43 PST (-0800), [email protected] wrote:
> Signed-off-by: Shea Levy <[email protected]>
> ---
> arch/riscv/mm/init.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index c77df8142be2..1c832b541e95 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -66,5 +66,11 @@ void free_initmem(void)
> #ifdef CONFIG_BLK_DEV_INITRD
> void free_initrd_mem(unsigned long start, unsigned long end)
> {
> + if (start == initrd_start)
> + start = round_down(start, PAGE_SIZE);
> + if (end == initrd_end)
> + end = round_up(end, PAGE_SIZE);
> +
> + free_reserved_area((void *)start, (void *)end, -1, "initrd");
> }
> #endif /* CONFIG_BLK_DEV_INITRD */

It looks like everyone is doing something slightly different here:

* arm64 doesn't round to a page size, and has keep_initrd.
* arm calls poison_init_mem(), and has keep_initrd.
* sparc64 doesn't round, and doesn't have a keep_initrd.
* mips doesn't round, and doesn't have a keep_initrd.
* x86 rounds end to a page size but not start, and doesn't have a keep_initrd.

It feels like this should be something generic. I'm adding linux-kernel to see
what people think.


2018-03-08 19:26:21

by Shea Levy

[permalink] [raw]
Subject: Re: [PATCH] riscv: Implement free_initrd_mem.

Hi Palmer,

Palmer Dabbelt <[email protected]> writes:

> On Tue, 20 Feb 2018 05:50:43 PST (-0800), [email protected] wrote:
>> Signed-off-by: Shea Levy <[email protected]>
>> ---
>> arch/riscv/mm/init.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>> index c77df8142be2..1c832b541e95 100644
>> --- a/arch/riscv/mm/init.c
>> +++ b/arch/riscv/mm/init.c
>> @@ -66,5 +66,11 @@ void free_initmem(void)
>> #ifdef CONFIG_BLK_DEV_INITRD
>> void free_initrd_mem(unsigned long start, unsigned long end)
>> {
>> + if (start == initrd_start)
>> + start = round_down(start, PAGE_SIZE);
>> + if (end == initrd_end)
>> + end = round_up(end, PAGE_SIZE);
>> +
>> + free_reserved_area((void *)start, (void *)end, -1, "initrd");
>> }
>> #endif /* CONFIG_BLK_DEV_INITRD */
>
> It looks like everyone is doing something slightly different here:
>
> * arm64 doesn't round to a page size, and has keep_initrd.
> * arm calls poison_init_mem(), and has keep_initrd.
> * sparc64 doesn't round, and doesn't have a keep_initrd.
> * mips doesn't round, and doesn't have a keep_initrd.
> * x86 rounds end to a page size but not start, and doesn't have a keep_initrd.
>
> It feels like this should be something generic. I'm adding linux-kernel to see
> what people think.

Should I try to whip up something generic?

Thanks,
Shea


Attachments:
signature.asc (847.00 B)

2018-03-08 19:37:02

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH] riscv: Implement free_initrd_mem.

On Thu, 08 Mar 2018 11:14:52 PST (-0800), [email protected] wrote:
> Hi Palmer,
>
> Palmer Dabbelt <[email protected]> writes:
>
>> On Tue, 20 Feb 2018 05:50:43 PST (-0800), [email protected] wrote:
>>> Signed-off-by: Shea Levy <[email protected]>
>>> ---
>>> arch/riscv/mm/init.c | 6 ++++++
>>> 1 file changed, 6 insertions(+)
>>>
>>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>>> index c77df8142be2..1c832b541e95 100644
>>> --- a/arch/riscv/mm/init.c
>>> +++ b/arch/riscv/mm/init.c
>>> @@ -66,5 +66,11 @@ void free_initmem(void)
>>> #ifdef CONFIG_BLK_DEV_INITRD
>>> void free_initrd_mem(unsigned long start, unsigned long end)
>>> {
>>> + if (start == initrd_start)
>>> + start = round_down(start, PAGE_SIZE);
>>> + if (end == initrd_end)
>>> + end = round_up(end, PAGE_SIZE);
>>> +
>>> + free_reserved_area((void *)start, (void *)end, -1, "initrd");
>>> }
>>> #endif /* CONFIG_BLK_DEV_INITRD */
>>
>> It looks like everyone is doing something slightly different here:
>>
>> * arm64 doesn't round to a page size, and has keep_initrd.
>> * arm calls poison_init_mem(), and has keep_initrd.
>> * sparc64 doesn't round, and doesn't have a keep_initrd.
>> * mips doesn't round, and doesn't have a keep_initrd.
>> * x86 rounds end to a page size but not start, and doesn't have a keep_initrd.
>>
>> It feels like this should be something generic. I'm adding linux-kernel to see
>> what people think.
>
> Should I try to whip up something generic?

I think that'd be best. Nobody has said anything specific, but it's generally
been suggested to take bits that we copy into our port and make them generic.
If there's no clean way do to so then I'm OK taking this, though.

2018-03-08 19:48:59

by Shea Levy

[permalink] [raw]
Subject: Re: [PATCH] riscv: Implement free_initrd_mem.

Palmer Dabbelt <[email protected]> writes:

> On Thu, 08 Mar 2018 11:14:52 PST (-0800), [email protected] wrote:
>> Hi Palmer,
>>
>> Palmer Dabbelt <[email protected]> writes:
>>
>>> On Tue, 20 Feb 2018 05:50:43 PST (-0800), [email protected] wrote:
>>>> Signed-off-by: Shea Levy <[email protected]>
>>>> ---
>>>> arch/riscv/mm/init.c | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>>
>>>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>>>> index c77df8142be2..1c832b541e95 100644
>>>> --- a/arch/riscv/mm/init.c
>>>> +++ b/arch/riscv/mm/init.c
>>>> @@ -66,5 +66,11 @@ void free_initmem(void)
>>>> #ifdef CONFIG_BLK_DEV_INITRD
>>>> void free_initrd_mem(unsigned long start, unsigned long end)
>>>> {
>>>> + if (start == initrd_start)
>>>> + start = round_down(start, PAGE_SIZE);
>>>> + if (end == initrd_end)
>>>> + end = round_up(end, PAGE_SIZE);
>>>> +
>>>> + free_reserved_area((void *)start, (void *)end, -1, "initrd");
>>>> }
>>>> #endif /* CONFIG_BLK_DEV_INITRD */
>>>
>>> It looks like everyone is doing something slightly different here:
>>>
>>> * arm64 doesn't round to a page size, and has keep_initrd.
>>> * arm calls poison_init_mem(), and has keep_initrd.
>>> * sparc64 doesn't round, and doesn't have a keep_initrd.
>>> * mips doesn't round, and doesn't have a keep_initrd.
>>> * x86 rounds end to a page size but not start, and doesn't have a keep_initrd.
>>>
>>> It feels like this should be something generic. I'm adding linux-kernel to see
>>> what people think.
>>
>> Should I try to whip up something generic?
>
> I think that'd be best. Nobody has said anything specific, but it's generally
> been suggested to take bits that we copy into our port and make them generic.
> If there's no clean way do to so then I'm OK taking this, though.

OK, will add it to my queue.


Attachments:
signature.asc (847.00 B)

2018-03-08 20:32:41

by Palmer Dabbelt

[permalink] [raw]
Subject: Re: [PATCH] riscv: Implement free_initrd_mem.

On Thu, 08 Mar 2018 11:47:08 PST (-0800), [email protected] wrote:
> Palmer Dabbelt <[email protected]> writes:
>
>> On Thu, 08 Mar 2018 11:14:52 PST (-0800), [email protected] wrote:
>>> Hi Palmer,
>>>
>>> Palmer Dabbelt <[email protected]> writes:
>>>
>>>> On Tue, 20 Feb 2018 05:50:43 PST (-0800), [email protected] wrote:
>>>>> Signed-off-by: Shea Levy <[email protected]>
>>>>> ---
>>>>> arch/riscv/mm/init.c | 6 ++++++
>>>>> 1 file changed, 6 insertions(+)
>>>>>
>>>>> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
>>>>> index c77df8142be2..1c832b541e95 100644
>>>>> --- a/arch/riscv/mm/init.c
>>>>> +++ b/arch/riscv/mm/init.c
>>>>> @@ -66,5 +66,11 @@ void free_initmem(void)
>>>>> #ifdef CONFIG_BLK_DEV_INITRD
>>>>> void free_initrd_mem(unsigned long start, unsigned long end)
>>>>> {
>>>>> + if (start == initrd_start)
>>>>> + start = round_down(start, PAGE_SIZE);
>>>>> + if (end == initrd_end)
>>>>> + end = round_up(end, PAGE_SIZE);
>>>>> +
>>>>> + free_reserved_area((void *)start, (void *)end, -1, "initrd");
>>>>> }
>>>>> #endif /* CONFIG_BLK_DEV_INITRD */
>>>>
>>>> It looks like everyone is doing something slightly different here:
>>>>
>>>> * arm64 doesn't round to a page size, and has keep_initrd.
>>>> * arm calls poison_init_mem(), and has keep_initrd.
>>>> * sparc64 doesn't round, and doesn't have a keep_initrd.
>>>> * mips doesn't round, and doesn't have a keep_initrd.
>>>> * x86 rounds end to a page size but not start, and doesn't have a keep_initrd.
>>>>
>>>> It feels like this should be something generic. I'm adding linux-kernel to see
>>>> what people think.
>>>
>>> Should I try to whip up something generic?
>>
>> I think that'd be best. Nobody has said anything specific, but it's generally
>> been suggested to take bits that we copy into our port and make them generic.
>> If there's no clean way do to so then I'm OK taking this, though.
>
> OK, will add it to my queue.

Thanks!