Module Name:    src
Committed By:   palle
Date:           Sun Mar 22 19:37:54 UTC 2015

Modified Files:
        src/sys/arch/sparc64/sparc64: cpu.c

Log Message:
sun4v: Fixed bug in cpu_cache_info_sun4v() causing non-cache nodes to be 
processed - this should fix crashes on T2-based systems (e.g. T5120) when 
retrieving L2$ info during bootstrap. Tested by rodent@


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/sys/arch/sparc64/sparc64/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/sparc64/sparc64/cpu.c
diff -u src/sys/arch/sparc64/sparc64/cpu.c:1.123 src/sys/arch/sparc64/sparc64/cpu.c:1.124
--- src/sys/arch/sparc64/sparc64/cpu.c:1.123	Wed Feb 11 04:44:11 2015
+++ src/sys/arch/sparc64/sparc64/cpu.c	Sun Mar 22 19:37:54 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu.c,v 1.123 2015/02/11 04:44:11 palle Exp $ */
+/*	$NetBSD: cpu.c,v 1.124 2015/03/22 19:37:54 palle Exp $ */
 
 /*
  * Copyright (c) 1996
@@ -52,7 +52,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.123 2015/02/11 04:44:11 palle Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.124 2015/03/22 19:37:54 palle Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -161,18 +161,21 @@ cpu_cache_info_sun4v(const char *type, i
 	uint64_t val = 0;;
 	idx = mdesc_find_node_by_idx(idx, "cache");
 	while (idx != -1 && val == 0) {
-		const char *p;
-		size_t len = 0;
-		p = mdesc_get_prop_data(idx, "type", &len);
-		if (p == NULL)
-			panic("No type found\n");
-		if (len == 0)
-			panic("Len is zero");
-		if (type == NULL || strcmp(p, type) == 0) {
-			uint64_t l;
-			l = mdesc_get_prop_val(idx, "level");
-			if (l == level)
-				val = mdesc_get_prop_val(idx, prop);
+		const char *name = mdesc_name_by_idx(idx);
+		if (strcmp("cache", name) == 0) {
+			const char *p;
+			size_t len = 0;
+			p = mdesc_get_prop_data(idx, "type", &len);
+			if (p == NULL)
+				panic("No type found\n");
+			if (len == 0)
+				panic("Len is zero");
+			if (type == NULL || strcmp(p, type) == 0) {
+				uint64_t l;
+				l = mdesc_get_prop_val(idx, "level");
+				if (l == level)
+					val = mdesc_get_prop_val(idx, prop);
+			}
 		}
 		if (val == 0)
 			idx = mdesc_next_node(idx);

Reply via email to