aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Safonov <dsafonov@virtuozzo.com>2016-09-05 09:33:06 -0400
committerThomas Gleixner <tglx@linutronix.de>2016-09-14 15:28:10 -0400
commit90954e7b940778478754452f1ec8b23ea9a9ad42 (patch)
tree932c1f7de89b5a216d562677e99ccfd9d4d30300
parent2eefd8789698e89c4a5d610921dc3c1b66e3bd0d (diff)
x86/coredump: Use pr_reg size, rather that TIF_IA32 flag
Killed PR_REG_SIZE and PR_REG_PTR macro as we can get regset size from regset view. I wish I could also kill PRSTATUS_SIZE nicely. Suggested-by: Oleg Nesterov <oleg@redhat.com> Signed-off-by: Dmitry Safonov <dsafonov@virtuozzo.com> Cc: 0x7f454c46@gmail.com Cc: linux-mm@kvack.org Cc: luto@kernel.org Cc: gorcunov@openvz.org Cc: xemul@virtuozzo.com Link: http://lkml.kernel.org/r/20160905133308.28234-5-dsafonov@virtuozzo.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--arch/x86/include/asm/compat.h8
-rw-r--r--fs/binfmt_elf.c23
2 files changed, 12 insertions, 19 deletions
diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
index a18806165fe4..03d269bed941 100644
--- a/arch/x86/include/asm/compat.h
+++ b/arch/x86/include/asm/compat.h
@@ -275,10 +275,10 @@ struct compat_shmid64_ds {
275#ifdef CONFIG_X86_X32_ABI 275#ifdef CONFIG_X86_X32_ABI
276typedef struct user_regs_struct compat_elf_gregset_t; 276typedef struct user_regs_struct compat_elf_gregset_t;
277 277
278#define PR_REG_SIZE(S) (test_thread_flag(TIF_IA32) ? 68 : 216) 278/* Full regset -- prstatus on x32, otherwise on ia32 */
279#define PRSTATUS_SIZE(S) (test_thread_flag(TIF_IA32) ? 144 : 296) 279#define PRSTATUS_SIZE(S, R) (R != sizeof(S.pr_reg) ? 144 : 296)
280#define SET_PR_FPVALID(S,V) \ 280#define SET_PR_FPVALID(S, V, R) \
281 do { *(int *) (((void *) &((S)->pr_reg)) + PR_REG_SIZE(0)) = (V); } \ 281 do { *(int *) (((void *) &((S)->pr_reg)) + R) = (V); } \
282 while (0) 282 while (0)
283 283
284#define COMPAT_USE_64BIT_TIME \ 284#define COMPAT_USE_64BIT_TIME \
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index e5495f37c6ed..2472af2798c7 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -1624,20 +1624,12 @@ static void do_thread_regset_writeback(struct task_struct *task,
1624 regset->writeback(task, regset, 1); 1624 regset->writeback(task, regset, 1);
1625} 1625}
1626 1626
1627#ifndef PR_REG_SIZE
1628#define PR_REG_SIZE(S) sizeof(S)
1629#endif
1630
1631#ifndef PRSTATUS_SIZE 1627#ifndef PRSTATUS_SIZE
1632#define PRSTATUS_SIZE(S) sizeof(S) 1628#define PRSTATUS_SIZE(S, R) sizeof(S)
1633#endif
1634
1635#ifndef PR_REG_PTR
1636#define PR_REG_PTR(S) (&((S)->pr_reg))
1637#endif 1629#endif
1638 1630
1639#ifndef SET_PR_FPVALID 1631#ifndef SET_PR_FPVALID
1640#define SET_PR_FPVALID(S, V) ((S)->pr_fpvalid = (V)) 1632#define SET_PR_FPVALID(S, V, R) ((S)->pr_fpvalid = (V))
1641#endif 1633#endif
1642 1634
1643static int fill_thread_core_info(struct elf_thread_core_info *t, 1635static int fill_thread_core_info(struct elf_thread_core_info *t,
@@ -1645,6 +1637,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
1645 long signr, size_t *total) 1637 long signr, size_t *total)
1646{ 1638{
1647 unsigned int i; 1639 unsigned int i;
1640 unsigned int regset_size = view->regsets[0].n * view->regsets[0].size;
1648 1641
1649 /* 1642 /*
1650 * NT_PRSTATUS is the one special case, because the regset data 1643 * NT_PRSTATUS is the one special case, because the regset data
@@ -1653,12 +1646,11 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
1653 * We assume that regset 0 is NT_PRSTATUS. 1646 * We assume that regset 0 is NT_PRSTATUS.
1654 */ 1647 */
1655 fill_prstatus(&t->prstatus, t->task, signr); 1648 fill_prstatus(&t->prstatus, t->task, signr);
1656 (void) view->regsets[0].get(t->task, &view->regsets[0], 1649 (void) view->regsets[0].get(t->task, &view->regsets[0], 0, regset_size,
1657 0, PR_REG_SIZE(t->prstatus.pr_reg), 1650 &t->prstatus.pr_reg, NULL);
1658 PR_REG_PTR(&t->prstatus), NULL);
1659 1651
1660 fill_note(&t->notes[0], "CORE", NT_PRSTATUS, 1652 fill_note(&t->notes[0], "CORE", NT_PRSTATUS,
1661 PRSTATUS_SIZE(t->prstatus), &t->prstatus); 1653 PRSTATUS_SIZE(t->prstatus, regset_size), &t->prstatus);
1662 *total += notesize(&t->notes[0]); 1654 *total += notesize(&t->notes[0]);
1663 1655
1664 do_thread_regset_writeback(t->task, &view->regsets[0]); 1656 do_thread_regset_writeback(t->task, &view->regsets[0]);
@@ -1688,7 +1680,8 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
1688 regset->core_note_type, 1680 regset->core_note_type,
1689 size, data); 1681 size, data);
1690 else { 1682 else {
1691 SET_PR_FPVALID(&t->prstatus, 1); 1683 SET_PR_FPVALID(&t->prstatus,
1684 1, regset_size);
1692 fill_note(&t->notes[i], "CORE", 1685 fill_note(&t->notes[i], "CORE",
1693 NT_PRFPREG, size, data); 1686 NT_PRFPREG, size, data);
1694 } 1687 }