diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-12-09 14:27:35 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2009-12-09 14:27:35 +0000 |
commit | 62e20001a22537cd09005eaa87a882f508f37eb1 (patch) | |
tree | cff0a579538216918ff25dff34c3970960bdd0b8 /sys/arch | |
parent | f699d60fad50f050a8c1c226bd1e9da0b20f59fb (diff) |
Detect the cache line size for the clflush instruction when we identify
the cpu.
ok kettenis@ as part of a larger diff.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/identcpu.c | 7 | ||||
-rw-r--r-- | sys/arch/amd64/include/cpu.h | 3 | ||||
-rw-r--r-- | sys/arch/i386/i386/machdep.c | 11 | ||||
-rw-r--r-- | sys/arch/i386/include/cpu.h | 3 |
4 files changed, 19 insertions, 5 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index 90f71996406..715982bd734 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.24 2009/10/07 02:15:48 kevlo Exp $ */ +/* $OpenBSD: identcpu.c,v 1.25 2009/12/09 14:27:33 oga Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -264,7 +264,7 @@ void identifycpu(struct cpu_info *ci) { u_int64_t last_tsc; - u_int32_t dummy, val, pnfeatset; + u_int32_t dummy, val, pnfeatset, cflushsz; u_int32_t brand[12]; u_int32_t vendor[4]; int i, max; @@ -354,6 +354,9 @@ identifycpu(struct cpu_info *ci) } if (!strncmp(cpu_model, "Intel", 5)) { + CPUID(0x01, dummy, cflushsz, dummy, dummy); + /* cflush cacheline size is equal to bits 15-8 of ebx * 8 */ + ci->ci_cflushsz = ((cflushsz >> 8) & 0xff) * 8; CPUID(0x06, val, dummy, dummy, dummy); if (val & 0x1) { strlcpy(ci->ci_sensordev.xname, ci->ci_dev->dv_xname, diff --git a/sys/arch/amd64/include/cpu.h b/sys/arch/amd64/include/cpu.h index a0e731c9def..71286c5b7d1 100644 --- a/sys/arch/amd64/include/cpu.h +++ b/sys/arch/amd64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.50 2009/11/22 21:41:37 pirofti Exp $ */ +/* $OpenBSD: cpu.h,v 1.51 2009/12/09 14:27:34 oga Exp $ */ /* $NetBSD: cpu.h,v 1.1 2003/04/26 18:39:39 fvdl Exp $ */ /*- @@ -95,6 +95,7 @@ struct cpu_info { u_int32_t ci_signature; u_int32_t ci_family; u_int32_t ci_model; + u_int32_t ci_cflushsz; u_int64_t ci_tsc_freq; struct cpu_functions *ci_func; diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index 6298e1c731f..14db05ddc26 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.467 2009/12/01 18:59:13 jsg Exp $ */ +/* $OpenBSD: machdep.c,v 1.468 2009/12/09 14:27:34 oga Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -1720,6 +1720,15 @@ identifycpu(struct cpu_info *ci) } } + if (vendor == CPUVENDOR_INTEL && + curcpu()->ci_feature_flags & CPUID_CFLUSH) { + /* to get the cachline size you must do cpuid with eax 0x01 */ + u_int regs[4]; + + cpuid(0x01, regs); + ci->ci_cflushsz = ((regs[1] >> 8) & 0xff) * 8; + } + /* Remove leading and duplicated spaces from cpu_brandstr */ brandstr_from = brandstr_to = cpu_brandstr; skipspace = 1; diff --git a/sys/arch/i386/include/cpu.h b/sys/arch/i386/include/cpu.h index 1380944ca1c..1511b4f15ec 100644 --- a/sys/arch/i386/include/cpu.h +++ b/sys/arch/i386/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.108 2009/06/03 00:49:12 art Exp $ */ +/* $OpenBSD: cpu.h,v 1.109 2009/12/09 14:27:34 oga Exp $ */ /* $NetBSD: cpu.h,v 1.35 1996/05/05 19:29:26 christos Exp $ */ /*- @@ -118,6 +118,7 @@ struct cpu_info { u_int32_t ci_model; /* extended cpuid model */ u_int32_t ci_feature_flags; /* X86 CPUID feature bits */ u_int32_t cpu_class; /* CPU class */ + u_int32_t ci_cflushsz; /* clflush cache-line size */ struct cpu_functions *ci_func; /* start/stop functions */ void (*cpu_setup)(struct cpu_info *); /* proc-dependant init */ |