ia64/xen-unstable

changeset 5595:63c1bb85fcea

bitkeeper revision 1.1763 (42c11c79p9Z_K0YwZk_N5zJU0rjzDg)

Merge arcadians.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xeno.bk
into arcadians.cl.cam.ac.uk:/auto/anfs/nos1/ach61/bk
author ach61@arcadians.cl.cam.ac.uk
date Tue Jun 28 09:46:33 2005 +0000 (2005-06-28)
parents 9bcdcf2dbb54 c2b00e4bfb8f
children cb1cad0ed221
files tools/firmware/rombios/rombios.c tools/firmware/vmxassist/setup.c tools/firmware/vmxassist/util.c tools/firmware/vmxassist/util.h tools/firmware/vmxassist/vm86.c xen/arch/x86/boot/x86_32.S xen/arch/x86/setup.c xen/arch/x86/vmx.c xen/arch/x86/x86_32/mm.c xen/common/grant_table.c
line diff
     1.1 --- a/tools/firmware/rombios/rombios.c	Tue Jun 28 07:23:41 2005 +0000
     1.2 +++ b/tools/firmware/rombios/rombios.c	Tue Jun 28 09:46:33 2005 +0000
     1.3 @@ -27,6 +27,7 @@
     1.4  // ROM BIOS for use with Bochs/Plex x86 emulation environment
     1.5  
     1.6  #define VMXASSIST
     1.7 +#undef VMXTEST
     1.8  
     1.9  // ROM BIOS compatability entry points:
    1.10  // ===================================
    1.11 @@ -4070,10 +4071,10 @@ ASM_END
    1.12          switch(regs.u.r8.al)
    1.13          {
    1.14           case 0x20: // coded by osmaker aka K.J.
    1.15 -            if(regs.u.r32.edx == 0x534D4150)
    1.16 +            if(regs.u.r32.edx == 0x534D4150) /* SMAP */
    1.17              {
    1.18  #ifdef VMXASSIST
    1.19 -		if ((regs.u.r16.bx / 0x14)* 0x14 == regs.u.r16.bx) {
    1.20 +		if ((regs.u.r16.bx / 0x14) * 0x14 == regs.u.r16.bx) {
    1.21  		    Bit16u e820_table_size = read_word(0xe000, 0x8) * 0x14;
    1.22  
    1.23  		    if (regs.u.r16.bx + 0x14 <= e820_table_size) {
    1.24 @@ -10353,8 +10354,17 @@ dummy_iret_handler:
    1.25    HALT(__LINE__)
    1.26    iret
    1.27  
    1.28 +#ifdef VMXTEST
    1.29 +.org 0xffe0
    1.30 +  jmp 0xf000:post;
    1.31 +#endif
    1.32 +
    1.33  .org 0xfff0 ; Power-up Entry Point
    1.34 +#ifdef VMXTEST
    1.35 +  jmp 0xd000:0x0003;
    1.36 +#else
    1.37    jmp 0xf000:post
    1.38 +#endif
    1.39  
    1.40  .org 0xfff5 ; ASCII Date ROM was built - 8 characters in MM/DD/YY
    1.41  .ascii BIOS_BUILD_DATE
     2.1 --- a/tools/firmware/vmxassist/setup.c	Tue Jun 28 07:23:41 2005 +0000
     2.2 +++ b/tools/firmware/vmxassist/setup.c	Tue Jun 28 09:46:33 2005 +0000
     2.3 @@ -46,7 +46,19 @@ struct dtr idtr = { sizeof(idt)-1, (unsi
     2.4  
     2.5  #ifdef TEST
     2.6  unsigned pgd[NR_PGD] __attribute__ ((aligned(PGSIZE))) = { 0 };
     2.7 -#endif
     2.8 +
     2.9 +struct e820entry e820map[] = {
    2.10 +	{ 0x0000000000000000ULL, 0x000000000009F800ULL, E820_RAM },
    2.11 +	{ 0x000000000009F800ULL, 0x0000000000000800ULL, E820_RESERVED },
    2.12 +	{ 0x00000000000A0000ULL, 0x0000000000020000ULL, E820_IO },
    2.13 +	{ 0x00000000000C0000ULL, 0x0000000000040000ULL, E820_RESERVED },
    2.14 +	{ 0x0000000000100000ULL, 0x0000000000000000ULL, E820_RAM },
    2.15 +	{ 0x0000000000000000ULL, 0x0000000000001000ULL, E820_SHARED },
    2.16 +	{ 0x0000000000000000ULL, 0x0000000000003000ULL, E820_NVS },
    2.17 +	{ 0x0000000000003000ULL, 0x000000000000A000ULL, E820_ACPI },
    2.18 +	{ 0x00000000FEC00000ULL, 0x0000000001400000ULL, E820_IO },
    2.19 +};
    2.20 +#endif /* TEST */
    2.21  
    2.22  struct vmx_assist_context oldctx;
    2.23  struct vmx_assist_context newctx;
    2.24 @@ -72,7 +84,20 @@ banner(void)
    2.25  		    (((get_cmos(0x31) << 8) | get_cmos(0x30)) + 0x400) << 10;
    2.26  	memory_size += 0x400 << 10; /* + 1MB */
    2.27  
    2.28 +#ifdef TEST
    2.29 +	/* Create an SMAP for our debug environment */
    2.30 +	e820map[4].size = memory_size - e820map[4].addr - PGSIZE;
    2.31 +	e820map[5].addr = memory_size - PGSIZE;
    2.32 +	e820map[6].addr = memory_size;
    2.33 +	e820map[7].addr += memory_size;
    2.34 +
    2.35 +	*LINUX_E820_MAP_NR = sizeof(e820map)/sizeof(e820map[0]);
    2.36 +	memcpy(LINUX_E820_MAP, e820map, sizeof(e820map));
    2.37 +#endif
    2.38 +
    2.39  	printf("Memory size %ld MB\n", memory_size >> 20);
    2.40 +	printf("E820 map:\n");
    2.41 +	print_e820_map(LINUX_E820_MAP, *LINUX_E820_MAP_NR);
    2.42  	printf("\n");
    2.43  }
    2.44  
     3.1 --- a/tools/firmware/vmxassist/util.c	Tue Jun 28 07:23:41 2005 +0000
     3.2 +++ b/tools/firmware/vmxassist/util.c	Tue Jun 28 09:46:33 2005 +0000
     3.3 @@ -74,6 +74,36 @@ hexdump(unsigned char *data, int sz)
     3.4  }
     3.5  
     3.6  void
     3.7 +print_e820_map(struct e820entry *map, int entries)
     3.8 +{
     3.9 +	struct e820entry *m;
    3.10 +
    3.11 +	if (entries > 32)
    3.12 +		entries = 32;
    3.13 +
    3.14 +	for (m = map; m < &map[entries]; m++) {
    3.15 +		printf("%08lx%08lx - %08lx%08lx ",
    3.16 +			(unsigned long) (m->addr >> 32),
    3.17 +			(unsigned long) (m->addr),
    3.18 +			(unsigned long) ((m->addr+m->size) >> 32),
    3.19 +			(unsigned long) ((m->addr+m->size)));
    3.20 +
    3.21 +		switch (m->type) {
    3.22 +		case E820_RAM:
    3.23 +			printf("(RAM)\n"); break;
    3.24 +		case E820_RESERVED:
    3.25 +			printf("(Reserved)\n"); break;
    3.26 +		case E820_ACPI:
    3.27 +			printf("(ACPI Data)\n"); break;
    3.28 +		case E820_NVS:
    3.29 +			printf("(ACPI NVS)\n"); break;
    3.30 +		default:
    3.31 +			printf("(Type %ld)\n", m->type); break;
    3.32 +		}
    3.33 +	}
    3.34 +}
    3.35 +
    3.36 +void
    3.37  dump_dtr(unsigned long base, unsigned long limit)
    3.38  {
    3.39  	unsigned long long entry;
     4.1 --- a/tools/firmware/vmxassist/util.h	Tue Jun 28 07:23:41 2005 +0000
     4.2 +++ b/tools/firmware/vmxassist/util.h	Tue Jun 28 09:46:33 2005 +0000
     4.3 @@ -23,6 +23,24 @@
     4.4  #include <stdarg.h>
     4.5  #include <vm86.h>
     4.6  
     4.7 +
     4.8 +#define	LINUX_E820_MAP_NR	((unsigned char *)0x901E8)
     4.9 +#define	LINUX_E820_MAP		((struct e820entry *)0x902D0)
    4.10 +
    4.11 +#define	E820_RAM	1
    4.12 +#define	E820_RESERVED	2
    4.13 +#define	E820_ACPI	3
    4.14 +#define	E820_NVS	4
    4.15 +#define	E820_IO		16
    4.16 +#define	E820_SHARED	17
    4.17 +
    4.18 +struct e820entry {
    4.19 +	unsigned long long	addr;
    4.20 +	unsigned long long	size;
    4.21 +	unsigned long		type;
    4.22 +} __attribute__((packed));
    4.23 +
    4.24 +
    4.25  #define	offsetof(type, member)	((unsigned) &((type *)0)->member)
    4.26  
    4.27  struct vmx_assist_context;
    4.28 @@ -30,6 +48,7 @@ struct vmx_assist_context;
    4.29  extern void hexdump(unsigned char *, int);
    4.30  extern void dump_regs(struct regs *);
    4.31  extern void dump_vmx_context(struct vmx_assist_context *);
    4.32 +extern void print_e820_map(struct e820entry *, int);
    4.33  extern void dump_dtr(unsigned long, unsigned long);
    4.34  extern void *memcpy(void *, const void *, unsigned);
    4.35  extern void *memset(void *, int, unsigned);
     5.1 --- a/tools/firmware/vmxassist/vm86.c	Tue Jun 28 07:23:41 2005 +0000
     5.2 +++ b/tools/firmware/vmxassist/vm86.c	Tue Jun 28 09:46:33 2005 +0000
     5.3 @@ -950,7 +950,7 @@ trap(int trapno, int errno, struct regs 
     5.4  
     5.5  	default:
     5.6  	invalid:
     5.7 -		printf("Trap (%d) while in %s mode\n",
     5.8 +		printf("Trap (0x%x) while in %s mode\n",
     5.9  		    trapno, regs->eflags & EFLAGS_VM ? "real" : "protected");
    5.10  		if (trapno == 14)
    5.11  			printf("Page fault address 0x%x\n", get_cr2());
     6.1 --- a/xen/arch/x86/boot/x86_32.S	Tue Jun 28 07:23:41 2005 +0000
     6.2 +++ b/xen/arch/x86/boot/x86_32.S	Tue Jun 28 09:46:33 2005 +0000
     6.3 @@ -20,16 +20,10 @@ ENTRY(start)
     6.4  	/* Checksum: must be the negated sum of the first two fields. */
     6.5  	.long	-0x1BADB005
     6.6          
     6.7 -bad_cpu_msg:
     6.8 -        .asciz "ERR: Not a P6-compatible CPU!"
     6.9  not_multiboot_msg:
    6.10          .asciz "ERR: Not a Multiboot bootloader!"
    6.11 -bad_cpu:
    6.12 -        mov     $bad_cpu_msg-__PAGE_OFFSET,%esi
    6.13 -        jmp     print_err
    6.14  not_multiboot:
    6.15          mov     $not_multiboot_msg-__PAGE_OFFSET,%esi
    6.16 -print_err:
    6.17          mov     $0xB8000,%edi  # VGA framebuffer
    6.18  1:      mov     (%esi),%bl
    6.19          test    %bl,%bl        # Terminate on '\0' sentinel
    6.20 @@ -61,19 +55,6 @@ 1:      lss     stack_start-__PAGE_OFFSE
    6.21  	pushl	$0
    6.22  	popf
    6.23  
    6.24 -        /* CPU type checks. We need P6+. */
    6.25 -        mov     $0x200000,%edx
    6.26 -        pushfl
    6.27 -        pop     %ecx
    6.28 -        and     %edx,%ecx
    6.29 -        jne     bad_cpu            # ID bit should be clear
    6.30 -        pushl   %edx
    6.31 -        popfl
    6.32 -        pushfl
    6.33 -        pop     %ecx
    6.34 -        and     %edx,%ecx
    6.35 -        je      bad_cpu            # ID bit should be set
    6.36 -
    6.37          /* Set up FPU. */
    6.38          fninit
    6.39          
     7.1 --- a/xen/arch/x86/setup.c	Tue Jun 28 07:23:41 2005 +0000
     7.2 +++ b/xen/arch/x86/setup.c	Tue Jun 28 09:46:33 2005 +0000
     7.3 @@ -87,7 +87,7 @@ struct cpuinfo_x86 boot_cpu_data = { 0, 
     7.4  #if CONFIG_PAGING_LEVELS > 2
     7.5  unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE | X86_CR4_PAE;
     7.6  #else
     7.7 -unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE;
     7.8 +unsigned long mmu_cr4_features = X86_CR4_PSE;
     7.9  #endif
    7.10  EXPORT_SYMBOL(mmu_cr4_features);
    7.11  
     8.1 --- a/xen/arch/x86/vmx.c	Tue Jun 28 07:23:41 2005 +0000
     8.2 +++ b/xen/arch/x86/vmx.c	Tue Jun 28 09:46:33 2005 +0000
     8.3 @@ -1159,15 +1159,19 @@ asmlinkage void vmx_vmexit_handler(struc
     8.4  
     8.5      __vmread(IDT_VECTORING_INFO_FIELD, &idtv_info_field);
     8.6      if (idtv_info_field & INTR_INFO_VALID_MASK) {
     8.7 -        __vmwrite(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field);
     8.8 -        if ((idtv_info_field & 0xff) == 14) {
     8.9 -            unsigned long error_code;
    8.10 +	if ((idtv_info_field & 0x0700) != 0x400) { /* exclude soft ints */
    8.11 +            __vmwrite(VM_ENTRY_INTR_INFO_FIELD, idtv_info_field);
    8.12  
    8.13 -            __vmread(VM_EXIT_INTR_ERROR_CODE, &error_code);
    8.14 -            printk("#PG error code: %lx\n", error_code);
    8.15 -        }
    8.16 -        VMX_DBG_LOG(DBG_LEVEL_1, "idtv_info_field=%x",
    8.17 -                idtv_info_field);
    8.18 +	    if (idtv_info_field & 0x800) { /* valid error code */
    8.19 +		unsigned long error_code;
    8.20 +		printk("VMX exit %x: %x/%lx\n",
    8.21 +			exit_reason, idtv_info_field, error_code);
    8.22 +		__vmread(VM_EXIT_INTR_ERROR_CODE, &error_code);
    8.23 +		__vmwrite(VM_ENTRY_EXCEPTION_ERROR_CODE, error_code);
    8.24 +	    } else
    8.25 +	    	printk("VMX exit %x: %x\n", exit_reason, idtv_info_field);
    8.26 +	}
    8.27 +        VMX_DBG_LOG(DBG_LEVEL_1, "idtv_info_field=%x", idtv_info_field);
    8.28      }
    8.29  
    8.30      /* don't bother H/W interrutps */
    8.31 @@ -1399,7 +1403,6 @@ asmlinkage void load_cr2(void)
    8.32  #else
    8.33      asm volatile("movq %0,%%cr2": :"r" (d->arch.arch_vmx.cpu_cr2));
    8.34  #endif
    8.35 -
    8.36  }
    8.37  
    8.38  #endif /* CONFIG_VMX */
     9.1 --- a/xen/arch/x86/x86_32/mm.c	Tue Jun 28 07:23:41 2005 +0000
     9.2 +++ b/xen/arch/x86/x86_32/mm.c	Tue Jun 28 09:46:33 2005 +0000
     9.3 @@ -80,6 +80,7 @@ void __init paging_init(void)
     9.4      if ( cpu_has_pge )
     9.5      {
     9.6          /* Suitable Xen mapping can be GLOBAL. */
     9.7 +        set_in_cr4(X86_CR4_PGE);
     9.8          PAGE_HYPERVISOR         |= _PAGE_GLOBAL;
     9.9          PAGE_HYPERVISOR_NOCACHE |= _PAGE_GLOBAL;
    9.10          /* Transform early mappings (e.g., the frametable). */
    10.1 --- a/xen/common/grant_table.c	Tue Jun 28 07:23:41 2005 +0000
    10.2 +++ b/xen/common/grant_table.c	Tue Jun 28 09:46:33 2005 +0000
    10.3 @@ -32,6 +32,12 @@
    10.4  #include <xen/mm.h>
    10.5  #include <acm/acm_hooks.h>
    10.6  
    10.7 +#if defined(CONFIG_X86_64)
    10.8 +#define GRANT_PTE_FLAGS (_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
    10.9 +#else
   10.10 +#define GRANT_PTE_FLAGS (_PAGE_PRESENT|_PAGE_ACCESSED|_PAGE_DIRTY)
   10.11 +#endif
   10.12 +
   10.13  #define PIN_FAIL(_lbl, _rc, _f, _a...)   \
   10.14      do {                           \
   10.15          DPRINTK( _f, ## _a );      \
   10.16 @@ -258,11 +264,7 @@ static int
   10.17      {
   10.18          /* Write update into the pagetable. */
   10.19          l1_pgentry_t pte;
   10.20 -        pte = l1e_from_pfn(frame, _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY
   10.21 -#if defined(__x86_64__)
   10.22 -            | _PAGE_USER               
   10.23 -#endif
   10.24 -            );
   10.25 +        pte = l1e_from_pfn(frame, GRANT_PTE_FLAGS);
   10.26          if ( !(dev_hst_ro_flags & GNTMAP_readonly) )
   10.27              l1e_add_flags(pte,_PAGE_RW);
   10.28          rc = update_grant_va_mapping( host_virt_addr, pte,