Commit 686d6649 authored by Ingo Molnar's avatar Ingo Molnar Committed by Linus Torvalds

[PATCH] Re: Limit in set_thread_area

the attached patch does the set_thread_area parameter simplification - it
also cleans up some other TLS issues, it removes the tls_* fields from the
thread_struct, and removes the now unused page-granularity flag.
parent 603e29ca
...@@ -831,34 +831,27 @@ unsigned long get_wchan(struct task_struct *p) ...@@ -831,34 +831,27 @@ unsigned long get_wchan(struct task_struct *p)
/* /*
* Set the Thread-Local Storage area: * Set the Thread-Local Storage area:
*/ */
asmlinkage int sys_set_thread_area(unsigned int base, unsigned int limit, unsigned int flags) asmlinkage int sys_set_thread_area(unsigned long base, unsigned long flags)
{ {
struct thread_struct *t = &current->thread; struct thread_struct *t = &current->thread;
int limit_in_pages = 0, writable = 0; int writable = 0;
int cpu; int cpu;
/* do not allow unused flags */ /* do not allow unused flags */
if (flags & ~TLS_FLAGS_MASK) if (flags & ~TLS_FLAGS_MASK)
return -EINVAL; return -EINVAL;
/* check limit */
if (limit & 0xfff00000)
return -EINVAL;
/* /*
* Clear the TLS? * Clear the TLS?
*/ */
if (flags & TLS_FLAG_CLEAR) { if (flags & TLS_FLAG_CLEAR) {
cpu = get_cpu(); cpu = get_cpu();
t->tls_base = t->tls_limit = t->tls_flags = 0;
t->tls_desc.a = t->tls_desc.b = 0; t->tls_desc.a = t->tls_desc.b = 0;
load_TLS_desc(t, cpu); load_TLS_desc(t, cpu);
put_cpu(); put_cpu();
return 0; return 0;
} }
if (flags & TLS_FLAG_LIMIT_IN_PAGES)
limit_in_pages = 1;
if (flags & TLS_FLAG_WRITABLE) if (flags & TLS_FLAG_WRITABLE)
writable = 1; writable = 1;
...@@ -866,15 +859,12 @@ asmlinkage int sys_set_thread_area(unsigned int base, unsigned int limit, unsign ...@@ -866,15 +859,12 @@ asmlinkage int sys_set_thread_area(unsigned int base, unsigned int limit, unsign
* We must not get preempted while modifying the TLS. * We must not get preempted while modifying the TLS.
*/ */
cpu = get_cpu(); cpu = get_cpu();
t->tls_base = base;
t->tls_limit = limit;
t->tls_flags = flags;
t->tls_desc.a = ((base & 0x0000ffff) << 16) | (limit & 0x0ffff); t->tls_desc.a = ((base & 0x0000ffff) << 16) | 0xffff;
t->tls_desc.b = (base & 0xff000000) | ((base & 0x00ff0000) >> 16) | t->tls_desc.b = (base & 0xff000000) | ((base & 0x00ff0000) >> 16) |
(limit & 0xf0000) | (writable << 9) | (1 << 15) | 0xf0000 | (writable << 9) | (1 << 15) |
(1 << 22) | (limit_in_pages << 23) | 0x7000; (1 << 22) | (1 << 23) | 0x7000;
load_TLS_desc(t, cpu); load_TLS_desc(t, cpu);
put_cpu(); put_cpu();
......
...@@ -86,11 +86,10 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size) ...@@ -86,11 +86,10 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int size)
_set_tssldt_desc(&cpu_gdt_table[cpu][LDT_ENTRY], (int)addr, ((size << 3)-1), 0x82); _set_tssldt_desc(&cpu_gdt_table[cpu][LDT_ENTRY], (int)addr, ((size << 3)-1), 0x82);
} }
#define TLS_FLAGS_MASK 0x00000007 #define TLS_FLAGS_MASK 0x00000003
#define TLS_FLAG_LIMIT_IN_PAGES 0x00000001 #define TLS_FLAG_WRITABLE 0x00000001
#define TLS_FLAG_WRITABLE 0x00000002 #define TLS_FLAG_CLEAR 0x00000002
#define TLS_FLAG_CLEAR 0x00000004
static inline void load_TLS_desc(struct thread_struct *t, unsigned int cpu) static inline void load_TLS_desc(struct thread_struct *t, unsigned int cpu)
{ {
......
...@@ -376,8 +376,7 @@ struct thread_struct { ...@@ -376,8 +376,7 @@ struct thread_struct {
unsigned long v86flags, v86mask, v86mode, saved_esp0; unsigned long v86flags, v86mask, v86mode, saved_esp0;
/* IO permissions */ /* IO permissions */
unsigned long *ts_io_bitmap; unsigned long *ts_io_bitmap;
/* TLS info and cached descriptor */ /* TLS cached descriptor */
unsigned int tls_base, tls_limit, tls_flags;
struct desc_struct tls_desc; struct desc_struct tls_desc;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment