Wed Jan 1 17:28:17 2020 UTC ()
Remove superfluous splclock()/splx() pair around tc_setclock().


(thorpej)
diff -r1.201 -r1.202 src/sys/kern/kern_time.c
diff -r1.40 -r1.41 src/sys/kern/kern_todr.c

cvs diff -r1.201 -r1.202 src/sys/kern/kern_time.c (expand / switch to unified diff)

--- src/sys/kern/kern_time.c 2019/10/05 12:57:40 1.201
+++ src/sys/kern/kern_time.c 2020/01/01 17:28:17 1.202
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_time.c,v 1.201 2019/10/05 12:57:40 kamil Exp $ */ 1/* $NetBSD: kern_time.c,v 1.202 2020/01/01 17:28:17 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 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 Christopher G. Demetriou, and by Andrew Doran. 8 * by Christopher G. Demetriou, and by Andrew Doran.
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.
@@ -51,27 +51,27 @@ @@ -51,27 +51,27 @@
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE. 58 * SUCH DAMAGE.
59 * 59 *
60 * @(#)kern_time.c 8.4 (Berkeley) 5/26/95 60 * @(#)kern_time.c 8.4 (Berkeley) 5/26/95
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.201 2019/10/05 12:57:40 kamil Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.202 2020/01/01 17:28:17 thorpej Exp $");
65 65
66#include <sys/param.h> 66#include <sys/param.h>
67#include <sys/resourcevar.h> 67#include <sys/resourcevar.h>
68#include <sys/kernel.h> 68#include <sys/kernel.h>
69#include <sys/systm.h> 69#include <sys/systm.h>
70#include <sys/proc.h> 70#include <sys/proc.h>
71#include <sys/vnode.h> 71#include <sys/vnode.h>
72#include <sys/signalvar.h> 72#include <sys/signalvar.h>
73#include <sys/syslog.h> 73#include <sys/syslog.h>
74#include <sys/timetc.h> 74#include <sys/timetc.h>
75#include <sys/timex.h> 75#include <sys/timex.h>
76#include <sys/kauth.h> 76#include <sys/kauth.h>
77#include <sys/mount.h> 77#include <sys/mount.h>
@@ -126,53 +126,48 @@ time_init2(void) @@ -126,53 +126,48 @@ time_init2(void)
126 * 126 *
127 * These routines provide the kernel entry points to get and set 127 * These routines provide the kernel entry points to get and set
128 * the time-of-day and per-process interval timers. Subroutines 128 * the time-of-day and per-process interval timers. Subroutines
129 * here provide support for adding and subtracting timeval structures 129 * here provide support for adding and subtracting timeval structures
130 * and decrementing interval timers, optionally reloading the interval 130 * and decrementing interval timers, optionally reloading the interval
131 * timers when they expire. 131 * timers when they expire.
132 */ 132 */
133 133
134/* This function is used by clock_settime and settimeofday */ 134/* This function is used by clock_settime and settimeofday */
135static int 135static int
136settime1(struct proc *p, const struct timespec *ts, bool check_kauth) 136settime1(struct proc *p, const struct timespec *ts, bool check_kauth)
137{ 137{
138 struct timespec delta, now; 138 struct timespec delta, now;
139 int s; 
140 139
141 /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */ 140 /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
142 s = splclock(); 
143 nanotime(&now); 141 nanotime(&now);
144 timespecsub(ts, &now, &delta); 142 timespecsub(ts, &now, &delta);
145 143
146 if (check_kauth && kauth_authorize_system(kauth_cred_get(), 144 if (check_kauth && kauth_authorize_system(kauth_cred_get(),
147 KAUTH_SYSTEM_TIME, KAUTH_REQ_SYSTEM_TIME_SYSTEM, __UNCONST(ts), 145 KAUTH_SYSTEM_TIME, KAUTH_REQ_SYSTEM_TIME_SYSTEM, __UNCONST(ts),
148 &delta, KAUTH_ARG(check_kauth ? false : true)) != 0) { 146 &delta, KAUTH_ARG(check_kauth ? false : true)) != 0) {
149 splx(s); 
150 return (EPERM); 147 return (EPERM);
151 } 148 }
152 149
153#ifdef notyet 150#ifdef notyet
154 if ((delta.tv_sec < 86400) && securelevel > 0) { /* XXX elad - notyet */ 151 if ((delta.tv_sec < 86400) && securelevel > 0) { /* XXX elad - notyet */
155 splx(s); 
156 return (EPERM); 152 return (EPERM);
157 } 153 }
158#endif 154#endif
159 155
160 tc_setclock(ts); 156 tc_setclock(ts);
161 157
162 timespecadd(&boottime, &delta, &boottime); 158 timespecadd(&boottime, &delta, &boottime);
163 159
164 resettodr(); 160 resettodr();
165 splx(s); 
166 161
167 return (0); 162 return (0);
168} 163}
169 164
170int 165int
171settime(struct proc *p, struct timespec *ts) 166settime(struct proc *p, struct timespec *ts)
172{ 167{
173 return (settime1(p, ts, true)); 168 return (settime1(p, ts, true));
174} 169}
175 170
176/* ARGSUSED */ 171/* ARGSUSED */
177int 172int
178sys___clock_gettime50(struct lwp *l, 173sys___clock_gettime50(struct lwp *l,

cvs diff -r1.40 -r1.41 src/sys/kern/kern_todr.c (expand / switch to unified diff)

--- src/sys/kern/kern_todr.c 2019/07/07 15:12:59 1.40
+++ src/sys/kern/kern_todr.c 2020/01/01 17:28:17 1.41
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: kern_todr.c,v 1.40 2019/07/07 15:12:59 maxv Exp $ */ 1/* $NetBSD: kern_todr.c,v 1.41 2020/01/01 17:28:17 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1992, 1993 5 * Copyright (c) 1992, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department and Ralph Campbell. 10 * Science Department and Ralph Campbell.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * from: Utah Hdr: clock.c 1.18 91/01/21 36 * from: Utah Hdr: clock.c 1.18 91/01/21
37 * 37 *
38 * @(#)clock.c 8.1 (Berkeley) 6/10/93 38 * @(#)clock.c 8.1 (Berkeley) 6/10/93
39 */ 39 */
40 40
41#include "opt_todr.h" 41#include "opt_todr.h"
42 42
43#include <sys/cdefs.h> 43#include <sys/cdefs.h>
44__KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.40 2019/07/07 15:12:59 maxv Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: kern_todr.c,v 1.41 2020/01/01 17:28:17 thorpej Exp $");
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/kernel.h> 47#include <sys/kernel.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/device.h> 49#include <sys/device.h>
50#include <sys/timetc.h> 50#include <sys/timetc.h>
51#include <sys/intr.h> 51#include <sys/intr.h>
52#include <sys/rndsource.h> 52#include <sys/rndsource.h>
53 53
54#include <dev/clock_subr.h> /* hmm.. this should probably move to sys */ 54#include <dev/clock_subr.h> /* hmm.. this should probably move to sys */
55 55
56static todr_chip_handle_t todr_handle = NULL; 56static todr_chip_handle_t todr_handle = NULL;
57 57
@@ -71,27 +71,26 @@ todr_attach(todr_chip_handle_t todr) @@ -71,27 +71,26 @@ todr_attach(todr_chip_handle_t todr)
71 71
72static bool timeset = false; 72static bool timeset = false;
73 73
74/* 74/*
75 * Set up the system's time, given a `reasonable' time value. 75 * Set up the system's time, given a `reasonable' time value.
76 */ 76 */
77void 77void
78inittodr(time_t base) 78inittodr(time_t base)
79{ 79{
80 bool badbase = false; 80 bool badbase = false;
81 bool waszero = (base == 0); 81 bool waszero = (base == 0);
82 bool goodtime = false; 82 bool goodtime = false;
83 bool badrtc = false; 83 bool badrtc = false;
84 int s; 
85 struct timespec ts; 84 struct timespec ts;
86 struct timeval tv; 85 struct timeval tv;
87 86
88 rnd_add_data(NULL, &base, sizeof(base), 0); 87 rnd_add_data(NULL, &base, sizeof(base), 0);
89 88
90 if (base < 5 * SECS_PER_COMMON_YEAR) { 89 if (base < 5 * SECS_PER_COMMON_YEAR) {
91 struct clock_ymdhms basedate; 90 struct clock_ymdhms basedate;
92 91
93 /* 92 /*
94 * If base is 0, assume filesystem time is just unknown 93 * If base is 0, assume filesystem time is just unknown
95 * instead of preposterous. Don't bark. 94 * instead of preposterous. Don't bark.
96 */ 95 */
97 if (base != 0) 96 if (base != 0)
@@ -159,29 +158,27 @@ inittodr(time_t base) @@ -159,29 +158,27 @@ inittodr(time_t base)
159 if (badbase) { 158 if (badbase) {
160 printf("WARNING: using default initial time\n"); 159 printf("WARNING: using default initial time\n");
161 } else { 160 } else {
162 printf("WARNING: using filesystem time\n"); 161 printf("WARNING: using filesystem time\n");
163 } 162 }
164 tv.tv_sec = base; 163 tv.tv_sec = base;
165 tv.tv_usec = 0; 164 tv.tv_usec = 0;
166 } 165 }
167 166
168 timeset = true; 167 timeset = true;
169 168
170 ts.tv_sec = tv.tv_sec; 169 ts.tv_sec = tv.tv_sec;
171 ts.tv_nsec = tv.tv_usec * 1000; 170 ts.tv_nsec = tv.tv_usec * 1000;
172 s = splclock(); 
173 tc_setclock(&ts); 171 tc_setclock(&ts);
174 splx(s); 
175 172
176 if (waszero || goodtime) 173 if (waszero || goodtime)
177 return; 174 return;
178 175
179 printf("WARNING: CHECK AND RESET THE DATE!\n"); 176 printf("WARNING: CHECK AND RESET THE DATE!\n");
180} 177}
181 178
182/* 179/*
183 * Reset the TODR based on the time value; used when the TODR 180 * Reset the TODR based on the time value; used when the TODR
184 * has a preposterous value and also when the time is reset 181 * has a preposterous value and also when the time is reset
185 * by the stime system call. Also called when the TODR goes past 182 * by the stime system call. Also called when the TODR goes past
186 * TODRZERO + 100*(SECS_PER_COMMON_YEAR+2*SECS_PER_DAY) 183 * TODRZERO + 100*(SECS_PER_COMMON_YEAR+2*SECS_PER_DAY)
187 * (e.g. on Jan 2 just after midnight) to wrap the TODR around. 184 * (e.g. on Jan 2 just after midnight) to wrap the TODR around.