Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Introduce _UC_MACHINE_FP() as a macro
details: https://anonhg.NetBSD.org/src/rev/b0a3f2714770
branches: trunk
changeset: 359564:b0a3f2714770
user: kamil <kamil%NetBSD.org@localhost>
date: Thu Feb 15 15:53:56 2018 +0000
description:
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>
diffstat:
sys/arch/aarch64/include/mcontext.h | 3 ++-
sys/arch/alpha/include/mcontext.h | 3 ++-
sys/arch/amd64/include/mcontext.h | 3 ++-
sys/arch/arm/include/mcontext.h | 3 ++-
sys/arch/hppa/include/mcontext.h | 3 ++-
sys/arch/i386/include/mcontext.h | 3 ++-
sys/arch/ia64/include/mcontext.h | 3 ++-
sys/arch/m68k/include/mcontext.h | 3 ++-
sys/arch/mips/include/mcontext.h | 3 ++-
sys/arch/or1k/include/mcontext.h | 3 ++-
sys/arch/powerpc/include/mcontext.h | 3 ++-
sys/arch/riscv/include/mcontext.h | 3 ++-
sys/arch/sh3/include/mcontext.h | 3 ++-
sys/arch/sparc/include/mcontext.h | 5 ++++-
sys/arch/vax/include/mcontext.h | 3 ++-
15 files changed, 32 insertions(+), 15 deletions(-)
diffs (262 lines):
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/aarch64/include/mcontext.h
--- a/sys/arch/aarch64/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/aarch64/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.2 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -106,6 +106,7 @@
#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_X29])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_X0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/alpha/include/mcontext.h
--- a/sys/arch/alpha/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/alpha/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.8 2012/09/12 02:00:54 manu Exp $ */
+/* $NetBSD: mcontext.h,v 1.9 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -96,6 +96,7 @@
#define _UC_TLSBASE 0x20 /* valid process-unique value in _REG_UNIQUE */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S6])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/amd64/include/mcontext.h
--- a/sys/arch/amd64/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/amd64/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.18 2014/05/12 22:50:03 uebayasi Exp $ */
+/* $NetBSD: mcontext.h,v 1.19 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -68,6 +68,7 @@
/* AMD64 ABI 128-bytes "red zone". */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_RSP] - 128)
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_RBP])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_RIP])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RAX])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/arm/include/mcontext.h
--- a/sys/arch/arm/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/arm/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.18 2015/03/24 08:38:29 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.19 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -110,6 +110,7 @@
#define _UC_MACHINE_PAD 1 /* Padding appended to ucontext_t */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R11])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/hppa/include/mcontext.h
--- a/sys/arch/hppa/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/hppa/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.8 2014/02/19 13:01:51 skrll Exp $ */
+/* $NetBSD: mcontext.h,v 1.9 2018/02/15 15:53:56 kamil Exp $ */
#ifndef _HPPA_MCONTEXT_H_
#define _HPPA_MCONTEXT_H_
@@ -50,6 +50,7 @@
} mcontext_t;
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[3])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PCOQH])
#define _UC_MACHINE_SET_PC(uc, pc) \
do { \
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/i386/include/mcontext.h
--- a/sys/arch/i386/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/i386/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.13 2017/08/12 07:35:08 maxv Exp $ */
+/* $NetBSD: mcontext.h,v 1.14 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -105,6 +105,7 @@
#ifndef _UC_MACHINE_SP
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_UESP])
#endif
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_EBP])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EIP])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_EAX])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/ia64/include/mcontext.h
--- a/sys/arch/ia64/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/ia64/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.5 2016/08/05 17:01:13 scole Exp $ */
+/* $NetBSD: mcontext.h,v 1.6 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -112,6 +112,7 @@
} mcontext_t;
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.mc_special.sp)
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[79])
/* XXX or assembly "mov Rn = ip" or ...? */
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.mc_special.iip)
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/m68k/include/mcontext.h
--- a/sys/arch/m68k/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/m68k/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.9 2011/11/22 15:25:28 joerg Exp $ */
+/* $NetBSD: mcontext.h,v 1.10 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -102,6 +102,7 @@
#define _UC_TLSBASE 0x00080000
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_A7])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_A6])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_D0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/mips/include/mcontext.h
--- a/sys/arch/mips/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/mips/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.21 2015/05/26 02:16:38 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.22 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -159,6 +159,7 @@
#define _UC_TLSBASE 0x00040000
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S8])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EPC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/or1k/include/mcontext.h
--- a/sys/arch/or1k/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/or1k/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.2 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -88,6 +88,7 @@
#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R2])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/powerpc/include/mcontext.h
--- a/sys/arch/powerpc/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/powerpc/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.17 2014/08/12 20:27:10 joerg Exp $ */
+/* $NetBSD: mcontext.h,v 1.18 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -133,6 +133,7 @@
#define _UC_TLSBASE 0x00080000 /* thread context valid in R2 */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_R1])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R31])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R3])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/riscv/include/mcontext.h
--- a/sys/arch/riscv/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/riscv/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.4 2015/04/01 21:55:33 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.5 2018/02/15 15:53:56 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -118,6 +118,7 @@
#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/sh3/include/mcontext.h
--- a/sys/arch/sh3/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/sh3/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.10 2012/09/12 02:00:54 manu Exp $ */
+/* $NetBSD: mcontext.h,v 1.11 2018/02/15 15:53:57 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -82,6 +82,7 @@
} mcontext_t;
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R14])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/sparc/include/mcontext.h
--- a/sys/arch/sparc/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/sparc/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.13 2012/09/12 02:00:54 manu Exp $ */
+/* $NetBSD: mcontext.h,v 1.14 2018/02/15 15:53:57 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -146,11 +146,14 @@
#ifdef __arch64__
#define _UC_MACHINE_PAD 8 /* Padding appended to ucontext_t */
#define _UC_MACHINE_SP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0x7ff)
+#define _UC_MACHINE_FP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0x80e)
#define _UC_MACHINE32_PAD 43 /* compat_netbsd32 variant */
#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6])
+#define _UC_MACHINE32_FP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0xf)
#else
#define _UC_MACHINE_PAD 43 /* Padding appended to ucontext_t */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6])
+#define _UC_MACHINE_FP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0xf)
#endif
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_O0])
diff -r 1c3a27d053ba -r b0a3f2714770 sys/arch/vax/include/mcontext.h
--- a/sys/arch/vax/include/mcontext.h Thu Feb 15 13:51:32 2018 +0000
+++ b/sys/arch/vax/include/mcontext.h Thu Feb 15 15:53:56 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.8 2012/02/02 18:32:16 matt Exp $ */
+/* $NetBSD: mcontext.h,v 1.9 2018/02/15 15:53:57 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -68,6 +68,7 @@
#define _UC_TLSBASE 0x00080000
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
+#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R0])
Home |
Main Index |
Thread Index |
Old Index