Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4078456yba; Sun, 19 May 2019 10:10:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqxam70VyjRD+1jmqe2K6bYEIg0q/da55HYNDI6rGLTL2dPv+rJhbD9c474mdT4Po2+EWBhf X-Received: by 2002:a17:902:5e1:: with SMTP id f88mr23605524plf.226.1558285836210; Sun, 19 May 2019 10:10:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558285836; cv=none; d=google.com; s=arc-20160816; b=NT8Ux+pdH44cUfhk6Lw6BFE1t0OG93PYKfF/NYBMKEv9CIztqYBpO7Au/OqLss8Euq tNB532ieZya4deZ0SSTy1eI2UE362OXeOv/LZJnSuMjFvxIbI4OtzCt+oR6nlfNVL2iu n9wgCLz61eq4Rd78WW6+AzN9NAq6TV6p3T3P8OhThsCuE+R9HwTE9bPiXbmO/jutqJ6H 7AJbQxsTnagmtH8UpeiU32JFETnPKMR98nE92XUl2QPkNMKQU0gdOUsWNy8+JJiFBmFe TmZFkpFRMLaS1GCpqVl7Hto6E0/Cm1wfBN/9EpQ3Cm9i6YBLH0c60GjemkpvQ6eRbSFA jxUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gCFKWEfomzC/p8Cp2zu9+tMCVjDMCf+wEVZ+N8bS+5w=; b=qP3ZGI08GNSnm5LIPNVgAJZo8A1sefkjIAkNh3cRir3IDVAfP0c2o/KYw7bjE8ZRUn FEMpURA0y9gmzvBS30QBziZ2Wc16NHICKyvN2zLJ89iawoHdJbYOBqE0WkCDV9+YWAZc ANeCK5yfMjHzixlSi+ANzKYlDzYbJg3So2eC41xQtH8rNgBnn/D+MVntOztuRNv6tQ8L kAcE833psAYqrCBuJhUdur0oTRoTnJfysK1uqjCqJmG5ClEfzi0Yeo9CM/q7XXkI/5Go 5Vj5THuWkMHczyrS4XDNU3xThn8hObeXlxR9di/trvujz0BNl7PQe/MUxQXiGWoQYjyr uBPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="T/7IReFv"; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si15980117pgq.374.2019.05.19.10.10.21; Sun, 19 May 2019 10:10:36 -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=@chromium.org header.s=google header.b="T/7IReFv"; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726567AbfESRJO (ORCPT + 99 others); Sun, 19 May 2019 13:09:14 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39379 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbfESRJO (ORCPT ); Sun, 19 May 2019 13:09:14 -0400 Received: by mail-pf1-f194.google.com with SMTP id z26so6043629pfg.6 for ; Sun, 19 May 2019 10:09:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gCFKWEfomzC/p8Cp2zu9+tMCVjDMCf+wEVZ+N8bS+5w=; b=T/7IReFvKjKaF14U1oGtHscyU/22SyS4d7KmRC5r07CtvxiAbogbfeuIroE/8H2wz0 nLTWIIZriLKgXnWDXlyBKjqUAsl9SsAMjTTs4IMZaZBFvDrupg39ZL7WTW3wXN2yB8aj f8BzAcUBvMPTNeGH08JCB9Xs2xfvt2oFwNK1Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gCFKWEfomzC/p8Cp2zu9+tMCVjDMCf+wEVZ+N8bS+5w=; b=YGe5ErxeOQtI/yZVr9AM0b4SKOcu+TtE2z6NTmQGTQfuLcG0FJeqaSn9r5W/YVFMSs lcKWmBqlwBqnSPUr2fX20sKvczHEw2hFw4WsNKy752IyL+hLnPBGAGVAq6f1SaTD6ohL KqJbX1kDyReMuu/Q5ZpdujKPniRX/4JyG97KlVlXcqQqVRcp9e4Iv29+ZI3I1+ZAZ5d8 79h5DoSUrHYXWhfAtJ94iDgznVCiwX6khGxEKNOFtC6piHbMlKFYphLh0E9WL56iOden BGB03scES80a3YD1kZbplw/XmM6AK2p32QqSm7zeP0UFIaWol5i1Jzw4MBYaYdcQsLtV Khnw== X-Gm-Message-State: APjAAAV5V1Nld3jRf0G1xsU6GcZPGyrEh25v1B3haoP/cnN6HWb7QR1g sT2rvQOWLLoxIP4+oQNcEJoaqw== X-Received: by 2002:a63:a08:: with SMTP id 8mr69721219pgk.46.1558281910923; Sun, 19 May 2019 09:05:10 -0700 (PDT) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id b23sm17547007pfi.6.2019.05.19.09.05.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 19 May 2019 09:05:10 -0700 (PDT) From: Hsin-Yi Wang To: linux-arm-kernel@lists.infradead.org Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Frank Rowand , Catalin Marinas , Will Deacon , Andrew Morton , Mike Rapoport , Ard Biesheuvel , Miles Chen , Hsin-Yi Wang , James Morse , Andrew Murray , Mark Rutland , Jun Yao , Yu Zhao , Robin Murphy , Laura Abbott , Stephen Boyd , Kees Cook Subject: [PATCH v4 2/3] fdt: add support for rng-seed Date: Mon, 20 May 2019 00:04:45 +0800 Message-Id: <20190519160446.320-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190519160446.320-1-hsinyi@chromium.org> References: <20190519160446.320-1-hsinyi@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introducing a chosen node, rng-seed, which is an entropy that can be passed to kernel called very early to increase initial device randomness. Bootloader should provide this entropy and the value is read from /chosen/rng-seed in DT. Signed-off-by: Hsin-Yi Wang --- change log v2->v4: * v3 abandoned * fix doc error --- Documentation/devicetree/bindings/chosen.txt | 14 ++++++++++++++ drivers/of/fdt.c | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/Documentation/devicetree/bindings/chosen.txt b/Documentation/devicetree/bindings/chosen.txt index 45e79172a646..678e81bc4383 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 serves as an entropy to add device randomness. It is parsed +as a byte array, e.g. + +/ { + chosen { + rng-seed = <0x31 0x95 0x1b 0x3c 0xc9 0xfa 0xb3 ...>; + }; +}; + +This random value should be provided by bootloader. + stdout-path ----------- diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index de893c9616a1..7f3d72921b23 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -24,6 +24,7 @@ #include #include #include +#include #include /* for COMMAND_LINE_SIZE */ #include @@ -1079,6 +1080,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, { int l; const char *p; + const void *rng_seed; pr_debug("search \"chosen\", depth: %d, uname: %s\n", depth, uname); @@ -1113,6 +1115,14 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, pr_debug("Command line is: %s\n", (char*)data); + rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l); + if (rng_seed && l > 0) { + add_device_randomness(rng_seed, l); + + /* try to clear seed so it won't be found. */ + fdt_delprop(initial_boot_params, node, "rng-seed"); + } + /* break now */ return 1; } -- 2.20.1