MCPcopy Create free account
hub / github.com/F-Stack/f-stack / init_via

Function init_via

freebsd/amd64/amd64/initcpu.c:202–236  ·  view source on GitHub ↗

* Initialize special VIA features */

Source from the content-addressed store, hash-verified

200 * Initialize special VIA features
201 */
202static void
203init_via(void)
204{
205 u_int regs[4], val;
206
207 /*
208 * Check extended CPUID for PadLock features.
209 *
210 * http://www.via.com.tw/en/downloads/whitepapers/initiatives/padlock/programming_guide.pdf
211 */
212 do_cpuid(0xc0000000, regs);
213 if (regs[0] >= 0xc0000001) {
214 do_cpuid(0xc0000001, regs);
215 val = regs[3];
216 } else
217 return;
218
219 /* Enable RNG if present. */
220 if ((val & VIA_CPUID_HAS_RNG) != 0) {
221 via_feature_rng = VIA_HAS_RNG;
222 wrmsr(0x110B, rdmsr(0x110B) | VIA_CPUID_DO_RNG);
223 }
224
225 /* Enable PadLock if present. */
226 if ((val & VIA_CPUID_HAS_ACE) != 0)
227 via_feature_xcrypt |= VIA_HAS_AES;
228 if ((val & VIA_CPUID_HAS_ACE2) != 0)
229 via_feature_xcrypt |= VIA_HAS_AESCTR;
230 if ((val & VIA_CPUID_HAS_PHE) != 0)
231 via_feature_xcrypt |= VIA_HAS_SHA;
232 if ((val & VIA_CPUID_HAS_PMM) != 0)
233 via_feature_xcrypt |= VIA_HAS_MM;
234 if (via_feature_xcrypt != 0)
235 wrmsr(0x1107, rdmsr(0x1107) | (1 << 28));
236}
237
238/*
239 * The value for the TSC_AUX MSR and rdtscp/rdpid on the invoking CPU.

Callers 1

initializecpuFunction · 0.70

Calls 3

do_cpuidFunction · 0.50
wrmsrFunction · 0.50
rdmsrFunction · 0.50

Tested by

no test coverage detected