Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 43005
b: refs/heads/master
c: e5e3a04
h: refs/heads/master
i:
  43003: cf7c019
v: v3
  • Loading branch information
Jeremy Fitzhardinge authored and Andi Kleen committed Dec 7, 2006
1 parent 94336b1 commit 3501f03
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e2764a1e306c986053a52b33748c33463cf888de
refs/heads/master: e5e3a0428968dcc1f9318ce1c941a918e99f8b84
4 changes: 1 addition & 3 deletions trunk/arch/i386/kernel/ldt.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ static int read_default_ldt(void __user * ptr, unsigned long bytecount)
{
int err;
unsigned long size;
void *address;

err = 0;
address = &default_ldt[0];
size = 5*sizeof(struct desc_struct);
if (size > bytecount)
size = bytecount;

err = size;
if (copy_to_user(ptr, address, size))
if (clear_user(ptr, size))
err = -EFAULT;

return err;
Expand Down
3 changes: 0 additions & 3 deletions trunk/arch/i386/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ int panic_on_unrecovered_nmi;

asmlinkage int system_call(void);

struct desc_struct default_ldt[] = { { 0, 0 }, { 0, 0 }, { 0, 0 },
{ 0, 0 }, { 0, 0 } };

/* Do we ignore FPU interrupts ? */
char ignore_fpu_irq = 0;

Expand Down
50 changes: 19 additions & 31 deletions trunk/include/asm-i386/desc.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
return (struct desc_struct *)per_cpu(cpu_gdt_descr, cpu).address;
}

/*
* This is the ldt that every process will get unless we need
* something other than this.
*/
extern struct desc_struct default_ldt[];
extern struct desc_struct idt_table[];
extern void set_intr_gate(unsigned int irq, void * addr);

Expand Down Expand Up @@ -65,7 +60,6 @@ static inline void pack_gate(__u32 *a, __u32 *b,
#define DESCTYPE_S 0x10 /* !system */

#define load_TR_desc() __asm__ __volatile__("ltr %w0"::"q" (GDT_ENTRY_TSS*8))
#define load_LDT_desc() __asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8))

#define load_gdt(dtr) __asm__ __volatile("lgdt %0"::"m" (*dtr))
#define load_idt(dtr) __asm__ __volatile("lidt %0"::"m" (*dtr))
Expand Down Expand Up @@ -115,13 +109,20 @@ static inline void __set_tss_desc(unsigned int cpu, unsigned int entry, const vo
write_gdt_entry(get_cpu_gdt_table(cpu), entry, a, b);
}

static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entries)
static inline void set_ldt(void *addr, unsigned int entries)
{
__u32 a, b;
pack_descriptor(&a, &b, (unsigned long)addr,
entries * sizeof(struct desc_struct) - 1,
DESCTYPE_LDT, 0);
write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
if (likely(entries == 0))
__asm__ __volatile__("lldt %w0"::"q" (0));
else {
unsigned cpu = smp_processor_id();
__u32 a, b;

pack_descriptor(&a, &b, (unsigned long)addr,
entries * sizeof(struct desc_struct) - 1,
DESCTYPE_LDT, 0);
write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_LDT, a, b);
__asm__ __volatile__("lldt %w0"::"q" (GDT_ENTRY_LDT*8));
}
}

#define set_tss_desc(cpu,addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr)
Expand Down Expand Up @@ -153,35 +154,22 @@ static inline void set_ldt_desc(unsigned int cpu, void *addr, unsigned int entri

static inline void clear_LDT(void)
{
int cpu = get_cpu();

set_ldt_desc(cpu, &default_ldt[0], 5);
load_LDT_desc();
put_cpu();
set_ldt(NULL, 0);
}

/*
* load one particular LDT into the current CPU
*/
static inline void load_LDT_nolock(mm_context_t *pc, int cpu)
static inline void load_LDT_nolock(mm_context_t *pc)
{
void *segments = pc->ldt;
int count = pc->size;

if (likely(!count)) {
segments = &default_ldt[0];
count = 5;
}

set_ldt_desc(cpu, segments, count);
load_LDT_desc();
set_ldt(pc->ldt, pc->size);
}

static inline void load_LDT(mm_context_t *pc)
{
int cpu = get_cpu();
load_LDT_nolock(pc, cpu);
put_cpu();
preempt_disable();
load_LDT_nolock(pc);
preempt_enable();
}

static inline unsigned long get_desc_base(unsigned long *desc)
Expand Down
4 changes: 2 additions & 2 deletions trunk/include/asm-i386/mmu_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static inline void switch_mm(struct mm_struct *prev,
* load the LDT, if the LDT is different:
*/
if (unlikely(prev->context.ldt != next->context.ldt))
load_LDT_nolock(&next->context, cpu);
load_LDT_nolock(&next->context);
}
#ifdef CONFIG_SMP
else {
Expand All @@ -56,7 +56,7 @@ static inline void switch_mm(struct mm_struct *prev,
* tlb flush IPI delivery. We must reload %cr3.
*/
load_cr3(next->pgd);
load_LDT_nolock(&next->context, cpu);
load_LDT_nolock(&next->context);
}
}
#endif
Expand Down

0 comments on commit 3501f03

Please sign in to comment.