Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Feb 2004 17:37:12 -0800
From:      Gregory Neil Shapiro <gshapiro@freebsd.org>
To:        Mark Andrews <Mark_Andrews@isc.org>
Cc:        freebsd-stable@freebsd.org
Subject:   Re: rndcontrol doesn't work on -STABLE?
Message-ID:  <20040223013712.GO62095@horsey.gshapiro.net>
In-Reply-To: <200402230127.i1N1RL3S007766@drugs.dv.isc.org>
References:  <20040223011455.GN62095@horsey.gshapiro.net> <200402230127.i1N1RL3S007766@drugs.dv.isc.org>

next in thread | previous in thread | raw e-mail | index | archive | help
> > +			for (i = 0; i < 24; i++)
> >  				if (irq & (1 << i))
> >  					printf(" %d", i);
> 
> 	This is broken.  'irq' is u_int16_t.

Thanks, I warned it was untested.  In case anyone wants a fixed patch,
still untested:

--- sys/sys/random.h.orig	Sun Feb 22 17:34:16 2004
+++ sys/sys/random.h	Sun Feb 22 17:34:35 2004
@@ -54,7 +54,7 @@
 
 #define	MEM_SETIRQ	_IOW('r', 1, u_int16_t)	/* set interrupt */
 #define	MEM_CLEARIRQ	_IOW('r', 2, u_int16_t)	/* clear interrupt */
-#define	MEM_RETURNIRQ	_IOR('r', 3, u_int16_t)	/* return interrupt */
+#define	MEM_RETURNIRQ	_IOR('r', 3, u_int32_t)	/* return interrupt */
 
 #ifdef _KERNEL
 
--- sys/i386/i386/mem.c.orig	Sun Feb 22 17:15:13 2004
+++ sys/i386/i386/mem.c	Sun Feb 22 17:33:05 2004
@@ -65,6 +65,7 @@
 #include <machine/psl.h>
 #include <machine/specialreg.h>
 #include <i386/isa/intr_machdep.h>
+#include <i386/isa/icu.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -96,7 +97,7 @@
 	/* bmaj */	-1
 };
 
-static struct random_softc random_softc[16];
+static struct random_softc random_softc[ICU_LEN];
 static caddr_t	zbuf;
 
 MALLOC_DEFINE(M_MEMDESC, "memdesc", "memory range descriptors");
@@ -471,9 +472,6 @@
 		return (ENOTTY);
 
 	/*
-	 * XXX the data is 16-bit due to a historical botch, so we use
-	 * magic 16's instead of ICU_LEN and can't support 24 interrupts
-	 * under SMP.
 	 * Even inspecting the state is privileged, since it gives a hint
 	 * about how easily the randomness might be guessed.
 	 */
@@ -489,7 +487,7 @@
 		error = suser(p);
 		if (error != 0)
 			return (error);
-		if (intr < 0 || intr >= 16)
+		if (intr < 0 || intr >= ICU_LEN)
 			return (EINVAL);
 		if (interrupt_allowed & interrupt_mask)
 			break;
@@ -506,7 +504,7 @@
 		error = suser(p);
 		if (error != 0)
 			return (error);
-		if (intr < 0 || intr >= 16)
+		if (intr < 0 || intr >= ICU_LEN)
 			return (EINVAL);
 		if (!(interrupt_allowed & interrupt_mask))
 			break;
@@ -520,7 +518,7 @@
 		error = suser(p);
 		if (error != 0)
 			return (error);
-		*(u_int16_t *)data = interrupt_allowed;
+		*(u_int32_t *)data = interrupt_allowed;
 		break;
 	}
 	return (0);
--- usr.sbin/rndcontrol/rndcontrol.c.orig	Sun Feb 22 17:15:13 2004
+++ usr.sbin/rndcontrol/rndcontrol.c	Sun Feb 22 17:33:16 2004
@@ -48,7 +48,7 @@
 main(int argc, char *argv[])
 {
 	int verbose, ch, fd, result, i;
-	u_int16_t irq;
+	u_int32_t irq;
 
 	verbose = 1;
 
@@ -95,7 +95,7 @@
 				return (1);
 			}
 			printf("%s: interrupts in use:", argv[0]);
-			for (i = 0; i < 16; i++)
+			for (i = 0; i < 24; i++)
 				if (irq & (1 << i))
 					printf(" %d", i);
 			printf("\n");



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