aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnshuman Khandual <khandual@linux.vnet.ibm.com>2016-07-27 22:57:43 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2016-07-31 21:15:23 -0400
commitcf89d4e1b181bda27a5d52f4afd239ea07e84eb0 (patch)
tree0e3bfda868eb78f5c26d9645a57a53d322f1bedc
parentfa439810cc1b3c927ec24ede17d02467e1b143a1 (diff)
powerpc/ptrace: Enable support for EBB registers
This patch enables support for EBB state registers related ELF core note NT_PPC_EBB based ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls. This is achieved through adding one new register sets REGSET_EBB in powerpc corresponding to the ELF core note sections added in this regard. It also implements the get, set and active functions for this new register sets added. Signed-off-by: Anshuman Khandual <khandual@linux.vnet.ibm.com> Signed-off-by: Simon Guo <wei.guo.simon@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--arch/powerpc/include/uapi/asm/elf.h1
-rw-r--r--arch/powerpc/kernel/ptrace.c75
2 files changed, 76 insertions, 0 deletions
diff --git a/arch/powerpc/include/uapi/asm/elf.h b/arch/powerpc/include/uapi/asm/elf.h
index e703c646163b..8c4d71a59259 100644
--- a/arch/powerpc/include/uapi/asm/elf.h
+++ b/arch/powerpc/include/uapi/asm/elf.h
@@ -94,6 +94,7 @@
94#define ELF_NVMX 34 /* includes all vector registers */ 94#define ELF_NVMX 34 /* includes all vector registers */
95#define ELF_NVSX 32 /* includes all VSX registers */ 95#define ELF_NVSX 32 /* includes all VSX registers */
96#define ELF_NTMSPRREG 3 /* include tfhar, tfiar, texasr */ 96#define ELF_NTMSPRREG 3 /* include tfhar, tfiar, texasr */
97#define ELF_NEBB 3 /* includes ebbrr, ebbhr, bescr */
97 98
98typedef unsigned long elf_greg_t64; 99typedef unsigned long elf_greg_t64;
99typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG]; 100typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index a1e166ae4b14..7942f9c575ef 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -1760,6 +1760,70 @@ static int tar_set(struct task_struct *target,
1760 &target->thread.tar, 0, sizeof(u64)); 1760 &target->thread.tar, 0, sizeof(u64));
1761 return ret; 1761 return ret;
1762} 1762}
1763
1764static int ebb_active(struct task_struct *target,
1765 const struct user_regset *regset)
1766{
1767 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
1768 return -ENODEV;
1769
1770 if (target->thread.used_ebb)
1771 return regset->n;
1772
1773 return 0;
1774}
1775
1776static int ebb_get(struct task_struct *target,
1777 const struct user_regset *regset,
1778 unsigned int pos, unsigned int count,
1779 void *kbuf, void __user *ubuf)
1780{
1781 /* Build tests */
1782 BUILD_BUG_ON(TSO(ebbrr) + sizeof(unsigned long) != TSO(ebbhr));
1783 BUILD_BUG_ON(TSO(ebbhr) + sizeof(unsigned long) != TSO(bescr));
1784
1785 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
1786 return -ENODEV;
1787
1788 if (!target->thread.used_ebb)
1789 return -ENODATA;
1790
1791 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
1792 &target->thread.ebbrr, 0, 3 * sizeof(unsigned long));
1793}
1794
1795static int ebb_set(struct task_struct *target,
1796 const struct user_regset *regset,
1797 unsigned int pos, unsigned int count,
1798 const void *kbuf, const void __user *ubuf)
1799{
1800 int ret = 0;
1801
1802 /* Build tests */
1803 BUILD_BUG_ON(TSO(ebbrr) + sizeof(unsigned long) != TSO(ebbhr));
1804 BUILD_BUG_ON(TSO(ebbhr) + sizeof(unsigned long) != TSO(bescr));
1805
1806 if (!cpu_has_feature(CPU_FTR_ARCH_207S))
1807 return -ENODEV;
1808
1809 if (target->thread.used_ebb)
1810 return -ENODATA;
1811
1812 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
1813 &target->thread.ebbrr, 0, sizeof(unsigned long));
1814
1815 if (!ret)
1816 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
1817 &target->thread.ebbhr, sizeof(unsigned long),
1818 2 * sizeof(unsigned long));
1819
1820 if (!ret)
1821 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
1822 &target->thread.bescr,
1823 2 * sizeof(unsigned long), 3 * sizeof(unsigned long));
1824
1825 return ret;
1826}
1763#endif 1827#endif
1764/* 1828/*
1765 * These are our native regset flavors. 1829 * These are our native regset flavors.
@@ -1792,6 +1856,7 @@ enum powerpc_regset {
1792#endif 1856#endif
1793#ifdef CONFIG_PPC_BOOK3S_64 1857#ifdef CONFIG_PPC_BOOK3S_64
1794 REGSET_TAR, /* TAR register */ 1858 REGSET_TAR, /* TAR register */
1859 REGSET_EBB, /* EBB registers */
1795#endif 1860#endif
1796}; 1861};
1797 1862
@@ -1887,6 +1952,11 @@ static const struct user_regset native_regsets[] = {
1887 .size = sizeof(u64), .align = sizeof(u64), 1952 .size = sizeof(u64), .align = sizeof(u64),
1888 .get = tar_get, .set = tar_set 1953 .get = tar_get, .set = tar_set
1889 }, 1954 },
1955 [REGSET_EBB] = {
1956 .core_note_type = NT_PPC_EBB, .n = ELF_NEBB,
1957 .size = sizeof(u64), .align = sizeof(u64),
1958 .active = ebb_active, .get = ebb_get, .set = ebb_set
1959 },
1890#endif 1960#endif
1891}; 1961};
1892 1962
@@ -2173,6 +2243,11 @@ static const struct user_regset compat_regsets[] = {
2173 .size = sizeof(u64), .align = sizeof(u64), 2243 .size = sizeof(u64), .align = sizeof(u64),
2174 .get = tar_get, .set = tar_set 2244 .get = tar_get, .set = tar_set
2175 }, 2245 },
2246 [REGSET_EBB] = {
2247 .core_note_type = NT_PPC_EBB, .n = ELF_NEBB,
2248 .size = sizeof(u64), .align = sizeof(u64),
2249 .active = ebb_active, .get = ebb_get, .set = ebb_set
2250 },
2176#endif 2251#endif
2177}; 2252};
2178 2253