x86, 32-bit: trim memory not covered by wb mtrrs
[deliverable/linux.git] / arch / x86 / kernel / ptrace.c
index ef349ff170a7d7860160f647ffb6f46eb0a0b4bc..96286df1bb817fff6e314fead079d40c0cb29f6c 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/ptrace.h>
 #include <linux/regset.h>
 #include <linux/user.h>
+#include <linux/elf.h>
 #include <linux/security.h>
 #include <linux/audit.h>
 #include <linux/seccomp.h>
 #include <asm/proto.h>
 #include <asm/ds.h>
 
+#include "tls.h"
+
+enum x86_regset {
+       REGSET_GENERAL,
+       REGSET_FP,
+       REGSET_XFP,
+       REGSET_TLS,
+};
 
 /*
  * does not yet catch signals sent when the child dies.
@@ -549,7 +558,7 @@ static int ptrace_bts_read_record(struct task_struct *child,
 
        retval = ds_read_bts((void *)child->thread.ds_area_msr,
                             bts_index, &ret);
-       if (retval)
+       if (retval < 0)
                return retval;
 
        if (copy_to_user(out, &ret, sizeof(ret)))
@@ -582,6 +591,7 @@ static int ptrace_bts_clear(struct task_struct *child)
 }
 
 static int ptrace_bts_drain(struct task_struct *child,
+                           long size,
                            struct bts_struct __user *out)
 {
        int end, i;
@@ -594,6 +604,9 @@ static int ptrace_bts_drain(struct task_struct *child,
        if (end <= 0)
                return end;
 
+       if (size < (end * sizeof(struct bts_struct)))
+               return -EIO;
+
        for (i = 0; i < end; i++, out++) {
                struct bts_struct ret;
                int retval;
@@ -608,20 +621,95 @@ static int ptrace_bts_drain(struct task_struct *child,
 
        ds_clear(ds);
 
-       return i;
+       return end;
+}
+
+static int ptrace_bts_realloc(struct task_struct *child,
+                             int size, int reduce_size)
+{
+       unsigned long rlim, vm;
+       int ret, old_size;
+
+       if (size < 0)
+               return -EINVAL;
+
+       old_size = ds_get_bts_size((void *)child->thread.ds_area_msr);
+       if (old_size < 0)
+               return old_size;
+
+       ret = ds_free((void **)&child->thread.ds_area_msr);
+       if (ret < 0)
+               goto out;
+
+       size >>= PAGE_SHIFT;
+       old_size >>= PAGE_SHIFT;
+
+       current->mm->total_vm  -= old_size;
+       current->mm->locked_vm -= old_size;
+
+       if (size == 0)
+               goto out;
+
+       rlim = current->signal->rlim[RLIMIT_AS].rlim_cur >> PAGE_SHIFT;
+       vm = current->mm->total_vm  + size;
+       if (rlim < vm) {
+               ret = -ENOMEM;
+
+               if (!reduce_size)
+                       goto out;
+
+               size = rlim - current->mm->total_vm;
+               if (size <= 0)
+                       goto out;
+       }
+
+       rlim = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur >> PAGE_SHIFT;
+       vm = current->mm->locked_vm  + size;
+       if (rlim < vm) {
+               ret = -ENOMEM;
+
+               if (!reduce_size)
+                       goto out;
+
+               size = rlim - current->mm->locked_vm;
+               if (size <= 0)
+                       goto out;
+       }
+
+       ret = ds_allocate((void **)&child->thread.ds_area_msr,
+                         size << PAGE_SHIFT);
+       if (ret < 0)
+               goto out;
+
+       current->mm->total_vm  += size;
+       current->mm->locked_vm += size;
+
+out:
+       if (child->thread.ds_area_msr)
+               set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
+       else
+               clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
+
+       return ret;
 }
 
 static int ptrace_bts_config(struct task_struct *child,
+                            long cfg_size,
                             const struct ptrace_bts_config __user *ucfg)
 {
        struct ptrace_bts_config cfg;
-       unsigned long debugctl_mask;
-       int bts_size, ret;
+       int bts_size, ret = 0;
        void *ds;
 
+       if (cfg_size < sizeof(cfg))
+               return -EIO;
+
        if (copy_from_user(&cfg, ucfg, sizeof(cfg)))
                return -EFAULT;
 
+       if ((int)cfg.size < 0)
+               return -EINVAL;
+
        bts_size = 0;
        ds = (void *)child->thread.ds_area_msr;
        if (ds) {
@@ -629,67 +717,60 @@ static int ptrace_bts_config(struct task_struct *child,
                if (bts_size < 0)
                        return bts_size;
        }
+       cfg.size = PAGE_ALIGN(cfg.size);
 
        if (bts_size != cfg.size) {
-               ret = ds_free((void **)&child->thread.ds_area_msr);
+               ret = ptrace_bts_realloc(child, cfg.size,
+                                        cfg.flags & PTRACE_BTS_O_CUT_SIZE);
                if (ret < 0)
-                       return ret;
+                       goto errout;
 
-               if (cfg.size > 0)
-                       ret = ds_allocate((void **)&child->thread.ds_area_msr,
-                                         cfg.size);
                ds = (void *)child->thread.ds_area_msr;
-               if (ds)
-                       set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
-               else
-                       clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
-
-               if (ret < 0)
-                       return ret;
-
-               bts_size = ds_get_bts_size(ds);
-               if (bts_size <= 0)
-                       return bts_size;
-       }
-
-       if (ds) {
-               if (cfg.flags & PTRACE_BTS_O_SIGNAL) {
-                       ret = ds_set_overflow(ds, DS_O_SIGNAL);
-               } else {
-                       ret = ds_set_overflow(ds, DS_O_WRAP);
-               }
-               if (ret < 0)
-                       return ret;
        }
 
-       debugctl_mask = ds_debugctl_mask();
-       if (ds && (cfg.flags & PTRACE_BTS_O_TRACE)) {
-               child->thread.debugctlmsr |= debugctl_mask;
-               set_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
-       } else {
-               /* there is no way for us to check whether we 'own'
-                * the respective bits in the DEBUGCTL MSR, we're
-                * about to clear */
-               child->thread.debugctlmsr &= ~debugctl_mask;
+       if (cfg.flags & PTRACE_BTS_O_SIGNAL)
+               ret = ds_set_overflow(ds, DS_O_SIGNAL);
+       else
+               ret = ds_set_overflow(ds, DS_O_WRAP);
+       if (ret < 0)
+               goto errout;
 
