From nobody@FreeBSD.org  Mon Jan  9 21:59:34 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5CC1C106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Jan 2012 21:59:34 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 2E7388FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  9 Jan 2012 21:59:34 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q09LxXIV049249
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 9 Jan 2012 21:59:33 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q09LxXfA049248;
	Mon, 9 Jan 2012 21:59:33 GMT
	(envelope-from nobody)
Message-Id: <201201092159.q09LxXfA049248@red.freebsd.org>
Date: Mon, 9 Jan 2012 21:59:33 GMT
From: Stefan Krger <stadtkind2@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Via RNG not enabled on amd64
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         163974
>Category:       kern
>Synopsis:       Via RNG not enabled on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jkim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 09 22:00:26 UTC 2012
>Closed-Date:    Thu Feb 23 00:54:05 UTC 2012
>Last-Modified:  Thu Feb 23 00:54:05 UTC 2012
>Originator:     Stefan Krger
>Release:        FreeBSD 9.0-REL
>Organization:
>Environment:
FreeBSD fbsd9.some.lan 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan  9 21:46:25 UTC 2012     root@fbsd9.some.lan:/usr/obj/usr/src/sys/NANO  amd64
>Description:
The random kernel module on FreeBSD/amd64 doesn't support 64bit VIA CPUs hardware rng because the conf/Makefile/c files still assume Via CPUs are 32bit only.
>How-To-Repeat:
Boot FreeBSD/amd64 on a 64bit Via Nano CPU and notice that the hw rng is not used.
>Fix:


Patch attached with submission follows:

--- conf/files.amd64.orig	2012-01-09 22:08:51.000000000 +0100
+++ conf/files.amd64	2012-01-09 22:10:23.000000000 +0100
@@ -208,6 +208,7 @@
 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/qlxgb/qla_dbg.c		optional	qlxgb pci
 dev/qlxgb/qla_hw.c		optional	qlxgb pci
 dev/qlxgb/qla_ioctl.c		optional	qlxgb pci
--- modules/random/Makefile.orig	2012-01-09 22:07:22.000000000 +0100
+++ modules/random/Makefile	2012-01-09 22:07:27.000000000 +0100
@@ -6,7 +6,7 @@
 
 KMOD=	random
 SRCS=	randomdev.c probe.c
-.if ${MACHINE} == "i386"
+.if ${MACHINE} == "i386" || ${MACHINE} == "amd64"
 SRCS+=	nehemiah.c
 .endif
 SRCS+=	randomdev_soft.c yarrow.c hash.c
--- dev/random/probe.c.orig	2012-01-09 21:55:26.000000000 +0100
+++ dev/random/probe.c	2012-01-09 21:55:43.000000000 +0100
@@ -36,7 +36,7 @@
 #include <sys/stdint.h>
 #include <sys/sysctl.h>
 
-#if defined(__i386__) && !defined(PC98)
+#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
 #include <machine/cpufunc.h>
 #include <machine/cputypes.h>
 #include <machine/md_var.h>
@@ -55,7 +55,7 @@
 	*systat = random_yarrow;
 
 	/* Then go looking for hardware */
-#if defined(__i386__) && !defined(PC98)
+#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
 	if (via_feature_rng & VIA_HAS_RNG) {
 		*systat = random_nehemiah;
 	}


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jkim 
Responsible-Changed-By: jkim 
Responsible-Changed-When: Mon Jan 9 22:21:03 UTC 2012 
Responsible-Changed-Why:  
I can take it but I cannot test it because I do not have a VIA Nano processor 
platform any more.  I'll just assume the originator tested it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=163974 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/163974: commit references a PR
Date: Mon,  9 Jan 2012 23:20:52 +0000 (UTC)

 Author: jkim
 Date: Mon Jan  9 23:20:30 2012
 New Revision: 229887
 URL: http://svn.freebsd.org/changeset/base/229887
 
 Log:
   Enable hardware RNG for VIA Nano processors.
   
   PR:		kern/163974
 
 Modified:
   head/sys/conf/files.amd64
   head/sys/dev/random/probe.c
   head/sys/modules/random/Makefile
 
 Modified: head/sys/conf/files.amd64
 ==============================================================================
 --- head/sys/conf/files.amd64	Mon Jan  9 23:01:42 2012	(r229886)
 +++ head/sys/conf/files.amd64	Mon Jan  9 23:20:30 2012	(r229887)
 @@ -215,6 +215,7 @@ 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/qlxgb/qla_dbg.c		optional	qlxgb pci
  dev/qlxgb/qla_hw.c		optional	qlxgb pci
  dev/qlxgb/qla_ioctl.c		optional	qlxgb pci
 
 Modified: head/sys/dev/random/probe.c
 ==============================================================================
 --- head/sys/dev/random/probe.c	Mon Jan  9 23:01:42 2012	(r229886)
 +++ head/sys/dev/random/probe.c	Mon Jan  9 23:20:30 2012	(r229887)
 @@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
  #include <sys/stdint.h>
  #include <sys/sysctl.h>
  
 -#if defined(__i386__) && !defined(PC98)
 +#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
  #include <machine/cpufunc.h>
  #include <machine/cputypes.h>
  #include <machine/md_var.h>
 @@ -55,7 +55,7 @@ random_ident_hardware(struct random_syst
  	*systat = random_yarrow;
  
  	/* Then go looking for hardware */
 -#if defined(__i386__) && !defined(PC98)
 +#if defined(__amd64__) || (defined(__i386__) && !defined(PC98))
  	if (via_feature_rng & VIA_HAS_RNG) {
  		*systat = random_nehemiah;
  	}
 
 Modified: head/sys/modules/random/Makefile
 ==============================================================================
 --- head/sys/modules/random/Makefile	Mon Jan  9 23:01:42 2012	(r229886)
 +++ head/sys/modules/random/Makefile	Mon Jan  9 23:20:30 2012	(r229887)
 @@ -6,7 +6,7 @@
  
  KMOD=	random
  SRCS=	randomdev.c probe.c
 -.if ${MACHINE} == "i386"
 +.if ${MACHINE} == "amd64" || ${MACHINE} == "i386"
  SRCS+=	nehemiah.c
  .endif
  SRCS+=	randomdev_soft.c yarrow.c hash.c
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: jkim 
State-Changed-When: Thu Feb 23 00:53:24 UTC 2012 
State-Changed-Why:  
Committed to head and merged to stable/9.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=163974 
>Unformatted:
