Skip to content

Commit e3fdfa3

Browse files
author
Al Viro
committed
[ia64] access_uarea(): don't bother with fpregs_[gs]et()
similar to previous commit... Signed-off-by: Al Viro <[email protected]>
1 parent 6bc4f16 commit e3fdfa3

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

arch/ia64/kernel/ptrace.c

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,6 @@ access_uarea(struct task_struct *child, unsigned long addr,
18111811
unsigned long *data, int write_access)
18121812
{
18131813
unsigned int pos = -1; /* an invalid value */
1814-
int ret;
18151814
unsigned long *ptr, regnum;
18161815

18171816
if ((addr & 0x7) != 0) {
@@ -1843,14 +1842,39 @@ access_uarea(struct task_struct *child, unsigned long addr,
18431842
}
18441843

18451844
if (pos != -1) {
1846-
if (write_access)
1847-
ret = fpregs_set(child, NULL, pos,
1848-
sizeof(unsigned long), data, NULL);
1849-
else
1850-
ret = fpregs_get(child, NULL, pos,
1851-
sizeof(unsigned long), data, NULL);
1852-
if (ret != 0)
1853-
return -1;
1845+
unsigned reg = pos / sizeof(elf_fpreg_t);
1846+
int which_half = (pos / sizeof(unsigned long)) & 1;
1847+
1848+
if (reg < 32) { /* fr2-fr31 */
1849+
struct unw_frame_info info;
1850+
elf_fpreg_t fpreg;
1851+
1852+
memset(&info, 0, sizeof(info));
1853+
unw_init_from_blocked_task(&info, child);
1854+
if (unw_unwind_to_user(&info) < 0)
1855+
return 0;
1856+
1857+
if (unw_get_fr(&info, reg, &fpreg))
1858+
return -1;
1859+
if (write_access) {
1860+
fpreg.u.bits[which_half] = *data;
1861+
if (unw_set_fr(&info, reg, fpreg))
1862+
return -1;
1863+
} else {
1864+
*data = fpreg.u.bits[which_half];
1865+
}
1866+
} else { /* fph */
1867+
elf_fpreg_t *p = &child->thread.fph[reg - 32];
1868+
unsigned long *bits = &p->u.bits[which_half];
1869+
1870+
ia64_sync_fph(child);
1871+
if (write_access)
1872+
*bits = *data;
1873+
else if (child->thread.flags & IA64_THREAD_FPH_VALID)
1874+
*data = *bits;
1875+
else
1876+
*data = 0;
1877+
}
18541878
return 0;
18551879
}
18561880

0 commit comments

Comments
 (0)