aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hw_random/via-rng.c
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2008-02-06 04:37:13 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-06 13:41:05 -0500
commit11025e855235144271a0e447e3650b203f8215f4 (patch)
tree5a7ef8e0d286a4609fcda82b27a5ac5a82d1eedd /drivers/char/hw_random/via-rng.c
parentece95912db94d98e202cbedb8f35206deb29d83d (diff)
via-rng: enable secondary noise source on CPUs where it is present
In the padlock spec: "SRC Bits[9:8] Noise source select (I): These bits control the two noise sources on the processor that input bits to the accumulation buffers. On Nehemiah processors prior to stepping 8, these bits are reserved and undefined. The default RESET state is both bits = 0." Signed-off-by: Dave Jones <davej@redhat.com> Tested-by: Udo van den Heuvel <udovdh@xs4all.nl> Cc: Michael Buesch <mb@bu3sch.de> Cc: folkert van Heusden <folkert@vanheusden.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/hw_random/via-rng.c')
-rw-r--r--drivers/char/hw_random/via-rng.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/char/hw_random/via-rng.c b/drivers/char/hw_random/via-rng.c
index 868e39fd42e4..f7feae4ebb5e 100644
--- a/drivers/char/hw_random/via-rng.c
+++ b/drivers/char/hw_random/via-rng.c
@@ -42,6 +42,8 @@ enum {
42 VIA_STRFILT_ENABLE = (1 << 14), 42 VIA_STRFILT_ENABLE = (1 << 14),
43 VIA_RAWBITS_ENABLE = (1 << 13), 43 VIA_RAWBITS_ENABLE = (1 << 13),
44 VIA_RNG_ENABLE = (1 << 6), 44 VIA_RNG_ENABLE = (1 << 6),
45 VIA_NOISESRC1 = (1 << 8),
46 VIA_NOISESRC2 = (1 << 9),
45 VIA_XSTORE_CNT_MASK = 0x0F, 47 VIA_XSTORE_CNT_MASK = 0x0F,
46 48
47 VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */ 49 VIA_RNG_CHUNK_8 = 0x00, /* 64 rand bits, 64 stored bits */
@@ -119,6 +121,7 @@ static int via_rng_data_read(struct hwrng *rng, u32 *data)
119 121
120static int via_rng_init(struct hwrng *rng) 122static int via_rng_init(struct hwrng *rng)
121{ 123{
124 struct cpuinfo_x86 *c = &cpu_data(0);
122 u32 lo, hi, old_lo; 125 u32 lo, hi, old_lo;
123 126
124 /* Control the RNG via MSR. Tread lightly and pay very close 127 /* Control the RNG via MSR. Tread lightly and pay very close
@@ -134,6 +137,17 @@ static int via_rng_init(struct hwrng *rng)
134 lo &= ~VIA_XSTORE_CNT_MASK; 137 lo &= ~VIA_XSTORE_CNT_MASK;
135 lo &= ~(VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE); 138 lo &= ~(VIA_STRFILT_ENABLE | VIA_STRFILT_FAIL | VIA_RAWBITS_ENABLE);
136 lo |= VIA_RNG_ENABLE; 139 lo |= VIA_RNG_ENABLE;
140 lo |= VIA_NOISESRC1;
141
142 /* Enable secondary noise source on CPUs where it is present. */
143
144 /* Nehemiah stepping 8 and higher */
145 if ((c->x86_model == 9) && (c->x86_mask > 7))
146 lo |= VIA_NOISESRC2;
147
148 /* Esther */
149 if (c->x86_model >= 10)
150 lo |= VIA_NOISESRC2;
137 151
138 if (lo != old_lo) 152 if (lo != old_lo)
139 wrmsr(MSR_VIA_RNG, lo, hi); 153 wrmsr(MSR_VIA_RNG, lo, hi);