From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FF52C07542 for ; Mon, 27 May 2019 04:34:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 648D621707 for ; Mon, 27 May 2019 04:34:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="da7JOyRS"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="eNJuvDVN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 648D621707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nzjw0q79v9/8alwf5aPKEFqaIBdRwUlmBcYs58ZWSrs=; b=da7JOyRSmGgCM/ yVVgmY+mvuKMSIHYs+F0zInmWiPcQBqzDJtIn+8wLRUQm/WGQ8p5Cq2Ik9t4TKlIDE+d9YJs9PSEI ja0bw2FrquATtwMyOtQj/uLxr3eDkW6ul9T4ewpP0azv3EoP96M9bI21Ft4a/LOrdPBkQrJjc1Op1 jcp31YX+my2QgeHxQ504dUNunQdRnAoOGbHu+06UCvM6dp6Nt3Gds9u6UiwDPgCQ7g+5FGgIg/ZlS S3t6WZGR2KhT7vYHEHXoQ/1WD9TnFOtHSn4iUsQCn7VGAZodBhTZ4NDOq4giq67dHLIw05PxU40Fu z4yO+y4i6YBp2UbPCrCw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hV7LH-00015H-10; Mon, 27 May 2019 04:34:35 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hV7LD-00013t-Iu for linux-arm-kernel@lists.infradead.org; Mon, 27 May 2019 04:34:32 +0000 Received: by mail-pf1-x444.google.com with SMTP id z26so8818951pfg.6 for ; Sun, 26 May 2019 21:34:30 -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=HVbr8yPZVgrbjdDwY4oDGzG2x6LajTHk+u9YRL60Obc=; b=eNJuvDVNY0xCYnOoRFQPfq1KCk5IYm3S+jBuGBUvHHg8kTyIIJl38TFvpNXP/SkaOB TTeuYIMA7uK8ZTOOGX/phsARK9XUCj1WTYlfDQleA4JDu96H9l407xOgGgtYPOtQne/p AHd+zhN4N1HMICiYBF54QEtO92ry5XbAKy7JE= 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=HVbr8yPZVgrbjdDwY4oDGzG2x6LajTHk+u9YRL60Obc=; b=bgflTcKiHkqVHPn5OoUS5tzP+PGe3uTY71bxnb47lw0QirlQTI2NyWiU7TpsX9xtDa ILVuGHl68St7WSVXDD3bzT7Q8k5YyLCT+rUAynp1Kbo7T5wfxmy5ZfwHs29ya2YzZl3r bSjT6YBnCt8GFE+kO/ntlStr/2SKgCvYKswo3fd++Rc4/iPbOouxapam5B9Zwk5J1ilf L28zOkExwUeFhD3D4rTT1BtdsQjDg8AC8tEoOiNk0ZV5JpamgJJ4h0HiV+sQJuAPWzue 67u9hp6MVaW8EhRfF9QOzJ60FdQo+9miU/1Z1h8mOcFhqCxQ59aGovZQCcyrnnCCDeYX MsMA== X-Gm-Message-State: APjAAAUV/g2ECjcqPTT93M5rD94qd2IKkTEGhlSXzAr56PyvDwWRfSdy j6jUjyoAa9zcVcjDwpxOM0q20XSEYQ6w2g== X-Google-Smtp-Source: APXvYqw1TUPqLXbXV7nXMmmJo/a19DnZPKiDk3xHcy+XoSwyNQrhr4A/Z7BVajQoeX3y3yvo0B52dQ== X-Received: by 2002:a63:4d0f:: with SMTP id a15mr22151895pgb.59.1558931669720; Sun, 26 May 2019 21:34:29 -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 g9sm8236061pgs.78.2019.05.26.21.34.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 26 May 2019 21:34:29 -0700 (PDT) From: Hsin-Yi Wang To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v5 2/3] fdt: add support for rng-seed Date: Mon, 27 May 2019 12:33:35 +0800 Message-Id: <20190527043336.112854-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190527043336.112854-1-hsinyi@chromium.org> References: <20190527043336.112854-1-hsinyi@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190526_213431_617858_403FD2CF X-CRM114-Status: GOOD ( 15.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Nicolas Boichat , Yu Zhao , Kees Cook , Ard Biesheuvel , Catalin Marinas , Stephen Boyd , Will Deacon , linux-kernel@vger.kernel.org, Mike Rapoport , Jun Yao , Miles Chen , Rob Herring , James Morse , Hsin-Yi Wang , Andrew Murray , Andrew Morton , Laura Abbott , Frank Rowand , Robin Murphy Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.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 v4->v5: * use fdt_nop_property() since property might not be wiped entirely if following entries are smaller than property length. --- 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..9d63330582bb 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_nop_property(initial_boot_params, node, "rng-seed"); + } + /* break now */ return 1; } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel