Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Caller must have exclusive access ...



details:   https://anonhg.NetBSD.org/src/rev/fdfc173fc2e4
branches:  trunk
changeset: 813766:fdfc173fc2e4
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Feb 17 01:48:04 2016 +0000

description:
Caller must have exclusive access to rndsource for rnd_add_data(_sync).

diffstat:

 sys/rump/librump/rumpkern/hyperentropy.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (48 lines):

diff -r e4d6f3254225 -r fdfc173fc2e4 sys/rump/librump/rumpkern/hyperentropy.c
--- a/sys/rump/librump/rumpkern/hyperentropy.c  Wed Feb 17 01:42:25 2016 +0000
+++ b/sys/rump/librump/rumpkern/hyperentropy.c  Wed Feb 17 01:48:04 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hyperentropy.c,v 1.12 2016/02/17 01:42:25 riastradh Exp $      */
+/*     $NetBSD: hyperentropy.c,v 1.13 2016/02/17 01:48:04 riastradh Exp $      */
 
 /*
  * Copyright (c) 2014 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hyperentropy.c,v 1.12 2016/02/17 01:42:25 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hyperentropy.c,v 1.13 2016/02/17 01:48:04 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -37,6 +37,7 @@
 
 #include <rump/rumpuser.h>
 
+static kmutex_t rndsrc_lock;
 static krndsource_t rndsrc;
 
 #define MAXGET (RND_POOLBITS/NBBY)
@@ -48,8 +49,11 @@
 
        rnddata = kmem_intr_alloc(MAXGET, KM_SLEEP);
        if (rumpuser_getrandom(rnddata, MIN(MAXGET, bytes),
-           RUMPUSER_RANDOM_HARD|RUMPUSER_RANDOM_NOWAIT, &dsize) == 0)
+           RUMPUSER_RANDOM_HARD|RUMPUSER_RANDOM_NOWAIT, &dsize) == 0) {
+               mutex_enter(&rndsrc_lock);
                rnd_add_data_sync(&rndsrc, rnddata, dsize, NBBY*dsize);
+               mutex_exit(&rndsrc_lock);
+       }
        kmem_intr_free(rnddata, MAXGET);
 }
 
@@ -57,6 +61,8 @@
 rump_hyperentropy_init(void)
 {
 
+       mutex_init(&rndsrc_lock, MUTEX_DEFAULT, IPL_VM);
+
        rndsource_setcb(&rndsrc, &feedrandom, NULL);
        rnd_attach_source(&rndsrc, "rump_hyperent", RND_TYPE_VM,
            RND_FLAG_COLLECT_VALUE|RND_FLAG_HASCB);



Home | Main Index | Thread Index | Old Index