mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-20 22:23:27 +00:00
cddd459140
Add patches for linux-5.4. The patches are from NXP LSDK-20.04 release which was tagged LSDK-20.04-V5.4. https://source.codeaurora.org/external/qoriq/qoriq-components/linux/ For boards LS1021A-IOT, and Traverse-LS1043 which are not involved in LSDK, port the dts patches from 4.14. The patches are sorted into the following categories: 301-arch-xxxx 302-dts-xxxx 303-core-xxxx 701-net-xxxx 801-audio-xxxx 802-can-xxxx 803-clock-xxxx 804-crypto-xxxx 805-display-xxxx 806-dma-xxxx 807-gpio-xxxx 808-i2c-xxxx 809-jailhouse-xxxx 810-keys-xxxx 811-kvm-xxxx 812-pcie-xxxx 813-pm-xxxx 814-qe-xxxx 815-sata-xxxx 816-sdhc-xxxx 817-spi-xxxx 818-thermal-xxxx 819-uart-xxxx 820-usb-xxxx 821-vfio-xxxx Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
109 lines
3.3 KiB
Diff
109 lines
3.3 KiB
Diff
From 387a26c56933fbfd0fa211ad5347d48d08695ea0 Mon Sep 17 00:00:00 2001
|
|
From: "Victoria Milhoan (b42089)" <vicki.milhoan@freescale.com>
|
|
Date: Fri, 17 Oct 2014 16:30:56 -0700
|
|
Subject: [PATCH] MLK-9769-8 crypto: caam - add a test for the RNG
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Freescale's CAAM includes a Random Number Generator. This change adds
|
|
a kernel configuration option to test the RNG's capabilities via the
|
|
hw_random framework.
|
|
|
|
Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com>
|
|
Signed-off-by: Dan Douglass <dan.douglass@freescale.com>
|
|
Signed-off-by: Vipul Kumar <vipul_kumar@mentor.com>
|
|
(cherry picked from commit 05fba1bb857d5329fdcf79e736643fce0944a86d)
|
|
|
|
-fixed compilation warning:
|
|
drivers/crypto/caam/caamrng.c:271:2: warning: format '%d' expects argument of type 'int', but argument 2 has type 'size_t' [-Wformat=]
|
|
|
|
-changed commit headline
|
|
|
|
Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
|
|
---
|
|
drivers/crypto/caam/Kconfig | 8 ++++++++
|
|
drivers/crypto/caam/caamrng.c | 47 +++++++++++++++++++++++++++++++++++++++++++
|
|
2 files changed, 55 insertions(+)
|
|
|
|
--- a/drivers/crypto/caam/Kconfig
|
|
+++ b/drivers/crypto/caam/Kconfig
|
|
@@ -147,6 +147,14 @@ config CRYPTO_DEV_FSL_CAAM_RNG_API
|
|
Selecting this will register the SEC4 hardware rng to
|
|
the hw_random API for suppying the kernel entropy pool.
|
|
|
|
+config CRYPTO_DEV_FSL_CAAM_RNG_TEST
|
|
+ bool "Test caam rng"
|
|
+ depends on CRYPTO_DEV_FSL_CAAM_RNG_API
|
|
+ help
|
|
+ Selecting this will enable a self-test to run for the
|
|
+ caam RNG. This test is several minutes long and executes
|
|
+ just before the RNG is registered with the hw_random API.
|
|
+
|
|
endif # CRYPTO_DEV_FSL_CAAM_JR
|
|
|
|
endif # CRYPTO_DEV_FSL_CAAM
|
|
--- a/drivers/crypto/caam/caamrng.c
|
|
+++ b/drivers/crypto/caam/caamrng.c
|
|
@@ -258,6 +258,49 @@ static void caam_cleanup(struct hwrng *r
|
|
rng_unmap_ctx(rng_ctx);
|
|
}
|
|
|
|
+#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_TEST
|
|
+static inline void test_len(struct hwrng *rng, size_t len, bool wait)
|
|
+{
|
|
+ u8 *buf;
|
|
+ int real_len;
|
|
+
|
|
+ buf = kzalloc(sizeof(u8) * len, GFP_KERNEL);
|
|
+ real_len = rng->read(rng, buf, len, wait);
|
|
+ if (real_len == 0 && wait)
|
|
+ pr_err("WAITING FAILED\n");
|
|
+ pr_info("wanted %zu bytes, got %d\n", len, real_len);
|
|
+ print_hex_dump(KERN_INFO, "random bytes@: ", DUMP_PREFIX_ADDRESS,
|
|
+ 16, 4, buf, real_len, 1);
|
|
+ kfree(buf);
|
|
+}
|
|
+
|
|
+static inline void test_mode_once(struct hwrng *rng, bool wait)
|
|
+{
|
|
+#define TEST_CHUNK (RN_BUF_SIZE / 4)
|
|
+
|
|
+ test_len(rng, TEST_CHUNK, wait);
|
|
+ test_len(rng, RN_BUF_SIZE * 2, wait);
|
|
+ test_len(rng, RN_BUF_SIZE * 2 - TEST_CHUNK, wait);
|
|
+}
|
|
+
|
|
+static inline void test_mode(struct hwrng *rng, bool wait)
|
|
+{
|
|
+#define TEST_PASS 1
|
|
+ int i;
|
|
+
|
|
+ for (i = 0; i < TEST_PASS; i++)
|
|
+ test_mode_once(rng, wait);
|
|
+}
|
|
+
|
|
+static void self_test(struct hwrng *rng)
|
|
+{
|
|
+ pr_info("testing without waiting\n");
|
|
+ test_mode(rng, false);
|
|
+ pr_info("testing with waiting\n");
|
|
+ test_mode(rng, true);
|
|
+}
|
|
+#endif
|
|
+
|
|
static int caam_init_buf(struct caam_rng_ctx *ctx, int buf_id)
|
|
{
|
|
struct buf_data *bd = &ctx->bufs[buf_id];
|
|
@@ -342,6 +385,10 @@ int caam_rng_init(struct device *ctrldev
|
|
if (err)
|
|
goto free_rng_ctx;
|
|
|
|
+#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_TEST
|
|
+ self_test(&caam_rng);
|
|
+#endif
|
|
+
|
|
dev_info(dev, "registering rng-caam\n");
|
|
|
|
err = hwrng_register(&caam_rng);
|