Commit 70f5088d authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Ingo Molnar

x86: prepare arch/x86/kernel/ldt_32/64.c for merging

White space and coding style cleanups.

Change unsigned to int. There is no win when we compare mincount against pc->size,
which is an int as well. Casting pc->size to unsigned just might hide real problems.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent fc2d625c
...@@ -27,8 +27,7 @@ static void flush_ldt(void *null) ...@@ -27,8 +27,7 @@ static void flush_ldt(void *null)
static int alloc_ldt(mm_context_t *pc, int mincount, int reload) static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
{ {
void *oldldt; void *oldldt, *newldt;
void *newldt;
int oldsize; int oldsize;
if (mincount <= pc->size) if (mincount <= pc->size)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/ldt.h> #include <asm/ldt.h>
#include <asm/desc.h> #include <asm/desc.h>
#include <asm/proto.h> #include <asm/mmu_context.h>
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
static void flush_ldt(void *null) static void flush_ldt(void *null)
...@@ -28,13 +28,12 @@ static void flush_ldt(void *null) ...@@ -28,13 +28,12 @@ static void flush_ldt(void *null)
} }
#endif #endif
static int alloc_ldt(mm_context_t *pc, unsigned mincount, int reload) static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
{ {
void *oldldt; void *oldldt, *newldt;
void *newldt; int oldsize;
unsigned oldsize;
if (mincount <= (unsigned)pc->size) if (mincount <= pc->size)
return 0; return 0;
oldsize = pc->size; oldsize = pc->size;
mincount = (mincount + 511) & (~511); mincount = (mincount + 511) & (~511);
...@@ -56,13 +55,14 @@ static int alloc_ldt(mm_context_t *pc, unsigned mincount, int reload) ...@@ -56,13 +55,14 @@ static int alloc_ldt(mm_context_t *pc, unsigned mincount, int reload)
wmb(); wmb();
pc->size = mincount; pc->size = mincount;
wmb(); wmb();
if (reload) { if (reload) {
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
cpumask_t mask; cpumask_t mask;
preempt_disable(); preempt_disable();
mask = cpumask_of_cpu(smp_processor_id());
load_LDT(pc); load_LDT(pc);
mask = cpumask_of_cpu(smp_processor_id());
if (!cpus_equal(current->mm->cpu_vm_mask, mask)) if (!cpus_equal(current->mm->cpu_vm_mask, mask))
smp_call_function(flush_ldt, NULL, 1, 1); smp_call_function(flush_ldt, NULL, 1, 1);
preempt_enable(); preempt_enable();
...@@ -115,7 +115,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm) ...@@ -115,7 +115,7 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
void destroy_context(struct mm_struct *mm) void destroy_context(struct mm_struct *mm)
{ {
if (mm->context.size) { if (mm->context.size) {
if ((unsigned)mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE) if (mm->context.size * LDT_ENTRY_SIZE > PAGE_SIZE)
vfree(mm->context.ldt); vfree(mm->context.ldt);
else else
kfree(mm->context.ldt); kfree(mm->context.ldt);
...@@ -170,18 +170,16 @@ static int read_default_ldt(void __user *ptr, unsigned long bytecount) ...@@ -170,18 +170,16 @@ static int read_default_ldt(void __user *ptr, unsigned long bytecount)
static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
{ {
struct task_struct *me = current; struct mm_struct *mm = current->mm;
struct mm_struct *mm = me->mm;
__u32 entry_1, entry_2; __u32 entry_1, entry_2;
int error; int error;
struct user_desc ldt_info; struct user_desc ldt_info;
error = -EINVAL; error = -EINVAL;
if (bytecount != sizeof(ldt_info)) if (bytecount != sizeof(ldt_info))
goto out; goto out;
error = -EFAULT; error = -EFAULT;
if (copy_from_user(&ldt_info, ptr, bytecount)) if (copy_from_user(&ldt_info, ptr, sizeof(ldt_info)))
goto out; goto out;
error = -EINVAL; error = -EINVAL;
...@@ -195,7 +193,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode) ...@@ -195,7 +193,7 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
} }
mutex_lock(&mm->context.lock); mutex_lock(&mm->context.lock);
if (ldt_info.entry_number >= (unsigned)mm->context.size) { if (ldt_info.entry_number >= mm->context.size) {
error = alloc_ldt(&current->mm->context, error = alloc_ldt(&current->mm->context,
ldt_info.entry_number + 1, 1); ldt_info.entry_number + 1, 1);
if (error < 0) if (error < 0)
......
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