Home | History | Annotate | Download | only in include
History log of /src/sys/arch/mips/include/mcontext.h
RevisionDateAuthorComments
 1.28  09-Apr-2025  rin mips/mcontext.h: Fix wrong size in comment for __UCONTEXT_SIZE_N64, NFC

Value itself is confirmed to be correct (also for {O,N}32 variants).
 1.27  30-Nov-2024  christos Create a new header lwp_private.h to contain _lwp_getprivate_fast,
_lwp_gettcb_fast, _lwp_settcb and remove them from mcontext.h, so that:
1. we don't need special hacks to hide them
2. we can include <lwp.h> where needed to get the necessary prototypes
without redefining them locally.
 1.26  04-Nov-2024  christos Undo previous lwp.h change.
 1.25  03-Nov-2024  christos Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.
 1.24  03-Oct-2020  martin branches: 1.24.26;
Add missing __BEGIN_DECLS/__END_DECLS to force function declarations into
the "C" namespace.
 1.23  26-Jul-2020  simonb #define<tab>
Nuke trailing whitespace.
 1.22  15-Feb-2018  kamil Introduce _UC_MACHINE_FP() as a macro

_UC_MACHINE_FP() is a helper macro to extract from mcontext a frame pointer.

Don't rely on this interface as a compiler might strip frame pointer or
optimize it making this interface unreliable.


For hppa assume a small frame context, for larger frames FP might be located
in a different register (4 instead of 3).

For ia64 there is no strict frame pointer, and registers might rotate.
Reuse 79 following:

./gcc/config/ia64/ia64.h:#define HARD_FRAME_POINTER_REGNUM LOC_REG (79)

Once ia64 will mature, this should be revisited.

A macro can encapsulate a real function for extracting Frame Pointer on
more complex CPUs / ABIs.


For the remaining CPUs, reuse standard register as defined in appropriate ABI.

The direct users of this macro are LLVM and GCC with Sanitizers.

Proposed on tech-userlevel@.

Sponsored by <The NetBSD Foundation>
 1.21  26-May-2015  matt branches: 1.21.10;
Change _lwp_getprivate_fast to use a syscall instead of rdhwr since rdhwr
emulation is problematic for the CN50xx.
 1.20  12-Sep-2012  matt branches: 1.20.14;
N32 uses dadd instructions to manipulate stack (actually, all ABIs except
O32 use dadd).
 1.19  05-Jul-2011  joerg branches: 1.19.2; 1.19.12;
Ensure that _lwp_setprivate has a correct prototype.
 1.18  03-Jul-2011  mrg s/#elif/#else/ -- when there's nothing to check.
 1.17  15-Mar-2011  matt Add MIPS TLS support.
 1.16  25-Feb-2011  joerg Be nicer to software that insists on -ansi and use __inline.
 1.15  24-Feb-2011  joerg Allow storing and receiving the LWP private pointer via ucontext_t
on all platforms except VAX and IA64. Add fast access via register for
AMD64, i386 and SH3 ports. Use this fast access in libpthread to replace
the stack based pthread_self(). Implement skeleton support for Alpha,
HPPA, PowerPC, SPARC and SPARC64, but leave it disabled.

Ports that support this feature provide __HAVE____LWP_GETPRIVATE_FAST in
machine/types.h and a corresponding __lwp_getprivate_fast in
machine/mcontext.h.

This material is based upon work partially supported by
The NetBSD Foundation under a contract with Joerg Sonnenberger.
 1.14  24-Feb-2011  matt make sure to define _UC_MACHINE32_PAD
 1.13  23-Feb-2011  matt Add __UCONTEXT*_SIZE*
 1.12  20-Feb-2011  matt Major merge forward from matt-nb5-mips64.
New fixup code.
New common SPL code.
New common interrupt code.
Move related variables into structures.
Cleanup locore (move MD variable into it).
Kill StudlyCaps
Use PCU for FPU
 1.11  14-Dec-2009  matt branches: 1.11.4; 1.11.6; 1.11.8;
Merge from matt-nb5-mips64
Merge mips-specific arch files.
 1.10  26-Nov-2009  matt Back out unintended commit.
 1.9  26-Nov-2009  matt Kill proc0paddr. Use lwp0.l_addr instead.
 1.8  28-Apr-2008  martin branches: 1.8.18;
Remove clause 3 and 4 from TNF licenses
 1.7  11-Dec-2005  christos branches: 1.7.74; 1.7.76; 1.7.78;
merge ktrace-lwp.
 1.6  03-Jul-2004  simonb Drop the "catchall" __fpregset_t, and use either a 32-bit or 64-bit
