From stenn@howland.udel.edu  Thu Jan 13 14:48:16 2000
Return-Path: <stenn@howland.udel.edu>
Received: from howland.udel.edu (howland.udel.edu [128.4.2.16])
	by hub.freebsd.org (Postfix) with ESMTP id A78BC14BCE
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Jan 2000 14:48:13 -0800 (PST)
	(envelope-from stenn@howland.udel.edu)
Received: (from stenn@localhost)
	by howland.udel.edu (8.9.3/8.9.3) id WAA01548;
	Thu, 13 Jan 2000 22:48:11 GMT
	(envelope-from stenn)
Message-Id: <200001132248.WAA01548@howland.udel.edu>
Date: Thu, 13 Jan 2000 22:48:11 GMT
From: stenn@whimsy.udel.edu
Sender: stenn@howland.udel.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: STABLE kernel page fault changing the timer frequency
X-Send-Pr-Version: 3.2

>Number:         16113
>Category:       kern
>Synopsis:       Kernel page fault panic using sysctl to change timer frequency
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jan 13 14:50:01 PST 2000
>Closed-Date:    Tue Jan 18 08:26:28 PST 2000
>Last-Modified:  Tue Jan 18 08:36:54 PST 2000
>Originator:     Harlan Stenn
>Release:        FreeBSD 3.4-20000105-STABLE i386
>Organization:
>Environment:

	3-STABLE (not 2-STABLE or -CURRENT)

>Description:

	Wrote a perl script to wiggle the timer frequency, based on ntpd's
	/etc/ntp.drift file and input from PHK.  It seems to work fine on
	2-STABLE and -CURRENT, but it panics a 3-STABLE kernel with a
	page fault.

>How-To-Repeat:

	Run ntpd long enough to get a valid /etc/ntp.drift file.
	Run the following script.

	#! /usr/bin/perl -w

	$driftfile = "/etc/ntp.drift";

	open(DF, $driftfile) || die "Can't open driftfile ($driftfile): $!\n";
	while(<DF>) {
	    chop;
	    if (/^-?\d+\.\d+$/) {
		$drift = $_;
	    } else {
		die "Bogus value in driftfile $driftfile: <$_>\n";
	    }
	}
	close(DF);

	print "drift is      <$drift>\n";

	$freq_adj = 1 - $drift / 1000000;

	print "freq_adj is <$freq_adj>\n";

	chop($i8254_freq = `sysctl -n machdep.i8254_freq`);
	chop($tsc_freq = `sysctl -n machdep.tsc_freq 2> /dev/null`);

	print "i8254_freq is <$i8254_freq>\n";
	print "tsc_freq is   <$tsc_freq>\n";

	if ($i8254_freq > 1) {
	    $i8254_freq = int $i8254_freq * $freq_adj;
	    print "i8254_freq -> <$i8254_freq>\n";
	    print "i8254: ".`sysctl -w machdep.i8254_freq=$i8254_freq`;
	}

	if ($tsc_freq > 1) {
	    $tsc_freq = int $tsc_freq * $freq_adj;
	    print "tsc_freq ->   <$tsc_freq>\n";
	    print "tsc: ".`sysctl -w machdep.tsc_freq=$tsc_freq`;
	}

>Fix:

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Tue Jan 18 08:26:28 PST 2000 
State-Changed-Why:  
Hopefully fixed in clock.c rev.1.129.2.6. 
The bug fixed only affects systems with unfortunate configurations 
(ones with a TSC, but with the TSC unused due to use of apm, 
misconfiguration of apm (configured but not active), or use of SMP. 
or use of a CPU with a known broken TSC. 
>Unformatted:
