x86/ptrace changes for v2.6.34
Subsystems (4)
Linus,
Please pull the latest x86-ptrace-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip.git x86-ptrace-for-linus
Seen and acked by Roland.
out-of-topic modifications in x86-ptrace-for-linus:
---------------------------------------------------arch/parisc/Kconfig # 5e6dbc2: parisc: Disable CONFIG_HAVE_ARCH_include/linux/elf.h # 2225a12: ptrace: Add support for generic P
# 5b3efd5: x86, ptrace: regset extensions toinclude/linux/ptrace.h # c6a0dd7: ptrace: Fix ptrace_regset() comme
# 2225a12: ptrace: Add support for generic Pkernel/ptrace.c # c6a0dd7: ptrace: Fix ptrace_regset() comme
# 2225a12: ptrace: Add support for generic P
Thanks,
Ingo
------------------>
Roland McGrath (1):
parisc: Disable CONFIG_HAVE_ARCH_TRACEHOOK
Suresh Siddha (5):
x86, ptrace: regset extensions to support xstate
ptrace: Add support for generic PTRACE_GETREGSET/PTRACE_SETREGSET
ptrace: Fix ptrace_regset() comments and diagnose errors specifically x86, ptrace: Simplify xstateregs_get()
x86, ptrace: Remove set_stopped_child_used_math() in [x]fpregs_set
arch/parisc/Kconfig | 1 - arch/x86/include/asm/i387.h | 12 +++++- arch/x86/include/asm/user.h | 58 +++++++++++++++++++++++++++ arch/x86/include/asm/xsave.h | 2 + arch/x86/kernel/i387.c | 71 ++++++++++++++++++++++++++++++++-- arch/x86/kernel/ptrace.c | 34 +++++++++++++++- arch/x86/kernel/xsave.c | 1 + include/linux/elf.h | 7 +++- include/linux/ptrace.h | 20 +++++++++ kernel/ptrace.c | 88 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 284 insertions(+), 10 deletions(-)
arch/parisc/Kconfig +0 -1
@@ -18,7 +18,6 @@ config PARISC select BUG select HAVE_PERF_EVENTS select GENERIC_ATOMIC64 if !64BIT - select HAVE_ARCH_TRACEHOOK help The PA-RISC microprocessor is designed by Hewlett-Packard and used in many of their workstations & servers (HP9000 700 and 800 series,
arch/x86/include/asm/i387.h +10 -2
@@ -33,8 +33,16 @@ extern void init_thread_xstate(void);extern int dump_fpu (struct pt_regs *,struct user_i387_struct *);extern user_regset_active_fn fpregs_active, xfpregs_active; -extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get; -extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set; +extern user_regset_get_fn fpregs_get, xfpregs_get, fpregs_soft_get, + xstateregs_get; +extern user_regset_set_fn fpregs_set, xfpregs_set, fpregs_soft_set, + xstateregs_set; + +/* +* xstateregs_active == fpregs_active. Please refer to the comment +* at the definition of fpregs_active. +*/ +#define xstateregs_active fpregs_activeextern struct _fpx_sw_bytes fx_sw_reserved;#ifdef CONFIG_IA32_EMULATION
arch/x86/include/asm/user.h +58 -0
63 lines not on this page · raw message
arch/x86/include/asm/xsave.h +2 -0
@@ -27,9 +27,11 @@extern unsigned int xstate_size;extern u64 pcntxt_mask;extern struct xsave_struct *init_xstate_buf; +extern u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS ];extern void xsave_cntxt_init (void );extern void xsave_init (void ); +extern void update_regset_xstate_info (unsigned int size,u64 xstate_mask);extern int init_fpu (struct task_struct *child); extern int check_for_xstate(struct i387_fxsave_struct __user *buf, void __user *fpstate,
arch/x86/kernel/i387.c +67 -4
95 lines not on this page · raw message
arch/x86/kernel/ptrace.c +32 -2
@@ -48,6 +48,7 @@ enum x86_regset {REGSET_FP ,REGSET_XFP ,REGSET_IOPERM64 =REGSET_XFP , +REGSET_XSTATE ,REGSET_TLS , REGSET_IOPERM32, };
@@ -1584,7 +1585,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, #ifdef CONFIG_X86_64 -static const struct user_regset x86_64_regsets[] = { +static struct user_regset x86_64_regsets[] __read_mostly = { [REGSET_GENERAL] = { .core_note_type = NT_PRSTATUS, .n = sizeof(struct user_regs_struct) / sizeof(long),
@@ -1597,6 +1598,12 @@ static const struct user_regset x86_64_regsets[] = { .size = sizeof(long), .align = sizeof(long), .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set }, + [REGSET_XSTATE] = { + .core_note_type = NT_X86_XSTATE, + .size = sizeof(u64), .align = sizeof(u64), + .active = xstateregs_active, .get = xstateregs_get, + .set = xstateregs_set + }, [REGSET_IOPERM64] = { .core_note_type = NT_386_IOPERM, .n = IO_BITMAP_LONGS,
@@ -1622,7 +1629,7 @@ static const struct user_regset_view user_x86_64_view = {#endif /* CONFIG_X86_64 */ #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION -static const struct user_regset x86_32_regsets[] = { +static struct user_regset x86_32_regsets[] __read_mostly = { [REGSET_GENERAL] = { .core_note_type = NT_PRSTATUS, .n = sizeof(struct user_regs_struct32) / sizeof(u32),
@@ -1641,6 +1648,12 @@ static const struct user_regset x86_32_regsets[] = { .size = sizeof(u32), .align = sizeof(u32), .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set }, + [REGSET_XSTATE] = { + .core_note_type = NT_X86_XSTATE, + .size = sizeof(u64), .align = sizeof(u64), + .active = xstateregs_active, .get = xstateregs_get, + .set = xstateregs_set + }, [REGSET_TLS] = { .core_note_type = NT_386_TLS, .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
@@ -1663,6 +1676,23 @@ static const struct user_regset_view user_x86_32_view = { };#endif +/* +* This represents bytes 464..511 in the memory layout exported through +* the REGSET_XSTATE interface. +*/ +u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS ]; + +void update_regset_xstate_info (unsigned int size,u64 xstate_mask) +{ +#ifdef CONFIG_X86_64 + x86_64_regsets[REGSET_XSTATE ].n = size /sizeof (u64); +#endif +#if definedCONFIG_X86_32 || definedCONFIG_IA32_EMULATION + x86_32_regsets[REGSET_XSTATE ].n = size /sizeof (u64); +#endif + xstate_fx_sw_bytes[USER_XSTATE_XCR0_WORD ] = xstate_mask; +} +const struct user_regset_view *task_user_regset_view (struct task_struct *task) {#ifdef CONFIG_IA32_EMULATION
arch/x86/kernel/xsave.c +1 -0
@@ -337,6 +337,7 @@ void __ref xsave_cntxt_init(void)cpuid_count (0xd ,0 , &eax, &ebx, &ecx, &edx); xstate_size = ebx; +update_regset_xstate_info (xstate_size, pcntxt_mask);prepare_fx_sw_frame ();setup_xstate_init ();
include/linux/elf.h +6 -1
@@ -349,7 +349,11 @@ typedef struct elf64_shdr {#define ELF_OSABI ELFOSABI_NONE#endif -/* Notes used in ET_CORE */ +/* +* Notes used in ET_CORE. Architectures export some of the arch register sets +* using the corresponding note types via the PTRACE_GETREGSET and +* PTRACE_SETREGSET requests. +*/ #define NT_PRSTATUS 1#define NT_PRFPREG 2#define NT_PRPSINFO 3
@@ -361,6 +365,7 @@ typedef struct elf64_shdr {#define NT_PPC_VSX 0x102/* PowerPC VSX registers */ #define NT_386_TLS 0x200/* i386 TLS slots (struct user_desc) */ #define NT_386_IOPERM 0x201/* x86 io permission bitmap (1=deny) */ +#define NT_X86_XSTATE 0x202/* x86 extended state using xsave */ #define NT_S390_HIGH_GPRS 0x300/* s390 upper register halves */
include/linux/ptrace.h +20 -0
@@ -27,6 +27,26 @@#define PTRACE_GETSIGINFO 0x4202#define PTRACE_SETSIGINFO 0x4203 +/* +* Generic ptrace interface that exports the architecture specific regsets +* using the corresponding NT_* types (which are also used in the core dump). +* Please note that the NT_PRSTATUS note type in a core dump contains a full +* 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the +* elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the +* other user_regset flavors, the user_regset layout and the ELF core dump note +* payload are exactly the same layout. +* +* This interface usage is as follows: +* struct iovec iov = { buf, len}; +* +* ret = ptrace(PTRACE_GETREGSET/PTRACE_SETREGSET, pid, NT_XXX_TYPE, &iov); +* +* On the successful completion, iov.len will be updated by the kernel, +* specifying how much the kernel has written/read to/from the user's iov.buf. +*/ +#define PTRACE_GETREGSET 0x4204 +#define PTRACE_SETREGSET 0x4205 +/* options set using PTRACE_SETOPTIONS */ #define PTRACE_O_TRACESYSGOOD 0x00000001#define PTRACE_O_TRACEFORK 0x00000002
kernel/ptrace.c +88 -0
112 lines not on this page · raw message