rump: Reduce startup latency

Since rump now requires large buffers of random numbers (>= 512 bytes), use the
jitterentropy library instead of the slow timer pseudo random number generation.

Fixes #1393
This commit is contained in:
Sebastian Sumpf 2015-02-04 10:17:57 +01:00 committed by Christian Helmuth
parent ab0fd6510f
commit 7ecd83373c
4 changed files with 47 additions and 18 deletions

View File

@ -12,6 +12,11 @@ RMAKE = $(RUMP_TOOLS)/rumpmake
#
VERBOSE_LEVEL ?= 0
#
# Libraries
#
LIBS += jitterentropy
#
# Sources
#

View File

@ -166,7 +166,7 @@ struct Sym_tab
/* set absolute value */
sym_tab[out_cnt].st_value += map->addr;
if (verbose)
PDBG("Read symbol %s val: %zx", name, sym_tab[out_cnt].st_value);
PDBG("Read symbol %s val: %lx", name, sym_tab[out_cnt].st_value);
out_cnt++;
}
}

View File

@ -21,6 +21,11 @@
#include <util/allocator_fap.h>
#include <util/string.h>
extern "C" {
namespace Jitter {
#include <jitterentropy.h>
}
}
extern "C" void wait_for_continue();
enum { SUPPORTED_RUMP_VERSION = 17 };
@ -31,6 +36,38 @@ static bool verbose = false;
struct rumpuser_hyperup _rump_upcalls;
/***********************************
** Jitter entropy for randomness **
***********************************/
struct Entropy
{
struct Jitter::rand_data *ec_stir;
Entropy()
{
Jitter::jent_entropy_init();
ec_stir = Jitter::jent_entropy_collector_alloc(0, 0);
}
static Entropy *e()
{
static Entropy _e;
return &_e;
}
size_t read(char *buf, size_t len)
{
int err;
if ((err = Jitter::jent_read_entropy(ec_stir, buf, len) < 0)) {
PERR("Failed to read entropy: %d", err);
return 0;
}
return len;
}
};
/********************
** Initialization **
********************/
@ -53,6 +90,9 @@ int rumpuser_init(int version, const struct rumpuser_hyperup *hyp)
*/
Genode::Timeout_thread::alarm_timer();
/* initialize jitter entropy */
Entropy::e();
return 0;
}
@ -296,14 +336,7 @@ int rumpuser_clock_sleep(int enum_rumpclock, int64_t sec, long nsec)
int rumpuser_getrandom(void *buf, size_t buflen, int flags, size_t *retp)
{
Timer::Connection *timer = myself()->timer();
uint8_t *rndbuf;
for (*retp = 0, rndbuf = (uint8_t *)buf; *retp < buflen; (*retp)++) {
*rndbuf++ = timer->elapsed_ms() & 0xff;
timer->msleep(timer->elapsed_ms() & 0xf);
}
*retp = Entropy::e()->read((char *)buf, buflen);
return 0;
}

View File

@ -15,15 +15,6 @@
#include <util/string.h>
/*
* On some platforms (namely ARM) we end-up pulling in string.h prototypes
*/
extern "C" void *memcpy(void *d, void *s, Genode::size_t n)
{
return Genode::memcpy(d, s, n);
}
extern "C" void *memset(void *s, int c, Genode::size_t n)
{
return Genode::memset(s, c, n);