diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/hw_random/via-rng.c | 14 |
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 | ||
120 | static int via_rng_init(struct hwrng *rng) | 122 | static 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); |