Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5092643yba; Wed, 8 May 2019 07:47:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxb/hiCCUC5JgW0Be1SCz/uWdlo+aBN2cEd5/o6knCG3Sm5P4zjg0pjwog4yC5sX6FEgDPn X-Received: by 2002:a65:528b:: with SMTP id y11mr36282970pgp.341.1557326844094; Wed, 08 May 2019 07:47:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557326844; cv=none; d=google.com; s=arc-20160816; b=fOTFB3sjLbbaQOAlYl4n78s/NfGyd3Vt2UsFporrY0sYT2J/jNltwI9jkkG10JJjt2 2qhUGRm3WSQOsH8eW0DTESvLFx9i44Ldc+mkp2ntEiCHV8skYW9bDJCl2l2+BAjS6mCb Qwegf1hjalt2YbBKSoeelFy1ztc22INAJtu3foHxF5yzKmI5mVAOjNwiDlgCW1H2R5gb cCZySTqrQy21svSk4JZ/rApK23IXlS7OdCatMaLLeBx24Py2ihmE//b1WCPDizbuamno BgBfK3ofa+6Fi/jiIl2XpqpS7pwuFUqbMfXPJhYjXHuxHiuN3CWEe3jqOksMBekdlBne Oh6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QQCa3fdk+eReyYHw5rYU/7RNfIsilIAn2EZBwhvFrVU=; b=tZVPVwymwsET4jcZ98JXnWy9doy6uzv8K/mhlYSUlrS+mfj1UfenbqHZN1HZE6rVww 9alQdALY+Zowr9QUaU7k7fA6BtJJX7LRZH7xpy806ybPv/uH5b1q3E47Pc/WHgH0w/zf nn6BTSof3vaYdm7L6y/j7dLP4nm/vbnhyP+eG6Eu89K7ghVxHgoVb8rEclmHTkemUpJn Vj9G1oJ5fHGPNUXO8SWMQltJauYOOqE/6EvWnNtXswXoL/b1L4nPu5vh6pe7FVmVFlo7 q4uM2NVcaM9OZjSyFv+1UjJF9B5h0tqf5PqzZNoGGdWLRrWxyOQ/pda3mtUDfl9VDXHC dC7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2buYcneB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k25si22673101pfa.273.2019.05.08.07.47.08; Wed, 08 May 2019 07:47:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2buYcneB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbfEHOEY (ORCPT + 99 others); Wed, 8 May 2019 10:04:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:41150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbfEHOEY (ORCPT ); Wed, 8 May 2019 10:04:24 -0400 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B663B20675; Wed, 8 May 2019 14:04:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557324262; bh=KlTf0lMaCe47EgBjCnPByj4hDErmqmcJfE6SdzLc12M=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=2buYcneBmgQ5V4Iw6o/K3ZrNV0b77ofTlHXyAj0b4jQdn9AtpAzSTjEwoAqk1h+gT ueccm04t06vQFNAXTBQ+YbLu1GfVVzYoBQuoRJdtEiSMwzKRKD8Oe//WdpKM+50KYZ 3ke6V30/bQeBnbleUiNNiV6w6lxABp63FSReE2gM= Received: by mail-qk1-f170.google.com with SMTP id g190so3412175qkf.8; Wed, 08 May 2019 07:04:22 -0700 (PDT) X-Gm-Message-State: APjAAAW0AV67+XHzAeoLmJgw1+ZmTBsRolfVgFVwH+2ehtXyBt2MT6/7 ltmqXgZLW4/EZugC0aX/ezH6VIWTvzoCmKnb2w== X-Received: by 2002:a37:4711:: with SMTP id u17mr29663919qka.326.1557324261976; Wed, 08 May 2019 07:04:21 -0700 (PDT) MIME-Version: 1.0 References: <20190507045433.542-1-hsinyi@chromium.org> In-Reply-To: From: Rob Herring Date: Wed, 8 May 2019 09:04:10 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: add support for rng-seed To: Hsin-Yi Wang Cc: "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Mark Rutland , Catalin Marinas , Will Deacon , Frank Rowand , Andrew Morton , Mike Rapoport , Michal Hocko , Ard Biesheuvel , James Morse , Andrew Murray , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Stephen Boyd , Architecture Mailman List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 7, 2019 at 11:08 PM Hsin-Yi Wang wrote: > > On Wed, May 8, 2019 at 3:47 AM Rob Herring wrote: > > > > +boot-architecture list as there was some discussion about this IIRC. > > > > On Mon, May 6, 2019 at 11:54 PM Hsin-Yi Wang wrote: > > > > > > Introducing a chosen node, rng-seed, which is an 64 bytes entropy > > > that can be passed to kernel called very early to increase device > > > randomness. Bootloader should provide this entropy and the value is > > > read from /chosen/rng-seed in DT. > > > > > > Signed-off-by: Hsin-Yi Wang > > > > > > --- > > > Documentation/devicetree/bindings/chosen.txt | 14 +++++++++ > > > > Actually, this file has been converted to json-schema and lives > > here[1]. I need to remove this one (or leave it with a reference to > > the new one). > > > > > arch/arm64/kernel/setup.c | 2 ++ > > > drivers/of/fdt.c | 33 ++++++++++++++++++++ > > > include/linux/of_fdt.h | 1 + > > > 4 files changed, 50 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt > > > index 45e79172a646..bfd360691650 100644 > > > --- a/Documentation/devicetree/bindings/chosen.txt > > > +++ b/Documentation/devicetree/bindings/chosen.txt > > > @@ -28,6 +28,20 @@ mode) when EFI_RNG_PROTOCOL is supported, it will be overwritten by > > > the Linux EFI stub (which will populate the property itself, using > > > EFI_RNG_PROTOCOL). > > > > > > +rng-seed > > > +----------- > > > + > > > +This property served as an entropy to add device randomness. It is parsed > > > +as a 64 byte value, e.g. > > > > Why only 64-bytes? > We can also not specify size and read what bootloader can provide. > > > > > + > > > +/ { > > > + chosen { > > > + rng-seed = <0x31951b3c 0xc9fab3a5 0xffdf1660 ...> > > > + }; > > > +}; > > > + > > > +This random value should be provided by bootloader. > > > + > > > stdout-path > > > ----------- > > > > > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c > > > index 413d566405d1..ade4261516dd 100644 > > > --- a/arch/arm64/kernel/setup.c > > > +++ b/arch/arm64/kernel/setup.c > > > @@ -292,6 +292,8 @@ void __init setup_arch(char **cmdline_p) > > > early_fixmap_init(); > > > early_ioremap_init(); > > > > > > + early_init_dt_rng_seed(__fdt_pointer); > > > + > > > > I'm trying to reduce or eliminate all these early_init_dt_* calls. > > > > Why is this arch specific and why can't this be done after > > unflattening? It doesn't look like add_device_randomness() needs > > anything early. > Currently unflattening is called after setup_machine_fdt(), which > called fixmap_remap_fdt() //__fixmap_remap_fdt(dt_phys, &size, > PAGE_KERNEL_RO), and we can't modify DT after that since it's read > only. But we need to clear (eg. write 0 to it) the rng-seed after > reading from DT. Why do you need to clear it? That wasn't necessary for kaslr-seed. Why not change the mapping to RW? It would be nice if this worked on more than one arch. Rob