Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Sep 2012 10:56:26 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r240994 - in stable/8/sys: amd64/conf conf dev/random i386/conf modules/random
Message-ID:  <201209271056.q8RAuQt1003611@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Sep 27 10:56:25 2012
New Revision: 240994
URL: http://svn.freebsd.org/changeset/base/240994

Log:
  MFC r240135:
  Add support for new Intel on-CPU Bull Mountain random number generator.
  
  MFC r240455:
  Rename the IVY_RNG option to RDRAND_RNG.

Added:
  stable/8/sys/dev/random/ivy.c
     - copied, changed from r240135, head/sys/dev/random/ivy.c
Deleted:
  stable/8/sys/dev/random/nehemiah.h
Modified:
  stable/8/sys/amd64/conf/GENERIC
  stable/8/sys/conf/files.amd64
  stable/8/sys/conf/files.i386
  stable/8/sys/conf/options.amd64
  stable/8/sys/conf/options.i386
  stable/8/sys/dev/random/nehemiah.c
  stable/8/sys/dev/random/probe.c
  stable/8/sys/i386/conf/GENERIC
  stable/8/sys/modules/random/Makefile
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/   (props changed)
  stable/8/sys/conf/   (props changed)
  stable/8/sys/dev/   (props changed)
  stable/8/sys/dev/random/   (props changed)
  stable/8/sys/i386/   (props changed)
  stable/8/sys/modules/   (props changed)

Modified: stable/8/sys/amd64/conf/GENERIC
==============================================================================
--- stable/8/sys/amd64/conf/GENERIC	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/amd64/conf/GENERIC	Thu Sep 27 10:56:25 2012	(r240994)
@@ -271,6 +271,8 @@ device		wi		# WaveLAN/Intersil/Symbol 80
 # Pseudo devices.
 device		loop		# Network loopback
 device		random		# Entropy device
+options 	PADLOCK_RNG	# VIA Padlock RNG
+options 	RDRAND_RNG	# Intel Bull Mountain RNG
 device		ether		# Ethernet support
 device		vlan		# 802.1Q VLAN support
 device		tun		# Packet tunnel.

Modified: stable/8/sys/conf/files.amd64
==============================================================================
--- stable/8/sys/conf/files.amd64	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/conf/files.amd64	Thu Sep 27 10:56:25 2012	(r240994)
@@ -223,7 +223,8 @@ dev/lindev/lindev.c		optional	lindev
 dev/nfe/if_nfe.c		optional	nfe pci
 dev/nve/if_nve.c		optional	nve pci
 dev/nvram/nvram.c		optional	nvram isa
-dev/random/nehemiah.c		optional	random
+dev/random/ivy.c		optional	random rdrand_rng
+dev/random/nehemiah.c		optional	random padlock_rng
 dev/sio/sio.c			optional	sio
 dev/sio/sio_isa.c		optional	sio isa
 dev/sio/sio_pccard.c		optional	sio pccard

Modified: stable/8/sys/conf/files.i386
==============================================================================
--- stable/8/sys/conf/files.i386	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/conf/files.i386	Thu Sep 27 10:56:25 2012	(r240994)
@@ -223,7 +223,8 @@ dev/nfe/if_nfe.c		optional nfe pci
 dev/nve/if_nve.c		optional nve pci
 dev/nvram/nvram.c		optional nvram isa
 dev/pcf/pcf_isa.c		optional pcf
-dev/random/nehemiah.c		optional random
+dev/random/ivy.c		optional random rdrand_rng
+dev/random/nehemiah.c		optional random padlock_rng
 dev/sbni/if_sbni.c		optional sbni
 dev/sbni/if_sbni_isa.c		optional sbni isa
 dev/sbni/if_sbni_pci.c		optional sbni pci

Modified: stable/8/sys/conf/options.amd64
==============================================================================
--- stable/8/sys/conf/options.amd64	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/conf/options.amd64	Thu Sep 27 10:56:25 2012	(r240994)
@@ -67,3 +67,7 @@ XENHVM			opt_global.h
 
 # options for the Intel C600 SAS driver (isci)
 ISCI_LOGGING	opt_isci.h
+
+# hw random number generators for random(4)
+PADLOCK_RNG		opt_cpu.h
+RDRAND_RNG		opt_cpu.h

Modified: stable/8/sys/conf/options.i386
==============================================================================
--- stable/8/sys/conf/options.i386	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/conf/options.i386	Thu Sep 27 10:56:25 2012	(r240994)
@@ -124,3 +124,7 @@ XENHVM			opt_global.h
 
 # options for the Intel C600 SAS driver (isci)
 ISCI_LOGGING	opt_isci.h
+
+# hw random number generators for random(4)
+PADLOCK_RNG		opt_cpu.h
+RDRAND_RNG		opt_cpu.h

