From owner-svn-src-projects@FreeBSD.ORG Tue Oct 8 22:14:09 2013 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E2049C3A; Tue, 8 Oct 2013 22:14:08 +0000 (UTC) (envelope-from markm@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id CEB4C2663; Tue, 8 Oct 2013 22:14:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r98ME8vj002408; Tue, 8 Oct 2013 22:14:08 GMT (envelope-from markm@svn.freebsd.org) Received: (from markm@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r98ME7wN002397; Tue, 8 Oct 2013 22:14:07 GMT (envelope-from markm@svn.freebsd.org) Message-Id: <201310082214.r98ME7wN002397@svn.freebsd.org> From: Mark Murray Date: Tue, 8 Oct 2013 22:14:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r256168 - projects/random_number_generator/sys/dev/random X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Oct 2013 22:14:09 -0000 Author: markm Date: Tue Oct 8 22:14:07 2013 New Revision: 256168 URL: http://svnweb.freebsd.org/changeset/base/256168 Log: Fix some just-noticed problems: o Allow this to work with "nodevice random" by fixing where the MALLOC pool is defined. o Fix the explicit reseed code. This was correct as submitted, but in the project branch doesn't need to set the "seeded" bit as this is done correctly in the "unblock" function. o Remove some debug ifdeffing. o Adjust comments. Modified: projects/random_number_generator/sys/dev/random/ivy.c projects/random_number_generator/sys/dev/random/nehemiah.c projects/random_number_generator/sys/dev/random/random_adaptors.c projects/random_number_generator/sys/dev/random/random_adaptors.h projects/random_number_generator/sys/dev/random/random_harvestq.c projects/random_number_generator/sys/dev/random/randomdev.c projects/random_number_generator/sys/dev/random/randomdev.h Modified: projects/random_number_generator/sys/dev/random/ivy.c ============================================================================== --- projects/random_number_generator/sys/dev/random/ivy.c Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/ivy.c Tue Oct 8 22:14:07 2013 (r256168) @@ -57,15 +57,6 @@ struct random_hardware_source random_ivy .read = random_ivy_read }; -#if 1 -static inline int -ivy_rng_store(uint64_t *tmp) -{ - *tmp = 0xF001FACE; - - return (sizeof(uint64_t)); -} -#else static inline int ivy_rng_store(uint64_t *tmp) { @@ -91,7 +82,6 @@ ivy_rng_store(uint64_t *tmp) return (0); #endif } -#endif static int random_ivy_read(void *buf, int c) @@ -124,10 +114,6 @@ rdrand_modevent(module_t mod, int type, switch (type) { case MOD_LOAD: -#if 1 - live_entropy_source_register(&random_ivy); - printf("%s: CRAP RDRAND is present\n", random_ivy.ident); -#else if (cpu_feature2 & CPUID2_RDRAND) live_entropy_source_register(&random_ivy); else @@ -136,7 +122,6 @@ rdrand_modevent(module_t mod, int type, #endif printf("%s: RDRAND is not present\n", random_ivy.ident); -#endif break; case MOD_UNLOAD: Modified: projects/random_number_generator/sys/dev/random/nehemiah.c ============================================================================== --- projects/random_number_generator/sys/dev/random/nehemiah.c Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/nehemiah.c Tue Oct 8 22:14:07 2013 (r256168) @@ -57,10 +57,13 @@ struct random_hardware_source random_neh .read = random_nehemiah_read }; -/* This H/W RNG never stores more than 8 bytes in one go */ - +/* TODO: now that the Davies-Meyer hash is gone and we only use + * the 'xstore' instruction, do we still need to preserve the + * FPU state with fpu_kern_(enter|leave)() ? + */ static struct fpu_kern_ctx *fpu_ctx_save; +/* This H/W source never stores more than 8 bytes in one go */ /* ARGSUSED */ static __inline size_t VIA_RNG_store(void *buf) Modified: projects/random_number_generator/sys/dev/random/random_adaptors.c ============================================================================== --- projects/random_number_generator/sys/dev/random/random_adaptors.c Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/random_adaptors.c Tue Oct 8 22:14:07 2013 (r256168) @@ -55,6 +55,8 @@ static struct sysctl_ctx_list random_cli struct random_adaptor *random_adaptor; +MALLOC_DEFINE(M_ENTROPY, "entropy", "Entropy harvesting buffers and data structures"); + int random_adaptor_register(const char *name, struct random_adaptor *rsp) { @@ -233,10 +235,8 @@ random_adaptors_reseed(void *unused) { (void)unused; - if (random_adaptor != NULL) { + if (random_adaptor != NULL) (*random_adaptor->reseed)(); - random_adaptor->seeded = 1; - } arc4rand(NULL, 0, 1); } SYSINIT(random_reseed, SI_SUB_INTRINSIC_POST, SI_ORDER_SECOND, Modified: projects/random_number_generator/sys/dev/random/random_adaptors.h ============================================================================== --- projects/random_number_generator/sys/dev/random/random_adaptors.h Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/random_adaptors.h Tue Oct 8 22:14:07 2013 (r256168) @@ -31,6 +31,8 @@ #include +MALLOC_DECLARE(M_ENTROPY); + struct random_adaptors { LIST_ENTRY(random_adaptors) entries; /* list of providers */ const char *name; /* name of random adaptor */ Modified: projects/random_number_generator/sys/dev/random/random_harvestq.c ============================================================================== --- projects/random_number_generator/sys/dev/random/random_harvestq.c Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/random_harvestq.c Tue Oct 8 22:14:07 2013 (r256168) @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include Modified: projects/random_number_generator/sys/dev/random/randomdev.c ============================================================================== --- projects/random_number_generator/sys/dev/random/randomdev.c Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/randomdev.c Tue Oct 8 22:14:07 2013 (r256168) @@ -74,8 +74,6 @@ static struct cdevsw random_cdevsw = { .d_name = "random", }; -MALLOC_DEFINE(M_ENTROPY, "entropy", "Entropy harvesting buffers"); - /* For use with make_dev(9)/destroy_dev(9). */ static struct cdev *random_dev; Modified: projects/random_number_generator/sys/dev/random/randomdev.h ============================================================================== --- projects/random_number_generator/sys/dev/random/randomdev.h Tue Oct 8 20:39:38 2013 (r256167) +++ projects/random_number_generator/sys/dev/random/randomdev.h Tue Oct 8 22:14:07 2013 (r256168) @@ -30,8 +30,6 @@ * and non algorithm-specific for the entropy processor */ -MALLOC_DECLARE(M_ENTROPY); - typedef void random_init_func_t(void); typedef void random_deinit_func_t(void); typedef int random_block_func_t(int);