Move kstack_contains() and GET_STACK_USAGE() to MD machine/stack.h

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D38320
This commit is contained in:
Konstantin Belousov
2023-02-01 00:47:40 +02:00
parent 6cc52efa13
commit 2555f175b3
24 changed files with 136 additions and 71 deletions
+1
View File
@@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/reg.h>
#include <machine/pcb.h>
#ifdef VFP
#include <machine/vfp.h>
#endif
-11
View File
@@ -56,15 +56,4 @@ struct mdproc {
#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_ */
+19
View File
@@ -63,6 +63,25 @@ struct linker_file;
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_ */