- }
-
- return ret;
-}
-
-
-/*
- * Perform get_thread_area on behalf of the traced child.
- */
-static int
-ia32_tls_get(struct task_struct *target,
- const struct utrace_regset *regset,
- unsigned int pos, unsigned int count,
- void *kbuf, void __user *ubuf)
-{
- struct user_desc info, *ip;
- const struct n_desc_struct *desc;
- const struct n_desc_struct *tls;
-
-/*
- * Get the current Thread-Local Storage area:
- */
-
-#define GET_BASE(desc) ( \
- (((desc)->a >> 16) & 0x0000ffff) | \
- (((desc)->b << 16) & 0x00ff0000) | \
- ( (desc)->b & 0xff000000) )
-
-#define GET_LIMIT(desc) ( \
- ((desc)->a & 0x0ffff) | \
- ((desc)->b & 0xf0000) )
-
-#define GET_32BIT(desc) (((desc)->b >> 22) & 1)
-#define GET_CONTENTS(desc) (((desc)->b >> 10) & 3)
-#define GET_WRITABLE(desc) (((desc)->b >> 9) & 1)
-#define GET_LIMIT_PAGES(desc) (((desc)->b >> 23) & 1)
-#define GET_PRESENT(desc) (((desc)->b >> 15) & 1)
-#define GET_USEABLE(desc) (((desc)->b >> 20) & 1)
-
- tls = (struct n_desc_struct *) target->thread.tls_array;
- desc = &tls[pos];
- ip = kbuf ?: &info;
- memset(ip, 0, sizeof *ip);
- for (; count > 0; count -= sizeof(struct user_desc), ++desc) {
- ip->entry_number = desc - tls + GDT_ENTRY_TLS_MIN;
- ip->base_addr = GET_BASE(desc);
- ip->limit = GET_LIMIT(desc);
- ip->seg_32bit = GET_32BIT(desc);
- ip->contents = GET_CONTENTS(desc);
- ip->read_exec_only = !GET_WRITABLE(desc);
- ip->limit_in_pages = GET_LIMIT_PAGES(desc);
- ip->seg_not_present = !GET_PRESENT(desc);
- ip->useable = GET_USEABLE(desc);
-
- if (kbuf)
- ++ip;
- else {
- if (__copy_to_user(ubuf, &info, sizeof(info)))
- return -EFAULT;
- ubuf += sizeof(info);
- }
- }
-
- return 0;
-}
-
-/*
- * Perform set_thread_area on behalf of the traced child.
- */
-static int
-ia32_tls_set(struct task_struct *target,
- const struct utrace_regset *regset,
- unsigned int pos, unsigned int count,
- const void *kbuf, const void __user *ubuf)
-{
- struct user_desc info;
- struct n_desc_struct *desc;
- struct n_desc_struct newtls[GDT_ENTRY_TLS_ENTRIES];
- unsigned int i;
- int cpu;
-
- pos /= sizeof(struct user_desc);
- count /= sizeof(struct user_desc);
-
- desc = &newtls[pos];
- for (i = 0; i < count; ++i, ++desc) {
- const struct user_desc *ip;
- if (kbuf) {
- ip = kbuf;
- kbuf += sizeof(struct user_desc);
- }
- else {
- ip = &info;
- if (__copy_from_user(&info, ubuf, sizeof(info)))
- return -EFAULT;
- ubuf += sizeof(struct user_desc);