Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Anshuman Khandual and committed by
Michael Ellerman
cf89d4e1 fa439810

+76
+1
arch/powerpc/include/uapi/asm/elf.h
··· 94 94 #define ELF_NVMX 34 /* includes all vector registers */ 95 95 #define ELF_NVSX 32 /* includes all VSX registers */ 96 96 #define ELF_NTMSPRREG 3 /* include tfhar, tfiar, texasr */ 97 + #define ELF_NEBB 3 /* includes ebbrr, ebbhr, bescr */ 97 98 98 99 typedef unsigned long elf_greg_t64; 99 100 typedef elf_greg_t64 elf_gregset_t64[ELF_NGREG];
+75
arch/powerpc/kernel/ptrace.c
··· 1760 1760 &target->thread.tar, 0, sizeof(u64)); 1761 1761 return ret; 1762 1762 } 1763 + 1764 + static 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 + 1776 + static 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 + 1795 + static 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 1827 #endif 1764 1828 /* 1765 1829 * These are our native regset flavors. ··· 1856 1792 #endif 1857 1793 #ifdef CONFIG_PPC_BOOK3S_64 1858 1794 REGSET_TAR, /* TAR register */ 1795 + REGSET_EBB, /* EBB registers */ 1859 1796 #endif 1860 1797 }; 1861 1798 ··· 1951 1886 .core_note_type = NT_PPC_TAR, .n = 1, 1952 1887 .size = sizeof(u64), .align = sizeof(u64), 1953 1888 .get = tar_get, .set = tar_set 1889 + }, 1890 + [REGSET_EBB] = { 1891 + .core_note_type = NT_PPC_EBB, .n = ELF_NEBB, 1892 + .size = sizeof(u64), .align = sizeof(u64), 1893 + .active = ebb_active, .get = ebb_get, .set = ebb_set 1954 1894 }, 1955 1895 #endif 1956 1896 }; ··· 2242 2172 .core_note_type = NT_PPC_TAR, .n = 1, 2243 2173 .size = sizeof(u64), .align = sizeof(u64), 2244 2174 .get = tar_get, .set = tar_set 2175 + }, 2176 + [REGSET_EBB] = { 2177 + .core_note_type = NT_PPC_EBB, .n = ELF_NEBB, 2178 + .size = sizeof(u64), .align = sizeof(u64), 2179 + .active = ebb_active, .get = ebb_get, .set = ebb_set 2245 2180 }, 2246 2181 #endif 2247 2182 };