Module Name:    src
Committed By:   martin
Date:           Sun Aug  2 07:33:38 UTC 2020

Modified Files:
        src/sys/arch/x86/x86 [netbsd-9]: cpu.c

Log Message:
Apply patch, requested by msaitoh in ticket #1031:

        sys/arch/x86/x86/cpu.c                  patch

Fix a panic on a CPU which has no rdtsc instruction. This bug was
added in ticket #1015.


To generate a diff of this commit:
cvs rdiff -u -r1.171.2.2 -r1.171.2.3 src/sys/arch/x86/x86/cpu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/cpu.c
diff -u src/sys/arch/x86/x86/cpu.c:1.171.2.2 src/sys/arch/x86/x86/cpu.c:1.171.2.3
--- src/sys/arch/x86/x86/cpu.c:1.171.2.2	Wed Jul 15 17:25:08 2020
+++ src/sys/arch/x86/x86/cpu.c	Sun Aug  2 07:33:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $	*/
+/*	$NetBSD: cpu.c,v 1.171.2.3 2020/08/02 07:33:38 martin Exp $	*/
 
 /*
  * Copyright (c) 2000-2012 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.2 2020/07/15 17:25:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.171.2.3 2020/08/02 07:33:38 martin Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"		/* for MPDEBUG */
@@ -1267,18 +1267,19 @@ cpu_get_tsc_freq(struct cpu_info *ci)
 {
 	uint64_t freq = 0, last_tsc;
 
-	if (cpu_hascounter())
+	if (cpu_hascounter()) {
 		freq = cpu_tsc_freq_cpuid(ci);
 
-	if (freq != 0) {
-		/* Use TSC frequency taken from CPUID. */
-		ci->ci_data.cpu_cc_freq = freq;
-	} else {
-		/* Calibrate TSC frequency. */
-		last_tsc = cpu_counter_serializing();
-		x86_delay(100000);
-		ci->ci_data.cpu_cc_freq =
-		    (cpu_counter_serializing() - last_tsc) * 10;
+		if (freq != 0) {
+			/* Use TSC frequency taken from CPUID. */
+			ci->ci_data.cpu_cc_freq = freq;
+		} else {
+			/* Calibrate TSC frequency. */
+			last_tsc = cpu_counter_serializing();
+			x86_delay(100000);
+			ci->ci_data.cpu_cc_freq =
+			    (cpu_counter_serializing() - last_tsc) * 10;
+		}
 	}
 }
 

Reply via email to