From: Masahiro Yamada <yamada.m@jp.panasonic.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 2/3] lib: rand: add call to hw_rand() - hardware random number generator
Date: Thu, 06 Mar 2014 13:58:09 +0900 [thread overview]
Message-ID: <20140306135808.6EB2.AA925319@jp.panasonic.com> (raw)
In-Reply-To: <20140305212206.GA16805@bill-the-cat>
Hello Tom,
> > unsigned int rand_r(unsigned int *seedp)
> > {
> > +#ifdef CONFIG_RAND_HW_ACCEL
> > + return hw_rand();
> > +#endif
> > *seedp ^= (*seedp << 13);
> > *seedp ^= (*seedp >> 17);
> > *seedp ^= (*seedp << 5);
>
> This doesn't already generate warnings about unreachable code?
>
> I hate to say at but I think we should add lib/hw_rand.c which does:
> void srand(uint seed) {}
> unsigned int rand(void) { return hw_rand(); }
> unsigned int rand_r(unsigned int *seedp) { seedp = hw_rand(); return
> *seedp;}
>
> (please double check how hw_rand() returns and net/link_local.c if we
> can really avoid using the callers pointer...).
>
> And then in correct Kbuild fashion, something like
> randsrc-y ?= rand.o
> randsrc-$(CONFIG_RAND_HW_ACCEL) = hw_rand.o
>
> (The above is probably wrong, help please Masahiro :))
In the first place, I don't like the idea to add a new function
hw_rand() very much.
I think lib/rand.c is just one implementation among
some possible choices.
drivers/crypto/ace_sha.c is another implementation.
How about treating them in the same way?
I mean, srand(), rand(), rand_r()
should be defined in drivers/crypto/ace_sha.c
rather than adding lib/hw_rand.c.
drivers/crypto/ace_sha.c is like this:
void srand(uint seed) {}
unsigned int rand(void)
{
<your hardware rand implementation>
}
unsigned int rand_r(unsigned int *seedp)
{
return rand();
}
lib/Makefile will be changed like this:
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -62,8 +62,6 @@ obj-y += time.o
obj-$(CONFIG_TRACE) += trace.o
obj-$(CONFIG_BOOTP_PXE) += uuid.o
obj-y += vsprintf.o
-obj-$(CONFIG_RANDOM_MACADDR) += rand.o
-obj-$(CONFIG_BOOTP_RANDOM_DELAY) += rand.o
-obj-$(CONFIG_CMD_LINK_LOCAL) += rand.o
+obj-$(CONFIG_SW_RAND) += rand.o
It looks like CONFIG_SW_RAND (or CONFIG_EXYNOS_ACE_SHA)
must be added to the following boards.
include/configs/lsxl.h (for CONFIG_RANDOM_MACADDR)
include/configs/MERGERBOX.h (for CONFIG_BOOTP_RAMDOM_DELAY)
include/configs/MVBC_P.h (for CONFIG_BOOTP_RAMDOM_DELAY)
include/configs/MVBLM7.h (for CONFIG_BOOTP_RAMDOM_DELAY)
include/configs/MVSMR.h (for CONFIG_BOOTP_RAMDOM_DELAY)
include/configs/bfin_adi_common.h (for CONFIG_BOOTP_RAMDOM_DELAY)
include/configs/sacsng.h (for CONFIG_BOOTP_RAMDOM_DELAY)
include/config_uncmd_spl.h (for CONFIG_CMD_LINK_LOCAL)
include/configs/a3m071.h (for CONFIG_CMD_LINK_LOCAL)
Best Regards
Masahiro Yamada
next prev parent reply other threads:[~2014-03-06 4:58 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 16:30 [U-Boot] [PATCH 1/3] cpu: exynos4: ace_sha: add hardware random number generator support Przemyslaw Marczak
2014-02-28 16:30 ` [U-Boot] [PATCH 2/3] lib: rand: add call to hw_rand() - hardware random number generator Przemyslaw Marczak
2014-02-28 17:02 ` Michael Walle
2014-03-03 14:19 ` Przemyslaw Marczak
2014-02-28 16:30 ` [U-Boot] [PATCH 3/3] trats/trats2: enable exynos security subsystem and function hw_rand() Przemyslaw Marczak
2014-03-05 16:57 ` [U-Boot] [PATCH V2 1/3] cpu: exynos4: ace_sha: add hardware random number generator support Przemyslaw Marczak
2014-03-05 16:57 ` [U-Boot] [PATCH V2 2/3] lib: rand: add call to hw_rand() - hardware random number generator Przemyslaw Marczak
2014-03-05 21:22 ` Tom Rini
2014-03-06 4:58 ` Masahiro Yamada [this message]
2014-03-05 16:57 ` [U-Boot] [PATCH V2 3/3] trats/trats2: enable exynos security subsystem and function hw_rand() Przemyslaw Marczak
2014-03-06 5:43 ` [U-Boot] [PATCH V2 1/3] cpu: exynos4: ace_sha: add hardware random number generator support Jaehoon Chung
2014-03-13 1:58 ` Minkyu Kang
2014-03-20 17:23 ` [U-Boot] [PATCH v3 1/4] lib: rand: introduce new configs: CONFIG_LIB_RAND CONFIG_LIB_HW_RAND Przemyslaw Marczak
2014-03-20 17:23 ` [U-Boot] [PATCH v3 2/4] cpu: exynos4: add ace sha base address Przemyslaw Marczak
2014-03-20 17:23 ` [U-Boot] [PATCH v3 3/4] drivers: crypto: ace_sha: add implementation of hardware based lib rand Przemyslaw Marczak
2014-03-20 17:23 ` [U-Boot] [PATCH v3 4/4] trats/trats2: enable exynos ace sha subsystem and " Przemyslaw Marczak
2014-03-20 17:36 ` [U-Boot] [PATCH v3 1/4] lib: rand: introduce new configs: CONFIG_LIB_RAND CONFIG_LIB_HW_RAND Przemyslaw Marczak
2014-03-20 21:10 ` Michael Walle
2014-03-21 8:56 ` [U-Boot] [PATCH v4 1/4] lib: rand: introduce new configs: CONFIG_LIB_RAND and CONFIG_LIB_HW_RAND Przemyslaw Marczak
2014-03-21 8:56 ` [U-Boot] [PATCH v4 2/4] cpu: exynos4: add ace sha base address Przemyslaw Marczak
2014-03-21 15:09 ` Tom Rini
2014-03-22 15:18 ` Minkyu Kang
2014-03-24 7:44 ` Przemyslaw Marczak
2014-03-25 1:26 ` Minkyu Kang
2014-03-25 7:38 ` Przemyslaw Marczak
2014-03-21 8:56 ` [U-Boot] [PATCH v4 3/4] drivers: crypto: ace_sha: add implementation of hardware based lib rand Przemyslaw Marczak
2014-03-21 15:14 ` Tom Rini
2014-03-21 8:56 ` [U-Boot] [PATCH v4 4/4] trats/trats2: enable exynos ace sha subsystem and " Przemyslaw Marczak
2014-03-21 15:14 ` Tom Rini
2014-03-21 9:00 ` [U-Boot] [PATCH v4 1/4] lib: rand: introduce new configs: CONFIG_LIB_RAND and CONFIG_LIB_HW_RAND Przemyslaw Marczak
2014-03-21 15:00 ` Tom Rini
2014-03-25 9:58 ` [U-Boot] [PATCH v5 " Przemyslaw Marczak
2014-03-25 9:58 ` [U-Boot] [PATCH v5 2/4] cpu: exynos4: add ace sha base address Przemyslaw Marczak
2014-03-28 21:17 ` [U-Boot] [U-Boot, v5, " Tom Rini
2014-03-25 9:58 ` [U-Boot] [PATCH v5 3/4] drivers: crypto: ace_sha: add implementation of hardware based lib rand Przemyslaw Marczak
2014-03-28 21:17 ` [U-Boot] [U-Boot, v5, " Tom Rini
2014-03-25 9:58 ` [U-Boot] [PATCH v5 4/4] trats/trats2: enable exynos ace sha subsystem and " Przemyslaw Marczak
2014-03-28 21:17 ` [U-Boot] [U-Boot, v5, " Tom Rini
2014-03-25 10:17 ` [U-Boot] [PATCH v5 1/4] lib: rand: introduce new configs: CONFIG_LIB_RAND and CONFIG_LIB_HW_RAND Przemyslaw Marczak
2014-03-28 21:16 ` [U-Boot] [U-Boot, v5, " Tom Rini
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=20140306135808.6EB2.AA925319@jp.panasonic.com \
--to=yamada.m@jp.panasonic.com \
--cc=u-boot@lists.denx.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