From patchwork Tue Feb 9 05:38:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 61505 Delivered-To: patches@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1843157lbl; Mon, 8 Feb 2016 21:39:02 -0800 (PST) X-Received: by 10.55.71.76 with SMTP id u73mr40024130qka.6.1454996342617; Mon, 08 Feb 2016 21:39:02 -0800 (PST) Return-Path: Received: from mail-qg0-x22a.google.com (mail-qg0-x22a.google.com. [2607:f8b0:400d:c04::22a]) by mx.google.com with ESMTPS id s9si34121956qhc.72.2016.02.08.21.39.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Feb 2016 21:39:02 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 2607:f8b0:400d:c04::22a as permitted sender) client-ip=2607:f8b0:400d:c04::22a; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dave.long@linaro.org designates 2607:f8b0:400d:c04::22a as permitted sender) smtp.mailfrom=dave.long@linaro.org; dkim=pass header.i=@linaro.org Received: by mail-qg0-x22a.google.com with SMTP id y9so129969303qgd.3 for ; Mon, 08 Feb 2016 21:39:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=PzqTz9To3g5wCeuaKv173hs6vXKQ/xdLCdl2uy18xcg=; b=eocn+Fg0tjbK+4sQFWLhE+feLsNlM/c+fVYjttmAYRFzX3hiTXqf0YhtRxdfgAN5bN NKEej2XZCqHCgt9B0kc02oNIYsBuc/cFq97isXF3G+lOwZ6rInbwzoJMh0I7gDk+B5rZ watepB+zWbizPcIQyFgKa047R618ctM3swX58= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=PzqTz9To3g5wCeuaKv173hs6vXKQ/xdLCdl2uy18xcg=; b=YPF9xEiRbHhN1Pqy4yj0NhzsqRLyF62OWgwtGiq4yNN/qX1Nw4iiMzot/baITqnRAf OwQ/GhMS/bOCNAe/nUkHbwCU9YAVM/7r9r6NnxiCvWOzmwBw7zVHqB8vj0DlC4/mlikO nk4O7JTM0TVrzRg0DgV3jPB/CzVwVEd0J1i2Ghf89D/66B4luy3uq4+xrAfDp54ygy6w UCpTavmd+NQsgMn4IkGz2UlUjhS4iMODevAtLcfPmnaU9Ce2SzOoHRho0xw7oQWhOv1K u1Rx2irKIMhX3LOnVSUFWS6nWLUaubpiu1x+PuR9Y8ap9c9M08psTv/sSWc1RN8hBDXu c4SQ== X-Gm-Message-State: AG10YORvEs7ulR3K1BimgqyOPyLkfMTYtzr6wZn6ZPiMyRcq0Sv8j6UW+tK/7uP5H/McX1svN5o= X-Received: by 10.140.18.114 with SMTP id 105mr39063347qge.41.1454996342334; Mon, 08 Feb 2016 21:39:02 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-249.cncdnh.fast00.myfairpoint.net. [72.71.243.249]) by smtp.googlemail.com with ESMTPSA id b135sm15390063qka.2.2016.02.08.21.39.00 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 08 Feb 2016 21:39:01 -0800 (PST) From: David Long To: "H. Peter Anvin" , "chengang@emindsoft.com.cn" , Andy Lutomirski , Benjamin Herrenschmidt , Borislav Petkov , Brian Gerst , David Hildenbrand , Denys Vlasenko , Heiko Carstens , Hendrik Brueckner , Ingo Molnar , Jan Beulich , Kees Cook , Martin Schwidefsky , Michael Ellerman , Oleg Nesterov , Paul Mackerras , Rashmica Gupta , Rich Felker , Richard Kuo , Roland McGrath , Russell King , Thomas Gleixner , Will Deacon , Yoshinori Sato , linux-arm-kernel@lists.infradead.org, linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [PATCH v3 1/2] Move the pt_regs_offset struct definition from arch to common include file Date: Tue, 9 Feb 2016 00:38:56 -0500 Message-Id: <1454996337-7935-2-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1454996337-7935-1-git-send-email-dave.long@linaro.org> References: <1454996337-7935-1-git-send-email-dave.long@linaro.org> From: "David A. Long" The pt_regs_offset structure is used for the HAVE_REGS_AND_STACK_ACCESS_API feature and has identical definitions in four different arch ptrace.h include files. It seems unlikely that definition would ever need to be changed regardless of architecture so lets move it into include/linux/ptrace.h, along with macros commonly used to access it. Signed-off-by: David A. Long Acked-by: Michael Ellerman --- arch/arm/kernel/ptrace.c | 7 +- arch/powerpc/kernel/ptrace.c | 31 ++++----- arch/sh/include/asm/ptrace.h | 9 +-- arch/sh/kernel/ptrace_32.c | 48 +++++++------- arch/sh/kernel/ptrace_64.c | 152 +++++++++++++++++++++---------------------- arch/x86/kernel/ptrace.c | 59 ++++++++--------- include/linux/ptrace.h | 12 ++++ 7 files changed, 152 insertions(+), 166 deletions(-) -- 2.5.0 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c index ef9119f..3b5a2ba 100644 --- a/arch/arm/kernel/ptrace.c +++ b/arch/arm/kernel/ptrace.c @@ -59,14 +59,9 @@ #define BREAKINST_THUMB 0xde01 #endif -struct pt_regs_offset { - const char *name; - int offset; -}; #define REG_OFFSET_NAME(r) \ {.name = #r, .offset = offsetof(struct pt_regs, ARM_##r)} -#define REG_OFFSET_END {.name = NULL, .offset = 0} static const struct pt_regs_offset regoffset_table[] = { REG_OFFSET_NAME(r0), @@ -87,7 +82,7 @@ static const struct pt_regs_offset regoffset_table[] = { REG_OFFSET_NAME(pc), REG_OFFSET_NAME(cpsr), REG_OFFSET_NAME(ORIG_r0), - REG_OFFSET_END, + REGS_OFFSET_END, }; /** diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 30a03c0..77bd4c4 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -52,17 +52,10 @@ #define PARAMETER_SAVE_AREA_OFFSET 48 /* bytes */ #endif -struct pt_regs_offset { - const char *name; - int offset; -}; - #define STR(s) #s /* convert to string */ -#define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)} #define GPR_OFFSET_NAME(num) \ {.name = STR(r##num), .offset = offsetof(struct pt_regs, gpr[num])}, \ {.name = STR(gpr##num), .offset = offsetof(struct pt_regs, gpr[num])} -#define REG_OFFSET_END {.name = NULL, .offset = 0} static const struct pt_regs_offset regoffset_table[] = { GPR_OFFSET_NAME(0), @@ -97,21 +90,21 @@ static const struct pt_regs_offset regoffset_table[] = { GPR_OFFSET_NAME(29), GPR_OFFSET_NAME(30), GPR_OFFSET_NAME(31), - REG_OFFSET_NAME(nip), - REG_OFFSET_NAME(msr), - REG_OFFSET_NAME(ctr), - REG_OFFSET_NAME(link), - REG_OFFSET_NAME(xer), - REG_OFFSET_NAME(ccr), + REGS_OFFSET_NAME(nip), + REGS_OFFSET_NAME(msr), + REGS_OFFSET_NAME(ctr), + REGS_OFFSET_NAME(link), + REGS_OFFSET_NAME(xer), + REGS_OFFSET_NAME(ccr), #ifdef CONFIG_PPC64 - REG_OFFSET_NAME(softe), + REGS_OFFSET_NAME(softe), #else - REG_OFFSET_NAME(mq), + REGS_OFFSET_NAME(mq), #endif - REG_OFFSET_NAME(trap), - REG_OFFSET_NAME(dar), - REG_OFFSET_NAME(dsisr), - REG_OFFSET_END, + REGS_OFFSET_NAME(trap), + REGS_OFFSET_NAME(dar), + REGS_OFFSET_NAME(dsisr), + REGS_OFFSET_END, }; /** diff --git a/arch/sh/include/asm/ptrace.h b/arch/sh/include/asm/ptrace.h index 2506c7d..523955f 100644 --- a/arch/sh/include/asm/ptrace.h +++ b/arch/sh/include/asm/ptrace.h @@ -23,17 +23,10 @@ /* * kprobe-based event tracer support */ -struct pt_regs_offset { - const char *name; - int offset; -}; - -#define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)} -#define REGS_OFFSET_NAME(num) \ +#define REG_OFFSET_NAME(num) \ {.name = __stringify(r##num), .offset = offsetof(struct pt_regs, regs[num])} #define TREGS_OFFSET_NAME(num) \ {.name = __stringify(tr##num), .offset = offsetof(struct pt_regs, tregs[num])} -#define REG_OFFSET_END {.name = NULL, .offset = 0} /* Query offset/name of register from its name/offset */ extern int regs_query_register_offset(const char *name); diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index c1a6b89..e6fe4f4 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c @@ -277,30 +277,30 @@ static int dspregs_active(struct task_struct *target, #endif const struct pt_regs_offset regoffset_table[] = { - REGS_OFFSET_NAME(0), - REGS_OFFSET_NAME(1), - REGS_OFFSET_NAME(2), - REGS_OFFSET_NAME(3), - REGS_OFFSET_NAME(4), - REGS_OFFSET_NAME(5), - REGS_OFFSET_NAME(6), - REGS_OFFSET_NAME(7), - REGS_OFFSET_NAME(8), - REGS_OFFSET_NAME(9), - REGS_OFFSET_NAME(10), - REGS_OFFSET_NAME(11), - REGS_OFFSET_NAME(12), - REGS_OFFSET_NAME(13), - REGS_OFFSET_NAME(14), - REGS_OFFSET_NAME(15), - REG_OFFSET_NAME(pc), - REG_OFFSET_NAME(pr), - REG_OFFSET_NAME(sr), - REG_OFFSET_NAME(gbr), - REG_OFFSET_NAME(mach), - REG_OFFSET_NAME(macl), - REG_OFFSET_NAME(tra), - REG_OFFSET_END, + REG_OFFSET_NAME(0), + REG_OFFSET_NAME(1), + REG_OFFSET_NAME(2), + REG_OFFSET_NAME(3), + REG_OFFSET_NAME(4), + REG_OFFSET_NAME(5), + REG_OFFSET_NAME(6), + REG_OFFSET_NAME(7), + REG_OFFSET_NAME(8), + REG_OFFSET_NAME(9), + REG_OFFSET_NAME(10), + REG_OFFSET_NAME(11), + REG_OFFSET_NAME(12), + REG_OFFSET_NAME(13), + REG_OFFSET_NAME(14), + REG_OFFSET_NAME(15), + REGS_OFFSET_NAME(pc), + REGS_OFFSET_NAME(pr), + REGS_OFFSET_NAME(sr), + REGS_OFFSET_NAME(gbr), + REGS_OFFSET_NAME(mach), + REGS_OFFSET_NAME(macl), + REGS_OFFSET_NAME(tra), + REGS_OFFSET_END, }; /* diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c index 5cea973..af55bb6 100644 --- a/arch/sh/kernel/ptrace_64.c +++ b/arch/sh/kernel/ptrace_64.c @@ -253,82 +253,82 @@ static int fpregs_active(struct task_struct *target, #endif const struct pt_regs_offset regoffset_table[] = { - REG_OFFSET_NAME(pc), - REG_OFFSET_NAME(sr), - REG_OFFSET_NAME(syscall_nr), - REGS_OFFSET_NAME(0), - REGS_OFFSET_NAME(1), - REGS_OFFSET_NAME(2), - REGS_OFFSET_NAME(3), - REGS_OFFSET_NAME(4), - REGS_OFFSET_NAME(5), - REGS_OFFSET_NAME(6), - REGS_OFFSET_NAME(7), - REGS_OFFSET_NAME(8), - REGS_OFFSET_NAME(9), - REGS_OFFSET_NAME(10), - REGS_OFFSET_NAME(11), - REGS_OFFSET_NAME(12), - REGS_OFFSET_NAME(13), - REGS_OFFSET_NAME(14), - REGS_OFFSET_NAME(15), - REGS_OFFSET_NAME(16), - REGS_OFFSET_NAME(17), - REGS_OFFSET_NAME(18), - REGS_OFFSET_NAME(19), - REGS_OFFSET_NAME(20), - REGS_OFFSET_NAME(21), - REGS_OFFSET_NAME(22), - REGS_OFFSET_NAME(23), - REGS_OFFSET_NAME(24), - REGS_OFFSET_NAME(25), - REGS_OFFSET_NAME(26), - REGS_OFFSET_NAME(27), - REGS_OFFSET_NAME(28), - REGS_OFFSET_NAME(29), - REGS_OFFSET_NAME(30), - REGS_OFFSET_NAME(31), - REGS_OFFSET_NAME(32), - REGS_OFFSET_NAME(33), - REGS_OFFSET_NAME(34), - REGS_OFFSET_NAME(35), - REGS_OFFSET_NAME(36), - REGS_OFFSET_NAME(37), - REGS_OFFSET_NAME(38), - REGS_OFFSET_NAME(39), - REGS_OFFSET_NAME(40), - REGS_OFFSET_NAME(41), - REGS_OFFSET_NAME(42), - REGS_OFFSET_NAME(43), - REGS_OFFSET_NAME(44), - REGS_OFFSET_NAME(45), - REGS_OFFSET_NAME(46), - REGS_OFFSET_NAME(47), - REGS_OFFSET_NAME(48), - REGS_OFFSET_NAME(49), - REGS_OFFSET_NAME(50), - REGS_OFFSET_NAME(51), - REGS_OFFSET_NAME(52), - REGS_OFFSET_NAME(53), - REGS_OFFSET_NAME(54), - REGS_OFFSET_NAME(55), - REGS_OFFSET_NAME(56), - REGS_OFFSET_NAME(57), - REGS_OFFSET_NAME(58), - REGS_OFFSET_NAME(59), - REGS_OFFSET_NAME(60), - REGS_OFFSET_NAME(61), - REGS_OFFSET_NAME(62), - REGS_OFFSET_NAME(63), - TREGS_OFFSET_NAME(0), - TREGS_OFFSET_NAME(1), - TREGS_OFFSET_NAME(2), - TREGS_OFFSET_NAME(3), - TREGS_OFFSET_NAME(4), - TREGS_OFFSET_NAME(5), - TREGS_OFFSET_NAME(6), - TREGS_OFFSET_NAME(7), - REG_OFFSET_END, + REGS_OFFSET_NAME(pc), + REGS_OFFSET_NAME(sr), + REGS_OFFSET_NAME(syscall_nr), + REG_OFFSET_NAME(0), + REG_OFFSET_NAME(1), + REG_OFFSET_NAME(2), + REG_OFFSET_NAME(3), + REG_OFFSET_NAME(4), + REG_OFFSET_NAME(5), + REG_OFFSET_NAME(6), + REG_OFFSET_NAME(7), + REG_OFFSET_NAME(8), + REG_OFFSET_NAME(9), + REG_OFFSET_NAME(10), + REG_OFFSET_NAME(11), + REG_OFFSET_NAME(12), + REG_OFFSET_NAME(13), + REG_OFFSET_NAME(14), + REG_OFFSET_NAME(15), + REG_OFFSET_NAME(16), + REG_OFFSET_NAME(17), + REG_OFFSET_NAME(18), + REG_OFFSET_NAME(19), + REG_OFFSET_NAME(20), + REG_OFFSET_NAME(21), + REG_OFFSET_NAME(22), + REG_OFFSET_NAME(23), + REG_OFFSET_NAME(24), + REG_OFFSET_NAME(25), + REG_OFFSET_NAME(26), + REG_OFFSET_NAME(27), + REG_OFFSET_NAME(28), + REG_OFFSET_NAME(29), + REG_OFFSET_NAME(30), + REG_OFFSET_NAME(31), + REG_OFFSET_NAME(32), + REG_OFFSET_NAME(33), + REG_OFFSET_NAME(34), + REG_OFFSET_NAME(35), + REG_OFFSET_NAME(36), + REG_OFFSET_NAME(37), + REG_OFFSET_NAME(38), + REG_OFFSET_NAME(39), + REG_OFFSET_NAME(40), + REG_OFFSET_NAME(41), + REG_OFFSET_NAME(42), + REG_OFFSET_NAME(43), + REG_OFFSET_NAME(44), + REG_OFFSET_NAME(45), + REG_OFFSET_NAME(46), + REG_OFFSET_NAME(47), + REG_OFFSET_NAME(48), + REG_OFFSET_NAME(49), + REG_OFFSET_NAME(50), + REG_OFFSET_NAME(51), + REG_OFFSET_NAME(52), + REG_OFFSET_NAME(53), + REG_OFFSET_NAME(54), + REG_OFFSET_NAME(55), + REG_OFFSET_NAME(56), + REG_OFFSET_NAME(57), + REG_OFFSET_NAME(58), + REG_OFFSET_NAME(59), + REG_OFFSET_NAME(60), + REG_OFFSET_NAME(61), + REG_OFFSET_NAME(62), + REG_OFFSET_NAME(63), + TREG_OFFSET_NAME(0), + TREG_OFFSET_NAME(1), + TREG_OFFSET_NAME(2), + TREG_OFFSET_NAME(3), + TREG_OFFSET_NAME(4), + TREG_OFFSET_NAME(5), + TREG_OFFSET_NAME(6), + TREG_OFFSET_NAME(7), + REGS_OFFSET_END, }; /* diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 32e9d9c..ff3314f 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -51,45 +51,38 @@ enum x86_regset { REGSET_IOPERM32, }; -struct pt_regs_offset { - const char *name; - int offset; -}; - -#define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)} -#define REG_OFFSET_END {.name = NULL, .offset = 0} static const struct pt_regs_offset regoffset_table[] = { #ifdef CONFIG_X86_64 - REG_OFFSET_NAME(r15), - REG_OFFSET_NAME(r14), - REG_OFFSET_NAME(r13), - REG_OFFSET_NAME(r12), - REG_OFFSET_NAME(r11), - REG_OFFSET_NAME(r10), - REG_OFFSET_NAME(r9), - REG_OFFSET_NAME(r8), + REGS_OFFSET_NAME(r15), + REGS_OFFSET_NAME(r14), + REGS_OFFSET_NAME(r13), + REGS_OFFSET_NAME(r12), + REGS_OFFSET_NAME(r11), + REGS_OFFSET_NAME(r10), + REGS_OFFSET_NAME(r9), + REGS_OFFSET_NAME(r8), #endif - REG_OFFSET_NAME(bx), - REG_OFFSET_NAME(cx), - REG_OFFSET_NAME(dx), - REG_OFFSET_NAME(si), - REG_OFFSET_NAME(di), - REG_OFFSET_NAME(bp), - REG_OFFSET_NAME(ax), + REGS_OFFSET_NAME(bx), + REGS_OFFSET_NAME(cx), + REGS_OFFSET_NAME(dx), + REGS_OFFSET_NAME(si), + REGS_OFFSET_NAME(di), + REGS_OFFSET_NAME(bp), + REGS_OFFSET_NAME(ax), #ifdef CONFIG_X86_32 - REG_OFFSET_NAME(ds), - REG_OFFSET_NAME(es), - REG_OFFSET_NAME(fs), - REG_OFFSET_NAME(gs), + REGS_OFFSET_NAME(ds), + REGS_OFFSET_NAME(es), + REGS_OFFSET_NAME(fs), + REGS_OFFSET_NAME(gs), #endif - REG_OFFSET_NAME(orig_ax), - REG_OFFSET_NAME(ip), - REG_OFFSET_NAME(cs), - REG_OFFSET_NAME(flags), - REG_OFFSET_NAME(sp), - REG_OFFSET_NAME(ss), - REG_OFFSET_END, + REGS_OFFSET_NAME(orig_ax), + REGS_OFFSET_NAME(ip), + REGS_OFFSET_NAME(cs), + REGS_OFFSET_NAME(flags), + REGS_OFFSET_NAME(sp), + REGS_OFFSET_NAME(ss), + REGS_OFFSET_END, }; /** diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 504c98a..4e1c6fd 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -406,4 +406,16 @@ extern int task_current_syscall(struct task_struct *target, long *callno, unsigned long args[6], unsigned int maxargs, unsigned long *sp, unsigned long *pc); +#ifdef CONFIG_HAVE_REGS_AND_STACK_ACCESS_API + +#define REGS_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)} +#define REGS_OFFSET_END {.name = NULL, .offset = 0} + +struct pt_regs_offset { + const char *name; + int offset; +}; + +#endif /* CONFIG_HAVE_REGS_AND_STACK_ACCESS_API */ + #endif