ia64/xen-unstable

changeset 5378:936540389715

bitkeeper revision 1.1691.1.11 (42a72af5QNdnBWsIc8m-lsGSZo47vQ)

Merge arcadians.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-2.0-testing.bk
into arcadians.cl.cam.ac.uk:/local/scratch-2/vh249/fpu/xen-unstable.bk
author vh249@arcadians.cl.cam.ac.uk
date Wed Jun 08 17:29:25 2005 +0000 (2005-06-08)
parents 9312a7006284 99d9ce2c0a65
children 312e36113cc5
files .rootkeys linux-2.6.11-xen-sparse/drivers/xen/blkfront/vbd.c linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/bugs.h
line diff
     1.1 --- a/.rootkeys	Wed Jun 08 15:13:43 2005 +0000
     1.2 +++ b/.rootkeys	Wed Jun 08 17:29:25 2005 +0000
     1.3 @@ -344,6 +344,7 @@ 41ee5e8ckZ9xVNvu9NHIZDK7JqApmQ linux-2.6
     1.4  41ee5e8ck9scpGirfqEZRARbGDyTXA linux-2.6.11-xen-sparse/drivers/xen/usbfront/xhci.h
     1.5  412f47e4RKD-R5IS5gEXvcT8L4v8gA linux-2.6.11-xen-sparse/include/asm-generic/pgtable.h
     1.6  42400318xlBIV46qyxLTaDepPLNyhg linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/agp.h
     1.7 +42a7252dZgup3r7qUeJGriyN5o9rUg linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/bugs.h
     1.8  40f56239YAjS52QG2FIAQpHDZAdGHg linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/desc.h
     1.9  4107adf1E5O4ztGHNGMzCCNhcvqNow linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/dma-mapping.h
    1.10  40f5623akIoBsQ3KxSB2kufkbgONXQ linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/fixmap.h
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/include/asm-xen/asm-i386/bugs.h	Wed Jun 08 17:29:25 2005 +0000
     3.3 @@ -0,0 +1,214 @@
     3.4 +/*
     3.5 + *  include/asm-i386/bugs.h
     3.6 + *
     3.7 + *  Copyright (C) 1994  Linus Torvalds
     3.8 + *
     3.9 + *  Cyrix stuff, June 1998 by:
    3.10 + *	- Rafael R. Reilova (moved everything from head.S),
    3.11 + *        <rreilova@ececs.uc.edu>
    3.12 + *	- Channing Corn (tests & fixes),
    3.13 + *	- Andrew D. Balsa (code cleanup).
    3.14 + *
    3.15 + *  Pentium III FXSR, SSE support
    3.16 + *	Gareth Hughes <gareth@valinux.com>, May 2000
    3.17 + */
    3.18 +
    3.19 +/*
    3.20 + * This is included by init/main.c to check for architecture-dependent bugs.
    3.21 + *
    3.22 + * Needs:
    3.23 + *	void check_bugs(void);
    3.24 + */
    3.25 +
    3.26 +#include <linux/config.h>
    3.27 +#include <linux/init.h>
    3.28 +#include <asm/processor.h>
    3.29 +#include <asm/i387.h>
    3.30 +#include <asm/msr.h>
    3.31 +
    3.32 +static int __init no_halt(char *s)
    3.33 +{
    3.34 +	boot_cpu_data.hlt_works_ok = 0;
    3.35 +	return 1;
    3.36 +}
    3.37 +
    3.38 +__setup("no-hlt", no_halt);
    3.39 +
    3.40 +static int __init mca_pentium(char *s)
    3.41 +{
    3.42 +	mca_pentium_flag = 1;
    3.43 +	return 1;
    3.44 +}
    3.45 +
    3.46 +__setup("mca-pentium", mca_pentium);
    3.47 +
    3.48 +static int __init no_387(char *s)
    3.49 +{
    3.50 +	boot_cpu_data.hard_math = 0;
    3.51 +	write_cr0(0xE | read_cr0());
    3.52 +	return 1;
    3.53 +}
    3.54 +
    3.55 +__setup("no387", no_387);
    3.56 +
    3.57 +static double __initdata x = 4195835.0;
    3.58 +static double __initdata y = 3145727.0;
    3.59 +
    3.60 +/*
    3.61 + * This used to check for exceptions.. 
    3.62 + * However, it turns out that to support that,
    3.63 + * the XMM trap handlers basically had to
    3.64 + * be buggy. So let's have a correct XMM trap
    3.65 + * handler, and forget about printing out
    3.66 + * some status at boot.
    3.67 + *
    3.68 + * We should really only care about bugs here
    3.69 + * anyway. Not features.
    3.70 + */
    3.71 +static void __init check_fpu(void)
    3.72 +{
    3.73 +	if (!boot_cpu_data.hard_math) {
    3.74 +#ifndef CONFIG_MATH_EMULATION
    3.75 +		printk(KERN_EMERG "No coprocessor found and no math emulation present.\n");
    3.76 +		printk(KERN_EMERG "Giving up.\n");
    3.77 +		for (;;) ;
    3.78 +#endif
    3.79 +		return;
    3.80 +	}
    3.81 +
    3.82 +/* Enable FXSR and company _before_ testing for FP problems. */
    3.83 +	/*
    3.84 +	 * Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned.
    3.85 +	 */
    3.86 +	if (offsetof(struct task_struct, thread.i387.fxsave) & 15) {
    3.87 +		extern void __buggy_fxsr_alignment(void);
    3.88 +		__buggy_fxsr_alignment();
    3.89 +	}
    3.90 +	if (cpu_has_fxsr) {
    3.91 +		printk(KERN_INFO "Enabling fast FPU save and restore... ");
    3.92 +		set_in_cr4(X86_CR4_OSFXSR);
    3.93 +		printk("done.\n");
    3.94 +	}
    3.95 +	if (cpu_has_xmm) {
    3.96 +		printk(KERN_INFO "Enabling unmasked SIMD FPU exception support... ");
    3.97 +		set_in_cr4(X86_CR4_OSXMMEXCPT);
    3.98 +		printk("done.\n");
    3.99 +	}
   3.100 +
   3.101 +	/* Test for the divl bug.. */
   3.102 +	__asm__("fninit\n\t"
   3.103 +		"fldl %1\n\t"
   3.104 +		"fdivl %2\n\t"
   3.105 +		"fmull %2\n\t"
   3.106 +		"fldl %1\n\t"
   3.107 +		"fsubp %%st,%%st(1)\n\t"
   3.108 +		"fistpl %0\n\t"
   3.109 +		"fwait\n\t"
   3.110 +		"fninit"
   3.111 +		: "=m" (*&boot_cpu_data.fdiv_bug)
   3.112 +		: "m" (*&x), "m" (*&y));
   3.113 +	stts();
   3.114 +	if (boot_cpu_data.fdiv_bug)
   3.115 +		printk("Hmm, FPU with FDIV bug.\n");
   3.116 +}
   3.117 +
   3.118 +static void __init check_hlt(void)
   3.119 +{
   3.120 +	printk(KERN_INFO "Checking 'hlt' instruction... ");
   3.121 +	if (!boot_cpu_data.hlt_works_ok) {
   3.122 +		printk("disabled\n");
   3.123 +		return;
   3.124 +	}
   3.125 +	__asm__ __volatile__("hlt ; hlt ; hlt ; hlt");
   3.126 +	printk("OK.\n");
   3.127 +}
   3.128 +
   3.129 +/*
   3.130 + *	Most 386 processors have a bug where a POPAD can lock the 
   3.131 + *	machine even from user space.
   3.132 + */
   3.133 + 
   3.134 +static void __init check_popad(void)
   3.135 +{
   3.136 +#ifndef CONFIG_X86_POPAD_OK
   3.137 +	int res, inp = (int) &res;
   3.138 +
   3.139 +	printk(KERN_INFO "Checking for popad bug... ");
   3.140 +	__asm__ __volatile__( 
   3.141 +	  "movl $12345678,%%eax; movl $0,%%edi; pusha; popa; movl (%%edx,%%edi),%%ecx "
   3.142 +	  : "=&a" (res)
   3.143 +	  : "d" (inp)
   3.144 +	  : "ecx", "edi" );
   3.145 +	/* If this fails, it means that any user program may lock the CPU hard. Too bad. */
   3.146 +	if (res != 12345678) printk( "Buggy.\n" );
   3.147 +		        else printk( "OK.\n" );
   3.148 +#endif
   3.149 +}
   3.150 +
   3.151 +/*
   3.152 + * Check whether we are able to run this kernel safely on SMP.
   3.153 + *
   3.154 + * - In order to run on a i386, we need to be compiled for i386
   3.155 + *   (for due to lack of "invlpg" and working WP on a i386)
   3.156 + * - In order to run on anything without a TSC, we need to be
   3.157 + *   compiled for a i486.
   3.158 + * - In order to support the local APIC on a buggy Pentium machine,
   3.159 + *   we need to be compiled with CONFIG_X86_GOOD_APIC disabled,
   3.160 + *   which happens implicitly if compiled for a Pentium or lower
   3.161 + *   (unless an advanced selection of CPU features is used) as an
   3.162 + *   otherwise config implies a properly working local APIC without
   3.163 + *   the need to do extra reads from the APIC.
   3.164 +*/
   3.165 +
   3.166 +static void __init check_config(void)
   3.167 +{
   3.168 +/*
   3.169 + * We'd better not be a i386 if we're configured to use some
   3.170 + * i486+ only features! (WP works in supervisor mode and the
   3.171 + * new "invlpg" and "bswap" instructions)
   3.172 + */
   3.173 +#if defined(CONFIG_X86_WP_WORKS_OK) || defined(CONFIG_X86_INVLPG) || defined(CONFIG_X86_BSWAP)
   3.174 +	if (boot_cpu_data.x86 == 3)
   3.175 +		panic("Kernel requires i486+ for 'invlpg' and other features");
   3.176 +#endif
   3.177 +
   3.178 +/*
   3.179 + * If we configured ourselves for a TSC, we'd better have one!
   3.180 + */
   3.181 +#ifdef CONFIG_X86_TSC
   3.182 +	if (!cpu_has_tsc)
   3.183 +		panic("Kernel compiled for Pentium+, requires TSC feature!");
   3.184 +#endif
   3.185 +
   3.186 +/*
   3.187 + * If we were told we had a good local APIC, check for buggy Pentia,
   3.188 + * i.e. all B steppings and the C2 stepping of P54C when using their
   3.189 + * integrated APIC (see 11AP erratum in "Pentium Processor
   3.190 + * Specification Update").
   3.191 + */
   3.192 +#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_GOOD_APIC)
   3.193 +	if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL
   3.194 +	    && cpu_has_apic
   3.195 +	    && boot_cpu_data.x86 == 5
   3.196 +	    && boot_cpu_data.x86_model == 2
   3.197 +	    && (boot_cpu_data.x86_mask < 6 || boot_cpu_data.x86_mask == 11))
   3.198 +		panic("Kernel compiled for PMMX+, assumes a local APIC without the read-before-write bug!");
   3.199 +#endif
   3.200 +}
   3.201 +
   3.202 +extern void alternative_instructions(void);
   3.203 +
   3.204 +static void __init check_bugs(void)
   3.205 +{
   3.206 +	identify_cpu(&boot_cpu_data);
   3.207 +#ifndef CONFIG_SMP
   3.208 +	printk("CPU: ");
   3.209 +	print_cpu_info(&boot_cpu_data);
   3.210 +#endif
   3.211 +	check_config();
   3.212 +	check_fpu();
   3.213 +	check_hlt();
   3.214 +	check_popad();
   3.215 +	system_utsname.machine[1] = '0' + (boot_cpu_data.x86 > 6 ? 6 : boot_cpu_data.x86);
   3.216 +	alternative_instructions(); 
   3.217 +}