-               if (!child->thread.debugctlmsr)
-                       clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
-       }
+       if (cfg.flags & PTRACE_BTS_O_TRACE)
+               child->thread.debugctlmsr |= ds_debugctl_mask();
+       else
+               child->thread.debugctlmsr &= ~ds_debugctl_mask();
 
-       if (ds && (cfg.flags & PTRACE_BTS_O_SCHED))
+       if (cfg.flags & PTRACE_BTS_O_SCHED)
                set_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
        else
                clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
 
-       return 0;
+       ret = sizeof(cfg);
+
+out:
+       if (child->thread.debugctlmsr)
+               set_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
+       else
+               clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
+
+       return ret;
+
+errout:
+       child->thread.debugctlmsr &= ~ds_debugctl_mask();
+       clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
+       goto out;
 }
 
 static int ptrace_bts_status(struct task_struct *child,
+                            long cfg_size,
                             struct ptrace_bts_config __user *ucfg)
 {
        void *ds = (void *)child->thread.ds_area_msr;
        struct ptrace_bts_config cfg;
 
+       if (cfg_size < sizeof(cfg))
+               return -EIO;
+
        memset(&cfg, 0, sizeof(cfg));
 
        if (ds) {
@@ -706,6 +787,8 @@ static int ptrace_bts_status(struct task_struct *child,
                        cfg.flags |= PTRACE_BTS_O_SCHED;
        }
 
+       cfg.bts_size = sizeof(struct bts_struct);
+
        if (copy_to_user(ucfg, &cfg, sizeof(cfg)))
                return -EFAULT;
 
@@ -717,7 +800,7 @@ void ptrace_bts_take_timestamp(struct task_struct *tsk,
 {
        struct bts_struct rec = {
                .qualifier = qualifier,
-               .variant.jiffies = jiffies
+               .variant.jiffies = jiffies_64
        };
 
        ptrace_bts_write_record(tsk, &rec);
@@ -734,25 +817,25 @@ void ptrace_disable(struct task_struct *child)
 #ifdef TIF_SYSCALL_EMU
        clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
 #endif
-       ptrace_bts_config(child, /* options = */ 0);
        if (child->thread.ds_area_msr) {
-           ds_free((void **)&child->thread.ds_area_msr);
-           clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
+               ptrace_bts_realloc(child, 0, 0);
+               child->thread.debugctlmsr &= ~ds_debugctl_mask();
+               if (!child->thread.debugctlmsr)
+                       clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
+               clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
        }
 }
 
+#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
+static const struct user_regset_view user_x86_32_view; /* Initialized below. */
+#endif
+
 long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 {
-       int i, ret;
+       int ret;
        unsigned long __user *datap = (unsigned long __user *)data;
 
        switch (request) {
-       /* when I and D space are separate, these will need to be fixed. */
-       case PTRACE_PEEKTEXT: /* read word at location addr. */
-       case PTRACE_PEEKDATA:
-               ret = generic_ptrace_peekdata(child, addr, data);
-               break;
-
        /* read the word at location addr in the USER area. */
        case PTRACE_PEEKUSR: {
                unsigned long tmp;
@@ -774,12 +857,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                break;
        }
 
-       /* when I and D space are separate, this will have to be fixed. */
-       case PTRACE_POKETEXT: /* write the word at location addr. */
-       case PTRACE_POKEDATA:
-               ret = generic_ptrace_pokedata(child, addr, data);
-               break;
-
        case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
                ret = -EIO;
                if ((addr & (sizeof(data) - 1)) || addr < 0 ||
@@ -796,82 +873,46 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                }
                break;
 
-       case PTRACE_GETREGS: { /* Get all gp regs from the child. */
-               if (!access_ok(VERIFY_WRITE, datap, sizeof(struct user_regs_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               for (i = 0; i < sizeof(struct user_regs_struct); i += sizeof(long)) {
-                       __put_user(getreg(child, i), datap);
-                       datap++;
-               }
-               ret = 0;
-               break;
-       }
-
-       case PTRACE_SETREGS: { /* Set all gp regs in the child. */
-               unsigned long tmp;
-               if (!access_ok(VERIFY_READ, datap, sizeof(struct user_regs_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               for (i = 0; i < sizeof(struct user_regs_struct); i += sizeof(long)) {
-                       __get_user(tmp, datap);
-                       putreg(child, i, tmp);
-                       datap++;
-               }
-               ret = 0;
-               break;
-       }
-
-       case PTRACE_GETFPREGS: { /* Get the child FPU state. */
-               if (!access_ok(VERIFY_WRITE, datap,
-                              sizeof(struct user_i387_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0;
-               if (!tsk_used_math(child))
-                       init_fpu(child);
-               get_fpregs((struct user_i387_struct __user *)data, child);
-               break;
-       }
-
-       case PTRACE_SETFPREGS: { /* Set the child FPU state. */
-               if (!access_ok(VERIFY_READ, datap,
-                              sizeof(struct user_i387_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               set_stopped_child_used_math(child);
-               set_fpregs(child, (struct user_i387_struct __user *)data);
-               ret = 0;
-               break;
-       }
+       case PTRACE_GETREGS:    /* Get all gp regs from the child. */
+               return copy_regset_to_user(child,
+                                          task_user_regset_view(current),
+                                          REGSET_GENERAL,
+                                          0, sizeof(struct user_regs_struct),
+                                          datap);
+
+       case PTRACE_SETREGS:    /* Set all gp regs in the child. */
+               return copy_regset_from_user(child,
+                                            task_user_regset_view(current),
+                                            REGSET_GENERAL,
+                                            0, sizeof(struct user_regs_struct),
+                                            datap);
+
+       case PTRACE_GETFPREGS:  /* Get the child FPU state. */
+               return copy_regset_to_user(child,
+                                          task_user_regset_view(current),
+                                          REGSET_FP,
+                                          0, sizeof(struct user_i387_struct),
+                                          datap);
+
+       case PTRACE_SETFPREGS:  /* Set the child FPU state. */
+               return copy_regset_from_user(child,
+                                            task_user_regset_view(current),
+                                            REGSET_FP,
+                                            0, sizeof(struct user_i387_struct),
+                                            datap);
 
 #ifdef CONFIG_X86_32
-       case PTRACE_GETFPXREGS: { /* Get the child extended FPU state. */
-               if (!access_ok(VERIFY_WRITE, datap,
-                              sizeof(struct user_fxsr_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               if (!tsk_used_math(child))
-                       init_fpu(child);
-               ret = get_fpxregs((struct user_fxsr_struct __user *)data, child);
-               break;
-       }
-
-       case PTRACE_SETFPXREGS: { /* Set the child extended FPU state. */
-               if (!access_ok(VERIFY_READ, datap,
-                              sizeof(struct user_fxsr_struct))) {
-                       ret = -EIO;
-                       break;
-               }
-               set_stopped_child_used_math(child);
-               ret = set_fpxregs(child, (struct user_fxsr_struct __user *)data);
-               break;
-       }
+       case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
+               return copy_regset_to_user(child, &user_x86_32_view,
+                                          REGSET_XFP,
+                                          0, sizeof(struct user_fxsr_struct),
+                                          datap);
+
+       case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
+               return copy_regset_from_user(child, &user_x86_32_view,
+                                            REGSET_XFP,
+                                            0, sizeof(struct user_fxsr_struct),
+                                            datap);
 #endif
 
 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
@@ -901,12 +942,12 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 
        case PTRACE_BTS_CONFIG:
                ret = ptrace_bts_config
-                       (child, (struct ptrace_bts_config __user *)addr);
+                       (child, data, (struct ptrace_bts_config __user *)addr);
                break;
 
        case PTRACE_BTS_STATUS:
                ret = ptrace_bts_status
-                       (child, (struct ptrace_bts_config __user *)addr);
+                       (child, data, (struct ptrace_bts_config __user *)addr);
                break;
 
        case PTRACE_BTS_SIZE:
@@ -924,7 +965,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 
        case PTRACE_BTS_DRAIN:
                ret = ptrace_bts_drain
-                       (child, (struct bts_struct __user *) addr);
+                       (child, data, (struct bts_struct __user *) addr);
                break;
 
        default:
@@ -1206,24 +1247,6 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
        childregs = task_pt_regs(child);
 
        switch (request) {
-       case PTRACE_PEEKDATA:
-       case PTRACE_PEEKTEXT:
-               ret = 0;
-               if (access_process_vm(child, addr, &val, sizeof(u32), 0) !=
-                   sizeof(u32))
-                       ret = -EIO;
-               else
-                       ret = put_user(val, (unsigned int __user *)datap);
-               break;
-
-       case PTRACE_POKEDATA:
-       case PTRACE_POKETEXT:
-               ret = 0;
-               if (access_process_vm(child, addr, &data, sizeof(u32), 1) !=
-                   sizeof(u32))
-                       ret = -EIO;
-               break;
-
        case PTRACE_PEEKUSR:
                ret = getreg32(child, addr, &val);
                if (ret == 0)
@@ -1234,98 +1257,43 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
                ret = putreg32(child, addr, data);
                break;
 
-       case PTRACE_GETREGS: { /* Get all gp regs from the child. */
-               int i;
-
-               if (!access_ok(VERIFY_WRITE, datap, 16*4)) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0;
-               for (i = 0; i < sizeof(struct user_regs_struct32); i += sizeof(__u32)) {
-                       getreg32(child, i, &val);
-                       ret |= __put_user(val, (u32 __user *)datap);
-                       datap += sizeof(u32);
-               }
-               break;
-       }
-
-       case PTRACE_SETREGS: { /* Set all gp regs in the child. */
-               unsigned long tmp;
-               int i;
-
-               if (!access_ok(VERIFY_READ, datap, 16*4)) {
-                       ret = -EIO;
-                       break;
-               }
-               ret = 0;
-               for (i = 0; i < sizeof(struct user_regs_struct32); i += sizeof(u32)) {
-                       ret |= __get_user(tmp, (u32 __user *)datap);
-                       putreg32(child, i, tmp);
-                       datap += sizeof(u32);
-               }
-               break;
-       }
-
-       case PTRACE_GETFPREGS:
-               ret = -EIO;
-               if (!access_ok(VERIFY_READ, compat_ptr(data),
-                              sizeof(struct user_i387_struct)))
-                       break;
-               save_i387_ia32(child, datap, childregs, 1);
-               ret = 0;
-                       break;
-
-       case PTRACE_SETFPREGS:
-               ret = -EIO;
-               if (!access_ok(VERIFY_WRITE, datap,
-                              sizeof(struct user_i387_struct)))
-                       break;
-               ret = 0;
-               /* don't check EFAULT to be bug-to-bug compatible to i386 */
-               restore_i387_ia32(child, datap, 1);
-               break;
-
-       case PTRACE_GETFPXREGS: {
-               struct user32_fxsr_struct __user *u = datap;
-
-               init_fpu(child);
-               ret = -EIO;
-               if (!access_ok(VERIFY_WRITE, u, sizeof(*u)))
-                       break;
-                       ret = -EFAULT;
-               if (__copy_to_user(u, &child->thread.i387.fxsave, sizeof(*u)))
-                       break;
-               ret = __put_user(childregs->cs, &u->fcs);
-               ret |= __put_user(child->thread.ds, &u->fos);
-               break;
-       }
-       case PTRACE_SETFPXREGS: {
-               struct user32_fxsr_struct __user *u = datap;
-
-               unlazy_fpu(child);
-               ret = -EIO;
-               if (!access_ok(VERIFY_READ, u, sizeof(*u)))
-                       break;
-               /*
-                * no checking to be bug-to-bug compatible with i386.
-                * but silence warning
-                */
-               if (__copy_from_user(&child->thread.i387.fxsave, u, sizeof(*u)))
-                       ;
-               set_stopped_child_used_math(child);
-               child->thread.i387.fxsave.mxcsr &= mxcsr_feature_mask;
-               ret = 0;
-               break;
-       }
-
-       case PTRACE_GETEVENTMSG:
-               ret = put_user(child->ptrace_message,
-                              (unsigned int __user *)compat_ptr(data));
-               break;
+       case PTRACE_GETREGS:    /* Get all gp regs from the child. */
+               return copy_regset_to_user(child, &user_x86_32_view,
+                                          REGSET_GENERAL,
+                                          0, sizeof(struct user_regs_struct32),
+                                          datap);
+
+       case PTRACE_SETREGS:    /* Set all gp regs in the child. */
+               return copy_regset_from_user(child, &user_x86_32_view,
+                                            REGSET_GENERAL, 0,
+                                            sizeof(struct user_regs_struct32),
+                                            datap);
+
+       case PTRACE_GETFPREGS:  /* Get the child FPU state. */
+               return copy_regset_to_user(child, &user_x86_32_view,
+                                          REGSET_FP, 0,
+                                          sizeof(struct user_i387_ia32_struct),
+                                          datap);
+
+       case PTRACE_SETFPREGS:  /* Set the child FPU state. */
+               return copy_regset_from_user(
+                       child, &user_x86_32_view, REGSET_FP,
+                       0, sizeof(struct user_i387_ia32_struct), datap);
+
+       case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
+               return copy_regset_to_user(child, &user_x86_32_view,
+                                          REGSET_XFP, 0,
+                                          sizeof(struct user32_fxsr_struct),
+                                          datap);
+
+       case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
+               return copy_regset_from_user(child, &user_x86_32_view,
+                                            REGSET_XFP, 0,
+                                            sizeof(struct user32_fxsr_struct),
+                                            datap);
 
        default:
-               BUG();
+               return compat_ptrace_request(child, request, addr, data);
        }
 
  out:
@@ -1335,6 +1303,85 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
 
 #endif /* CONFIG_IA32_EMULATION */
 
+#ifdef CONFIG_X86_64
+
+static const struct user_regset x86_64_regsets[] = {
+       [REGSET_GENERAL] = {
+               .core_note_type = NT_PRSTATUS,
+               .n = sizeof(struct user_regs_struct) / sizeof(long),
+               .size = sizeof(long), .align = sizeof(long),
+               .get = genregs_get, .set = genregs_set
+       },
+       [REGSET_FP] = {
+               .core_note_type = NT_PRFPREG,
+               .n = sizeof(struct user_i387_struct) / sizeof(long),
+               .size = sizeof(long), .align = sizeof(long),
+               .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
+       },
+};
+
+static const struct user_regset_view user_x86_64_view = {
+       .name = "x86_64", .e_machine = EM_X86_64,
+       .regsets = x86_64_regsets, .n = ARRAY_SIZE(x86_64_regsets)
+};
+
+#else  /* CONFIG_X86_32 */
+
+#define user_regs_struct32     user_regs_struct
+#define genregs32_get          genregs_get
+#define genregs32_set          genregs_set
+
+#endif /* CONFIG_X86_64 */
+
+#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
+static const struct user_regset x86_32_regsets[] = {
+       [REGSET_GENERAL] = {
+               .core_note_type = NT_PRSTATUS,
+               .n = sizeof(struct user_regs_struct32) / sizeof(u32),
+               .size = sizeof(u32), .align = sizeof(u32),
+               .get = genregs32_get, .set = genregs32_set
+       },
+       [REGSET_FP] = {
+               .core_note_type = NT_PRFPREG,
+               .n = sizeof(struct user_i387_struct) / sizeof(u32),
+               .size = sizeof(u32), .align = sizeof(u32),
+               .active = fpregs_active, .get = fpregs_get, .set = fpregs_set
+       },
+       [REGSET_XFP] = {
+               .core_note_type = NT_PRXFPREG,
+               .n = sizeof(struct user_i387_struct) / sizeof(u32),
+               .size = sizeof(u32), .align = sizeof(u32),
+               .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
+       },
+       [REGSET_TLS] = {
+               .core_note_type = NT_386_TLS,
+               .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
+               .size = sizeof(struct user_desc),
+               .align = sizeof(struct user_desc),
+               .active = regset_tls_active,
+               .get = regset_tls_get, .set = regset_tls_set
+       },
+};
+
+static const struct user_regset_view user_x86_32_view = {
+       .name = "i386", .e_machine = EM_386,
+       .regsets = x86_32_regsets, .n = ARRAY_SIZE(x86_32_regsets)
+};
+#endif
+
+const struct user_regset_view *task_user_regset_view(struct task_struct *task)
+{
+#ifdef CONFIG_IA32_EMULATION
+       if (test_tsk_thread_flag(task, TIF_IA32))
+#endif
+#if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
+               return &user_x86_32_view;
+#endif
+#ifdef CONFIG_X86_64
+       return &user_x86_64_view;
+#endif
+}
+
 #ifdef CONFIG_X86_32
 
 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
This page took 0.032735 seconds and 5 git commands to generate.