Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261837

[PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"

Path csiph.com!goblin3!goblin.stu.neva.ru!sewer!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Palmer Dabbelt <palmer@dabbelt.com>
Newsgroups linux.kernel
Subject [PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus"
Date Tue, 03 Nov 2015 21:00:03 +0100
Message-ID <qqPUn-79Z-39@gated-at.bofh.it> (permalink)
References <q8KT7-3i1-3@gated-at.bofh.it> <qqPKG-76u-7@gated-at.bofh.it>
X-Original-To arnd@arndb.de
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt_com.20150623.gappssmtp.com; s=20150623; h=from:to:to:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:subject :date:message-id:in-reply-to:references; bh=qM2fSWEqjbwtB388B1QTQr/XPUd1T50Jc+hNT0FV/yw=; b=uLQeYPnBPstGvkh7sGCeO/m+Ni6bS1MS9aebEpjmQ4jDk3a0PnOAzi32qlFqfFjljp HPLkIlCGVAWeqAgGuh1I9EZZwJ1rc2lanj6IbvOZpjqnN9GDb0ldTuchUojmGeDxHgUq jcBbxZYiBww8czWU2WCN/dofQU3UhyVHwQ0WdX3g4MC0O/YvWQM001BYUnxCKJ5Q87O8 XZhtgiQvtFUygfkIXr9ijgeZSFAfQJOF/pB6HmEE14EvC1xQ1+pJFCkPOrswAhoDPrM5 6xWLReiOk6MUjfbKcMRn5pehD/3u0qqpMLDRpKij5Hk4zEYKuNS1YW4zt2eMnkmUHkoH gzZA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:to:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc:cc :cc:cc:cc:cc:subject:date:message-id:in-reply-to:references; bh=qM2fSWEqjbwtB388B1QTQr/XPUd1T50Jc+hNT0FV/yw=; b=JDd2G7L1feVIjqjnupqbNUjCuUAGvC9yEaAIoiBwZLfZgM/sBrZb5jEHpIxJgPtNen 8bKRuDZyHDe1xDUaAE1qb7zcVbnb/eWsQssXiytToDNHeKhn4/u69P8dmNI0kjFHoi5g 1l0sPqXoC9NxaLrNsqTLU4jwZSEUawjKqJP6DzhzN06oKxhCCg0HyPmYTGt/FaC8PPLU mieLip+09+NVvpZHmuNi+/W1lDmOFt8oJjlEJwy8rG6xq4GPD6m2+qhgzZjg5S7a2qRx ckN4Dzj20dkPbyARl8Feomfdo8Gq8dAYJwv+q4C8+WL3hyyFEJosm2ms2ouXa9kZGJ/f epuQ==
X-Gm-Message-State ALoCoQkLEx/5J5J+tli40f/tWyv2TtOCAlvwBSDeV6vNpvhZ4UAp8ke9k6WJjqbLIXV2szq/rdKB
X-Received by 10.68.135.132 with SMTP id ps4mr35823188pbb.74.1446580012363; Tue, 03 Nov 2015 11:46:52 -0800 (PST)
X-Mailer git-send-email 2.4.10
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 217
Organization linux.* mail to news gateway
X-Original-Cc viro@zeniv.linux.org.uk
X-Original-Cc ast@plumgrid.com
X-Original-Cc aishchuk@linux.vnet.ibm.com
X-Original-Cc aarcange@redhat.com
X-Original-Cc akpm@linux-foundation.org
X-Original-Cc luto@kernel.org
X-Original-Cc acme@kernel.org
X-Original-Cc bhe@redhat.com
X-Original-Cc 3chas3@gmail.com
X-Original-Cc chris@zankel.net
X-Original-Cc dave@sr71.net
X-Original-Cc dyoung@redhat.com
X-Original-Cc drysdale@google.com
X-Original-Cc davem@davemloft.net
X-Original-Cc ebiederm@xmission.com
X-Original-Cc geoff@infradead.org
X-Original-Cc gregkh@linuxfoundation.org
X-Original-Cc hpa@zytor.com
X-Original-Cc mingo@kernel.org
X-Original-Cc iulia.manda21@gmail.com
X-Original-Cc plagnioj@jcrosoft.com
X-Original-Cc jikos@kernel.org
X-Original-Cc josh@joshtriplett.org
X-Original-Cc kexec@lists.infradead.org
X-Original-Cc linux-api@vger.kernel.org
X-Original-Cc linux-arch@vger.kernel.org
X-Original-Cc linux-fsdevel@vger.kernel.org
X-Original-Cc linux-kernel@vger.kernel.org
X-Original-Cc linux-xtensa@linux-xtensa.org
X-Original-Cc mathieu.desnoyers@efficios.com
X-Original-Cc jcmvbkbc@gmail.com
X-Original-Cc paulmck@linux.vnet.ibm.com
X-Original-Cc a.p.zijlstra@chello.nl
X-Original-Cc tglx@linutronix.de
X-Original-Cc tomi.valkeinen@ti.com
X-Original-Cc vgoyal@redhat.com
X-Original-Cc x86@kernel.org
X-Original-Cc Palmer Dabbelt <palmer@dabbelt.com>
X-Original-Date Tue, 3 Nov 2015 11:46:26 -0800
X-Original-Message-ID <1446579994-9937-6-git-send-email-palmer@dabbelt.com>
X-Original-References <1442271047-4908-1-git-send-email-palmer@dabbelt.com> <1446579994-9937-1-git-send-email-palmer@dabbelt.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
X-Original-To dhowells@redhat.com
Xref csiph.com linux.kernel:1261837

Show key headers only | View raw


This is a pretty big change that I haven't tested any, which worries
me a lot.  The general idea here is that "struct elf_prstatus" can be
visible to userspace (from <linux/ptrace.h>)

  "
   Generic ptrace interface that exports the architecture specific
   regsets using the corresponding NT_* types (which are also used in
   the core dump).  Please note that the NT_PRSTATUS note type in a
   core dump contains a full 'struct elf_prstatus'. But the
   user_regset for NT_PRSTATUS contains just the elf_gregset_t that is
   the pr_reg field of 'struct elf_prstatus'. For all the other
   user_regset flavors, the user_regset layout and the ELF core dump
   note payload are exactly the same layout.
  "

so it shouldn't have an "#ifdef CONFIG_" in there.

This splits the structure into two different structures, one still
named "struct elf_prstatus", and one for ELF FDPIC that is named
"struct elf_fdpic_prstatus" -- the idea here is that most users are
standard ELF, so that's the name that didn't change.

I tried to fix all the users of "struct elf_prstatus" that should now
be using "struct elf_fdpic_prstatus".  The only testing I did here was
to build a Blackfin defconfig with "struct elf_prstatus" not defined,
and to build an x86 defconfig with "struct elf_fdpic_prstatus" not
defined.

Note that this fails checkpatch.pl with a complaint about wanting open
braces on the same line as struct definitions.  The existing struct
definitions in this file have the brace a line afterwards, so I'm
going to leave this alone.

Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Reviewed-by: Andrew Waterman <waterman@eecs.berkeley.edu>
Reviewed-by: Albert Ou <aou@eecs.berkeley.edu>
---
 fs/binfmt_elf_fdpic.c        |  6 +++---
 fs/proc/kcore.c              | 16 ++++++++++++++++
 include/linux/kexec.h        |  4 ++++
 include/uapi/linux/elfcore.h | 37 +++++++++++++++++++++++++++++++++++--
 kernel/kexec_core.c          |  4 ++++
 5 files changed, 62 insertions(+), 5 deletions(-)

diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index d3634bf..587bf04 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -1323,7 +1323,7 @@ static inline void fill_note(struct memelfnote *note, const char *name, int type
  * fill up all the fields in prstatus from the given task struct, except
  * registers which need to be filled up separately.
  */
-static void fill_prstatus(struct elf_prstatus *prstatus,
+static void fill_prstatus(struct elf_fdpic_prstatus *prstatus,
 			  struct task_struct *p, long signr)
 {
 	prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
@@ -1406,7 +1406,7 @@ static int fill_psinfo(struct elf_prpsinfo *psinfo, struct task_struct *p,
 struct elf_thread_status
 {
 	struct list_head list;
-	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
@@ -1539,7 +1539,7 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
 	loff_t offset = 0, dataoff;
 	int numnote;
 	struct memelfnote *notes = NULL;
-	struct elf_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
+	struct elf_fdpic_prstatus *prstatus = NULL;	/* NT_PRSTATUS */
 	struct elf_prpsinfo *psinfo = NULL;	/* NT_PRPSINFO */
  	LIST_HEAD(thread_list);
  	struct list_head *t;
diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index 92e6726..b1edd77e 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -90,7 +90,11 @@ static size_t get_kcore_size(int *nphdr, size_t *elf_buflen)
 			(*nphdr + 2)*sizeof(struct elf_phdr) + 
 			3 * ((sizeof(struct elf_note)) +
 			     roundup(sizeof(CORE_STR), 4)) +
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+			roundup(sizeof(struct elf_fdpic_prstatus), 4) +
+#else
 			roundup(sizeof(struct elf_prstatus), 4) +
+#endif
 			roundup(sizeof(struct elf_prpsinfo), 4) +
 			roundup(arch_task_struct_size, 4);
 	*elf_buflen = PAGE_ALIGN(*elf_buflen);
@@ -318,7 +322,11 @@ static char *storenote(struct memelfnote *men, char *bufp)
  */
 static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;	/* NT_PRSTATUS */
+#else
 	struct elf_prstatus prstatus;	/* NT_PRSTATUS */
+#endif
 	struct elf_prpsinfo prpsinfo;	/* NT_PRPSINFO */
 	struct elf_phdr *nhdr, *phdr;
 	struct elfhdr *elf;
@@ -387,10 +395,18 @@ static void elf_kcore_store_hdr(char *bufp, int nphdr, int dataoff)
 	/* set up the process status */
 	notes[0].name = CORE_STR;
 	notes[0].type = NT_PRSTATUS;
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	notes[0].datasz = sizeof(struct elf_fdpic_prstatus);
+#else
 	notes[0].datasz = sizeof(struct elf_prstatus);
+#endif
 	notes[0].data = &prstatus;
 
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	memset(&prstatus, 0, sizeof(struct elf_fdpic_prstatus));
+#else
 	memset(&prstatus, 0, sizeof(struct elf_prstatus));
+#endif
 
 	nhdr->p_filesz	= notesize(&notes[0]);
 	bufp = storenote(&notes[0], bufp);
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index d140b1e..d9196cc 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -63,7 +63,11 @@
 #define KEXEC_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4)
 #define KEXEC_CORE_NOTE_NAME "CORE"
 #define KEXEC_CORE_NOTE_NAME_BYTES ALIGN(sizeof(KEXEC_CORE_NOTE_NAME), 4)
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+#define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_fdpic_prstatus), 4)
+#else
 #define KEXEC_CORE_NOTE_DESC_BYTES ALIGN(sizeof(struct elf_prstatus), 4)
+#endif
 /*
  * The per-cpu notes area is a list of notes terminated by a "NULL"
  * note header.  For kdump, the code in vmcore.c runs in the context
diff --git a/include/uapi/linux/elfcore.h b/include/uapi/linux/elfcore.h
index 569737c..697c52d 100644
--- a/include/uapi/linux/elfcore.h
+++ b/include/uapi/linux/elfcore.h
@@ -60,7 +60,40 @@ struct elf_prstatus
 	long	pr_instr;		/* Current instruction */
 #endif
 	elf_gregset_t pr_reg;	/* GP registers */
-#ifdef CONFIG_BINFMT_ELF_FDPIC
+	int pr_fpvalid;		/* True if math co-processor being used.  */
+};
+
+/* Architectures that set CONFIG_BINFMT_ELF_FDPIC use this instead of
+ * "struct elf_prstatus".
+ */
+struct elf_fdpic_prstatus
+{
+#if 0
+	long	pr_flags;	/* XXX Process flags */
+	short	pr_why;		/* XXX Reason for process halt */
+	short	pr_what;	/* XXX More detailed reason */
+#endif
+	struct elf_siginfo pr_info;	/* Info associated with signal */
+	short	pr_cursig;		/* Current signal */
+	unsigned long pr_sigpend;	/* Set of pending signals */
+	unsigned long pr_sighold;	/* Set of held signals */
+#if 0
+	struct sigaltstack pr_altstack;	/* Alternate stack info */
+	struct sigaction pr_action;	/* Signal action for current sig */
+#endif
+	pid_t	pr_pid;
+	pid_t	pr_ppid;
+	pid_t	pr_pgrp;
+	pid_t	pr_sid;
+	struct timeval pr_utime;	/* User time */
+	struct timeval pr_stime;	/* System time */
+	struct timeval pr_cutime;	/* Cumulative user time */
+	struct timeval pr_cstime;	/* Cumulative system time */
+#if 0
+	long	pr_instr;		/* Current instruction */
+#endif
+	elf_gregset_t pr_reg;	/* GP registers */
+
 	/* When using FDPIC, the loadmap addresses need to be communicated
 	 * to GDB in order for GDB to do the necessary relocations.  The
 	 * fields (below) used to communicate this information are placed
@@ -69,7 +102,7 @@ struct elf_prstatus
 	 */
 	unsigned long pr_exec_fdpic_loadmap;
 	unsigned long pr_interp_fdpic_loadmap;
-#endif
+
 	int pr_fpvalid;		/* True if math co-processor being used.  */
 };
 
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 201b453..8d2fc70 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -977,7 +977,11 @@ static void final_note(u32 *buf)
 
 void crash_save_cpu(struct pt_regs *regs, int cpu)
 {
+#ifdef CONFIG_BINFMT_ELF_FDPIC
+	struct elf_fdpic_prstatus prstatus;
+#else
 	struct elf_prstatus prstatus;
+#endif
 	u32 *buf;
 
 	if ((cpu < 0) || (cpu >= nr_cpu_ids))
-- 
2.4.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4] Remove #ifdef CONFIG_* from all userspace headers Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
    Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c kbuild test robot <lkp@intel.com> - 2015-11-03 22:30 +0100
    Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c kbuild test robot <lkp@intel.com> - 2015-11-03 22:40 +0100
    Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c Peter Zijlstra <peterz@infradead.org> - 2015-11-04 12:50 +0100
      Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c Peter Zijlstra <peterz@infradead.org> - 2015-11-04 13:30 +0100
        Re: [PATCH 09/13] Move bp_type_idx to kernel/event/hw_breakpoint.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-07 07:50 +0100
  [PATCH 03/13] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 11/13] Always define MAX_RAW_MINORS as 2**20 in userspace Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
    Re: [PATCH 11/13] Always define MAX_RAW_MINORS as 2**20 in userspace kbuild test robot <lkp@intel.com> - 2015-11-03 21:20 +0100
  [PATCH 13/13] Re-enable and clean up "check_config()" in headers_check.pl Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
    Re: [PATCH 13/13] Re-enable and clean up "check_config()" in  headers_check.pl kbuild test robot <lkp@intel.com> - 2015-11-03 21:30 +0100
    Re: [PATCH 13/13] Re-enable and clean up "check_config()" in  headers_check.pl kbuild test robot <lkp@intel.com> - 2015-11-03 21:30 +0100
  [PATCH 07/13] Make FB_BACKLIGHT_{LEVELS,MAX} always visible Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 02/13] Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 01/13] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 12/13] Remove AT_VECTOR_SIZE_ARCH on x86 Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 08/13] Move MAX_SHARED_LIBS to fs/binfmt_flat.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 20:50 +0100
  [PATCH 06/13] Move ep_take_care_of_epollwakeup() to fs/eventpoll.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 21:00 +0100
  [PATCH 04/13] Always expose MAP_UNINITIALIZED to userspace Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 21:00 +0100
  [PATCH 05/13] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus" Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-03 21:00 +0100
  [PATCH 10/14] Move USE_WCACHING to drivers/block/pktcdvd.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 07/14] Make FB_BACKLIGHT_{LEVELS,MAX} always visible Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 08/14] Move MAX_SHARED_LIBS to fs/binfmt_flat.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 05/14] Split FDPIC "struct elf_prstatus" to "struct elf_fdpic_prstatus" Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 02/14] Use sys_ni.c instead of #ifdef to disable fork on CONFIG_NOMMU Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 11/14] Always define MAX_RAW_MINORS as 2**20 in userspace Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 09/14] Move bp_type_idx to include/linux/hw_breakpoint.h Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 04/14] Always expose MAP_UNINITIALIZED to userspace Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 14/14] Re-enable and clean up "check_config()" in headers_check.pl Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 01/14] Remove #ifdef CONFIG_64BIT from all asm-generic/fcntl.h Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 13/14] Hide CONFIG_PHY_RAM_BASE_ADDRESS from userspace Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 12/14] Remove AT_VECTOR_SIZE_ARCH on x86 Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 03/14] Move COMPAT_ATM_ADDPARTY to net/atm/svc.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH 06/14] Move ep_take_care_of_epollwakeup() to fs/eventpoll.c Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100
  [PATCH v5] Remove #ifdef CONFIG_* from all userspace headers Palmer Dabbelt <palmer@dabbelt.com> - 2015-11-10 02:40 +0100

csiph-web