From c90fea5aae677377bfb7ca36a8045afcf24a35c5 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 15 Jun 2004 23:36:57 +0000 Subject: first parts of how C3 Esther will be handled; ok tom --- sys/arch/i386/i386/autoconf.c | 6 ++--- sys/arch/i386/i386/machdep.c | 55 ++++++++++++++++++++++++++++---------- sys/arch/i386/i386/via.c | 4 +-- sys/arch/i386/include/specialreg.h | 14 +++++----- 4 files changed, 51 insertions(+), 28 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/i386/i386/autoconf.c b/sys/arch/i386/i386/autoconf.c index 95a3059984b..9224ef984b5 100644 --- a/sys/arch/i386/i386/autoconf.c +++ b/sys/arch/i386/i386/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.53 2004/06/13 21:49:15 niklas Exp $ */ +/* $OpenBSD: autoconf.c,v 1.54 2004/06/15 23:36:55 deraadt Exp $ */ /* $NetBSD: autoconf.c,v 1.20 1996/05/03 19:41:56 christos Exp $ */ /*- @@ -89,8 +89,8 @@ extern int viac3_rnd_present; void viac3_rnd(void *); #ifdef CRYPTO -extern int viac3_crypto_present; void viac3_crypto_setup(void); +extern int i386_has_xcrypt; #endif /* CRYPTO */ #endif @@ -148,7 +148,7 @@ cpu_configure() /* * Also, if the chip has crypto available, enable it. */ - if (viac3_crypto_present) + if (i386_has_xcrypt) viac3_crypto_setup(); #endif /* CRYPTO */ #endif diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 6b08d58ae29..13e707c9163 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.298 2004/06/15 21:12:31 tom Exp $ */ +/* $OpenBSD: machdep.c,v 1.299 2004/06/15 23:36:55 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -951,7 +951,7 @@ const struct cpu_cpuid_nameclass i386_cpuid_cpus[] = { "C3 Samuel", "C3 Samuel 2/Ezra", "C3 Ezra-T", - "C3 Nehemiah", 0, 0, 0, 0, 0, 0, + "C3 Nehemiah", "C3 Esther", 0, 0, 0, 0, 0, "C3" /* Default */ }, cyrix3_cpu_setup @@ -1143,6 +1143,9 @@ cyrix3_cpu_setup(cpu_device, model, step) const char *cpu_device; int model, step; { +#ifdef CRYPTO + u_int64_t msreg; +#endif #if defined(I686_CPU) unsigned int val; #if !defined(SMALL_KERNEL) @@ -1152,7 +1155,6 @@ cyrix3_cpu_setup(cpu_device, model, step) pagezero = i686_pagezero; #endif - switch (model) { case 6: /* C3 Samuel 1 */ case 7: /* C3 Samuel 2 or C3 Ezra */ @@ -1169,9 +1171,12 @@ cyrix3_cpu_setup(cpu_device, model, step) case 9: if (step < 3) break; - /* - * C3 Nehemiah: + * C3 Nehemiah: fall through. + */ + case 10: + /* + * C3 Nehemiah/Esther: * First we check for extended feature flags, and then * (if present) retrieve the ones at 0xC0000001. In this * bit 2 tells us if the RNG is present. Bit 3 tells us @@ -1186,12 +1191,11 @@ cyrix3_cpu_setup(cpu_device, model, step) if (val >= 0xC0000001) { __asm __volatile("cpuid" : "=d" (val) : "a" (0xC0000001) : "cc"); - } else { + } else val = 0; - } /* Enable RNG if present and disabled */ - if (val & 0x44) + if (val & 0x44/*???*/) printf("%s:", cpu_device); if (val & 0x4) { extern int viac3_rnd_present; @@ -1210,20 +1214,43 @@ cyrix3_cpu_setup(cpu_device, model, step) /* Enable AES engine if present and disabled */ if (val & 0x40) { #ifdef CRYPTO - extern int viac3_crypto_present; - if (!(val & 0x80)) { - u_int64_t msreg; - msreg = rdmsr(0x1107); msreg |= (0x01 << 28); wrmsr(0x1107, msreg); } - viac3_crypto_present = 1; + i386_has_xcrypt |= C3_HAS_AES; #endif /* CRYPTO */ printf(" AES"); } - +#if 0 + /* Enable SHA engine if present and disabled */ + if (val & 0x40/**/) { +#ifdef CRYPTO + if (!(val & 0x80/**/)) { + msreg = rdmsr(0x1107); + msreg |= (0x01 << 28/**/); + wrmsr(0x1107, msreg); + } + i386_has_xcrypt |= C3_HAS_SHA; +#endif /* CRYPTO */ + printf(" SHA1 SHA256"); + } +#endif +#if 0 + /* Enable MM engine if present and disabled */ + if (val & 0x40/*???*/) { +#ifdef CRYPTO + if (!(val & 0x80/**/)) { + msreg = rdmsr(0x1107); + msreg |= (0x01 << 28/**/); + wrmsr(0x1107, msreg); + } + i386_has_xcrypt |= C3_HAS_MM; +#endif /* CRYPTO */ + printf(" RSA"); + } +#endif printf("\n"); break; } diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index 49f4e866596..57cfe70c215 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.2 2004/06/15 19:19:03 deraadt Exp $ */ +/* $OpenBSD: via.c,v 1.3 2004/06/15 23:36:55 deraadt Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -56,7 +56,6 @@ #include void viac3_rnd(void *); -int viac3_crypto_present; #ifdef CRYPTO @@ -112,7 +111,6 @@ viac3_crypto_setup(void) crypto_register(vc3_sc->sc_cid, algs, viac3_crypto_newsession, viac3_crypto_freesession, viac3_crypto_process); - i386_has_xcrypt = viac3_crypto_present; } int diff --git a/sys/arch/i386/include/specialreg.h b/sys/arch/i386/include/specialreg.h index 15c87a430ab..4d0e8965e73 100644 --- a/sys/arch/i386/include/specialreg.h +++ b/sys/arch/i386/include/specialreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: specialreg.h,v 1.22 2004/04/02 22:28:41 tedu Exp $ */ +/* $OpenBSD: specialreg.h,v 1.23 2004/06/15 23:36:56 deraadt Exp $ */ /* $NetBSD: specialreg.h,v 1.7 1994/10/27 04:16:26 cgd Exp $ */ /*- @@ -428,6 +428,11 @@ #define PMC6_SEG_REG_RENAMES 0xd5 /* P-II and P-III only */ #define PMC6_RET_SEG_RENAMES 0xd6 /* P-II and P-III only */ +/* VIA C3 crypto featureset: for i386_has_xcrypt */ +#define C3_HAS_AES 1 /* cpu has AES */ +#define C3_HAS_SHA 2 /* cpu has SHA1 & SHA256 */ +#define C3_HAS_MM 4 /* cpu has RSA instructions */ + /* VIA C3 xcrypt-* instruction context control options */ #define C3_CRYPT_CWLO_ROUND_M 0x0000000f #define C3_CRYPT_CWLO_ALG_M 0x00000070 @@ -442,10 +447,3 @@ #define C3_CRYPT_CWLO_KEY128 0x0000000a /* 128bit, 10 rds */ #define C3_CRYPT_CWLO_KEY192 0x0000040c /* 192bit, 12 rds */ #define C3_CRYPT_CWLO_KEY256 0x0000080e /* 256bit, 15 rds */ - -/* VIA C3 xcrypt-* opcodes */ -#define VIAC3_CRYPTOP_RNG 0xc0 /* rng */ -#define VIAC3_CRYPTOP_ECB 0xc8 /* aes-ecb */ -#define VIAC3_CRYPTOP_CBC 0xd0 /* aes-cbc */ -#define VIAC3_CRYPTOP_CFB 0xe0 /* aes-cfb */ -#define VIAC3_CRYPTOP_OFB 0xe8 /* aes-ofb */ -- cgit v1.2.3