From nobody Wed Feb 01 23:41:33 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P6djT4M5Zz3cMWn; Wed, 1 Feb 2023 23:41:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P6djT4BD6z3N3M; Wed, 1 Feb 2023 23:41:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675294893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fPIbFn2LvhY3BEcCP6tM1D4GrIuGgSBhcKdXa2ANvdk=; b=CdlOBOFK7ex40FZRhg8PsQmMPHjjjISkpKZhrEXdVl55QXlFC0WshMKccjNuH6m+EJJtqP St8xmfHrCtZaRLZ7TOwQsIFldRjdG7Ksc6h+Ha3/yltqIkrrEo9Oal7lc512QmUAlsHQgp 54Nj0MfGWVqiB5vHmXd3zuzYYLAliPy6rYfFogQhWATBJ5baJKnM35e/Y7Efl7ISu8OFwS S1ViYhuOnZZix5rLxR97LPONJhGV8t+8By9xKd+Bqft2g/8r5KRE5o37MRCaJWsIeS3FxM qXE2vP4CqsAVZA+YU/sDOjmECtkIcf+l8xDAiW8nLB/zbt2OlkXK6V78oi7G6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675294893; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fPIbFn2LvhY3BEcCP6tM1D4GrIuGgSBhcKdXa2ANvdk=; b=cSyCqnIfYxu6ylnxCVeW7VjvNVdHjFuxXxJxE7pKfiB5YaI5bVfCOrFlnGrI0wC/LU2FB3 7gW0fW6LKCudmhBOb8Cd9KUa7eGfExMelc14JV5ksRWnlb29RXJat5NKMzbx3aIZ6aUa3V AUc4wb7LslpHgMVnT67ZA6kVs+LbH2EYV6b0kwdvLVp2mqkCxIpfB58lC6WgE3qdnChezr pigfZHx4SMq/wpHzQhH3qwuSBuK+HBumPgZBy1LKiRsuOGsKPB9WOcIr/k1bbS9cQT8Ec2 kWsjq8WU41IdHDpTlBWeTNqSVxwsjA2ZkCS/jeg+kgffsfiProSbxYsXKmHhvQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675294893; a=rsa-sha256; cv=none; b=dUoO6tHk+KKuCTGzW7isKTMhu71QzzRrzN3aZSztN/kjAfFg1+914Sq6fUUCHvs3vPiBTW fAFlnpV4TndmTopKMMh/JHUtqf6rXnDU3OEkOPpNzWS6gz0FCav94kT11rXDhpGqlH02in GDrkSCz1i9+/McS11uTVzyD4tXkiLJTihuPQ7CHlbom6VHfFBpimqtlWiMq+VVsgHZMeRd f5LgwHlNV4j5AWj86JBvi16D2utwDC1H/U/LAvKfSWYDsMCFoh3h3mjTRpZSnaFwEOL2SS iP81aMFpAU4F42tizOxQlXxQQ872fjmXl0jbUbYcMRxNLDPUAlrxR8VMf7H8Ig== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P6djT3DvtzYSb; Wed, 1 Feb 2023 23:41:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 311NfXbH088865; Wed, 1 Feb 2023 23:41:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 311NfXpd088864; Wed, 1 Feb 2023 23:41:33 GMT (envelope-from git) Date: Wed, 1 Feb 2023 23:41:33 GMT Message-Id: <202302012341.311NfXpd088864@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 2555f175b368 - main - Move kstack_contains() and GET_STACK_USAGE() to MD machine/stack.h List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2555f175b368569dd98e1bd2b6bd095c933faed7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2555f175b368569dd98e1bd2b6bd095c933faed7 commit 2555f175b368569dd98e1bd2b6bd095c933faed7 Author: Konstantin Belousov AuthorDate: 2023-01-31 22:47:40 +0000 Commit: Konstantin Belousov CommitDate: 2023-02-01 22:59:26 +0000 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 --- sys/amd64/include/proc.h | 9 --------- sys/amd64/include/stack.h | 24 ++++++++++++++++++++++++ sys/arm/arm/ptrace_machdep.c | 1 + sys/arm/include/proc.h | 11 ----------- sys/arm/include/stack.h | 19 +++++++++++++++++++ sys/arm64/arm64/debug_monitor.c | 1 + sys/arm64/arm64/elf32_machdep.c | 1 + sys/arm64/arm64/freebsd32_machdep.c | 1 + sys/arm64/arm64/ptrace_machdep.c | 1 + sys/arm64/include/proc.h | 12 ------------ sys/arm64/include/stack.h | 18 ++++++++++++++++++ sys/arm64/linux/linux_sysvec.c | 2 +- sys/ddb/db_ps.c | 2 ++ sys/geom/geom_io.c | 1 + sys/i386/include/proc.h | 7 ------- sys/i386/include/stack.h | 23 +++++++++++++++++++++++ sys/kern/subr_epoch.c | 2 ++ sys/netgraph/ng_base.c | 2 ++ sys/powerpc/include/proc.h | 12 ------------ sys/powerpc/include/stack.h | 19 +++++++++++++++++++ sys/riscv/include/proc.h | 11 ----------- sys/riscv/include/stack.h | 19 +++++++++++++++++++ sys/sys/proc.h | 7 ------- sys/x86/x86/stack_machdep.c | 2 +- 24 files changed, 136 insertions(+), 71 deletions(-) diff --git a/sys/amd64/include/proc.h b/sys/amd64/include/proc.h index 6181df35261e..8015fe5da81a 100644 --- a/sys/amd64/include/proc.h +++ b/sys/amd64/include/proc.h @@ -97,15 +97,6 @@ struct mdproc { #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 index 091ae33893d4..ff21ee28b5a3 100644 --- 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 + +#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 index 3edadbd72ddf..a347a1dfac95 100644 --- a/sys/arm/arm/ptrace_machdep.c +++ b/sys/arm/arm/ptrace_machdep.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef VFP #include #endif diff --git a/sys/arm/include/proc.h b/sys/arm/include/proc.h index 76b05b335420..9db28358cc39 100644 --- a/sys/arm/include/proc.h +++ b/sys/arm/include/proc.h @@ -56,15 +56,4 @@ struct mdproc { #define KINFO_PROC_SIZE 816 -#ifdef _KERNEL -#include - -/* 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 index 4bc384f775bc..e8d130517be5 100644 --- a/sys/arm/include/stack.h +++ b/sys/arm/include/stack.h @@ -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 + +/* 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 index 2ec76c9a2f33..52bcf1e5e603 100644 --- a/sys/arm64/arm64/debug_monitor.c +++ b/sys/arm64/arm64/debug_monitor.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef DDB #include diff --git a/sys/arm64/arm64/elf32_machdep.c b/sys/arm64/arm64/elf32_machdep.c index 627973ecfd3d..7b346ed81b2c 100644 --- a/sys/arm64/arm64/elf32_machdep.c +++ b/sys/arm64/arm64/elf32_machdep.c @@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #ifdef VFP #include #endif diff --git a/sys/arm64/arm64/freebsd32_machdep.c b/sys/arm64/arm64/freebsd32_machdep.c index 9b62802efbc5..5fadef74df87 100644 --- a/sys/arm64/arm64/freebsd32_machdep.c +++ b/sys/arm64/arm64/freebsd32_machdep.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef VFP #include #endif diff --git a/sys/arm64/arm64/ptrace_machdep.c b/sys/arm64/arm64/ptrace_machdep.c index 01135978b39a..079391ac102c 100644 --- a/sys/arm64/arm64/ptrace_machdep.c +++ b/sys/arm64/arm64/ptrace_machdep.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include /* Only used to get/set 32bits VFP regs */ int diff --git a/sys/arm64/include/proc.h b/sys/arm64/include/proc.h index 15361a0e3788..9a22fe43833a 100644 --- a/sys/arm64/include/proc.h +++ b/sys/arm64/include/proc.h @@ -72,16 +72,4 @@ struct mdproc { #define KINFO_PROC_SIZE 1088 #define KINFO_PROC32_SIZE 816 -#ifdef _KERNEL - -#include - -#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 index 4b1d190df595..4c4c41bf9516 100644 --- a/sys/arm64/include/stack.h +++ b/sys/arm64/include/stack.h @@ -39,4 +39,22 @@ struct unwind_state { bool unwind_frame(struct thread *, struct unwind_state *); +#ifdef _SYS_PROC_H_ + +#include + +#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 index 41ac2912be29..9a82dc94b6ac 100644 --- a/sys/arm64/linux/linux_sysvec.c +++ b/sys/arm64/linux/linux_sysvec.c @@ -71,7 +71,7 @@ __FBSDID("$FreeBSD$"); #include #include - +#include #ifdef VFP #include #endif diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c index a5245528ca83..5d713264d975 100644 --- a/sys/ddb/db_ps.c +++ b/sys/ddb/db_ps.c @@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$"); #include +#include + #define PRINT_NONE 0 #define PRINT_ARGS 1 diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index 20e31b9b921b..777f698b6f1f 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include diff --git a/sys/i386/include/proc.h b/sys/i386/include/proc.h index 7affe60edab9..d693500f2c3e 100644 --- a/sys/i386/include/proc.h +++ b/sys/i386/include/proc.h @@ -66,13 +66,6 @@ struct mdproc { #include -/* 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 index 091ae33893d4..773aca1c66d9 100644 --- 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 + +#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 index 98a560e44c9d..2a0144412399 100644 --- a/sys/kern/subr_epoch.c +++ b/sys/kern/subr_epoch.c @@ -56,6 +56,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #ifdef __amd64__ diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c index 092231850f18..205b6041053b 100644 --- a/sys/netgraph/ng_base.c +++ b/sys/netgraph/ng_base.c @@ -66,6 +66,8 @@ #include #include +#include + #include #include diff --git a/sys/powerpc/include/proc.h b/sys/powerpc/include/proc.h index 2c6a00536b8a..0f8d36bfe856 100644 --- a/sys/powerpc/include/proc.h +++ b/sys/powerpc/include/proc.h @@ -59,16 +59,4 @@ struct mdproc { #define KINFO_PROC_SIZE 816 #endif -#ifdef _KERNEL - -#include - -/* 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 index c433a9fe09eb..953afd6f0aa4 100644 --- a/sys/powerpc/include/stack.h +++ b/sys/powerpc/include/stack.h @@ -33,4 +33,23 @@ extern int trapexit[]; extern int asttrapexit[]; extern int end[]; +#ifdef _SYS_PROC_H_ + +#include + +/* 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 index 648c529f4322..ce0a62675308 100644 --- a/sys/riscv/include/proc.h +++ b/sys/riscv/include/proc.h @@ -45,15 +45,4 @@ struct mdproc { #define KINFO_PROC_SIZE 1088 -#ifdef _KERNEL -#include - -/* 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 index 82f851096d7b..566081c3ebd0 100644 --- a/sys/riscv/include/stack.h +++ b/sys/riscv/include/stack.h @@ -48,4 +48,23 @@ struct unwind_state { bool unwind_frame(struct thread *, struct unwind_state *); +#ifdef _SYS_PROC_H_ + +#include + +/* 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 index 2da5d8edee6d..2ad4505405c8 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1324,13 +1324,6 @@ curthread_pflags2_restore(int save) 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 index 1243137d2ea0..5d7dfd251b0d 100644 --- a/sys/x86/x86/stack_machdep.c +++ b/sys/x86/x86/stack_machdep.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #ifdef __i386__ #define PCB_FP(pcb) ((pcb)->pcb_ebp)