Copied and modified: stable/8/sys/dev/random/ivy.c (from r240135, head/sys/dev/random/ivy.c)
==============================================================================
--- head/sys/dev/random/ivy.c	Wed Sep  5 13:18:51 2012	(r240135, copy source)
+++ stable/8/sys/dev/random/ivy.c	Thu Sep 27 10:56:25 2012	(r240994)
@@ -30,7 +30,7 @@ __FBSDID("$FreeBSD$");
 
 #include "opt_cpu.h"
 
-#ifdef IVY_RNG
+#ifdef RDRAND_RNG
 
 #include <sys/param.h>
 #include <sys/time.h>

Modified: stable/8/sys/dev/random/nehemiah.c
==============================================================================
--- stable/8/sys/dev/random/nehemiah.c	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/dev/random/nehemiah.c	Thu Sep 27 10:56:25 2012	(r240994)
@@ -28,6 +28,10 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_cpu.h"
+
+#ifdef PADLOCK_RNG
+
 #include <sys/param.h>
 #include <sys/time.h>
 #include <sys/lock.h>
@@ -203,3 +207,5 @@ random_nehemiah_read(void *buf, int c)
 	mtx_unlock(&random_nehemiah_mtx);
 	return (c);
 }
+
+#endif

Modified: stable/8/sys/dev/random/probe.c
==============================================================================
--- stable/8/sys/dev/random/probe.c	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/dev/random/probe.c	Thu Sep 27 10:56:25 2012	(r240994)
@@ -28,12 +28,17 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
+#include "opt_cpu.h"
+#endif
+
 #include <sys/types.h>
 #include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/random.h>
 #include <sys/selinfo.h>
-#include <sys/stdint.h>
 #include <sys/sysctl.h>
 
 #if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
@@ -45,7 +50,15 @@ __FBSDID("$FreeBSD$");
 
 #include <dev/random/randomdev.h>
 #include <dev/random/randomdev_soft.h>
-#include <dev/random/nehemiah.h>
+
+#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
+#ifdef PADLOCK_RNG
+extern struct random_systat random_nehemiah;
+#endif
+#ifdef RDRAND_RNG
+extern struct random_systat random_ivy;
+#endif
+#endif
 
 void
 random_ident_hardware(struct random_systat *systat)
@@ -56,8 +69,25 @@ random_ident_hardware(struct random_syst
 
 	/* Then go looking for hardware */
 #if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
+#ifdef PADLOCK_RNG
 	if (via_feature_rng & VIA_HAS_RNG) {
-		*systat = random_nehemiah;
+		int enable;
+
+		enable = 1;
+		TUNABLE_INT_FETCH("hw.nehemiah_rng_enable", &enable);
+		if (enable)
+			*systat = random_nehemiah;
 	}
 #endif
+#ifdef RDRAND_RNG
+	if (cpu_feature2 & CPUID2_RDRAND) {
+		int enable;
+
+		enable = 1;
+		TUNABLE_INT_FETCH("hw.ivy_rng_enable", &enable);
+		if (enable)
+			*systat = random_ivy;
+	}
+#endif
+#endif
 }

Modified: stable/8/sys/i386/conf/GENERIC
==============================================================================
--- stable/8/sys/i386/conf/GENERIC	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/i386/conf/GENERIC	Thu Sep 27 10:56:25 2012	(r240994)
@@ -284,6 +284,8 @@ device		wi		# WaveLAN/Intersil/Symbol 80
 # Pseudo devices.
 device		loop		# Network loopback
 device		random		# Entropy device
+options 	PADLOCK_RNG	# VIA Padlock RNG
+options 	RDRAND_RNG	# Intel Bull Mountain RNG
 device		ether		# Ethernet support
 device		vlan		# 802.1Q VLAN support
 device		tun		# Packet tunnel.

Modified: stable/8/sys/modules/random/Makefile
==============================================================================
--- stable/8/sys/modules/random/Makefile	Thu Sep 27 10:51:38 2012	(r240993)
+++ stable/8/sys/modules/random/Makefile	Thu Sep 27 10:56:25 2012	(r240994)
@@ -8,10 +8,11 @@ KMOD=	random
 SRCS=	randomdev.c probe.c
 .if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
 SRCS+=	nehemiah.c
+SRCS+=	ivy.c
 .endif
 SRCS+=	randomdev_soft.c yarrow.c hash.c
 SRCS+=	rijndael-alg-fst.c rijndael-api-fst.c sha2.c
-SRCS+=	bus_if.h device_if.h vnode_if.h
+SRCS+=	bus_if.h device_if.h vnode_if.h opt_cpu.h
 
 CFLAGS+= -I${.CURDIR}/../..
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209271056.q8RAuQt1003611>