Re: [PATCH 2/3] i386: use x86_64's desc_def.h
* Rusty Russell ([EMAIL PROTECTED]) wrote: > On Thu, 2007-07-19 at 09:27 +1000, Rusty Russell wrote: > > On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: > > > > +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) > > > > +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) > > > > > > You got rid of the duplicate definitions here, but then added new > > > duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? > > > > To be honest, I got sick of counting bits at this point, and didn't want > > to introduce bugs. > > > > Here's the updated version of PATCH 1/3: > > And 2/3: > === > i386: use x86_64's desc_def.h plus this needed as well now Index: linus-2.6/include/asm-i386/xen/hypercall.h === --- linus-2.6.orig/include/asm-i386/xen/hypercall.h +++ linus-2.6/include/asm-i386/xen/hypercall.h @@ -359,8 +359,8 @@ MULTI_update_descriptor(struct multicall mcl->op = __HYPERVISOR_update_descriptor; mcl->args[0] = maddr; mcl->args[1] = maddr >> 32; - mcl->args[2] = desc.a; - mcl->args[3] = desc.b; + mcl->args[2] = desc.raw32.a; + mcl->args[3] = desc.raw32.b; } static inline void Index: linus-2.6/drivers/lguest/interrupts_and_traps.c === --- linus-2.6.orig/drivers/lguest/interrupts_and_traps.c +++ linus-2.6/drivers/lguest/interrupts_and_traps.c @@ -103,9 +103,9 @@ void maybe_do_interrupt(struct lguest *l } idt = >idt[FIRST_EXTERNAL_VECTOR+irq]; - if (idt_present(idt->a, idt->b)) { + if (idt_present(idt->raw32.a, idt->raw32.b)) { clear_bit(irq, lg->irqs_pending); - set_guest_interrupt(lg, idt->a, idt->b, 0); + set_guest_interrupt(lg, idt->raw32.a, idt->raw32.b, 0); } } @@ -116,7 +116,7 @@ static int has_err(unsigned int trap) int deliver_trap(struct lguest *lg, unsigned int num) { - u32 lo = lg->idt[num].a, hi = lg->idt[num].b; + u32 lo = lg->idt[num].raw32.a, hi = lg->idt[num].raw32.b; if (!idt_present(lo, hi)) return 0; @@ -139,7 +139,7 @@ static int direct_trap(const struct lgue return 0; /* Interrupt gates (0xE) or not present (0x0) can't go direct. */ - return idt_type(trap->a, trap->b) == 0xF; + return idt_type(trap->raw32.a, trap->raw32.b) == 0xF; } void pin_stack_pages(struct lguest *lg) @@ -170,15 +170,15 @@ static void set_trap(struct lguest *lg, u8 type = idt_type(lo, hi); if (!idt_present(lo, hi)) { - trap->a = trap->b = 0; + trap->raw32.a = trap->raw32.b = 0; return; } if (type != 0xE && type != 0xF) kill_guest(lg, "bad IDT type %i", type); - trap->a = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x); - trap->b = (hi&0xEF00); + trap->raw32.a = ((__KERNEL_CS|GUEST_PL)<<16) | (lo&0x); + trap->raw32.b = (hi&0xEF00); } void load_guest_idt_entry(struct lguest *lg, unsigned int num, u32 lo, u32 hi) @@ -204,8 +204,8 @@ static void default_idt_entry(struct des if (trap == LGUEST_TRAP_ENTRY) flags |= (GUEST_PL << 13); - idt->a = (LGUEST_CS<<16) | (handler&0x); - idt->b = (handler&0x) | flags; + idt->raw32.a = (LGUEST_CS<<16) | (handler&0x); + idt->raw32.b = (handler&0x) | flags; } void setup_default_idt_entries(struct lguest_ro_state *state, Index: linus-2.6/drivers/lguest/lg.h === --- linus-2.6.orig/drivers/lguest/lg.h +++ linus-2.6/drivers/lguest/lg.h @@ -44,8 +44,8 @@ void free_pagetables(void); int init_pagetables(struct page **switcher_page, unsigned int pages); /* Full 4G segment descriptors, suitable for CS and DS. */ -#define FULL_EXEC_SEGMENT ((struct desc_struct){0x, 0x00cf9b00}) -#define FULL_SEGMENT ((struct desc_struct){0x, 0x00cf9300}) +#define FULL_EXEC_SEGMENT ((struct desc_struct){ {0x00cf9b00ULL} }) +#define FULL_SEGMENT ((struct desc_struct){ {0x00cf9300ULL} }) struct lguest_dma_info { Index: linus-2.6/drivers/lguest/lguest.c === --- linus-2.6.orig/drivers/lguest/lguest.c +++ linus-2.6/drivers/lguest/lguest.c @@ -173,7 +173,7 @@ static void lguest_load_idt(const struct struct desc_struct *idt = (void *)desc->address; for (i = 0; i < (desc->size+1)/8; i++) - hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b); + hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].raw32.a, idt[i].raw32.b); } static void lguest_load_gdt(const struct Xgt_desc_struct *desc) Index: linus-2.6/drivers/lguest/segments.c === ---
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
* Rusty Russell ([EMAIL PROTECTED]) wrote: On Thu, 2007-07-19 at 09:27 +1000, Rusty Russell wrote: On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) You got rid of the duplicate definitions here, but then added new duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? To be honest, I got sick of counting bits at this point, and didn't want to introduce bugs. Here's the updated version of PATCH 1/3: And 2/3: === i386: use x86_64's desc_def.h plus this needed as well now Index: linus-2.6/include/asm-i386/xen/hypercall.h === --- linus-2.6.orig/include/asm-i386/xen/hypercall.h +++ linus-2.6/include/asm-i386/xen/hypercall.h @@ -359,8 +359,8 @@ MULTI_update_descriptor(struct multicall mcl-op = __HYPERVISOR_update_descriptor; mcl-args[0] = maddr; mcl-args[1] = maddr 32; - mcl-args[2] = desc.a; - mcl-args[3] = desc.b; + mcl-args[2] = desc.raw32.a; + mcl-args[3] = desc.raw32.b; } static inline void Index: linus-2.6/drivers/lguest/interrupts_and_traps.c === --- linus-2.6.orig/drivers/lguest/interrupts_and_traps.c +++ linus-2.6/drivers/lguest/interrupts_and_traps.c @@ -103,9 +103,9 @@ void maybe_do_interrupt(struct lguest *l } idt = lg-idt[FIRST_EXTERNAL_VECTOR+irq]; - if (idt_present(idt-a, idt-b)) { + if (idt_present(idt-raw32.a, idt-raw32.b)) { clear_bit(irq, lg-irqs_pending); - set_guest_interrupt(lg, idt-a, idt-b, 0); + set_guest_interrupt(lg, idt-raw32.a, idt-raw32.b, 0); } } @@ -116,7 +116,7 @@ static int has_err(unsigned int trap) int deliver_trap(struct lguest *lg, unsigned int num) { - u32 lo = lg-idt[num].a, hi = lg-idt[num].b; + u32 lo = lg-idt[num].raw32.a, hi = lg-idt[num].raw32.b; if (!idt_present(lo, hi)) return 0; @@ -139,7 +139,7 @@ static int direct_trap(const struct lgue return 0; /* Interrupt gates (0xE) or not present (0x0) can't go direct. */ - return idt_type(trap-a, trap-b) == 0xF; + return idt_type(trap-raw32.a, trap-raw32.b) == 0xF; } void pin_stack_pages(struct lguest *lg) @@ -170,15 +170,15 @@ static void set_trap(struct lguest *lg, u8 type = idt_type(lo, hi); if (!idt_present(lo, hi)) { - trap-a = trap-b = 0; + trap-raw32.a = trap-raw32.b = 0; return; } if (type != 0xE type != 0xF) kill_guest(lg, bad IDT type %i, type); - trap-a = ((__KERNEL_CS|GUEST_PL)16) | (lo0x); - trap-b = (hi0xEF00); + trap-raw32.a = ((__KERNEL_CS|GUEST_PL)16) | (lo0x); + trap-raw32.b = (hi0xEF00); } void load_guest_idt_entry(struct lguest *lg, unsigned int num, u32 lo, u32 hi) @@ -204,8 +204,8 @@ static void default_idt_entry(struct des if (trap == LGUEST_TRAP_ENTRY) flags |= (GUEST_PL 13); - idt-a = (LGUEST_CS16) | (handler0x); - idt-b = (handler0x) | flags; + idt-raw32.a = (LGUEST_CS16) | (handler0x); + idt-raw32.b = (handler0x) | flags; } void setup_default_idt_entries(struct lguest_ro_state *state, Index: linus-2.6/drivers/lguest/lg.h === --- linus-2.6.orig/drivers/lguest/lg.h +++ linus-2.6/drivers/lguest/lg.h @@ -44,8 +44,8 @@ void free_pagetables(void); int init_pagetables(struct page **switcher_page, unsigned int pages); /* Full 4G segment descriptors, suitable for CS and DS. */ -#define FULL_EXEC_SEGMENT ((struct desc_struct){0x, 0x00cf9b00}) -#define FULL_SEGMENT ((struct desc_struct){0x, 0x00cf9300}) +#define FULL_EXEC_SEGMENT ((struct desc_struct){ {0x00cf9b00ULL} }) +#define FULL_SEGMENT ((struct desc_struct){ {0x00cf9300ULL} }) struct lguest_dma_info { Index: linus-2.6/drivers/lguest/lguest.c === --- linus-2.6.orig/drivers/lguest/lguest.c +++ linus-2.6/drivers/lguest/lguest.c @@ -173,7 +173,7 @@ static void lguest_load_idt(const struct struct desc_struct *idt = (void *)desc-address; for (i = 0; i (desc-size+1)/8; i++) - hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].a, idt[i].b); + hcall(LHCALL_LOAD_IDT_ENTRY, i, idt[i].raw32.a, idt[i].raw32.b); } static void lguest_load_gdt(const struct Xgt_desc_struct *desc) Index: linus-2.6/drivers/lguest/segments.c === --- linus-2.6.orig/drivers/lguest/segments.c +++ linus-2.6/drivers/lguest/segments.c @@ -3,12 +3,12 @@ static int
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
On Thu, Jul 19, 2007 at 09:27:41AM +1000, Rusty Russell wrote: > On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: > > > +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) > > > +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) > > > > You got rid of the duplicate definitions here, but then added new > > duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? > > To be honest, I got sick of counting bits at this point, and didn't want > to introduce bugs. Where is 1/ and 3/ ? I got an older version of this patch queued now -Andi - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: > > +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) > > +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) > > You got rid of the duplicate definitions here, but then added new > duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? To be honest, I got sick of counting bits at this point, and didn't want to introduce bugs. Here's the updated version of PATCH 1/3: === Standardize x86_64's desc_defs.h in preparation for exposure to i386. KVM has independent definitions of these structures, which is bad. However, the currently (i386-derived) x86-64 ones are suboptimal. The first step is to clean them up, especially by making desc_struct a union. Additional changes: 1) s/ldttss_desc/ldttss_desc_64/ to clearly indicate it's x86-64 only. 2) Changed the type of the tls_array in struct thread_struct: there seems little point to all these casts. 3) s/gate_struct/gate_struct_64/ to differentiate from new gate_struct_32. 4) New base/limit extraction convenience functions in desc_defs.h. Signed-off-by: Rusty Russell <[EMAIL PROTECTED]> diff -r ef94811a10d5 arch/x86_64/ia32/tls32.c --- a/arch/x86_64/ia32/tls32.c Wed Jul 18 14:46:15 2007 +1000 +++ b/arch/x86_64/ia32/tls32.c Thu Jul 19 09:09:02 2007 +1000 @@ -19,7 +19,7 @@ static int get_free_idx(void) int idx; for (idx = 0; idx < GDT_ENTRY_TLS_ENTRIES; idx++) - if (desc_empty((struct n_desc_struct *)(t->tls_array) + idx)) + if (desc_empty(t->tls_array + idx)) return idx + GDT_ENTRY_TLS_MIN; return -ESRCH; } @@ -31,7 +31,7 @@ int do_set_thread_area(struct thread_str int do_set_thread_area(struct thread_struct *t, struct user_desc __user *u_info) { struct user_desc info; - struct n_desc_struct *desc; + struct desc_struct *desc; int cpu, idx; if (copy_from_user(, u_info, sizeof(info))) @@ -54,7 +54,7 @@ int do_set_thread_area(struct thread_str if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX) return -EINVAL; - desc = ((struct n_desc_struct *)t->tls_array) + idx - GDT_ENTRY_TLS_MIN; + desc = t->tls_array + idx - GDT_ENTRY_TLS_MIN; /* * We must not get preempted while modifying the TLS. @@ -62,11 +62,10 @@ int do_set_thread_area(struct thread_str cpu = get_cpu(); if (LDT_empty()) { - desc->a = 0; - desc->b = 0; + desc->raw = 0; } else { - desc->a = LDT_entry_a(); - desc->b = LDT_entry_b(); + desc->raw32.a = LDT_entry_a(); + desc->raw32.b = LDT_entry_b(); } if (t == >thread) load_TLS(t, cpu); @@ -84,28 +83,10 @@ asmlinkage long sys32_set_thread_area(st /* * Get the current Thread-Local Storage area: */ - -#define GET_BASE(desc) ( \ - (((desc)->a >> 16) & 0x) | \ - (((desc)->b << 16) & 0x00ff) | \ - ( (desc)->b& 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)->a & 0x0) | \ -((desc)->b & 0xf) ) - -#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) -#define GET_LONGMODE(desc) (((desc)->b >> 21) & 1) - int do_get_thread_area(struct thread_struct *t, struct user_desc __user *u_info) { struct user_desc info; - struct n_desc_struct *desc; + struct desc_struct *desc; int idx; if (get_user(idx, _info->entry_number)) @@ -113,19 +94,19 @@ int do_get_thread_area(struct thread_str if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX) return -EINVAL; - desc = ((struct n_desc_struct *)t->tls_array) + idx - GDT_ENTRY_TLS_MIN; + desc = t->tls_array + idx - GDT_ENTRY_TLS_MIN; memset(, 0, sizeof(struct user_desc)); info.entry_number = idx; - info.base_addr = GET_BASE(desc); - info.limit = GET_LIMIT(desc); - info.seg_32bit = GET_32BIT(desc); - info.contents = GET_CONTENTS(desc); - info.read_exec_only = !GET_WRITABLE(desc); - info.limit_in_pages = GET_LIMIT_PAGES(desc); - info.seg_not_present = !GET_PRESENT(desc); - info.useable = GET_USEABLE(desc); - info.lm = GET_LONGMODE(desc); + info.base_addr = get_seg_desc_base(>seg); + info.limit = get_seg_desc_limit(>seg); + info.seg_32bit = desc->seg.d; + info.contents = get_seg_desc_contents(>seg); + info.read_exec_only = !get_seg_desc_writable(>seg); + info.limit_in_pages = desc->seg.g; + info.seg_not_present = !desc->seg.p; + info.useable =
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
On Thu, 2007-07-19 at 09:27 +1000, Rusty Russell wrote: > On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: > > > +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) > > > +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) > > > > You got rid of the duplicate definitions here, but then added new > > duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? > > To be honest, I got sick of counting bits at this point, and didn't want > to introduce bugs. > > Here's the updated version of PATCH 1/3: And 2/3: === i386: use x86_64's desc_def.h The main effect is to change the definition of "struct desc_struct" to a union of more complex types. I kept the old 32-bit comparisons, but many could be changed to use the 64-bit "desc->raw". Signed-off-by: Rusty Russell <[EMAIL PROTECTED]> diff -r e80364496ab1 arch/i386/kernel/cpu/common.c --- a/arch/i386/kernel/cpu/common.c Thu Jul 19 09:09:28 2007 +1000 +++ b/arch/i386/kernel/cpu/common.c Thu Jul 19 09:12:33 2007 +1000 @@ -22,31 +22,31 @@ #include "cpu.h" DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { - [GDT_ENTRY_KERNEL_CS] = { 0x, 0x00cf9a00 }, - [GDT_ENTRY_KERNEL_DS] = { 0x, 0x00cf9200 }, - [GDT_ENTRY_DEFAULT_USER_CS] = { 0x, 0x00cffa00 }, - [GDT_ENTRY_DEFAULT_USER_DS] = { 0x, 0x00cff200 }, + [GDT_ENTRY_KERNEL_CS] = { { 0x00cf9a00ULL } }, + [GDT_ENTRY_KERNEL_DS] = { { 0x00cf9200ULL } }, + [GDT_ENTRY_DEFAULT_USER_CS] = { { 0x00cffa00ULL } }, + [GDT_ENTRY_DEFAULT_USER_DS] = { { 0x00cff200ULL } }, /* * Segments used for calling PnP BIOS have byte granularity. * They code segments and data segments have fixed 64k limits, * the transfer segment sizes are set at run time. */ - [GDT_ENTRY_PNPBIOS_CS32] = { 0x, 0x00409a00 },/* 32-bit code */ - [GDT_ENTRY_PNPBIOS_CS16] = { 0x, 0x9a00 },/* 16-bit code */ - [GDT_ENTRY_PNPBIOS_DS] = { 0x, 0x9200 }, /* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS1] = { 0x, 0x9200 },/* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS2] = { 0x, 0x9200 },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_CS32] = { { 0x00409a00ULL } },/* 32-bit code */ + [GDT_ENTRY_PNPBIOS_CS16] = { { 0x9a00ULL } },/* 16-bit code */ + [GDT_ENTRY_PNPBIOS_DS] = { { 0x9200ULL } }, /* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS1] = { { 0x9200ULL } },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS2] = { { 0x9200ULL } },/* 16-bit data */ /* * The APM segments have byte granularity and their bases * are set at run time. All have 64k limits. */ - [GDT_ENTRY_APMBIOS_BASE] = { 0x, 0x00409a00 },/* 32-bit code */ + [GDT_ENTRY_APMBIOS_BASE] = { { 0x00409a00ULL } },/* 32-bit code */ /* 16-bit code */ - [GDT_ENTRY_APMBIOS_BASE+1] = { 0x, 0x9a00 }, - [GDT_ENTRY_APMBIOS_BASE+2] = { 0x, 0x00409200 }, /* data */ - - [GDT_ENTRY_ESPFIX_SS] = { 0x, 0x00c09200 }, - [GDT_ENTRY_PERCPU] = { 0x, 0x }, + [GDT_ENTRY_APMBIOS_BASE+1] = { { 0x9a00ULL } }, + [GDT_ENTRY_APMBIOS_BASE+2] = { { 0x00409200ULL } }, /* data */ + + [GDT_ENTRY_ESPFIX_SS] = { { 0x00c09200ULL } }, + [GDT_ENTRY_PERCPU] = { { 0xULL } }, } }; EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); diff -r e80364496ab1 arch/i386/kernel/process.c --- a/arch/i386/kernel/process.cThu Jul 19 09:09:28 2007 +1000 +++ b/arch/i386/kernel/process.cThu Jul 19 09:13:33 2007 +1000 @@ -466,8 +466,8 @@ int copy_thread(int nr, unsigned long cl goto out; desc = p->thread.tls_array + idx - GDT_ENTRY_TLS_MIN; - desc->a = LDT_entry_a(); - desc->b = LDT_entry_b(); + desc->raw32.a = LDT_entry_a(); + desc->raw32.b = LDT_entry_b(); } err = 0; @@ -863,11 +863,11 @@ asmlinkage int sys_set_thread_area(struc cpu = get_cpu(); if (LDT_empty()) { - desc->a = 0; - desc->b = 0; + desc->raw32.a = 0; + desc->raw32.b = 0; } else { - desc->a = LDT_entry_a(); - desc->b = LDT_entry_b(); + desc->raw32.a = LDT_entry_a(); + desc->raw32.b = LDT_entry_b(); } load_TLS(t, cpu); @@ -879,23 +879,6 @@ asmlinkage int sys_set_thread_area(struc /* * Get the current Thread-Local Storage area: */ - -#define GET_BASE(desc) ( \ - (((desc)->a >> 16) & 0x) | \ - (((desc)->b << 16) & 0x00ff) | \ - ( (desc)->b& 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)->a & 0x0) | \ -((desc)->b
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
Rusty Russell wrote: The main effect is to change the definition of "struct desc_struct" to a union of more complex types. Yay! Someone finally killed it. Every time I tried to kill it, I ended up off in the weeds chasing some bug. diff -r 656f3ff2c9ce arch/i386/kernel/process.c @@ -880,21 +880,8 @@ asmlinkage int sys_set_thread_area(struc * Get the current Thread-Local Storage area: */ -#define GET_BASE(desc) ( \ - (((desc)->a >> 16) & 0x) | \ - (((desc)->b << 16) & 0x00ff) | \ - ( (desc)->b& 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)->a & 0x0) | \ -((desc)->b & 0xf) ) - -#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) +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) diff -r 656f3ff2c9ce arch/i386/kernel/ptrace.c --- a/arch/i386/kernel/ptrace.c Wed Jul 18 16:21:04 2007 +1000 +++ b/arch/i386/kernel/ptrace.c Wed Jul 18 16:21:06 2007 +1000 @@ -283,22 +283,8 @@ ptrace_get_thread_area(struct task_struc /* * Get the current Thread-Local Storage area: */ - -#define GET_BASE(desc) ( \ - (((desc)->a >> 16) & 0x) | \ - (((desc)->b << 16) & 0x00ff) | \ - ( (desc)->b& 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)->a & 0x0) | \ -((desc)->b & 0xf) ) - -#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) +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) You got rid of the duplicate definitions here, but then added new duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? Zach - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 2/3] i386: use x86_64's desc_def.h
The main effect is to change the definition of "struct desc_struct" to a union of more complex types. I kept the old 32-bit comparisons, but many could be changed to use the 64-bit "desc->raw". Signed-off-by: Rusty Russell <[EMAIL PROTECTED]> diff -r 656f3ff2c9ce arch/i386/kernel/cpu/common.c --- a/arch/i386/kernel/cpu/common.c Wed Jul 18 16:21:04 2007 +1000 +++ b/arch/i386/kernel/cpu/common.c Wed Jul 18 16:29:06 2007 +1000 @@ -22,31 +22,31 @@ #include "cpu.h" DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { - [GDT_ENTRY_KERNEL_CS] = { 0x, 0x00cf9a00 }, - [GDT_ENTRY_KERNEL_DS] = { 0x, 0x00cf9200 }, - [GDT_ENTRY_DEFAULT_USER_CS] = { 0x, 0x00cffa00 }, - [GDT_ENTRY_DEFAULT_USER_DS] = { 0x, 0x00cff200 }, + [GDT_ENTRY_KERNEL_CS] = { { 0x00cf9a00ULL } }, + [GDT_ENTRY_KERNEL_DS] = { { 0x00cf9200ULL } }, + [GDT_ENTRY_DEFAULT_USER_CS] = { { 0x00cffa00ULL } }, + [GDT_ENTRY_DEFAULT_USER_DS] = { { 0x00cff200ULL } }, /* * Segments used for calling PnP BIOS have byte granularity. * They code segments and data segments have fixed 64k limits, * the transfer segment sizes are set at run time. */ - [GDT_ENTRY_PNPBIOS_CS32] = { 0x, 0x00409a00 },/* 32-bit code */ - [GDT_ENTRY_PNPBIOS_CS16] = { 0x, 0x9a00 },/* 16-bit code */ - [GDT_ENTRY_PNPBIOS_DS] = { 0x, 0x9200 }, /* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS1] = { 0x, 0x9200 },/* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS2] = { 0x, 0x9200 },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_CS32] = { { 0x00409a00ULL } },/* 32-bit code */ + [GDT_ENTRY_PNPBIOS_CS16] = { { 0x9a00ULL } },/* 16-bit code */ + [GDT_ENTRY_PNPBIOS_DS] = { { 0x9200ULL } }, /* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS1] = { { 0x9200ULL } },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS2] = { { 0x9200ULL } },/* 16-bit data */ /* * The APM segments have byte granularity and their bases * are set at run time. All have 64k limits. */ - [GDT_ENTRY_APMBIOS_BASE] = { 0x, 0x00409a00 },/* 32-bit code */ + [GDT_ENTRY_APMBIOS_BASE] = { { 0x00409a00ULL } },/* 32-bit code */ /* 16-bit code */ - [GDT_ENTRY_APMBIOS_BASE+1] = { 0x, 0x9a00 }, - [GDT_ENTRY_APMBIOS_BASE+2] = { 0x, 0x00409200 }, /* data */ - - [GDT_ENTRY_ESPFIX_SS] = { 0x, 0x00c09200 }, - [GDT_ENTRY_PERCPU] = { 0x, 0x }, + [GDT_ENTRY_APMBIOS_BASE+1] = { { 0x9a00ULL } }, + [GDT_ENTRY_APMBIOS_BASE+2] = { { 0x00409200ULL } }, /* data */ + + [GDT_ENTRY_ESPFIX_SS] = { { 0x00c09200ULL } }, + [GDT_ENTRY_PERCPU] = { { 0xULL } }, } }; EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); diff -r 656f3ff2c9ce arch/i386/kernel/process.c --- a/arch/i386/kernel/process.cWed Jul 18 16:21:04 2007 +1000 +++ b/arch/i386/kernel/process.cWed Jul 18 16:21:06 2007 +1000 @@ -466,8 +466,8 @@ int copy_thread(int nr, unsigned long cl goto out; desc = p->thread.tls_array + idx - GDT_ENTRY_TLS_MIN; - desc->a = LDT_entry_a(); - desc->b = LDT_entry_b(); + desc->raw32.a = LDT_entry_a(); + desc->raw32.b = LDT_entry_b(); } err = 0; @@ -863,11 +863,11 @@ asmlinkage int sys_set_thread_area(struc cpu = get_cpu(); if (LDT_empty()) { - desc->a = 0; - desc->b = 0; + desc->raw32.a = 0; + desc->raw32.b = 0; } else { - desc->a = LDT_entry_a(); - desc->b = LDT_entry_b(); + desc->raw32.a = LDT_entry_a(); + desc->raw32.b = LDT_entry_b(); } load_TLS(t, cpu); @@ -880,21 +880,8 @@ asmlinkage int sys_set_thread_area(struc * Get the current Thread-Local Storage area: */ -#define GET_BASE(desc) ( \ - (((desc)->a >> 16) & 0x) | \ - (((desc)->b << 16) & 0x00ff) | \ - ( (desc)->b& 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)->a & 0x0) | \ -((desc)->b & 0xf) ) - -#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) +#define GET_CONTENTS(desc) (((desc)->raw32.b >> 10) & 3) +#define GET_WRITABLE(desc) (((desc)->raw32.b >> 9) & 1) asmlinkage int sys_get_thread_area(struct user_desc __user *u_info) { @@ -912,14 +899,14 @@ asmlinkage
[PATCH 2/3] i386: use x86_64's desc_def.h
The main effect is to change the definition of struct desc_struct to a union of more complex types. I kept the old 32-bit comparisons, but many could be changed to use the 64-bit desc-raw. Signed-off-by: Rusty Russell [EMAIL PROTECTED] diff -r 656f3ff2c9ce arch/i386/kernel/cpu/common.c --- a/arch/i386/kernel/cpu/common.c Wed Jul 18 16:21:04 2007 +1000 +++ b/arch/i386/kernel/cpu/common.c Wed Jul 18 16:29:06 2007 +1000 @@ -22,31 +22,31 @@ #include cpu.h DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { - [GDT_ENTRY_KERNEL_CS] = { 0x, 0x00cf9a00 }, - [GDT_ENTRY_KERNEL_DS] = { 0x, 0x00cf9200 }, - [GDT_ENTRY_DEFAULT_USER_CS] = { 0x, 0x00cffa00 }, - [GDT_ENTRY_DEFAULT_USER_DS] = { 0x, 0x00cff200 }, + [GDT_ENTRY_KERNEL_CS] = { { 0x00cf9a00ULL } }, + [GDT_ENTRY_KERNEL_DS] = { { 0x00cf9200ULL } }, + [GDT_ENTRY_DEFAULT_USER_CS] = { { 0x00cffa00ULL } }, + [GDT_ENTRY_DEFAULT_USER_DS] = { { 0x00cff200ULL } }, /* * Segments used for calling PnP BIOS have byte granularity. * They code segments and data segments have fixed 64k limits, * the transfer segment sizes are set at run time. */ - [GDT_ENTRY_PNPBIOS_CS32] = { 0x, 0x00409a00 },/* 32-bit code */ - [GDT_ENTRY_PNPBIOS_CS16] = { 0x, 0x9a00 },/* 16-bit code */ - [GDT_ENTRY_PNPBIOS_DS] = { 0x, 0x9200 }, /* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS1] = { 0x, 0x9200 },/* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS2] = { 0x, 0x9200 },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_CS32] = { { 0x00409a00ULL } },/* 32-bit code */ + [GDT_ENTRY_PNPBIOS_CS16] = { { 0x9a00ULL } },/* 16-bit code */ + [GDT_ENTRY_PNPBIOS_DS] = { { 0x9200ULL } }, /* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS1] = { { 0x9200ULL } },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS2] = { { 0x9200ULL } },/* 16-bit data */ /* * The APM segments have byte granularity and their bases * are set at run time. All have 64k limits. */ - [GDT_ENTRY_APMBIOS_BASE] = { 0x, 0x00409a00 },/* 32-bit code */ + [GDT_ENTRY_APMBIOS_BASE] = { { 0x00409a00ULL } },/* 32-bit code */ /* 16-bit code */ - [GDT_ENTRY_APMBIOS_BASE+1] = { 0x, 0x9a00 }, - [GDT_ENTRY_APMBIOS_BASE+2] = { 0x, 0x00409200 }, /* data */ - - [GDT_ENTRY_ESPFIX_SS] = { 0x, 0x00c09200 }, - [GDT_ENTRY_PERCPU] = { 0x, 0x }, + [GDT_ENTRY_APMBIOS_BASE+1] = { { 0x9a00ULL } }, + [GDT_ENTRY_APMBIOS_BASE+2] = { { 0x00409200ULL } }, /* data */ + + [GDT_ENTRY_ESPFIX_SS] = { { 0x00c09200ULL } }, + [GDT_ENTRY_PERCPU] = { { 0xULL } }, } }; EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); diff -r 656f3ff2c9ce arch/i386/kernel/process.c --- a/arch/i386/kernel/process.cWed Jul 18 16:21:04 2007 +1000 +++ b/arch/i386/kernel/process.cWed Jul 18 16:21:06 2007 +1000 @@ -466,8 +466,8 @@ int copy_thread(int nr, unsigned long cl goto out; desc = p-thread.tls_array + idx - GDT_ENTRY_TLS_MIN; - desc-a = LDT_entry_a(info); - desc-b = LDT_entry_b(info); + desc-raw32.a = LDT_entry_a(info); + desc-raw32.b = LDT_entry_b(info); } err = 0; @@ -863,11 +863,11 @@ asmlinkage int sys_set_thread_area(struc cpu = get_cpu(); if (LDT_empty(info)) { - desc-a = 0; - desc-b = 0; + desc-raw32.a = 0; + desc-raw32.b = 0; } else { - desc-a = LDT_entry_a(info); - desc-b = LDT_entry_b(info); + desc-raw32.a = LDT_entry_a(info); + desc-raw32.b = LDT_entry_b(info); } load_TLS(t, cpu); @@ -880,21 +880,8 @@ asmlinkage int sys_set_thread_area(struc * Get the current Thread-Local Storage area: */ -#define GET_BASE(desc) ( \ - (((desc)-a 16) 0x) | \ - (((desc)-b 16) 0x00ff) | \ - ( (desc)-b 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)-a 0x0) | \ -((desc)-b 0xf) ) - -#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) +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) asmlinkage int sys_get_thread_area(struct user_desc __user *u_info) { @@ -912,14 +899,14 @@ asmlinkage int sys_get_thread_area(struc
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
Rusty Russell wrote: The main effect is to change the definition of struct desc_struct to a union of more complex types. Yay! Someone finally killed it. Every time I tried to kill it, I ended up off in the weeds chasing some bug. diff -r 656f3ff2c9ce arch/i386/kernel/process.c @@ -880,21 +880,8 @@ asmlinkage int sys_set_thread_area(struc * Get the current Thread-Local Storage area: */ -#define GET_BASE(desc) ( \ - (((desc)-a 16) 0x) | \ - (((desc)-b 16) 0x00ff) | \ - ( (desc)-b 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)-a 0x0) | \ -((desc)-b 0xf) ) - -#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) +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) diff -r 656f3ff2c9ce arch/i386/kernel/ptrace.c --- a/arch/i386/kernel/ptrace.c Wed Jul 18 16:21:04 2007 +1000 +++ b/arch/i386/kernel/ptrace.c Wed Jul 18 16:21:06 2007 +1000 @@ -283,22 +283,8 @@ ptrace_get_thread_area(struct task_struc /* * Get the current Thread-Local Storage area: */ - -#define GET_BASE(desc) ( \ - (((desc)-a 16) 0x) | \ - (((desc)-b 16) 0x00ff) | \ - ( (desc)-b 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)-a 0x0) | \ -((desc)-b 0xf) ) - -#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) +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) You got rid of the duplicate definitions here, but then added new duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? Zach - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) You got rid of the duplicate definitions here, but then added new duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? To be honest, I got sick of counting bits at this point, and didn't want to introduce bugs. Here's the updated version of PATCH 1/3: === Standardize x86_64's desc_defs.h in preparation for exposure to i386. KVM has independent definitions of these structures, which is bad. However, the currently (i386-derived) x86-64 ones are suboptimal. The first step is to clean them up, especially by making desc_struct a union. Additional changes: 1) s/ldttss_desc/ldttss_desc_64/ to clearly indicate it's x86-64 only. 2) Changed the type of the tls_array in struct thread_struct: there seems little point to all these casts. 3) s/gate_struct/gate_struct_64/ to differentiate from new gate_struct_32. 4) New base/limit extraction convenience functions in desc_defs.h. Signed-off-by: Rusty Russell [EMAIL PROTECTED] diff -r ef94811a10d5 arch/x86_64/ia32/tls32.c --- a/arch/x86_64/ia32/tls32.c Wed Jul 18 14:46:15 2007 +1000 +++ b/arch/x86_64/ia32/tls32.c Thu Jul 19 09:09:02 2007 +1000 @@ -19,7 +19,7 @@ static int get_free_idx(void) int idx; for (idx = 0; idx GDT_ENTRY_TLS_ENTRIES; idx++) - if (desc_empty((struct n_desc_struct *)(t-tls_array) + idx)) + if (desc_empty(t-tls_array + idx)) return idx + GDT_ENTRY_TLS_MIN; return -ESRCH; } @@ -31,7 +31,7 @@ int do_set_thread_area(struct thread_str int do_set_thread_area(struct thread_struct *t, struct user_desc __user *u_info) { struct user_desc info; - struct n_desc_struct *desc; + struct desc_struct *desc; int cpu, idx; if (copy_from_user(info, u_info, sizeof(info))) @@ -54,7 +54,7 @@ int do_set_thread_area(struct thread_str if (idx GDT_ENTRY_TLS_MIN || idx GDT_ENTRY_TLS_MAX) return -EINVAL; - desc = ((struct n_desc_struct *)t-tls_array) + idx - GDT_ENTRY_TLS_MIN; + desc = t-tls_array + idx - GDT_ENTRY_TLS_MIN; /* * We must not get preempted while modifying the TLS. @@ -62,11 +62,10 @@ int do_set_thread_area(struct thread_str cpu = get_cpu(); if (LDT_empty(info)) { - desc-a = 0; - desc-b = 0; + desc-raw = 0; } else { - desc-a = LDT_entry_a(info); - desc-b = LDT_entry_b(info); + desc-raw32.a = LDT_entry_a(info); + desc-raw32.b = LDT_entry_b(info); } if (t == current-thread) load_TLS(t, cpu); @@ -84,28 +83,10 @@ asmlinkage long sys32_set_thread_area(st /* * Get the current Thread-Local Storage area: */ - -#define GET_BASE(desc) ( \ - (((desc)-a 16) 0x) | \ - (((desc)-b 16) 0x00ff) | \ - ( (desc)-b 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)-a 0x0) | \ -((desc)-b 0xf) ) - -#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) -#define GET_LONGMODE(desc) (((desc)-b 21) 1) - int do_get_thread_area(struct thread_struct *t, struct user_desc __user *u_info) { struct user_desc info; - struct n_desc_struct *desc; + struct desc_struct *desc; int idx; if (get_user(idx, u_info-entry_number)) @@ -113,19 +94,19 @@ int do_get_thread_area(struct thread_str if (idx GDT_ENTRY_TLS_MIN || idx GDT_ENTRY_TLS_MAX) return -EINVAL; - desc = ((struct n_desc_struct *)t-tls_array) + idx - GDT_ENTRY_TLS_MIN; + desc = t-tls_array + idx - GDT_ENTRY_TLS_MIN; memset(info, 0, sizeof(struct user_desc)); info.entry_number = idx; - info.base_addr = GET_BASE(desc); - info.limit = GET_LIMIT(desc); - info.seg_32bit = GET_32BIT(desc); - info.contents = GET_CONTENTS(desc); - info.read_exec_only = !GET_WRITABLE(desc); - info.limit_in_pages = GET_LIMIT_PAGES(desc); - info.seg_not_present = !GET_PRESENT(desc); - info.useable = GET_USEABLE(desc); - info.lm = GET_LONGMODE(desc); + info.base_addr = get_seg_desc_base(desc-seg); + info.limit = get_seg_desc_limit(desc-seg); + info.seg_32bit = desc-seg.d; + info.contents = get_seg_desc_contents(desc-seg); + info.read_exec_only = !get_seg_desc_writable(desc-seg); + info.limit_in_pages = desc-seg.g; + info.seg_not_present = !desc-seg.p; + info.useable = desc-seg.avl; + info.lm =
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
On Thu, 2007-07-19 at 09:27 +1000, Rusty Russell wrote: On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) You got rid of the duplicate definitions here, but then added new duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? To be honest, I got sick of counting bits at this point, and didn't want to introduce bugs. Here's the updated version of PATCH 1/3: And 2/3: === i386: use x86_64's desc_def.h The main effect is to change the definition of struct desc_struct to a union of more complex types. I kept the old 32-bit comparisons, but many could be changed to use the 64-bit desc-raw. Signed-off-by: Rusty Russell [EMAIL PROTECTED] diff -r e80364496ab1 arch/i386/kernel/cpu/common.c --- a/arch/i386/kernel/cpu/common.c Thu Jul 19 09:09:28 2007 +1000 +++ b/arch/i386/kernel/cpu/common.c Thu Jul 19 09:12:33 2007 +1000 @@ -22,31 +22,31 @@ #include cpu.h DEFINE_PER_CPU(struct gdt_page, gdt_page) = { .gdt = { - [GDT_ENTRY_KERNEL_CS] = { 0x, 0x00cf9a00 }, - [GDT_ENTRY_KERNEL_DS] = { 0x, 0x00cf9200 }, - [GDT_ENTRY_DEFAULT_USER_CS] = { 0x, 0x00cffa00 }, - [GDT_ENTRY_DEFAULT_USER_DS] = { 0x, 0x00cff200 }, + [GDT_ENTRY_KERNEL_CS] = { { 0x00cf9a00ULL } }, + [GDT_ENTRY_KERNEL_DS] = { { 0x00cf9200ULL } }, + [GDT_ENTRY_DEFAULT_USER_CS] = { { 0x00cffa00ULL } }, + [GDT_ENTRY_DEFAULT_USER_DS] = { { 0x00cff200ULL } }, /* * Segments used for calling PnP BIOS have byte granularity. * They code segments and data segments have fixed 64k limits, * the transfer segment sizes are set at run time. */ - [GDT_ENTRY_PNPBIOS_CS32] = { 0x, 0x00409a00 },/* 32-bit code */ - [GDT_ENTRY_PNPBIOS_CS16] = { 0x, 0x9a00 },/* 16-bit code */ - [GDT_ENTRY_PNPBIOS_DS] = { 0x, 0x9200 }, /* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS1] = { 0x, 0x9200 },/* 16-bit data */ - [GDT_ENTRY_PNPBIOS_TS2] = { 0x, 0x9200 },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_CS32] = { { 0x00409a00ULL } },/* 32-bit code */ + [GDT_ENTRY_PNPBIOS_CS16] = { { 0x9a00ULL } },/* 16-bit code */ + [GDT_ENTRY_PNPBIOS_DS] = { { 0x9200ULL } }, /* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS1] = { { 0x9200ULL } },/* 16-bit data */ + [GDT_ENTRY_PNPBIOS_TS2] = { { 0x9200ULL } },/* 16-bit data */ /* * The APM segments have byte granularity and their bases * are set at run time. All have 64k limits. */ - [GDT_ENTRY_APMBIOS_BASE] = { 0x, 0x00409a00 },/* 32-bit code */ + [GDT_ENTRY_APMBIOS_BASE] = { { 0x00409a00ULL } },/* 32-bit code */ /* 16-bit code */ - [GDT_ENTRY_APMBIOS_BASE+1] = { 0x, 0x9a00 }, - [GDT_ENTRY_APMBIOS_BASE+2] = { 0x, 0x00409200 }, /* data */ - - [GDT_ENTRY_ESPFIX_SS] = { 0x, 0x00c09200 }, - [GDT_ENTRY_PERCPU] = { 0x, 0x }, + [GDT_ENTRY_APMBIOS_BASE+1] = { { 0x9a00ULL } }, + [GDT_ENTRY_APMBIOS_BASE+2] = { { 0x00409200ULL } }, /* data */ + + [GDT_ENTRY_ESPFIX_SS] = { { 0x00c09200ULL } }, + [GDT_ENTRY_PERCPU] = { { 0xULL } }, } }; EXPORT_PER_CPU_SYMBOL_GPL(gdt_page); diff -r e80364496ab1 arch/i386/kernel/process.c --- a/arch/i386/kernel/process.cThu Jul 19 09:09:28 2007 +1000 +++ b/arch/i386/kernel/process.cThu Jul 19 09:13:33 2007 +1000 @@ -466,8 +466,8 @@ int copy_thread(int nr, unsigned long cl goto out; desc = p-thread.tls_array + idx - GDT_ENTRY_TLS_MIN; - desc-a = LDT_entry_a(info); - desc-b = LDT_entry_b(info); + desc-raw32.a = LDT_entry_a(info); + desc-raw32.b = LDT_entry_b(info); } err = 0; @@ -863,11 +863,11 @@ asmlinkage int sys_set_thread_area(struc cpu = get_cpu(); if (LDT_empty(info)) { - desc-a = 0; - desc-b = 0; + desc-raw32.a = 0; + desc-raw32.b = 0; } else { - desc-a = LDT_entry_a(info); - desc-b = LDT_entry_b(info); + desc-raw32.a = LDT_entry_a(info); + desc-raw32.b = LDT_entry_b(info); } load_TLS(t, cpu); @@ -879,23 +879,6 @@ asmlinkage int sys_set_thread_area(struc /* * Get the current Thread-Local Storage area: */ - -#define GET_BASE(desc) ( \ - (((desc)-a 16) 0x) | \ - (((desc)-b 16) 0x00ff) | \ - ( (desc)-b 0xff00) ) - -#define GET_LIMIT(desc) ( \ - ((desc)-a 0x0) | \ -((desc)-b 0xf) ) -
Re: [PATCH 2/3] i386: use x86_64's desc_def.h
On Thu, Jul 19, 2007 at 09:27:41AM +1000, Rusty Russell wrote: On Wed, 2007-07-18 at 09:19 -0700, Zachary Amsden wrote: +#define GET_CONTENTS(desc) (((desc)-raw32.b 10) 3) +#define GET_WRITABLE(desc) (((desc)-raw32.b 9) 1) You got rid of the duplicate definitions here, but then added new duplicates (GET_CONTENTS / WRITABLE). Can you stick them in desc.h? To be honest, I got sick of counting bits at this point, and didn't want to introduce bugs. Where is 1/ and 3/ ? I got an older version of this patch queued now -Andi - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/