structure depending on the current ABI.

Part of fix for PR port-mips/25942. Thanks to Christos Zoulas and
Klaus Klein for help with debugging this.
 1.5  29-Oct-2003  christos branches: 1.5.2;
first pass siginfo for mips
 1.4  08-Oct-2003  thorpej Add some accessor macros for the ucontext:
* _UC_MACHINE_PC() - access the program counter
* _UC_MACHINE_INTRV() - access the integer return value register
* _UC_MACHINE_SET_PC() - set the program counter (this requires
special handling on some platforms).
 1.3  01-Oct-2003  simonb Quieten down lint a little with a /* LONGLONG */ comment.
 1.2  17-Jan-2003  thorpej branches: 1.2.2;
Merge the nathanw_sa branch.
 1.1  17-Nov-2001  wdk branches: 1.1.2;
file mcontext.h was initially added on branch nathanw_sa.
 1.1.2.4  17-Dec-2002  thorpej * Always include the SR in the gregset.
* Create space for the 32 64-bit double-precision registers used
in 64-bit ABIs.

This means we don't follow the SVR4 MIPS PS document, but that document
is somewhat out of date with regard to modern MIPS processors.

Per discussion with Chris Demetriou.
 1.1.2.3  28-Dec-2001  nathanw Add a macro, _UC_MACHINE_SP(), to fetch the user stack pointer from
