Sun Apr 18 15:25:53 2010 UTC ()
Fix a test semantic in cpu_probe(): check that the CPU currently probed
is the first one booting by comparing its struct cpu_info address with
cpu_info_primary, rather than supposing that cpu_feature variables are
set to 0.


(jym)
diff -r1.18 -r1.19 src/sys/arch/x86/x86/identcpu.c

cvs diff -r1.18 -r1.19 src/sys/arch/x86/x86/identcpu.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/identcpu.c 2010/01/18 16:40:18 1.18
+++ src/sys/arch/x86/x86/identcpu.c 2010/04/18 15:25:53 1.19
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: identcpu.c,v 1.18 2010/01/18 16:40:18 rmind Exp $ */ 1/* $NetBSD: identcpu.c,v 1.19 2010/04/18 15:25:53 jym Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden, and by Jason R. Thorpe. 8 * by Frank van der Linden, and by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.18 2010/01/18 16:40:18 rmind Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: identcpu.c,v 1.19 2010/04/18 15:25:53 jym Exp $");
34 34
35#include "opt_enhanced_speedstep.h" 35#include "opt_enhanced_speedstep.h"
36#include "opt_intel_odcm.h" 36#include "opt_intel_odcm.h"
37#include "opt_intel_coretemp.h" 37#include "opt_intel_coretemp.h"
38#include "opt_via_c7temp.h" 38#include "opt_via_c7temp.h"
39#include "opt_powernow_k8.h" 39#include "opt_powernow_k8.h"
40#include "opt_xen.h" 40#include "opt_xen.h"
41#ifdef i386 /* XXX */ 41#ifdef i386 /* XXX */
42#include "opt_powernow_k7.h" 42#include "opt_powernow_k7.h"
43#endif 43#endif
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/systm.h> 46#include <sys/systm.h>
@@ -650,27 +650,27 @@ cpu_probe(struct cpu_info *ci) @@ -650,27 +650,27 @@ cpu_probe(struct cpu_info *ci)
650 cpu_probe_cyrix(ci); 650 cpu_probe_cyrix(ci);
651 cpu_probe_winchip(ci); 651 cpu_probe_winchip(ci);
652 cpu_probe_c3(ci); 652 cpu_probe_c3(ci);
653 cpu_probe_geode(ci); 653 cpu_probe_geode(ci);
654 654
655 x86_cpu_topology(ci); 655 x86_cpu_topology(ci);
656 656
657 if (cpu_vendor != CPUVENDOR_AMD && (ci->ci_feature_flags & CPUID_TM) && 657 if (cpu_vendor != CPUVENDOR_AMD && (ci->ci_feature_flags & CPUID_TM) &&
658 (rdmsr(MSR_MISC_ENABLE) & (1 << 3)) == 0) { 658 (rdmsr(MSR_MISC_ENABLE) & (1 << 3)) == 0) {
659 /* Enable thermal monitor 1. */ 659 /* Enable thermal monitor 1. */
660 wrmsr(MSR_MISC_ENABLE, rdmsr(MSR_MISC_ENABLE) | (1<<3)); 660 wrmsr(MSR_MISC_ENABLE, rdmsr(MSR_MISC_ENABLE) | (1<<3));
661 } 661 }
662 662
663 if ((cpu_feature | cpu_feature2) == 0) { 663 if (ci == &cpu_info_primary) {
664 /* If first. */ 664 /* If first. */
665 cpu_feature = ci->ci_feature_flags; 665 cpu_feature = ci->ci_feature_flags;
666 cpu_feature2 = ci->ci_feature2_flags; 666 cpu_feature2 = ci->ci_feature2_flags;
667 /* Early patch of text segment. */ 667 /* Early patch of text segment. */
668#ifndef XEN 668#ifndef XEN
669 x86_patch(true); 669 x86_patch(true);
670#endif 670#endif
671 } else { 671 } else {
672 /* If not first. */ 672 /* If not first. */
673 cpu_feature &= ci->ci_feature_flags; 673 cpu_feature &= ci->ci_feature_flags;
674 cpu_feature2 &= ci->ci_feature2_flags; 674 cpu_feature2 &= ci->ci_feature2_flags;
675 } 675 }
676} 676}