NetBSD Problem Report #39955

From wiz@hiro.nih.at  Tue Nov 18 23:33:00 2008
Return-Path: <wiz@hiro.nih.at>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by narn.NetBSD.org (Postfix) with ESMTP id DC5B863B874
	for <gnats-bugs@gnats.netbsd.org>; Tue, 18 Nov 2008 23:33:00 +0000 (UTC)
Message-Id: <20081118233240.E6E9628E352D@hiro.nih.at>
Date: Wed, 19 Nov 2008 00:32:40 +0100 (CET)
From: Thomas Klausner <wiz@NetBSD.org>
Reply-To: Thomas Klausner <wiz@NetBSD.org>
To: gnats-bugs@gnats.NetBSD.org
Subject: cpuctl identifies non-existing CPUs
X-Send-Pr-Version: 3.95

>Number:         39955
>Category:       bin
>Synopsis:       cpuctl identifies non-existing CPUs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    cegger
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Nov 18 23:35:00 +0000 2008
>Closed-Date:    Wed Nov 19 11:17:44 +0000 2008
>Last-Modified:  Sat Nov 22 16:35:01 +0000 2008
>Originator:     Thomas Klausner
>Release:        NetBSD 5.99.01
>Organization:
>Environment:


Architecture: x86_64
Machine: amd64
>Description:
cpuctl identify swallows obviously incorrect arguments without problem.
# cpuctl identify 5000
cpu5000: AMD Athlon 64 or Sempron (686-class), 2210.32 MHz, id 0x40ff2
cpu5000: features 78bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
cpu5000: features 78bfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX>
cpu5000: features 78bfbff<FXSR,SSE,SSE2>
cpu5000: features2 2001<SSE3,CX16>
cpu5000: features3 ebd3fbff<SCALL/RET,NOX,MXX,FFXSR,RDTSCP,LONG,3DNOW2,3DNOW>
cpu5000: features4 1d<LAHF,SVM,EAPIC,ALTMOVCR0>
cpu5000: "AMD Athlon(tm) 64 Processor 3500+"
cpu5000: I-cache 64KB 64B/line 2-way, D-cache 64KB 64B/line 2-way
cpu5000: L2 cache 1MB 64B/line 16-way
cpu5000: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu5000: DTLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu5000: Initial APIC ID 0
cpu5000: AMD Power Management features:
cpu5000: family 0f model 0f extfamily 00 extmodel 04

At least the output seems to be the same as for correct values:
# cpuctl identify 0
cpu0: AMD Athlon 64 or Sempron (686-class), 2210.32 MHz, id 0x40ff2
cpu0: features 78bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
cpu0: features 78bfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX>
cpu0: features 78bfbff<FXSR,SSE,SSE2>
cpu0: features2 2001<SSE3,CX16>
cpu0: features3 ebd3fbff<SCALL/RET,NOX,MXX,FFXSR,RDTSCP,LONG,3DNOW2,3DNOW>
cpu0: features4 1d<LAHF,SVM,EAPIC,ALTMOVCR0>
cpu0: "AMD Athlon(tm) 64 Processor 3500+"
cpu0: I-cache 64KB 64B/line 2-way, D-cache 64KB 64B/line 2-way
cpu0: L2 cache 1MB 64B/line 16-way
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: Initial APIC ID 0
cpu0: AMD Power Management features:
cpu0: family 0f model 0f extfamily 00 extmodel 04
>How-To-Repeat:
cpuctl identify 5000
>Fix:
cpuctl flow is slightly strange, or at least I don't completely
understand it.
Easiest fix is probably comparing the argument against hw.ncpu. Is that ok?

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: bin-bug-people->cegger
Responsible-Changed-By: cegger@NetBSD.org
Responsible-Changed-When: Wed, 19 Nov 2008 10:40:58 +0000
Responsible-Changed-Why:
mine


