Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151093829
D38320.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
11 KB
Referenced Files
None
Subscribers
None
D38320.id.diff
View Options
diff --git a/sys/amd64/include/proc.h b/sys/amd64/include/proc.h
--- a/sys/amd64/include/proc.h
+++ b/sys/amd64/include/proc.h
@@ -97,15 +97,6 @@
#ifdef _KERNEL
-/* Get the current kernel thread stack usage. */
-#define GET_STACK_USAGE(total, used) do { \
- struct thread *td = curthread; \
- (total) = td->td_kstack_pages * PAGE_SIZE; \
- (used) = (char *)td->td_kstack + \
- td->td_kstack_pages * PAGE_SIZE - \
- (char *)&td; \
-} while (0)
-
struct proc_ldt *user_ldt_alloc(struct proc *, int);
void user_ldt_free(struct thread *);
struct sysarch_args;
diff --git a/sys/amd64/include/stack.h b/sys/amd64/include/stack.h
--- a/sys/amd64/include/stack.h
+++ b/sys/amd64/include/stack.h
@@ -3,4 +3,28 @@
*/
/* $FreeBSD$ */
+#ifndef _MACHINE_STACK_H_
+#define _MACHINE_STACK_H_
+
#include <x86/stack.h>
+
+#ifdef _SYS_PROC_H_
+
+/* Get the current kernel thread stack usage. */
+#define GET_STACK_USAGE(total, used) do { \
+ struct thread *td = curthread; \
+ (total) = td->td_kstack_pages * PAGE_SIZE; \
+ (used) = (char *)td->td_kstack + \
+ td->td_kstack_pages * PAGE_SIZE - \
+ (char *)&td; \
+} while (0)
+
+static __inline bool
+kstack_contains(struct thread *td, vm_offset_t va, size_t len)
+{
+ return (va >= td->td_kstack && va + len >= va &&
+ va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+}
+#endif /* _SYS_PROC_H_ */
+
+#endif
diff --git a/sys/arm/arm/ptrace_machdep.c b/sys/arm/arm/ptrace_machdep.c
--- a/sys/arm/arm/ptrace_machdep.c
+++ b/sys/arm/arm/ptrace_machdep.c
@@ -32,6 +32,7 @@
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/reg.h>
+#include <machine/pcb.h>
#ifdef VFP
#include <machine/vfp.h>
#endif
diff --git a/sys/arm/include/proc.h b/sys/arm/include/proc.h
--- a/sys/arm/include/proc.h
+++ b/sys/arm/include/proc.h
@@ -56,15 +56,4 @@
#define KINFO_PROC_SIZE 816
-#ifdef _KERNEL
-#include <machine/pcb.h>
-
-/* Get the current kernel thread stack usage. */
-#define GET_STACK_USAGE(total, used) do { \
- struct thread *td = curthread; \
- (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
- (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
-} while (0)
-
-#endif /* _KERNEL */
#endif /* !_MACHINE_PROC_H_ */
diff --git a/sys/arm/include/stack.h b/sys/arm/include/stack.h
--- a/sys/arm/include/stack.h
+++ b/sys/arm/include/stack.h
@@ -63,6 +63,25 @@
void unwind_module_loaded(struct linker_file *);
void unwind_module_unloaded(struct linker_file *);
+#ifdef _SYS_PROC_H_
+
+#include <machine/pcb.h>
+
+/* Get the current kernel thread stack usage. */
+#define GET_STACK_USAGE(total, used) do { \
+ struct thread *td = curthread; \
+ (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+ (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
+} while (0)
+
+static __inline bool
+kstack_contains(struct thread *td, vm_offset_t va, size_t len)
+{
+ return (va >= td->td_kstack && va + len >= va &&
+ va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+}
+#endif /* _SYS_PROC_H_ */
+
#endif
#endif /* !_MACHINE_STACK_H_ */
diff --git a/sys/arm64/arm64/debug_monitor.c b/sys/arm64/arm64/debug_monitor.c
--- a/sys/arm64/arm64/debug_monitor.c
+++ b/sys/arm64/arm64/debug_monitor.c
@@ -44,6 +44,7 @@
#include <machine/cpu.h>
#include <machine/debug_monitor.h>
#include <machine/kdb.h>
+#include <machine/pcb.h>
#ifdef DDB
#include <ddb/ddb.h>
diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c
--- a/sys/arm64/arm64/elf32_machdep.c
+++ b/sys/arm64/arm64/elf32_machdep.c
@@ -52,6 +52,7 @@
#include <sys/vnode.h>
#include <machine/elf.h>
+#include <machine/pcb.h>
#ifdef VFP
#include <machine/vfp.h>
#endif
diff --git a/sys/arm64/arm64/freebsd32_machdep.c b/sys/arm64/arm64/freebsd32_machdep.c
--- a/sys/arm64/arm64/freebsd32_machdep.c
+++ b/sys/arm64/arm64/freebsd32_machdep.c
@@ -37,6 +37,7 @@
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <machine/armreg.h>
+#include <machine/pcb.h>
#ifdef VFP
#include <machine/vfp.h>
#endif
diff --git a/sys/arm64/arm64/ptrace_machdep.c b/sys/arm64/arm64/ptrace_machdep.c
--- a/sys/arm64/arm64/ptrace_machdep.c
+++ b/sys/arm64/arm64/ptrace_machdep.c
@@ -48,6 +48,7 @@
#include <sys/ucontext.h>
#include <machine/armreg.h>
+#include <machine/pcb.h>
/* Only used to get/set 32bits VFP regs */
int
diff --git a/sys/arm64/include/proc.h b/sys/arm64/include/proc.h
--- a/sys/arm64/include/proc.h
+++ b/sys/arm64/include/proc.h
@@ -72,16 +72,4 @@
#define KINFO_PROC_SIZE 1088
#define KINFO_PROC32_SIZE 816
-#ifdef _KERNEL
-
-#include <machine/pcb.h>
-
-#define GET_STACK_USAGE(total, used) do { \
- struct thread *td = curthread; \
- (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
- (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
-} while (0)
-
-#endif
-
#endif /* !_MACHINE_PROC_H_ */
diff --git a/sys/arm64/include/stack.h b/sys/arm64/include/stack.h
--- a/sys/arm64/include/stack.h
+++ b/sys/arm64/include/stack.h
@@ -39,4 +39,22 @@
bool unwind_frame(struct thread *, struct unwind_state *);
+#ifdef _SYS_PROC_H_
+
+#include <machine/pcb.h>
+
+#define GET_STACK_USAGE(total, used) do { \
+ struct thread *td = curthread; \
+ (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+ (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
+} while (0)
+
+static __inline bool
+kstack_contains(struct thread *td, vm_offset_t va, size_t len)
+{
+ return (va >= td->td_kstack && va + len >= va &&
+ va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+}
+#endif /* _SYS_PROC_H_ */
+
#endif /* !_MACHINE_STACK_H_ */
diff --git a/sys/arm64/linux/linux_sysvec.c b/sys/arm64/linux/linux_sysvec.c
--- a/sys/arm64/linux/linux_sysvec.c
+++ b/sys/arm64/linux/linux_sysvec.c
@@ -71,7 +71,7 @@
#include <arm64/linux/linux_sigframe.h>
#include <machine/md_var.h>
-
+#include <machine/pcb.h>
#ifdef VFP
#include <machine/vfp.h>
#endif
diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c
--- a/sys/ddb/db_ps.c
+++ b/sys/ddb/db_ps.c
@@ -49,6 +49,8 @@
#include <ddb/ddb.h>
+#include <machine/stack.h>
+
#define PRINT_NONE 0
#define PRINT_ARGS 1
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -53,6 +53,7 @@
#include <sys/stack.h>
#include <sys/sysctl.h>
#include <sys/vmem.h>
+#include <machine/stack.h>
#include <machine/stdarg.h>
#include <sys/errno.h>
diff --git a/sys/i386/include/proc.h b/sys/i386/include/proc.h
--- a/sys/i386/include/proc.h
+++ b/sys/i386/include/proc.h
@@ -66,13 +66,6 @@
#include <machine/md_var.h>
-/* Get the current kernel thread stack usage. */
-#define GET_STACK_USAGE(total, used) do { \
- struct thread *td = curthread; \
- (total) = (vm_offset_t)get_pcb_td(td) - td->td_kstack; \
- (used) = (vm_offset_t)get_pcb_td(td) - (vm_offset_t)&td; \
-} while (0)
-
void set_user_ldt(struct mdproc *);
struct proc_ldt *user_ldt_alloc(struct mdproc *, int);
void user_ldt_free(struct thread *);
diff --git a/sys/i386/include/stack.h b/sys/i386/include/stack.h
--- a/sys/i386/include/stack.h
+++ b/sys/i386/include/stack.h
@@ -3,4 +3,27 @@
*/
/* $FreeBSD$ */
+#ifndef _MACHINE_STACK_H_
+#define _MACHINE_STACK_H_
+
#include <x86/stack.h>
+
+#ifdef _SYS_PROC_H_
+
+/* Get the current kernel thread stack usage. */
+#define GET_STACK_USAGE(total, used) do { \
+ struct thread *td = curthread; \
+ (total) = (vm_offset_t)get_pcb_td(td) - td->td_kstack; \
+ (used) = (vm_offset_t)get_pcb_td(td) - (vm_offset_t)&td; \
+} while (0)
+
+static __inline bool
+kstack_contains(struct thread *td, vm_offset_t va, size_t len)
+{
+ return (va >= td->td_kstack && va + len >= va &&
+ va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+}
+
+#endif /* _SYS_PROC_H_ */
+
+#endif
diff --git a/sys/kern/subr_epoch.c b/sys/kern/subr_epoch.c
--- a/sys/kern/subr_epoch.c
+++ b/sys/kern/subr_epoch.c
@@ -56,6 +56,8 @@
#include <vm/vm_kern.h>
#include <vm/uma.h>
+#include <machine/stack.h>
+
#include <ck_epoch.h>
#ifdef __amd64__
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -66,6 +66,8 @@
#include <machine/cpu.h>
#include <vm/uma.h>
+#include <machine/stack.h>
+
#include <net/netisr.h>
#include <net/vnet.h>
diff --git a/sys/powerpc/include/proc.h b/sys/powerpc/include/proc.h
--- a/sys/powerpc/include/proc.h
+++ b/sys/powerpc/include/proc.h
@@ -59,16 +59,4 @@
#define KINFO_PROC_SIZE 816
#endif
-#ifdef _KERNEL
-
-#include <machine/pcb.h>
-
-/* Get the current kernel thread stack usage. */
-#define GET_STACK_USAGE(total, used) do { \
- struct thread *td = curthread; \
- (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
- (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
-} while (0)
-#endif
-
#endif /* !_MACHINE_PROC_H_ */
diff --git a/sys/powerpc/include/stack.h b/sys/powerpc/include/stack.h
--- a/sys/powerpc/include/stack.h
+++ b/sys/powerpc/include/stack.h
@@ -33,4 +33,23 @@
extern int asttrapexit[];
extern int end[];
+#ifdef _SYS_PROC_H_
+
+#include <machine/pcb.h>
+
+/* Get the current kernel thread stack usage. */
+#define GET_STACK_USAGE(total, used) do { \
+ struct thread *td = curthread; \
+ (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+ (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
+} while (0)
+
+static __inline bool
+kstack_contains(struct thread *td, vm_offset_t va, size_t len)
+{
+ return (va >= td->td_kstack && va + len >= va &&
+ va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+}
+#endif /* _SYS_PROC_H_ */
+
#endif /* !_MACHINE_STACK_H_ */
diff --git a/sys/riscv/include/proc.h b/sys/riscv/include/proc.h
--- a/sys/riscv/include/proc.h
+++ b/sys/riscv/include/proc.h
@@ -45,15 +45,4 @@
#define KINFO_PROC_SIZE 1088
-#ifdef _KERNEL
-#include <machine/pcb.h>
-
-/* Get the current kernel thread stack usage. */
-#define GET_STACK_USAGE(total, used) do { \
- struct thread *td = curthread; \
- (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
- (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
-} while (0)
-
-#endif /* _KERNEL */
#endif /* !_MACHINE_PROC_H_ */
diff --git a/sys/riscv/include/stack.h b/sys/riscv/include/stack.h
--- a/sys/riscv/include/stack.h
+++ b/sys/riscv/include/stack.h
@@ -48,4 +48,23 @@
bool unwind_frame(struct thread *, struct unwind_state *);
+#ifdef _SYS_PROC_H_
+
+#include <machine/pcb.h>
+
+/* Get the current kernel thread stack usage. */
+#define GET_STACK_USAGE(total, used) do { \
+ struct thread *td = curthread; \
+ (total) = td->td_kstack_pages * PAGE_SIZE - sizeof(struct pcb); \
+ (used) = td->td_kstack + (total) - (vm_offset_t)&td; \
+} while (0)
+
+static __inline bool
+kstack_contains(struct thread *td, vm_offset_t va, size_t len)
+{
+ return (va >= td->td_kstack && va + len >= va &&
+ va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+}
+#endif /* _SYS_PROC_H_ */
+
#endif /* !_MACHINE_STACK_H_ */
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1324,13 +1324,6 @@
curthread->td_pflags2 &= save;
}
-static __inline bool
-kstack_contains(struct thread *td, vm_offset_t va, size_t len)
-{
- return (va >= td->td_kstack && va + len >= va &&
- va + len <= td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
-}
-
static __inline __pure2 struct td_sched *
td_get_sched(struct thread *td)
{
diff --git a/sys/x86/x86/stack_machdep.c b/sys/x86/x86/stack_machdep.c
--- a/sys/x86/x86/stack_machdep.c
+++ b/sys/x86/x86/stack_machdep.c
@@ -45,7 +45,7 @@
#include <vm/vm_param.h>
#include <vm/pmap.h>
-#include <x86/stack.h>
+#include <machine/stack.h>
#ifdef __i386__
#define PCB_FP(pcb) ((pcb)->pcb_ebp)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Apr 6, 11:56 PM (2 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31002903
Default Alt Text
D38320.id.diff (11 KB)
Attached To
Mode
D38320: Improve kstack_contains() to account for pcb/fpu save area
Attached
Detach File
Event Timeline
Log In to Comment