diff options
author | Anshuman Khandual <khandual@linux.vnet.ibm.com> | 2016-07-27 22:57:42 -0400 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2016-07-31 21:15:22 -0400 |
commit | fa439810cc1b3c927ec24ede17d02467e1b143a1 (patch) | |
tree | 1b91445dba993ea2538d9ce4881b93ee4572ea4a | |
parent | c45dc9003a0722fdebf603cb63033046a70d24cd (diff) |
powerpc/ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR
This patch enables support for running TAR, PPR, DSCR registers
related ELF core notes NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR based
ptrace requests through PTRACE_GETREGSET, PTRACE_SETREGSET calls.
This is achieved through adding three new register sets REGSET_TAR,
REGSET_PPR, REGSET_DSCR in powerpc corresponding to the ELF core
note sections added in this regad. It implements the get, set and
active functions for all these 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/kernel/ptrace.c | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index a81e2d7cbdb9..a1e166ae4b14 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c | |||
@@ -1689,6 +1689,78 @@ static int tm_dscr_set(struct task_struct *target, | |||
1689 | } | 1689 | } |
1690 | #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ | 1690 | #endif /* CONFIG_PPC_TRANSACTIONAL_MEM */ |
1691 | 1691 | ||
1692 | #ifdef CONFIG_PPC64 | ||
1693 | static int ppr_get(struct task_struct *target, | ||
1694 | const struct user_regset *regset, | ||
1695 | unsigned int pos, unsigned int count, | ||
1696 | void *kbuf, void __user *ubuf) | ||
1697 | { | ||
1698 | int ret; | ||
1699 | |||
1700 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, | ||
1701 | &target->thread.ppr, 0, sizeof(u64)); | ||
1702 | return ret; | ||
1703 | } | ||
1704 | |||
1705 | static int ppr_set(struct task_struct *target, | ||
1706 | const struct user_regset *regset, | ||
1707 | unsigned int pos, unsigned int count, | ||
1708 | const void *kbuf, const void __user *ubuf) | ||
1709 | { | ||
1710 | int ret; | ||
1711 | |||
1712 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
1713 | &target->thread.ppr, 0, sizeof(u64)); | ||
1714 | return ret; | ||
1715 | } | ||
1716 | |||
1717 | static int dscr_get(struct task_struct *target, | ||
1718 | const struct user_regset *regset, | ||
1719 | unsigned int pos, unsigned int count, | ||
1720 | void *kbuf, void __user *ubuf) | ||
1721 | { | ||
1722 | int ret; | ||
1723 | |||
1724 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, | ||
1725 | &target->thread.dscr, 0, sizeof(u64)); | ||
1726 | return ret; | ||
1727 | } | ||
1728 | static int dscr_set(struct task_struct *target, | ||
1729 | const struct user_regset *regset, | ||
1730 | unsigned int pos, unsigned int count, | ||
1731 | const void *kbuf, const void __user *ubuf) | ||
1732 | { | ||
1733 | int ret; | ||
1734 | |||
1735 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
1736 | &target->thread.dscr, 0, sizeof(u64)); | ||
1737 | return ret; | ||
1738 | } | ||
1739 | #endif | ||
1740 | #ifdef CONFIG_PPC_BOOK3S_64 | ||
1741 | static int tar_get(struct task_struct *target, | ||
1742 | const struct user_regset *regset, | ||
1743 | unsigned int pos, unsigned int count, | ||
1744 | void *kbuf, void __user *ubuf) | ||
1745 | { | ||
1746 | int ret; | ||
1747 | |||
1748 | ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, | ||
1749 | &target->thread.tar, 0, sizeof(u64)); | ||
1750 | return ret; | ||
1751 | } | ||
1752 | static int tar_set(struct task_struct *target, | ||
1753 | const struct user_regset *regset, | ||
1754 | unsigned int pos, unsigned int count, | ||
1755 | const void *kbuf, const void __user *ubuf) | ||
1756 | { | ||
1757 | int ret; | ||
1758 | |||
1759 | ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, | ||
1760 | &target->thread.tar, 0, sizeof(u64)); | ||
1761 | return ret; | ||
1762 | } | ||
1763 | #endif | ||
1692 | /* | 1764 | /* |
1693 | * These are our native regset flavors. | 1765 | * These are our native regset flavors. |
1694 | */ | 1766 | */ |
@@ -1714,6 +1786,13 @@ enum powerpc_regset { | |||
1714 | REGSET_TM_CPPR, /* TM checkpointed PPR register */ | 1786 | REGSET_TM_CPPR, /* TM checkpointed PPR register */ |
1715 | REGSET_TM_CDSCR, /* TM checkpointed DSCR register */ | 1787 | REGSET_TM_CDSCR, /* TM checkpointed DSCR register */ |
1716 | #endif | 1788 | #endif |
1789 | #ifdef CONFIG_PPC64 | ||
1790 | REGSET_PPR, /* PPR register */ | ||
1791 | REGSET_DSCR, /* DSCR register */ | ||
1792 | #endif | ||
1793 | #ifdef CONFIG_PPC_BOOK3S_64 | ||
1794 | REGSET_TAR, /* TAR register */ | ||
1795 | #endif | ||
1717 | }; | 1796 | }; |
1718 | 1797 | ||
1719 | static const struct user_regset native_regsets[] = { | 1798 | static const struct user_regset native_regsets[] = { |
@@ -1790,6 +1869,25 @@ static const struct user_regset native_regsets[] = { | |||
1790 | .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set | 1869 | .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set |
1791 | }, | 1870 | }, |
1792 | #endif | 1871 | #endif |
1872 | #ifdef CONFIG_PPC64 | ||
1873 | [REGSET_PPR] = { | ||
1874 | .core_note_type = NT_PPC_PPR, .n = 1, | ||
1875 | .size = sizeof(u64), .align = sizeof(u64), | ||
1876 | .get = ppr_get, .set = ppr_set | ||
1877 | }, | ||
1878 | [REGSET_DSCR] = { | ||
1879 | .core_note_type = NT_PPC_DSCR, .n = 1, | ||
1880 | .size = sizeof(u64), .align = sizeof(u64), | ||
1881 | .get = dscr_get, .set = dscr_set | ||
1882 | }, | ||
1883 | #endif | ||
1884 | #ifdef CONFIG_PPC_BOOK3S_64 | ||
1885 | [REGSET_TAR] = { | ||
1886 | .core_note_type = NT_PPC_TAR, .n = 1, | ||
1887 | .size = sizeof(u64), .align = sizeof(u64), | ||
1888 | .get = tar_get, .set = tar_set | ||
1889 | }, | ||
1890 | #endif | ||
1793 | }; | 1891 | }; |
1794 | 1892 | ||
1795 | static const struct user_regset_view user_ppc_native_view = { | 1893 | static const struct user_regset_view user_ppc_native_view = { |
@@ -2057,6 +2155,25 @@ static const struct user_regset compat_regsets[] = { | |||
2057 | .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set | 2155 | .active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set |
2058 | }, | 2156 | }, |
2059 | #endif | 2157 | #endif |
2158 | #ifdef CONFIG_PPC64 | ||
2159 | [REGSET_PPR] = { | ||
2160 | .core_note_type = NT_PPC_PPR, .n = 1, | ||
2161 | .size = sizeof(u64), .align = sizeof(u64), | ||
2162 | .get = ppr_get, .set = ppr_set | ||
2163 | }, | ||
2164 | [REGSET_DSCR] = { | ||
2165 | .core_note_type = NT_PPC_DSCR, .n = 1, | ||
2166 | .size = sizeof(u64), .align = sizeof(u64), | ||
2167 | .get = dscr_get, .set = dscr_set | ||
2168 | }, | ||
2169 | #endif | ||
2170 | #ifdef CONFIG_PPC_BOOK3S_64 | ||
2171 | [REGSET_TAR] = { | ||
2172 | .core_note_type = NT_PPC_TAR, .n = 1, | ||
2173 | .size = sizeof(u64), .align = sizeof(u64), | ||
2174 | .get = tar_get, .set = tar_set | ||
2175 | }, | ||
2176 | #endif | ||
2060 | }; | 2177 | }; |
2061 | 2178 | ||
2062 | static const struct user_regset_view user_ppc_compat_view = { | 2179 | static const struct user_regset_view user_ppc_compat_view = { |