From: "Jan Beulich" Subject: [PATCH] x86-64: bump STACK_SIZE to 32k Date: Tue, 03 Jul 2007 11:21:05 +0100 Message-ID: <468A3F31.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 .. so that trampoline and IST stacks fit without undue squeezing. Signed-off-by: Jan Beulich Index: 2007-07-03/xen/arch/x86/hvm/svm/svm.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 --- 2007-07-03.orig/xen/arch/x86/hvm/svm/svm.c 2007-07-02 08:13:50.0000000= 00 +0200 +++ 2007-07-03/xen/arch/x86/hvm/svm/svm.c 2007-07-03 10:34:45.0000000= 00 +0200 @@ -807,9 +807,9 @@ static void svm_ctxt_switch_from(struct=20 =20 #ifdef __x86_64__ /* Resume use of ISTs now that the host TR is reinstated. */ - idt_tables[cpu][TRAP_double_fault].a |=3D 1UL << 32; /* IST1 */ - idt_tables[cpu][TRAP_nmi].a |=3D 2UL << 32; /* IST2 */ - idt_tables[cpu][TRAP_machine_check].a |=3D 3UL << 32; /* IST3 */ + idt_tables[cpu][TRAP_double_fault].a |=3D IST_DF << 32; + idt_tables[cpu][TRAP_nmi].a |=3D IST_NMI << 32; + idt_tables[cpu][TRAP_machine_check].a |=3D IST_MCE << 32; #endif } =20 @@ -832,9 +832,9 @@ static void svm_ctxt_switch_to(struct vc * Cannot use ISTs for NMI/#MC/#DF while we are running with the = guest TR. * But this doesn't matter: the IST is only req'd to handle SYSCALL/SY= SRET. */ - idt_tables[cpu][TRAP_double_fault].a &=3D ~(3UL << 32); - idt_tables[cpu][TRAP_nmi].a &=3D ~(3UL << 32); - idt_tables[cpu][TRAP_machine_check].a &=3D ~(3UL << 32); + idt_tables[cpu][TRAP_double_fault].a &=3D ~(7UL << 32); + idt_tables[cpu][TRAP_nmi].a &=3D ~(7UL << 32); + idt_tables[cpu][TRAP_machine_check].a &=3D ~(7UL << 32); #endif =20 svm_restore_dr(v); Index: 2007-07-03/xen/arch/x86/setup.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 --- 2007-07-03.orig/xen/arch/x86/setup.c 2007-06-22 16:57:45.0000000= 00 +0200 +++ 2007-07-03/xen/arch/x86/setup.c 2007-07-03 10:30:34.000000000 = +0200 @@ -109,7 +109,7 @@ extern void early_cpu_init(void); =20 struct tss_struct init_tss[NR_CPUS]; =20 -char __attribute__ ((__section__(".bss.page_aligned"))) cpu0_stack[STACK_S= IZE]; +char __attribute__ ((__section__(".bss.stack_aligned"))) cpu0_stack[STACK_= SIZE]; =20 struct cpuinfo_x86 boot_cpu_data =3D { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; =20 Index: 2007-07-03/xen/arch/x86/x86_32/xen.lds.S =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 --- 2007-07-03.orig/xen/arch/x86/x86_32/xen.lds.S 2007-01-05 = 10:09:13.000000000 +0100 +++ 2007-07-03/xen/arch/x86/x86_32/xen.lds.S 2007-07-03 10:30:34.0000000= 00 +0200 @@ -70,12 +70,14 @@ SECTIONS .data.percpu : { *(.data.percpu) } :text __per_cpu_data_end =3D .; . =3D __per_cpu_start + (NR_CPUS << PERCPU_SHIFT); - . =3D ALIGN(STACK_SIZE); + . =3D ALIGN(PAGE_SIZE); __per_cpu_end =3D .; =20 __bss_start =3D .; /* BSS */ .bss : { + . =3D ALIGN(STACK_SIZE); *(.bss.stack_aligned) + . =3D ALIGN(PAGE_SIZE); *(.bss.page_aligned) *(.bss) } :text Index: 2007-07-03/xen/arch/x86/x86_64/traps.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 --- 2007-07-03.orig/xen/arch/x86/x86_64/traps.c 2007-06-22 16:57:45.0000000= 00 +0200 +++ 2007-07-03/xen/arch/x86/x86_64/traps.c 2007-07-03 10:34:30.0000000= 00 +0200 @@ -292,11 +292,11 @@ void __init percpu_traps_init(void) =20 if ( cpu =3D=3D 0 ) { - /* Specify dedicated interrupt stacks for NMIs and double faults. = */ + /* Specify dedicated interrupt stacks for NMI, #DF, and #MC. */ set_intr_gate(TRAP_double_fault, &double_fault); - idt_table[TRAP_double_fault].a |=3D 1UL << 32; /* IST1 */ - idt_table[TRAP_nmi].a |=3D 2UL << 32; /* IST2 */ - idt_table[TRAP_machine_check].a |=3D 3UL << 32; /* IST3 */ + idt_table[TRAP_double_fault].a |=3D IST_DF << 32; + idt_table[TRAP_nmi].a |=3D IST_NMI << 32; + idt_table[TRAP_machine_check].a |=3D IST_MCE << 32; =20 /* * The 32-on-64 hypercall entry vector is only accessible from = ring 1. @@ -311,17 +311,18 @@ void __init percpu_traps_init(void) stack_bottom =3D (char *)get_stack_bottom(); stack =3D (char *)((unsigned long)stack_bottom & ~(STACK_SIZE = - 1)); =20 - /* Machine Check handler has its own per-CPU 1kB stack. */ - init_tss[cpu].ist[2] =3D (unsigned long)&stack[1024]; + /* Machine Check handler has its own per-CPU 4kB stack. */ + init_tss[cpu].ist[IST_MCE] =3D (unsigned long)&stack[IST_MCE * = PAGE_SIZE]; =20 - /* Double-fault handler has its own per-CPU 1kB stack. */ - init_tss[cpu].ist[0] =3D (unsigned long)&stack[2048]; + /* Double-fault handler has its own per-CPU 4kB stack. */ + init_tss[cpu].ist[IST_DF] =3D (unsigned long)&stack[IST_DF * = PAGE_SIZE]; =20 - /* NMI handler has its own per-CPU 1kB stack. */ - init_tss[cpu].ist[1] =3D (unsigned long)&stack[3072]; + /* NMI handler has its own per-CPU 4kB stack. */ + init_tss[cpu].ist[IST_NMI] =3D (unsigned long)&stack[IST_NMI * = PAGE_SIZE]; =20 /* Trampoline for SYSCALL entry from long mode. */ - stack =3D &stack[3072]; /* Skip the NMI and DF stacks. */ + BUILD_BUG_ON((IST_MAX + 1) * PAGE_SIZE + DEBUG_STACK_SIZE > STACK_SIZE= ); + stack =3D &stack[IST_MAX * PAGE_SIZE]; /* Skip the IST stacks. */ wrmsr(MSR_LSTAR, (unsigned long)stack, ((unsigned long)stack>>32)); stack +=3D write_stack_trampoline(stack, stack_bottom, FLAT_KERNEL_CS6= 4); =20 Index: 2007-07-03/xen/arch/x86/x86_64/xen.lds.S =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 --- 2007-07-03.orig/xen/arch/x86/x86_64/xen.lds.S 2007-06-04 = 08:35:35.000000000 +0200 +++ 2007-07-03/xen/arch/x86/x86_64/xen.lds.S 2007-07-03 10:30:34.0000000= 00 +0200 @@ -68,12 +68,14 @@ SECTIONS .data.percpu : { *(.data.percpu) } :text __per_cpu_data_end =3D .; . =3D __per_cpu_start + (NR_CPUS << PERCPU_SHIFT); - . =3D ALIGN(STACK_SIZE); + . =3D ALIGN(PAGE_SIZE); __per_cpu_end =3D .; =20 __bss_start =3D .; /* BSS */ .bss : { + . =3D ALIGN(STACK_SIZE); *(.bss.stack_aligned) + . =3D ALIGN(PAGE_SIZE); *(.bss.page_aligned) *(.bss) } :text Index: 2007-07-03/xen/include/asm-x86/config.h =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 --- 2007-07-03.orig/xen/include/asm-x86/config.h 2007-06-11 = 15:01:03.000000000 +0200 +++ 2007-07-03/xen/include/asm-x86/config.h 2007-07-03 10:30:34.0000000= 00 +0200 @@ -77,7 +77,11 @@ #define MEMORY_GUARD #endif =20 +#ifdef __i386__ #define STACK_ORDER 2 +#else +#define STACK_ORDER 3 +#endif #define STACK_SIZE (PAGE_SIZE << STACK_ORDER) =20 /* Debug stack is restricted to 8kB by guard pages. */ Index: 2007-07-03/xen/include/asm-x86/processor.h =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 --- 2007-07-03.orig/xen/include/asm-x86/processor.h 2007-07-02 = 08:13:50.000000000 +0200 +++ 2007-07-03/xen/include/asm-x86/processor.h 2007-07-03 10:30:34.0000000= 00 +0200 @@ -448,6 +448,13 @@ struct tss_struct { u8 __cacheline_filler[24]; } __cacheline_aligned __attribute__((packed)); =20 +#ifdef __x86_64__ +# define IST_DF 1UL +# define IST_NMI 2UL +# define IST_MCE 3UL +# define IST_MAX 3UL +#endif + #define IDT_ENTRIES 256 extern idt_entry_t idt_table[]; extern idt_entry_t *idt_tables[];