From owner-freebsd-stable@FreeBSD.ORG Sun Feb 22 17:37:12 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B6DE716A4CE for ; Sun, 22 Feb 2004 17:37:12 -0800 (PST) Received: from horsey.gshapiro.net (horsey.gshapiro.net [64.105.95.154]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6F56F43D1D for ; Sun, 22 Feb 2004 17:37:12 -0800 (PST) (envelope-from gshapiro@gshapiro.net) Received: from horsey.gshapiro.net (localhost [127.0.0.1]) id i1N1bChP000799 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 22 Feb 2004 17:37:12 -0800 (PST) Received: (from gshapiro@localhost)i1N1bCik000798; Sun, 22 Feb 2004 17:37:12 -0800 (PST) Date: Sun, 22 Feb 2004 17:37:12 -0800 From: Gregory Neil Shapiro To: Mark Andrews Message-ID: <20040223013712.GO62095@horsey.gshapiro.net> References: <20040223011455.GN62095@horsey.gshapiro.net> <200402230127.i1N1RL3S007766@drugs.dv.isc.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200402230127.i1N1RL3S007766@drugs.dv.isc.org> User-Agent: Mutt/1.5.6i cc: freebsd-stable@freebsd.org Subject: Re: rndcontrol doesn't work on -STABLE? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Feb 2004 01:37:12 -0000 > > + 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 #include #include +#include #include #include @@ -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");