Mon Mar 9 18:43:52 2020 UTC ()
Don't expose curproc/curlwp and other random kernel macros/functions/variables
du-jour.


(christos)
diff -r1.108 -r1.109 src/sys/arch/arm/include/cpu.h

cvs diff -r1.108 -r1.109 src/sys/arch/arm/include/cpu.h (expand / switch to unified diff)

--- src/sys/arch/arm/include/cpu.h 2020/02/15 08:16:11 1.108
+++ src/sys/arch/arm/include/cpu.h 2020/03/09 18:43:52 1.109
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cpu.h,v 1.108 2020/02/15 08:16:11 skrll Exp $ */ 1/* $NetBSD: cpu.h,v 1.109 2020/03/09 18:43:52 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1994-1996 Mark Brinicombe. 4 * Copyright (c) 1994-1996 Mark Brinicombe.
5 * Copyright (c) 1994 Brini. 5 * Copyright (c) 1994 Brini.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * This code is derived from software written for Brini by Mark Brinicombe 8 * This code is derived from software written for Brini by Mark Brinicombe
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.
@@ -91,27 +91,27 @@ void cpu_proc_fork(struct proc *, struct @@ -91,27 +91,27 @@ void cpu_proc_fork(struct proc *, struct
91 * Kernel-only definitions 91 * Kernel-only definitions
92 */ 92 */
93 93
94#if !defined(_MODULE) && defined(_KERNEL_OPT) 94#if !defined(_MODULE) && defined(_KERNEL_OPT)
95#include "opt_multiprocessor.h" 95#include "opt_multiprocessor.h"
96#include "opt_cpuoptions.h" 96#include "opt_cpuoptions.h"
97#include "opt_lockdebug.h" 97#include "opt_lockdebug.h"
98#include "opt_cputypes.h" 98#include "opt_cputypes.h"
99#endif /* !_MODULE && _KERNEL_OPT */ 99#endif /* !_MODULE && _KERNEL_OPT */
100 100
101#ifndef _LOCORE 101#ifndef _LOCORE
102#if defined(TPIDRPRW_IS_CURLWP) || defined(TPIDRPRW_IS_CURCPU) 102#if defined(TPIDRPRW_IS_CURLWP) || defined(TPIDRPRW_IS_CURCPU)
103#include <arm/armreg.h> 103#include <arm/armreg.h>
104#endif 104#endif /* TPIDRPRW_IS_CURLWP || TPIDRPRW_IS_CURCPU */
105 105
106/* 1 == use cpu_sleep(), 0 == don't */ 106/* 1 == use cpu_sleep(), 0 == don't */
107extern int cpu_do_powersave; 107extern int cpu_do_powersave;
108extern int cpu_fpu_present; 108extern int cpu_fpu_present;
109 109
110/* All the CLKF_* macros take a struct clockframe * as an argument. */ 110/* All the CLKF_* macros take a struct clockframe * as an argument. */
111 111
112/* 112/*
113 * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the 113 * CLKF_USERMODE: Return TRUE/FALSE (1/0) depending on whether the
114 * frame came from USR mode or not. 114 * frame came from USR mode or not.
115 */ 115 */
116#define CLKF_USERMODE(cf) (((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_USR32_MODE) 116#define CLKF_USERMODE(cf) (((cf)->cf_tf.tf_spsr & PSR_MODE) == PSR_USR32_MODE)
117 117
@@ -207,26 +207,27 @@ struct cpu_info { @@ -207,26 +207,27 @@ struct cpu_info {
207 struct arm_cache_info * 207 struct arm_cache_info *
208 ci_cacheinfo; 208 ci_cacheinfo;
209 209
210#if defined(MP_CPU_INFO_MEMBERS) 210#if defined(MP_CPU_INFO_MEMBERS)
211 MP_CPU_INFO_MEMBERS 211 MP_CPU_INFO_MEMBERS
212#endif 212#endif
213}; 213};
214 214
215extern struct cpu_info cpu_info_store[]; 215extern struct cpu_info cpu_info_store[];
216 216
217struct lwp *arm_curlwp(void); 217struct lwp *arm_curlwp(void);
218struct cpu_info *arm_curcpu(void); 218struct cpu_info *arm_curcpu(void);
219 219
 220#ifdef _KERNEL
220#if defined(_MODULE) 221#if defined(_MODULE)
221 222
222#define curlwp arm_curlwp() 223#define curlwp arm_curlwp()
223#define curcpu() arm_curcpu() 224#define curcpu() arm_curcpu()
224 225
225#elif defined(TPIDRPRW_IS_CURLWP) 226#elif defined(TPIDRPRW_IS_CURLWP)
226static inline struct lwp * 227static inline struct lwp *
227_curlwp(void) 228_curlwp(void)
228{ 229{
229 return (struct lwp *) armreg_tpidrprw_read(); 230 return (struct lwp *) armreg_tpidrprw_read();
230} 231}
231 232
232static inline void 233static inline void
@@ -333,24 +334,26 @@ cpu_dosoftints(void) @@ -333,24 +334,26 @@ cpu_dosoftints(void)
333#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, \ 334#define cpu_need_proftick(l) ((l)->l_pflag |= LP_OWEUPC, \
334 setsoftast((l)->l_cpu)) 335 setsoftast((l)->l_cpu))
335 336
336/* 337/*
337 * We've already preallocated the stack for the idlelwps for additional CPUs. 338 * We've already preallocated the stack for the idlelwps for additional CPUs.
338 * This hook allows to return them. 339 * This hook allows to return them.
339 */ 340 */
340vaddr_t cpu_uarea_alloc_idlelwp(struct cpu_info *); 341vaddr_t cpu_uarea_alloc_idlelwp(struct cpu_info *);
341 342
342#ifdef _ARM_ARCH_6 343#ifdef _ARM_ARCH_6
343int cpu_maxproc_hook(int); 344int cpu_maxproc_hook(int);
344#endif 345#endif
345 346
 347#endif /* _KERNEL */
 348
346#endif /* !_LOCORE */ 349#endif /* !_LOCORE */
347 350
348#endif /* _KERNEL */ 351#endif /* _KERNEL || _KMEMUSER */
349 352
350#elif defined(__aarch64__) 353#elif defined(__aarch64__)
351 354
352#include <aarch64/cpu.h> 355#include <aarch64/cpu.h>
353 356
354#endif /* __arm__/__aarch64__ */ 357#endif /* __arm__/__aarch64__ */
355 358
356#endif /* !_ARM_CPU_H_ */ 359#endif /* !_ARM_CPU_H_ */