U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Tim Harvey <tharvey@gateworks.com>
Cc: u-boot@lists.denx.de, Tom Rini <trini@konsulko.com>,
	Simon Glass <sjg@chromium.org>,
	Patrick Delaunay <patrick.delaunay@foss.st.com>,
	Patrice Chotard <patrice.chotard@foss.st.com>,
	Devarsh Thakkar <devarsht@ti.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Hugo Villeneuve <hvilleneuve@dimonoff.com>
Subject: Re: [PATCH] fdt: add kaslr-seed if DM_RNG is enabled
Date: Wed, 15 May 2024 20:35:38 +0200	[thread overview]
Message-ID: <91a62c19-d565-4cd8-a20d-75d682acf95f@denx.de> (raw)
In-Reply-To: <CAJ+vNU0nSV-xKkrrXtod9zYfsSe2vUQsCVEgq9PntTxCnqV0dA@mail.gmail.com>

On 5/15/24 6:29 PM, Tim Harvey wrote:
> On Tue, May 14, 2024 at 5:50 PM Marek Vasut <marex@denx.de> wrote:
>>
>> On 5/15/24 2:22 AM, Tim Harvey wrote:
>>> If RANDOMIZE_BASE is enabled in the Linux kernel instructing it to
>>> randomize the virtual address at which the kernel image is loaded, it
>>> expects entropy to be provided by the bootloader by populating
>>> /chosen/kaslr-seed with a 64-bit value from source of entropy at boot.
>>
>> Thanks for working on this one, this is really nice.
>>
>>> If we have DM_RNG enabled poulate this value automatically when
>>> fdt_chosen is called.
> 
> Hi Marek,
> 
> Just noticed a typo in the commit log - I'll s/poulate/populate/ in v2
> 
>>>
>>> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>>> ---
>>>    boot/fdt_support.c | 23 +++++++++++++++++++++++
>>>    1 file changed, 23 insertions(+)
>>>
>>> diff --git a/boot/fdt_support.c b/boot/fdt_support.c
>>> index 874ca4d6f5af..cd3069baf450 100644
>>> --- a/boot/fdt_support.c
>>> +++ b/boot/fdt_support.c
>>> @@ -7,10 +7,12 @@
>>>     */
>>>
>>>    #include <abuf.h>
>>> +#include <dm.h>
>>>    #include <env.h>
>>>    #include <log.h>
>>>    #include <mapmem.h>
>>>    #include <net.h>
>>> +#include <rng.h>
>>>    #include <stdio_dev.h>
>>>    #include <dm/ofnode.h>
>>>    #include <linux/ctype.h>
>>> @@ -300,6 +302,27 @@ int fdt_chosen(void *fdt)
>>>        if (nodeoffset < 0)
>>>                return nodeoffset;
>>>
>>> +     if (IS_ENABLED(CONFIG_DM_RNG)) {
>>> +             struct udevice *dev;
>>> +             size_t len = 0x8;
>>> +             u64 *data;
>>> +
>>> +             data = malloc(len);
>>
>> Can you allocate this 8 byte array on stack , i.e. u64 data[2]; ?
>>
> 
> Sure... that makes sense - u64 data (just 1 64bit value)

Oh, right. Thanks for fixing it all up and keeping an eye on all the bugs !

      reply	other threads:[~2024-05-15 19:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-15  0:22 [PATCH] fdt: add kaslr-seed if DM_RNG is enabled Tim Harvey
2024-05-15  0:50 ` Marek Vasut
2024-05-15  5:03   ` Heinrich Schuchardt
2024-05-15 19:57     ` Tim Harvey
2024-05-15 20:05       ` Marek Vasut
2024-05-15 16:29   ` Tim Harvey
2024-05-15 18:35     ` Marek Vasut [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=91a62c19-d565-4cd8-a20d-75d682acf95f@denx.de \
    --to=marex@denx.de \
    --cc=devarsht@ti.com \
    --cc=hvilleneuve@dimonoff.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=patrick.delaunay@foss.st.com \
    --cc=sjg@chromium.org \
    --cc=tharvey@gateworks.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox