From patchwork Mon Jul 27 04:39:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 51480 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 0E02A22DA5 for ; Mon, 27 Jul 2015 04:39:43 +0000 (UTC) Received: by lafd3 with SMTP id d3sf23473000laf.1 for ; Sun, 26 Jul 2015 21:39:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=MzJW4UxuX/geB2/gTCsMna6F7o7SNqvY0FpUTImb9xg=; b=jQogCzhU7T88zPP1hoDlCyVhd50cLieNG1QRWU3YXHdBz5QVTB+ycbqeNNl5CVeZFn /2pz7mXgoYuoEN++bUSUYUZfJj1vVuq8tZb+RiuNjhwAyv1zfCKuv/v7Zgu0pitIgqEY a9iN5Tk0tC6hmxHyqkz3mca4hbh7H9FGTlHx14Sh5M/LP4lcrDD57l89bzc+ib9x8jVR 2ACvtISDj4dt2+Am/B8F5pBRYUqn21Mpos4Z2Ibv9ycc9eHVIgGlYinbsKYLpcFoEIqL laDMaqm9e8WoSXKvcRHIWdKj3KEoghXka/DkAOnaHfofdTLWrMJgYssqWNj0Nr1Umoc6 r60Q== X-Gm-Message-State: ALoCoQlMpKptVfR3pLz0yiWmJuD+XFq2UlOCCyB+3OdXlr+lF5cIejBfJv57NmYiM/zUrAsbvpbV X-Received: by 10.112.171.41 with SMTP id ar9mr11371985lbc.24.1437971981640; Sun, 26 Jul 2015 21:39:41 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.227 with SMTP id n3ls626891lan.0.gmail; Sun, 26 Jul 2015 21:39:41 -0700 (PDT) X-Received: by 10.152.30.4 with SMTP id o4mr24522084lah.74.1437971981486; Sun, 26 Jul 2015 21:39:41 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id 6si14322477lai.40.2015.07.26.21.39.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 21:39:41 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by lahh5 with SMTP id h5so41624789lah.2 for ; Sun, 26 Jul 2015 21:39:41 -0700 (PDT) X-Received: by 10.112.55.207 with SMTP id u15mr24998573lbp.88.1437971981350; Sun, 26 Jul 2015 21:39:41 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.7.198 with SMTP id l6csp1307872lba; Sun, 26 Jul 2015 21:39:40 -0700 (PDT) X-Received: by 10.55.17.151 with SMTP id 23mr36781837qkr.103.1437971979718; Sun, 26 Jul 2015 21:39:39 -0700 (PDT) Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com. [209.85.220.179]) by mx.google.com with ESMTPS id 143si19639716qhw.9.2015.07.26.21.39.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jul 2015 21:39:39 -0700 (PDT) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.179 as permitted sender) client-ip=209.85.220.179; Received: by qkbm65 with SMTP id m65so35715897qkb.2 for ; Sun, 26 Jul 2015 21:39:39 -0700 (PDT) X-Received: by 10.55.27.9 with SMTP id b9mr37198949qkb.101.1437971979135; Sun, 26 Jul 2015 21:39:39 -0700 (PDT) Received: from localhost.localdomain (pool-72-71-243-249.cncdnh.fast00.myfairpoint.net. [72.71.243.249]) by smtp.googlemail.com with ESMTPSA id 66sm3187178qhy.27.2015.07.26.21.39.37 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 26 Jul 2015 21:39:38 -0700 (PDT) From: David Long To: "H. Peter Anvin" , Andy Lutomirski , Anton Blanchard , Behan Webster , Benjamin Herrenschmidt , Eric Paris , Heiko Carstens , Ingo Molnar , Jan Willeke , Kees Cook , Martin Schwidefsky , Michael Ellerman , Nikolay Borisov , Oleg Nesterov , Paul Mackerras , Richard Kuo , Robert Richter , Roland McGrath , Russell King , Tejun Heo , Thomas Gleixner , Will Deacon , 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, linux390@de.ibm.com, linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: [PATCH v2 1/2] Move the pt_regs_offset struct definition from arch to common include file Date: Mon, 27 Jul 2015 00:39:33 -0400 Message-Id: <1437971974-2434-2-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1437971974-2434-1-git-send-email-dave.long@linaro.org> References: <1437971974-2434-1-git-send-email-dave.long@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: dave.long@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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(-) 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 f21897b..b8f054c 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -52,16 +52,9 @@ #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(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), @@ -96,21 +89,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 a7bc794..2efc6aa 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -53,45 +53,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 987a73a..dbb8df1 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h @@ -383,4 +383,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