From: Christoph Egger <Christoph_Egger@gmx.de>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
 Thomas Klausner <wiz@NetBSD.org>
Subject: Re: bin/39955 (cpuctl identifies non-existing CPUs)
Date: Wed, 19 Nov 2008 11:58:54 +0100

 This is a multi-part message in MIME format.
 --------------050206040500020204050609
 Content-Type: text/plain; charset=ISO-8859-15
 Content-Transfer-Encoding: 7bit


 This diff should fix it.



 --------------050206040500020204050609
 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
  name="cpuctl.diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="cpuctl.diff"

 Index: usr.sbin/cpuctl/cpuctl.c
 ===================================================================
 RCS file: /cvsroot/src/usr.sbin/cpuctl/cpuctl.c,v
 retrieving revision 1.10
 diff -u -p -r1.10 cpuctl.c
 --- usr.sbin/cpuctl/cpuctl.c	15 Oct 2008 08:22:06 -0000	1.10
 +++ usr.sbin/cpuctl/cpuctl.c	19 Nov 2008 10:52:26 -0000
 @@ -147,11 +147,12 @@ void
  cpu_identify(char **argv)
  {
  	char name[32];
 -	int id, np;
 +	u_int id;
 +	long np;
  	cpuset_t *cpuset;

  	id = getcpuid(argv);
 -	snprintf(name, sizeof(name), "cpu%d", id);
 +	snprintf(name, sizeof(name), "cpu%u", id);

  	np = sysconf(_SC_NPROCESSORS_CONF);
  	if (np != 0) {
 @@ -179,10 +180,18 @@ getcpuid(char **argv)
  {
  	char *argp;
  	u_int id;
 +	long np;

 -	id = (int)strtoul(argv[0], &argp, 0);
 +	id = (u_int)strtoul(argv[0], &argp, 0);
  	if (*argp != '\0')
  		usage();
 +
 +	np = sysconf(_SC_NPROCESSORS_CONF);
 +	if (id >= np) {
 +		err(EXIT_FAILURE, "More than %li CPUs not configured", np);
 +		/* UNREACHED */
 +	}
 +
  	return id;
  }


 --------------050206040500020204050609--

From: Mindaugas Rasiukevicius <rmind@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39955 CVS commit: src/usr.sbin/cpuctl
Date: Wed, 19 Nov 2008 11:05:40 +0000 (UTC)

 Module Name:	src
 Committed By:	rmind
 Date:		Wed Nov 19 11:05:40 UTC 2008

 Modified Files:
 	src/usr.sbin/cpuctl: cpuctl.c

 Log Message:
 cpu_identify: check ID against number of processors.
 Fix for PR/39955.


 To generate a diff of this commit:
 cvs rdiff -r1.10 -r1.11 src/usr.sbin/cpuctl/cpuctl.c

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

State-Changed-From-To: open->closed
State-Changed-By: rmind@NetBSD.org
State-Changed-When: Wed, 19 Nov 2008 11:17:44 +0000
State-Changed-Why:
It is discussable if _sched_setaffinity() should check for non-existing 
processors in the cpuset, but that is separate question...

Fixed, thanks!


From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/39955 CVS commit: [netbsd-5] src/usr.sbin/cpuctl
Date: Sat, 22 Nov 2008 16:32:24 +0000 (UTC)

 Module Name:	src
 Committed By:	snj
 Date:		Sat Nov 22 16:32:24 UTC 2008

 Modified Files:
 	src/usr.sbin/cpuctl [netbsd-5]: cpuctl.c

 Log Message:
 Pull up following revision(s) (requested by cegger in ticket #105):
 	usr.sbin/cpuctl/cpuctl.c: revision 1.11
 cpu_identify: check ID against number of processors.
 Fix for PR/39955.


 To generate a diff of this commit:
 cvs rdiff -r1.10 -r1.10.2.1 src/usr.sbin/cpuctl/cpuctl.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.