Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86/x86 In addition to %[er]ax, rep xstore-rng al...
details: https://anonhg.NetBSD.org/src/rev/bd5c2624b8f2
branches: trunk
changeset: 772802:bd5c2624b8f2
user: jakllsch <jakllsch%NetBSD.org@localhost>
date: Tue Jan 17 03:39:33 2012 +0000
description:
In addition to %[er]ax, rep xstore-rng also clobbers %[er]cx and %[er]di.
As such, mark them as outputs, as is done in the VIA Padlock example code.
Additionally, let's assume that VIAC3_RNG_BUFSIZ is in bytes and not DWords.
Furthermore assume that there are not 1 but NBBY bits of entropy per byte.
Fixes PR kern/45847 for me.
diffstat:
sys/arch/x86/x86/via_padlock.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diffs (50 lines):
diff -r 468f90d73847 -r bd5c2624b8f2 sys/arch/x86/x86/via_padlock.c
--- a/sys/arch/x86/x86/via_padlock.c Tue Jan 17 03:06:33 2012 +0000
+++ b/sys/arch/x86/x86/via_padlock.c Tue Jan 17 03:39:33 2012 +0000
@@ -1,5 +1,5 @@
/* $OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $ */
-/* $NetBSD: via_padlock.c,v 1.19 2012/01/17 03:06:33 jakllsch Exp $ */
+/* $NetBSD: via_padlock.c,v 1.20 2012/01/17 03:39:33 jakllsch Exp $ */
/*-
* Copyright (c) 2003 Jason Wright
@@ -20,7 +20,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.19 2012/01/17 03:06:33 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.20 2012/01/17 03:39:33 jakllsch Exp $");
#ifdef _KERNEL_OPT
# include "rnd.h"
@@ -85,8 +85,9 @@
{
struct via_padlock_softc *sc = arg;
- unsigned int rv, creg0, len = VIAC3_RNG_BUFSIZ;
- static uint32_t buffer[VIAC3_RNG_BUFSIZ + 2]; /* XXX 2? */
+ uint32_t creg0, len = VIAC3_RNG_BUFSIZ;
+ uint32_t buffer[VIAC3_RNG_BUFSIZ/4 + 1]; /* CPU goes 3 bytes beyond */
+ uint32_t eax, ecx, edi; /* XXX write-only, but necessary it seems */
/*
* Sadly, we have to monkey with the coprocessor enable and fault
@@ -109,14 +110,14 @@
* if we will feed the data to SHA1?) (%edx[0,1] = "11").
*/
__asm __volatile("rep xstorerng"
- : "=a" (rv) : "d" (3), "D" (buffer),
- "c" (len * sizeof(int)) : "memory", "cc");
+ : "=a" (eax), "=c" (ecx), "=D" (edi)
+ : "d" (3), "D" (buffer), "c" (len)
+ : "memory", "cc");
/* Put CR0 back how it was */
lcr0(creg0);
x86_enable_intr();
kpreempt_enable();
- rnd_add_data(&sc->sc_rnd_source, buffer, len * sizeof(int),
- len * sizeof(int));
+ rnd_add_data(&sc->sc_rnd_source, buffer, len, len * NBBY);
callout_reset(&sc->sc_rnd_co, sc->sc_rnd_hz, via_c3_rnd, sc);
}
Home |
Main Index |
Thread Index |
Old Index