Tue Jan 17 03:06:33 2012 UTC ()
leading whitespace too!


(jakllsch)
diff -r1.18 -r1.19 src/sys/arch/x86/x86/via_padlock.c

cvs diff -r1.18 -r1.19 src/sys/arch/x86/x86/via_padlock.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/via_padlock.c 2012/01/17 03:01:39 1.18
+++ src/sys/arch/x86/x86/via_padlock.c 2012/01/17 03:06:33 1.19
@@ -1,36 +1,36 @@ @@ -1,36 +1,36 @@
1/* $OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $ */ 1/* $OpenBSD: via.c,v 1.8 2006/11/17 07:47:56 tom Exp $ */
2/* $NetBSD: via_padlock.c,v 1.18 2012/01/17 03:01:39 jakllsch Exp $ */ 2/* $NetBSD: via_padlock.c,v 1.19 2012/01/17 03:06:33 jakllsch Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2003 Jason Wright 5 * Copyright (c) 2003 Jason Wright
6 * Copyright (c) 2003, 2004 Theo de Raadt 6 * Copyright (c) 2003, 2004 Theo de Raadt
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Permission to use, copy, modify, and distribute this software for any 9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above 10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies. 11 * copyright notice and this permission notice appear in all copies.
12 * 12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 */ 20 */
21 21
22#include <sys/cdefs.h> 22#include <sys/cdefs.h>
23__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.18 2012/01/17 03:01:39 jakllsch Exp $"); 23__KERNEL_RCSID(0, "$NetBSD: via_padlock.c,v 1.19 2012/01/17 03:06:33 jakllsch Exp $");
24 24
25#ifdef _KERNEL_OPT 25#ifdef _KERNEL_OPT
26# include "rnd.h" 26# include "rnd.h"
27# if NRND == 0 27# if NRND == 0
28# error padlock requires rnd pseudo-devices 28# error padlock requires rnd pseudo-devices
29# endif 29# endif
30#endif 30#endif
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/signalvar.h> 34#include <sys/signalvar.h>
35#include <sys/kernel.h> 35#include <sys/kernel.h>
36#include <sys/device.h> 36#include <sys/device.h>
@@ -83,27 +83,27 @@ static __inline void via_padlock_cbc(voi @@ -83,27 +83,27 @@ static __inline void via_padlock_cbc(voi
83static void 83static void
84via_c3_rnd(void *arg) 84via_c3_rnd(void *arg)
85{ 85{
86 struct via_padlock_softc *sc = arg; 86 struct via_padlock_softc *sc = arg;
87 87
88 unsigned int rv, creg0, len = VIAC3_RNG_BUFSIZ; 88 unsigned int rv, creg0, len = VIAC3_RNG_BUFSIZ;
89 static uint32_t buffer[VIAC3_RNG_BUFSIZ + 2]; /* XXX 2? */ 89 static uint32_t buffer[VIAC3_RNG_BUFSIZ + 2]; /* XXX 2? */
90 90
91 /* 91 /*
92 * Sadly, we have to monkey with the coprocessor enable and fault 92 * Sadly, we have to monkey with the coprocessor enable and fault
93 * registers, which are really for the FPU, in order to read 93 * registers, which are really for the FPU, in order to read
94 * from the RNG. 94 * from the RNG.
95 * 95 *
96 * Don't remove CR0_TS from the call below -- comments in the Linux 96 * Don't remove CR0_TS from the call below -- comments in the Linux
97 * driver indicate that the xstorerng instruction can generate 97 * driver indicate that the xstorerng instruction can generate
98 * spurious DNA faults though no FPU or SIMD state is changed 98 * spurious DNA faults though no FPU or SIMD state is changed
99 * even if such a fault is generated. 99 * even if such a fault is generated.
100 * 100 *
101 */ 101 */
102 kpreempt_disable(); 102 kpreempt_disable();
103 x86_disable_intr(); 103 x86_disable_intr();
104 creg0 = rcr0(); 104 creg0 = rcr0();
105 lcr0(creg0 & ~(CR0_EM|CR0_TS)); /* Permit access to SIMD/FPU path */ 105 lcr0(creg0 & ~(CR0_EM|CR0_TS)); /* Permit access to SIMD/FPU path */
106 /* 106 /*
107 * Collect the random data from the C3 RNG into our buffer. 107 * Collect the random data from the C3 RNG into our buffer.
108 * We turn on maximum whitening (is this actually desirable 108 * We turn on maximum whitening (is this actually desirable
109 * if we will feed the data to SHA1?) (%edx[0,1] = "11"). 109 * if we will feed the data to SHA1?) (%edx[0,1] = "11").