Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Dec 1995 12:06:57 +1100
From:      Bruce Evans <bde@zeta.org.au>
To:        current@FreeBSD.ORG, kato@eclogite.eps.nagoya-u.ac.jp
Subject:   Re: outb in random.c
Message-ID:  <199512210106.MAA26975@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
The function add_timer_randomness() in sys/i386/isa/random.c contains:

>    outb(TIMER_LATCH|TIMER_SEL0, TIMER_MODE); /* latch the count ASAP */

>This is outb(data, port).   I think this should be

>    outb(TIMER_MODE, TIMER_LATCH|TIMER_SEL0); /* latch the count ASAP */

Gak!  outb() and inb() are well known to have back to front args in
Linux, where this code was derived from.  This outb clobbers i/o port 0
(part of the address for DMA channel 0) and the following inb's give a
result that is random in a different way than was intended.

Bruce



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