Skip to content

Commit fa43981

Browse files
Anshuman Khandualmpe
Anshuman Khandual
authored andcommitted
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 <[email protected]> Signed-off-by: Simon Guo <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent c45dc90 commit fa43981

File tree

1 file changed

+117
-0
lines changed

1 file changed

+117
-0
lines changed

arch/powerpc/kernel/ptrace.c

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,78 @@ static int tm_dscr_set(struct task_struct *target,
16891689
}
16901690
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
16911691

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
16921764
/*
16931765
* These are our native regset flavors.
16941766
*/
@@ -1714,6 +1786,13 @@ enum powerpc_regset {
17141786
REGSET_TM_CPPR, /* TM checkpointed PPR register */
17151787
REGSET_TM_CDSCR, /* TM checkpointed DSCR register */
17161788
#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
17171796
};
17181797

17191798
static const struct user_regset native_regsets[] = {
@@ -1790,6 +1869,25 @@ static const struct user_regset native_regsets[] = {
17901869
.active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set
17911870
},
17921871
#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
17931891
};
17941892

17951893
static const struct user_regset_view user_ppc_native_view = {
@@ -2057,6 +2155,25 @@ static const struct user_regset compat_regsets[] = {
20572155
.active = tm_dscr_active, .get = tm_dscr_get, .set = tm_dscr_set
20582156
},
20592157
#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
20602177
};
20612178

20622179
static const struct user_regset_view user_ppc_compat_view = {

0 commit comments

Comments
 (0)