From: "Jan Beulich" Subject: [PATCH] linux/x86: fix initial GDT setup Date: Thu, 06 Dec 2007 15:55:42 +0000 Message-ID: <4758298E.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org cpu_gdt_init() can be static, can have its argument point to const, and the number of descriptors should be calculated from one more than the table's limit. As usual, written and tested against 2.6.24-rc3 and made apply against 2.6.18 without further testing. Signed-off-by: Jan Beulich Index: head-2007-11-30/arch/i386/kernel/cpu/common-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-11-30.orig/arch/i386/kernel/cpu/common-xen.c 2007-12-04 = 08:34:05.000000000 +0100 +++ head-2007-11-30/arch/i386/kernel/cpu/common-xen.c 2007-12-04 = 14:44:46.000000000 +0100 @@ -590,7 +590,7 @@ #endif } =20 -void __cpuinit cpu_gdt_init(struct Xgt_desc_struct *gdt_descr) +static void __cpuinit cpu_gdt_init(const struct Xgt_desc_struct *gdt_descr= ) { unsigned long frames[16]; unsigned long va; @@ -603,7 +603,7 @@ make_lowmem_page_readonly( (void *)va, XENFEAT_writable_descriptor_tables); } - if (HYPERVISOR_set_gdt(frames, gdt_descr->size / 8)) + if (HYPERVISOR_set_gdt(frames, (gdt_descr->size + 1) / 8)) BUG(); } =20 Index: head-2007-11-30/arch/x86_64/kernel/setup64-xen.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2007-11-30.orig/arch/x86_64/kernel/setup64-xen.c 2007-12-06 = 11:25:13.000000000 +0100 +++ head-2007-11-30/arch/x86_64/kernel/setup64-xen.c 2007-12-06 = 11:25:28.000000000 +0100 @@ -134,7 +134,7 @@ xen_new_user_pt(__pa_symbol(__user_pgd(init_level4_pgt))); } =20 -void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr) +static void __cpuinit cpu_gdt_init(const struct desc_ptr *gdt_descr) { unsigned long frames[16]; unsigned long va; @@ -147,7 +147,7 @@ make_page_readonly( (void *)va, XENFEAT_writable_descriptor_tables); } - if (HYPERVISOR_set_gdt(frames, gdt_descr->size / + if (HYPERVISOR_set_gdt(frames, (gdt_descr->size + 1) / sizeof (struct desc_struct))) BUG(); } @@ -157,7 +157,7 @@ asm volatile("movq %0,%%cr3" :: "r" (__pa_symbol(&init_level4_pgt))= ); } =20 -void __init cpu_gdt_init(struct desc_ptr *gdt_descr) +static void __cpuinit cpu_gdt_init(const struct desc_ptr *gdt_descr) { asm volatile("lgdt %0" :: "m" (*gdt_descr)); asm volatile("lidt %0" :: "m" (idt_descr));