a ucontext_t.
 1.1.2.2  21-Nov-2001  wdk Make __ASSEMBLER__ proof
 1.1.2.1  17-Nov-2001  wdk mcontext support for MIPS based ports.
 1.2.2.3  21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.2.2  18-Sep-2004  skrll Sync with HEAD.
 1.2.2.1  03-Aug-2004  skrll Sync with HEAD
 1.5.2.1  04-Jul-2004  he Pull up revision 1.6 (requested by simonb in ticket #589):
Changes fixing PR#25942:
o Drop the ``catchall'' __fpregset_t, and use either a
32-bit or 64-bit structure depending on the current ABI
 1.7.78.2  11-Mar-2010  yamt sync with head
 1.7.78.1  16-May-2008  yamt sync with head.
 1.7.76.1  18-May-2008  yamt sync with head.
 1.7.74.1  02-Jun-2008  mjf Sync with HEAD.
 1.8.18.5  29-Apr-2011  matt Major merge to/from current.
Adds MIPS32/MIPS64 R2 support (24k, 74k, etc.) including COP0_USERLOCAL
Adds support for emulation of rdhwr $3,$29 instruction.
Major cleanup of SMP code. (stable on multi-core / single thread per core)
llsc locking code only used in MP capable kernels.
 1.8.18.4  30-Apr-2010  matt Define mcontext_o32_t if !O32
 1.8.18.3  13-Sep-2009  matt Use __int32_t instead int32_t to make userland happy.
 1.8.18.2  12-Sep-2009  matt Add COMPAT_NETBSD32 support.
 1.8.18.1  16-Aug-2009  matt Kill use of _MIPS_BSD_ABI - switch to __mips_<abi>
Use device_t where appropriate.
Remove magic numbers.
 1.11.8.1  05-Mar-2011  bouyer Sync with HEAD
 1.11.6.1  06-Jun-2011  jruoho Sync with HEAD.
 1.11.4.2  21-Apr-2011  rmind sync with head
 1.11.4.1  05-Mar-2011  rmind sync with head
 1.19.12.2  03-Dec-2017  jdolecek update from HEAD
 1.19.12.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.19.2.1  30-Oct-2012  yamt sync with head
 1.20.14.1  06-Jun-2015  skrll Sync with HEAD
 1.21.10.3  21-Mar-2018  martin Pull up the following, requested by kamil in ticket #552:

external/gpl3/gcc{.old}/dist/libsanitizer/asan/asan_linux.cc 1.4
sys/arch/aarch64/include/mcontext.h 1.2
sys/arch/alpha/include/mcontext.h 1.9
sys/arch/amd64/include/mcontext.h 1.19
sys/arch/arm/include/mcontext.h 1.19
sys/arch/hppa/include/mcontext.h 1.9
sys/arch/i386/include/mcontext.h 1.14
sys/arch/ia64/include/mcontext.h 1.6
sys/arch/m68k/include/mcontext.h 1.10
sys/arch/mips/include/mcontext.h 1.22
sys/arch/or1k/include/mcontext.h 1.2
sys/arch/powerpc/include/mcontext.h 1.18
sys/arch/riscv/include/mcontext.h 1.5
sys/arch/sh3/include/mcontext.h 1.11
sys/arch/sparc/include/mcontext.h 1.14-1.17
sys/arch/sparc64/include/mcontext.h 1.10
sys/arch/vax/include/mcontext.h 1.9
tests/lib/libc/sys/Makefile 1.50
tests/lib/libc/sys/t_ucontext.c 1.2-1.5
sys/arch/hppa/include/mcontext.h 1.10
sys/arch/ia64/include/mcontext.h 1.7

- Introduce _UC_MACHINE_FP(). _UC_MACHINE_FP() is a helper
macro to extract from mcontext a frame pointer.
- Add new tests in lib/libc/sys/t_ucontext:
* ucontext_sp (testing _UC_MACHINE_SP)
* ucontext_fp (testing _UC_MACHINE_FP)
* ucontext_pc (testing _UC_MACHINE_PC)
* ucontext_intrv (testing _UC_MACHINE_INTRV)

Add a dummy implementation of _UC_MACHINE_INTRV() for ia64.

Implement _UC_MACHINE_INTRV() for hppa.

Make the t_ucontext.c test more portable.

We now have _UC_MACHINE_FP.
 1.21.10.2  26-Feb-2018  snj revert ticket 552, which broke the build
 1.21.10.1  25-Feb-2018  snj Pull up following revision(s) (requested by kamil in ticket #552):
sys/arch/aarch64/include/mcontext.h: 1.2
sys/arch/alpha/include/mcontext.h: 1.9
sys/arch/amd64/include/mcontext.h: 1.19
sys/arch/arm/include/mcontext.h: 1.19
sys/arch/hppa/include/mcontext.h: 1.9
sys/arch/i386/include/mcontext.h: 1.14
sys/arch/ia64/include/mcontext.h: 1.6
sys/arch/m68k/include/mcontext.h: 1.10
sys/arch/mips/include/mcontext.h: 1.22
sys/arch/or1k/include/mcontext.h: 1.2
sys/arch/powerpc/include/mcontext.h: 1.18
sys/arch/riscv/include/mcontext.h: 1.5
sys/arch/sh3/include/mcontext.h: 1.11
sys/arch/sparc/include/mcontext.h: 1.14-1.17
sys/arch/sparc64/include/mcontext.h: 1.10
sys/arch/vax/include/mcontext.h: 1.9
tests/lib/libc/sys/Makefile: 1.50
tests/lib/libc/sys/t_ucontext.c: 1.2
Introduce _UC_MACHINE_FP() as a macro
_UC_MACHINE_FP() is a helper macro to extract from mcontext a frame pointer.
Don't rely on this interface as a compiler might strip frame pointer or
optimize it making this interface unreliable.
For hppa assume a small frame context, for larger frames FP might be located
in a different register (4 instead of 3).
For ia64 there is no strict frame pointer, and registers might rotate.
Reuse 79 following:
./gcc/config/ia64/ia64.h:#define HARD_FRAME_POINTER_REGNUM LOC_REG (79)
Once ia64 will mature, this should be revisited.
A macro can encapsulate a real function for extracting Frame Pointer on
more complex CPUs / ABIs.
For the remaining CPUs, reuse standard register as defined in appropriate ABI.
The direct users of this macro are LLVM and GCC with Sanitizers.
Proposed on tech-userlevel@.
Sponsored by <The NetBSD Foundation>
--
Improve _UC_MACHINE_FP() for SPARC/SPARC64
Introduce a static inline function _uc_machine_fp() that contains improved
caluclation of a frame pointer.
Algorithm:
uptr *stk_ptr;
# if defined (__arch64__)
stk_ptr = (uptr *) (*sp + 2047);
# else
stk_ptr = (uptr *) *sp;
# endif
*bp = stk_ptr[15];
Noted by <mrg>
--
Make _UC_MACHINE_FP() compile again and fix it so that it does not add
the offset twice.
--
fix _UC_MACHINE32_FP() -- use 32 bit pointer value so that [15] is
the right offset. do this by using __greg32_t, which is only in
the sparc64 version, and these are only useful there, so move them.
--
Add new tests in lib/libc/sys/t_ucontext
New tests:
- ucontext_sp
- ucontext_fp
- ucontext_pc
- ucontext_intrv
They test respectively:
- _UC_MACHINE_SP
- _UC_MACHINE_FP
- _UC_MACHINE_PC
- _UC_MACHINE_INTRV
These tests attempt to access and print the values from ucontext, without
interpreting the values.
This is a follow up of the _UC_MACHINE_FP() introduction.
These tests use PRIxREGISTER, and require to be built with -D_KERNTYPES.
Sponsored by <The NetBSD Foundation>
 1.24.26.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed