Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Sep 2013 20:21:23 +0100
From:      Mark R V Murray <mark@grondar.org>
To:        sbruno@freebsd.org
Cc:        "freebsd-current@freebsd.org" <freebsd-current@freebsd.org>
Subject:   Re: random(4) update causes mips compile fail | mips boot fail
Message-ID:  <C8A27508-4874-4DE1-A703-030925181097@grondar.org>
In-Reply-To: <1378581133.1588.18.camel@localhost>
References:  <1378572186.1588.5.camel@localhost> <24DB010A-F374-491B-9203-FDDD7EA14A51@grondar.org> <1378579011.1588.16.camel@localhost> <9240BEF1-2791-4D58-A422-08AEF1CD306C@grondar.org> <1378579756.1588.17.camel@localhost> <D8D37885-C474-44C9-9ED2-E35D31CD87F8@grondar.org> <1378581133.1588.18.camel@localhost>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A
Content-Type: multipart/mixed;
	boundary="Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7"


--Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii


On 7 Sep 2013, at 20:12, Sean Bruno <sean_bruno@yahoo.com> wrote:

> On Sat, 2013-09-07 at 19:56 +0100, Mark R V Murray wrote:
>>> Ok.  Right now, the mips kernel doesn't build unless I have random
>> built
>>> in, we were using it as a module previously.  
>> 
>> 
>> I'm testing a fix, but if you want to help out, please move the
>> random_null_func()
>> from randomdev.c to pseudo_rng.c in sys/dev/random. Patch enclosed.
>> 
>> Thanks!
>> 
>> M 
> 
> Closer:
> 
> --- kernel.debug ---
> linking kernel.debug
> random_adaptors.o: In function `random_sysctl_active_adaptor_handler':
> /home/sbruno/bsd/head/sys/dev/random/random_adaptors.c:(.text+0x2dc):
> undefined reference to `random_get_active_adaptor'
> /home/sbruno/bsd/head/sys/dev/random/random_adaptors.c:(.text+0x2dc):
> relocation truncated to fit: R_MIPS_26 against
> `random_get_active_adaptor'
> *** [kernel.debug] Error code 1

Nearly there - I saw that too.

Proposed fix enclosed.

M
-- 
Mark R V Murray

--Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7
Content-Disposition: attachment;
	filename=rng_fix.patch
Content-Type: application/octet-stream;
	name="rng_fix.patch"
Content-Transfer-Encoding: 7bit

Index: arm/arm/locore.S
===================================================================
--- arm/arm/locore.S	(revision 255362)
+++ arm/arm/locore.S	(working copy)
@@ -84,6 +84,17 @@
 	mov	ip, r2		/* Save meta data */
 	mov	fp, r3		/* Future expantion */
 
+#if defined(CPU_CORTEXA)
+        /* Get this bit done early so we have some decent startup jitter in CCNT */
+	/* Better to do access to these counters as some kind of device? */
+	/* Set INTENS to 0 to block all counter interrupts */
+	mov	r7, #0x8000000F
+	mcr	p15, 0, r7, c9, c14, 2
+	/* Set PMNC[0] to 1 to enable CCNT, used in get_cyclecount() */
+	mov	r7, #1
+	mcr	p15, 0, r7, c9, c12, 0
+#endif
+
 	/* Make sure interrupts are disabled. */
 	mrs	r7, cpsr
 	orr	r7, r7, #(I32_bit|F32_bit)
Index: arm/include/cpu.h
===================================================================
--- arm/include/cpu.h	(revision 255362)
+++ arm/include/cpu.h	(working copy)
@@ -13,11 +13,18 @@
 static __inline uint64_t
 get_cyclecount(void)
 {
+#if defined(CPU_CORTEXA)
+	uint32_t ccnt;
+
+	/* Read CCNT. Darn; its only 32 bits. */
+	__asm __volatile("mrc p15, 0, %0, c9, c13, 0": "=r" (ccnt));
+	return ((uint64_t)ccnt);
+#else
 	struct bintime bt;
 
 	binuptime(&bt);
 	return ((uint64_t)bt.sec << 56 | bt.frac >> 8);
-			
+#endif
 }
 #endif
 
Index: dev/random/pseudo_rng.c
===================================================================
--- dev/random/pseudo_rng.c	(revision 255362)
+++ dev/random/pseudo_rng.c	(working copy)
@@ -39,6 +39,12 @@
 
 static struct mtx	pseudo_random_block_mtx;
 
+/* Used to fake out unused random calls in random_adaptor */
+void
+random_null_func(void)
+{
+}
+
 static int
 pseudo_random_block_read(void *buf __unused, int c __unused)
 {
Index: dev/random/random_adaptors.c
===================================================================
--- dev/random/random_adaptors.c	(revision 255362)
+++ dev/random/random_adaptors.c	(working copy)
@@ -53,6 +53,8 @@
 /* List for the dynamic sysctls */
 static struct sysctl_ctx_list random_clist;
 
+struct random_adaptor *random_adaptor;
+
 MALLOC_DEFINE(M_RANDOM_ADAPTORS, "random_adaptors", "Random adaptors buffers");
 
 int
@@ -230,7 +232,7 @@
 	int error;
 
 	name = NULL;
-	rsp = random_get_active_adaptor();
+	rsp = random_adaptor;
 
 	if (rsp != NULL) {
 		sx_slock(&adaptors_lock);
Index: dev/random/random_adaptors.h
===================================================================
--- dev/random/random_adaptors.h	(revision 255362)
+++ dev/random/random_adaptors.h	(working copy)
@@ -41,6 +41,8 @@
 int random_adaptor_register(const char *, struct random_adaptor *);
 void random_adaptor_choose(struct random_adaptor **);
 
+extern struct random_adaptor *random_adaptor;
+
 /*
  * random_adaptor's should be registered prior to
  * random module (SI_SUB_DRIVERS/SI_ORDER_MIDDLE)
Index: dev/random/randomdev.c
===================================================================
--- dev/random/randomdev.c	(revision 255362)
+++ dev/random/randomdev.c	(working copy)
@@ -72,27 +72,12 @@
 	.d_name = "random",
 };
 
-static struct random_adaptor *random_adaptor;
 static eventhandler_tag attach_tag;
 static int random_inited;
 
-
 /* For use with make_dev(9)/destroy_dev(9). */
 static struct cdev *random_dev;
 
-/* Used to fake out unused random calls in random_adaptor */
-void
-random_null_func(void)
-{
-}
-
-struct random_adaptor *
-random_get_active_adaptor(void)
-{ 
-
-	return (random_adaptor);
-}
-
 /* ARGSUSED */
 static int
 random_close(struct cdev *dev __unused, int flags, int fmt __unused,
Index: dev/random/randomdev.h
===================================================================
--- dev/random/randomdev.h	(revision 255362)
+++ dev/random/randomdev.h	(working copy)
@@ -53,4 +53,3 @@
 
 extern void random_ident_hardware(struct random_adaptor **);
 extern void random_null_func(void);
-struct random_adaptor *random_get_active_adaptor(void);

--Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
	charset=us-ascii



--Apple-Mail=_0B85307E-2FF8-44C6-9BCD-82B73B023BB7--

--Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.20 (Darwin)
Comment: GPGTools - http://gpgtools.org

iQCVAwUBUit8s958vKOKE6LNAQouFgP8CUonQkFn7z4JUsPLKVjeij2LVWBGIKmu
mK9MeKSV3K/qZg8Z2eGQyWDHFcp6enCrv4eTiTY2tYpw6wNA4VZGpOlMs0fqUrYK
5cqxzyoZzop8KTwkuoCF5DRBX0/ykvrQ/KMhEuuV7TTDEWbgbKuLeM7vbdFDXt9b
elpIRkNSs4g=
=mN42
-----END PGP SIGNATURE-----

--Apple-Mail=_6773E15C-F2D7-4499-9C6C-B6C799B2C96A--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C8A27508-4874-4DE1-A703-030925181097>