ia64/xen-unstable

changeset 9470:c745e47d8154

Merged.
author emellor@leeni.uk.xensource.com
date Tue Mar 28 11:52:47 2006 +0100 (2006-03-28)
parents 1c4e1d0fd1bb 2604abf98ede
children c43d7806ca5a
files
line diff
     1.1 --- a/.hgtags	Tue Mar 28 11:51:06 2006 +0100
     1.2 +++ b/.hgtags	Tue Mar 28 11:52:47 2006 +0100
     1.3 @@ -13,3 +13,4 @@ 9afec5bc14aeb197ef37ea54a57eacd427463fc3
     1.4  30c521db4c71960b0cf1d9c9e1b658e77b535a3e split-1.0
     1.5  3d330e41f41ce1bc118c02346e18949ad5d67f6b split-1.1
     1.6  c8fdb0caa77b429cf47f9707926e83947778cb48 RELEASE-3.0.0
     1.7 +af0573e9e5258db0a9d28aa954dd302ddd2c2d23 3.0.2-rc
     2.1 --- a/Makefile	Tue Mar 28 11:51:06 2006 +0100
     2.2 +++ b/Makefile	Tue Mar 28 11:52:47 2006 +0100
     2.3 @@ -2,7 +2,7 @@
     2.4  # Grand Unified Makefile for Xen.
     2.5  #
     2.6  
     2.7 -KERNELS ?= linux-2.6-xen0 linux-2.6-xenU
     2.8 +KERNELS ?= linux-2.6-xen
     2.9  # You may use wildcards in the above e.g. KERNELS=*2.6*
    2.10  
    2.11  XKERNELS := $(foreach kernel, $(KERNELS), $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.$(kernel))) )
     3.1 --- a/buildconfigs/linux-defconfig_xen0_ia64	Tue Mar 28 11:51:06 2006 +0100
     3.2 +++ b/buildconfigs/linux-defconfig_xen0_ia64	Tue Mar 28 11:52:47 2006 +0100
     3.3 @@ -1,7 +1,7 @@
     3.4  #
     3.5  # Automatically generated make config: don't edit
     3.6 -# Linux kernel version: 2.6.16-rc3-xen0
     3.7 -# Thu Feb 16 13:20:46 2006
     3.8 +# Linux kernel version: 2.6.16-xen0
     3.9 +# Mon Mar 27 14:46:03 2006
    3.10  #
    3.11  
    3.12  #
    3.13 @@ -95,8 +95,7 @@ CONFIG_ARCH_XEN=y
    3.14  CONFIG_XEN_PRIVILEGED_GUEST=y
    3.15  CONFIG_XEN_BLKDEV_GRANT=y
    3.16  CONFIG_XEN_BLKDEV_FRONTEND=y
    3.17 -CONFIG_XEN_VT=y
    3.18 -CONFIG_VT=y
    3.19 +CONFIG_XEN_BLKDEV_BACKEND=y
    3.20  CONFIG_XEN_SYSFS=y
    3.21  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
    3.22  CONFIG_DMA_IS_DMA32=y
    3.23 @@ -378,7 +377,7 @@ CONFIG_BLK_DEV_IDESCSI=y
    3.24  #
    3.25  # IDE chipset support/bugfixes
    3.26  #
    3.27 -CONFIG_IDE_GENERIC=y
    3.28 +# CONFIG_IDE_GENERIC is not set
    3.29  CONFIG_BLK_DEV_IDEPCI=y
    3.30  # CONFIG_IDEPCI_SHARE_IRQ is not set
    3.31  # CONFIG_BLK_DEV_OFFBOARD is not set
    3.32 @@ -706,6 +705,7 @@ CONFIG_GAMEPORT=y
    3.33  #
    3.34  # Character devices
    3.35  #
    3.36 +CONFIG_VT=y
    3.37  CONFIG_VT_CONSOLE=y
    3.38  CONFIG_HW_CONSOLE=y
    3.39  CONFIG_SERIAL_NONSTANDARD=y
    3.40 @@ -1252,11 +1252,7 @@ CONFIG_USB_MON=y
    3.41  # CONFIG_INFINIBAND is not set
    3.42  
    3.43  #
    3.44 -# SN Devices
    3.45 -#
    3.46 -
    3.47 -#
    3.48 -# EDAC - error detection and reporting (RAS)
    3.49 +# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
    3.50  #
    3.51  
    3.52  #
     4.1 --- a/buildconfigs/linux-defconfig_xenU_ia64	Tue Mar 28 11:51:06 2006 +0100
     4.2 +++ b/buildconfigs/linux-defconfig_xenU_ia64	Tue Mar 28 11:52:47 2006 +0100
     4.3 @@ -1,7 +1,7 @@
     4.4  #
     4.5  # Automatically generated make config: don't edit
     4.6 -# Linux kernel version: 2.6.16-rc3-xenU
     4.7 -# Thu Feb 16 13:47:59 2006
     4.8 +# Linux kernel version: 2.6.16-xenU
     4.9 +# Mon Mar 27 14:01:13 2006
    4.10  #
    4.11  
    4.12  #
    4.13 @@ -92,8 +92,7 @@ CONFIG_ARCH_XEN=y
    4.14  CONFIG_XEN_PRIVILEGED_GUEST=y
    4.15  CONFIG_XEN_BLKDEV_GRANT=y
    4.16  CONFIG_XEN_BLKDEV_FRONTEND=y
    4.17 -# CONFIG_XEN_VT is not set
    4.18 -# CONFIG_VT is not set
    4.19 +CONFIG_XEN_BLKDEV_BACKEND=y
    4.20  CONFIG_XEN_SYSFS=y
    4.21  CONFIG_SCHED_NO_NO_OMIT_FRAME_POINTER=y
    4.22  CONFIG_DMA_IS_DMA32=y
    4.23 @@ -607,6 +606,9 @@ CONFIG_SERIO=y
    4.24  #
    4.25  # Character devices
    4.26  #
    4.27 +CONFIG_VT=y
    4.28 +CONFIG_VT_CONSOLE=y
    4.29 +CONFIG_HW_CONSOLE=y
    4.30  # CONFIG_SERIAL_NONSTANDARD is not set
    4.31  
    4.32  #
    4.33 @@ -865,6 +867,13 @@ CONFIG_FB_RADEON_DEBUG=y
    4.34  # CONFIG_FB_VIRTUAL is not set
    4.35  
    4.36  #
    4.37 +# Console display driver support
    4.38 +#
    4.39 +CONFIG_VGA_CONSOLE=y
    4.40 +CONFIG_DUMMY_CONSOLE=y
    4.41 +# CONFIG_FRAMEBUFFER_CONSOLE is not set
    4.42 +
    4.43 +#
    4.44  # Logo configuration
    4.45  #
    4.46  CONFIG_LOGO=y
    4.47 @@ -1122,11 +1131,7 @@ CONFIG_USB_MON=y
    4.48  # CONFIG_INFINIBAND is not set
    4.49  
    4.50  #
    4.51 -# SN Devices
    4.52 -#
    4.53 -
    4.54 -#
    4.55 -# EDAC - error detection and reporting (RAS)
    4.56 +# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
    4.57  #
    4.58  
    4.59  #
     5.1 --- a/buildconfigs/linux-defconfig_xen_x86_64	Tue Mar 28 11:51:06 2006 +0100
     5.2 +++ b/buildconfigs/linux-defconfig_xen_x86_64	Tue Mar 28 11:52:47 2006 +0100
     5.3 @@ -1,7 +1,7 @@
     5.4  #
     5.5  # Automatically generated make config: don't edit
     5.6 -# Linux kernel version: 2.6.16-rc3-xen
     5.7 -# Mon Feb 20 11:37:11 2006
     5.8 +# Linux kernel version: 2.6.16-xen
     5.9 +# Mon Mar 27 09:43:44 2006
    5.10  #
    5.11  CONFIG_X86_64=y
    5.12  CONFIG_64BIT=y
    5.13 @@ -102,6 +102,8 @@ CONFIG_X86_PC=y
    5.14  # CONFIG_MPSC is not set
    5.15  CONFIG_GENERIC_CPU=y
    5.16  CONFIG_X86_64_XEN=y
    5.17 +CONFIG_X86_NO_TSS=y
    5.18 +CONFIG_X86_NO_IDT=y
    5.19  CONFIG_X86_L1_CACHE_BYTES=128
    5.20  CONFIG_X86_L1_CACHE_SHIFT=7
    5.21  CONFIG_X86_GOOD_APIC=y
    5.22 @@ -1138,7 +1140,7 @@ CONFIG_AMD8111_ETH=m
    5.23  CONFIG_AMD8111E_NAPI=y
    5.24  CONFIG_ADAPTEC_STARFIRE=m
    5.25  CONFIG_ADAPTEC_STARFIRE_NAPI=y
    5.26 -CONFIG_B44=m
    5.27 +# CONFIG_B44 is not set
    5.28  CONFIG_FORCEDETH=m
    5.29  CONFIG_DGRS=m
    5.30  CONFIG_EEPRO100=m
    5.31 @@ -1782,8 +1784,8 @@ CONFIG_VIDEO_DPC=m
    5.32  CONFIG_VIDEO_HEXIUM_ORION=m
    5.33  CONFIG_VIDEO_HEXIUM_GEMINI=m
    5.34  CONFIG_VIDEO_CX88=m
    5.35 +CONFIG_VIDEO_CX88_ALSA=m
    5.36  CONFIG_VIDEO_CX88_DVB=m
    5.37 -CONFIG_VIDEO_CX88_ALSA=m
    5.38  CONFIG_VIDEO_CX88_DVB_ALL_FRONTENDS=y
    5.39  CONFIG_VIDEO_CX88_VP3054=m
    5.40  CONFIG_VIDEO_EM28XX=m
    5.41 @@ -2331,11 +2333,7 @@ CONFIG_INFINIBAND_IPOIB=m
    5.42  CONFIG_INFINIBAND_SRP=m
    5.43  
    5.44  #
    5.45 -# SN Devices
    5.46 -#
    5.47 -
    5.48 -#
    5.49 -# EDAC - error detection and reporting (RAS)
    5.50 +# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
    5.51  #
    5.52  CONFIG_EDAC=m
    5.53  
     6.1 --- a/linux-2.6-xen-sparse/arch/ia64/Kconfig	Tue Mar 28 11:51:06 2006 +0100
     6.2 +++ b/linux-2.6-xen-sparse/arch/ia64/Kconfig	Tue Mar 28 11:52:47 2006 +0100
     6.3 @@ -84,19 +84,6 @@ config XEN_BLKDEV_BACKEND
     6.4  	bool
     6.5  	default y
     6.6  
     6.7 -config XEN_VT
     6.8 -	bool "Override for turning on CONFIG_VT for domU"
     6.9 -	default y
    6.10 -	help
    6.11 -	  Hack to turn off CONFIG_VT for domU
    6.12 -
    6.13 -config VT
    6.14 -	bool
    6.15 -	default y if XEN && XEN_VT
    6.16 -	default n if XEN && !XEN_VT
    6.17 -	help
    6.18 -	  Hack to turn off CONFIG_VT for domU
    6.19 -
    6.20  config XEN_SYSFS
    6.21  	bool "Export Xen attributes in sysfs"
    6.22  	depends on XEN && SYSFS
     7.1 --- a/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c	Tue Mar 28 11:51:06 2006 +0100
     7.2 +++ b/linux-2.6-xen-sparse/arch/ia64/kernel/setup.c	Tue Mar 28 11:52:47 2006 +0100
     7.3 @@ -506,6 +506,22 @@ setup_arch (char **cmdline_p)
     7.4  			conswitchp = &vga_con;
     7.5  # endif
     7.6  	}
     7.7 +#ifdef CONFIG_XEN
     7.8 +	if (running_on_xen) {
     7.9 +		extern shared_info_t *HYPERVISOR_shared_info;
    7.10 +
    7.11 +		/* xen_start_info isn't setup yet, get the flags manually */
    7.12 +		if (HYPERVISOR_shared_info->arch.flags & SIF_INITDOMAIN) {
    7.13 +			if (!(HYPERVISOR_shared_info->arch.flags & SIF_PRIVILEGED))
    7.14 +				panic("Xen granted us console access "
    7.15 +				      "but not privileged status");
    7.16 +		} else {
    7.17 +			extern int console_use_vt;
    7.18 +			conswitchp = NULL;
    7.19 +			console_use_vt = 0;
    7.20 +		}
    7.21 +	}
    7.22 +#endif
    7.23  #endif
    7.24  
    7.25  	/* enable IA-64 Machine Check Abort Handling unless disabled */
     8.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Tue Mar 28 11:51:06 2006 +0100
     8.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Tue Mar 28 11:52:47 2006 +0100
     8.3 @@ -855,32 +855,12 @@ ecrit:  /**** END OF CRITICAL REGION ***
     8.4  # i.e. it just resumes from the next instruction interrupted with the same context. 
     8.5  	
     8.6  # Hypervisor uses this for application faults while it executes.
     8.7 +# Unlike i386 there is no need to reload the saved segment selectors:
     8.8 +# Xen already reloaded all valid ones and zeroed the others.
     8.9  ENTRY(failsafe_callback)
    8.10 -	addq $0x10,%rsp /* skip rcx and r11 */	
    8.11 -1:	mov  (%rsp),%ds
    8.12 -2:	mov  8(%rsp),%es
    8.13 -3:	mov  16(%rsp),%fs
    8.14 -4:	mov  24(%rsp),%gs
    8.15 -	addq $0x20,%rsp /* skip the above selectors */		
    8.16 +	addq $0x30,%rsp /* skip %rcx,%r11,%ds,%es,%fs,%gs */
    8.17  	SAVE_ALL
    8.18  	jmp  error_exit
    8.19 -.section .fixup,"ax";	\
    8.20 -6:	movq $0,(%rsp);	\
    8.21 -	jmp 1b;		\
    8.22 -7:	movq $0,8(%rsp);	\
    8.23 -	jmp 2b;		\
    8.24 -8:	movq $0,16(%rsp);	\
    8.25 -	jmp 3b;		\
    8.26 -9:	movq $0,24(%rsp);	\
    8.27 -	jmp 4b;		\
    8.28 -.previous;		\
    8.29 -.section __ex_table,"a";\
    8.30 -	.align 16;	\
    8.31 -	.quad 1b,6b;	\
    8.32 -	.quad 2b,7b;	\
    8.33 -	.quad 3b,8b;	\
    8.34 -	.quad 4b,9b;	\
    8.35 -.previous
    8.36   
    8.37  #if 0	      
    8.38          .section __ex_table,"a"
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Mar 28 11:51:06 2006 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Tue Mar 28 11:52:47 2006 +0100
     9.3 @@ -1039,8 +1039,7 @@ static int __init xenbus_probe_init(void
     9.4  		xsd_port_intf = create_xen_proc_entry("xsd_port", 0400);
     9.5  		if (xsd_port_intf)
     9.6  			xsd_port_intf->read_proc = xsd_port_read;
     9.7 -	}
     9.8 -	else
     9.9 +	} else
    9.10  		xenstored_ready = 1;
    9.11  
    9.12  	/* Initialize the interface to xenstore. */
    10.1 --- a/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/processor.h	Tue Mar 28 11:51:06 2006 +0100
    10.2 +++ b/linux-2.6-xen-sparse/include/asm-i386/mach-xen/asm/processor.h	Tue Mar 28 11:52:47 2006 +0100
    10.3 @@ -237,20 +237,11 @@ extern unsigned long mmu_cr4_features;
    10.4  
    10.5  static inline void set_in_cr4 (unsigned long mask)
    10.6  {
    10.7 +	unsigned cr4;
    10.8  	mmu_cr4_features |= mask;
    10.9 -	switch (mask) {
   10.10 -	case X86_CR4_OSFXSR:
   10.11 -	case X86_CR4_OSXMMEXCPT:
   10.12 -		break;
   10.13 -	default:
   10.14 -		do {
   10.15 -			const char *msg = "Xen unsupported cr4 update\n";
   10.16 -			(void)HYPERVISOR_console_io(
   10.17 -				CONSOLEIO_write, __builtin_strlen(msg),
   10.18 -				(char *)msg);
   10.19 -			BUG();
   10.20 -		} while (0);
   10.21 -	}
   10.22 +	cr4 = read_cr4();
   10.23 +	cr4 |= mask;
   10.24 +	write_cr4(cr4);
   10.25  }
   10.26  
   10.27  static inline void clear_in_cr4 (unsigned long mask)
    11.1 --- a/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h	Tue Mar 28 11:51:06 2006 +0100
    11.2 +++ b/linux-2.6-xen-sparse/include/asm-x86_64/mach-xen/asm/processor.h	Tue Mar 28 11:52:47 2006 +0100
    11.3 @@ -141,31 +141,21 @@ extern unsigned long mmu_cr4_features;
    11.4  static inline void set_in_cr4 (unsigned long mask)
    11.5  {
    11.6  	mmu_cr4_features |= mask;
    11.7 -	switch (mask) {
    11.8 -	case X86_CR4_OSFXSR:
    11.9 -	case X86_CR4_OSXMMEXCPT:
   11.10 -		break;
   11.11 -	default:
   11.12 -		do {
   11.13 -			const char *msg = "Xen unsupported cr4 update\n";
   11.14 -			(void)HYPERVISOR_console_io(
   11.15 -				CONSOLEIO_write, __builtin_strlen(msg),
   11.16 -				(char *)msg);
   11.17 -			BUG();
   11.18 -		} while (0);
   11.19 -	}
   11.20 +	__asm__("movq %%cr4,%%rax\n\t"
   11.21 +		"orq %0,%%rax\n\t"
   11.22 +		"movq %%rax,%%cr4\n"
   11.23 +		: : "irg" (mask)
   11.24 +		:"ax");
   11.25  }
   11.26  
   11.27  static inline void clear_in_cr4 (unsigned long mask)
   11.28  {
   11.29 -#ifndef CONFIG_XEN
   11.30  	mmu_cr4_features &= ~mask;
   11.31  	__asm__("movq %%cr4,%%rax\n\t"
   11.32  		"andq %0,%%rax\n\t"
   11.33  		"movq %%rax,%%cr4\n"
   11.34  		: : "irg" (~mask)
   11.35  		:"ax");
   11.36 -#endif
   11.37  }
   11.38  
   11.39  
    12.1 --- a/tools/Makefile	Tue Mar 28 11:51:06 2006 +0100
    12.2 +++ b/tools/Makefile	Tue Mar 28 11:52:47 2006 +0100
    12.3 @@ -37,6 +37,7 @@ install: check
    12.4  		$(MAKE) -C $$subdir $@; \
    12.5  	done
    12.6  	$(MAKE) ioemuinstall
    12.7 +	$(INSTALL_DIR) -p $(DESTDIR)/var/xen/dump
    12.8  
    12.9  clean: check_clean
   12.10  	@set -e; for subdir in $(SUBDIRS); do \
    13.1 --- a/tools/debugger/gdb/README	Tue Mar 28 11:51:06 2006 +0100
    13.2 +++ b/tools/debugger/gdb/README	Tue Mar 28 11:52:47 2006 +0100
    13.3 @@ -11,8 +11,8 @@ To build the GDB server:
    13.4      to your test machine.
    13.5  
    13.6  To build a debuggable guest kernel image:
    13.7 - 1. cd linux-2.6.12-xenU
    13.8 - 2. ARCH=xen make menuconfig
    13.9 + 1. cd linux-2.6.xx-xenU
   13.10 + 2. make menuconfig
   13.11   3. From within the configurator, enable the following options:
   13.12      # Kernel hacking -> Compile the kernel with debug info [*]
   13.13                       -> Compile the kernel with frame pointers
    14.1 --- a/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/configure.srv	Tue Mar 28 11:51:06 2006 +0100
    14.2 +++ b/tools/debugger/gdb/gdb-6.2.1-xen-sparse/gdb/gdbserver/configure.srv	Tue Mar 28 11:52:47 2006 +0100
    14.3 @@ -61,7 +61,7 @@ case "${target}" in
    14.4  			srv_linux_thread_db=yes
    14.5  			;;
    14.6    x86_64-*-linux*)	srv_regobj=reg-x86-64.o
    14.7 -			srv_tgtobj="linux-low.o linux-x86-64-low.o i387-fp.o"
    14.8 +			srv_tgtobj="linux-xen-low.o linux-x86-64-low.o i387-fp.o"
    14.9  			srv_linux_regsets=yes
   14.10  			;;
   14.11    xscale*-*-linux*)	srv_regobj=reg-arm.o
    15.1 --- a/tools/examples/xen-backend.agent	Tue Mar 28 11:51:06 2006 +0100
    15.2 +++ b/tools/examples/xen-backend.agent	Tue Mar 28 11:52:47 2006 +0100
    15.3 @@ -2,6 +2,10 @@
    15.4  
    15.5  PATH=/etc/xen/scripts:$PATH
    15.6  
    15.7 +. /etc/xen/scripts/locking.sh
    15.8 +
    15.9 +claim_lock xenbus_hotplug_global
   15.10 +
   15.11  case "$XENBUS_TYPE" in
   15.12    vbd)
   15.13      /etc/xen/scripts/block "$ACTION"
   15.14 @@ -25,3 +29,5 @@ case "$ACTION" in
   15.15    offline)
   15.16      ;;
   15.17  esac
   15.18 +
   15.19 +release_lock xenbus_hotplug_global
    16.1 --- a/tools/ioemu/hw/pcnet.c	Tue Mar 28 11:51:06 2006 +0100
    16.2 +++ b/tools/ioemu/hw/pcnet.c	Tue Mar 28 11:52:47 2006 +0100
    16.3 @@ -45,21 +45,6 @@
    16.4  #define PCNET_PNPMMIO_SIZE      0x20
    16.5  
    16.6  
    16.7 -typedef struct PCNetState_st PCNetState;
    16.8 -
    16.9 -struct PCNetState_st {
   16.10 -    PCIDevice dev;
   16.11 -    NetDriverState *nd;
   16.12 -    int mmio_io_addr, rap, isr, lnkst;
   16.13 -    target_phys_addr_t rdra, tdra;
   16.14 -    uint8_t prom[16];
   16.15 -    uint16_t csr[128];
   16.16 -    uint16_t bcr[32];
   16.17 -    uint64_t timer;
   16.18 -    int xmit_pos, recv_pos;
   16.19 -    uint8_t buffer[4096];
   16.20 -};
   16.21 -
   16.22  #include "pcnet.h"
   16.23  
   16.24  static void pcnet_poll(PCNetState *s);
   16.25 @@ -217,6 +202,11 @@ static void pcnet_init(PCNetState *s)
   16.26      CSR_RCVRC(s) = CSR_RCVRL(s);
   16.27      CSR_XMTRC(s) = CSR_XMTRL(s);
   16.28  
   16.29 +    /* flush any cached receive descriptors */
   16.30 +    s->crmd.rmd1.own = 0;
   16.31 +    s->nrmd.rmd1.own = 0;
   16.32 +    s->nnrmd.rmd1.own = 0;
   16.33 +
   16.34  #ifdef PCNET_DEBUG
   16.35      printf("pcnet ss32=%d rdra=0x%08x[%d] tdra=0x%08x[%d]\n", 
   16.36          BCR_SSIZE32(s),
   16.37 @@ -239,6 +229,11 @@ static void pcnet_start(PCNetState *s)
   16.38      if (!CSR_DRX(s))
   16.39          s->csr[0] |= 0x0020;    /* set RXON */
   16.40  
   16.41 +    /* flush any cached receive descriptors */
   16.42 +    s->crmd.rmd1.own = 0;
   16.43 +    s->nrmd.rmd1.own = 0;
   16.44 +    s->nnrmd.rmd1.own = 0;
   16.45 +
   16.46      s->csr[0] &= ~0x0004;       /* clear STOP bit */
   16.47      s->csr[0] |= 0x0002;
   16.48  }
   16.49 @@ -260,29 +255,21 @@ static void pcnet_rdte_poll(PCNetState *
   16.50      s->csr[28] = s->csr[29] = 0;
   16.51      if (s->rdra) {
   16.52          int bad = 0;
   16.53 -#if 1
   16.54          target_phys_addr_t crda = pcnet_rdra_addr(s, CSR_RCVRC(s));
   16.55          target_phys_addr_t nrda = pcnet_rdra_addr(s, -1 + CSR_RCVRC(s));
   16.56          target_phys_addr_t nnrd = pcnet_rdra_addr(s, -2 + CSR_RCVRC(s));
   16.57 -#else
   16.58 -        target_phys_addr_t crda = s->rdra + 
   16.59 -            (CSR_RCVRL(s) - CSR_RCVRC(s)) *
   16.60 -            (BCR_SWSTYLE(s) ? 16 : 8 );
   16.61 -        int nrdc = CSR_RCVRC(s)<=1 ? CSR_RCVRL(s) : CSR_RCVRC(s)-1;
   16.62 -        target_phys_addr_t nrda = s->rdra + 
   16.63 -            (CSR_RCVRL(s) - nrdc) *
   16.64 -            (BCR_SWSTYLE(s) ? 16 : 8 );
   16.65 -        int nnrc = nrdc<=1 ? CSR_RCVRL(s) : nrdc-1;
   16.66 -        target_phys_addr_t nnrd = s->rdra + 
   16.67 -            (CSR_RCVRL(s) - nnrc) *
   16.68 -            (BCR_SWSTYLE(s) ? 16 : 8 );
   16.69 -#endif
   16.70  
   16.71 -        CHECK_RMD(PHYSADDR(s,crda), bad);
   16.72 +	if (!s->crmd.rmd1.own) {
   16.73 +	    CHECK_RMD(&(s->crmd),PHYSADDR(s,crda), bad);
   16.74 +	}
   16.75          if (!bad) {
   16.76 -            CHECK_RMD(PHYSADDR(s,nrda), bad);
   16.77 +	    if (s->crmd.rmd1.own && !s->nrmd.rmd1.own) {
   16.78 +		CHECK_RMD(&(s->nrmd),PHYSADDR(s,nrda), bad);
   16.79 +	    }
   16.80              if (bad || (nrda == crda)) nrda = 0;
   16.81 -            CHECK_RMD(PHYSADDR(s,nnrd), bad);
   16.82 +	    if (s->crmd.rmd1.own && s->nrmd.rmd1.own && !s->nnrmd.rmd1.own) {
   16.83 +		CHECK_RMD(&(s->nnrmd),PHYSADDR(s,nnrd), bad);
   16.84 +	    }
   16.85              if (bad || (nnrd == crda)) nnrd = 0;
   16.86  
   16.87              s->csr[28] = crda & 0xffff;
   16.88 @@ -303,14 +290,12 @@ static void pcnet_rdte_poll(PCNetState *
   16.89      }
   16.90      
   16.91      if (CSR_CRDA(s)) {
   16.92 -        struct pcnet_RMD rmd;
   16.93 -        RMDLOAD(&rmd, PHYSADDR(s,CSR_CRDA(s)));
   16.94 -        CSR_CRBC(s) = rmd.rmd1.bcnt;
   16.95 -        CSR_CRST(s) = ((uint32_t *)&rmd)[1] >> 16;
   16.96 +        CSR_CRBC(s) = s->crmd.rmd1.bcnt;
   16.97 +        CSR_CRST(s) = ((uint32_t *)&(s->crmd))[1] >> 16;
   16.98  #ifdef PCNET_DEBUG_RMD_X
   16.99          printf("CRDA=0x%08x CRST=0x%04x RCVRC=%d RMD1=0x%08x RMD2=0x%08x\n",
  16.100                  PHYSADDR(s,CSR_CRDA(s)), CSR_CRST(s), CSR_RCVRC(s),
  16.101 -                ((uint32_t *)&rmd)[1], ((uint32_t *)&rmd)[2]);
  16.102 +                ((uint32_t *)&(s->crmd))[1], ((uint32_t *)&(s->crmd))[2]);
  16.103          PRINT_RMD(&rmd);
  16.104  #endif
  16.105      } else {
  16.106 @@ -318,10 +303,8 @@ static void pcnet_rdte_poll(PCNetState *
  16.107      }
  16.108      
  16.109      if (CSR_NRDA(s)) {
  16.110 -        struct pcnet_RMD rmd;
  16.111 -        RMDLOAD(&rmd, PHYSADDR(s,CSR_NRDA(s)));
  16.112 -        CSR_NRBC(s) = rmd.rmd1.bcnt;
  16.113 -        CSR_NRST(s) = ((uint32_t *)&rmd)[1] >> 16;
  16.114 +        CSR_NRBC(s) = s->nrmd.rmd1.bcnt;
  16.115 +        CSR_NRST(s) = ((uint32_t *)&(s->nrmd))[1] >> 16;
  16.116      } else {
  16.117          CSR_NRBC(s) = CSR_NRST(s) = 0;
  16.118      }
  16.119 @@ -336,6 +319,7 @@ static int pcnet_tdte_poll(PCNetState *s
  16.120              (CSR_XMTRL(s) - CSR_XMTRC(s)) *
  16.121              (BCR_SWSTYLE(s) ? 16 : 8 );
  16.122          int bad = 0;
  16.123 +	s->csr[0] &= ~0x0008;   /* clear TDMD */
  16.124          CHECK_TMD(PHYSADDR(s, cxda),bad);
  16.125          if (!bad) {
  16.126              if (CSR_CXDA(s) != cxda) {
  16.127 @@ -354,12 +338,8 @@ static int pcnet_tdte_poll(PCNetState *s
  16.128      }
  16.129  
  16.130      if (CSR_CXDA(s)) {
  16.131 -        struct pcnet_TMD tmd;
  16.132 -
  16.133 -        TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s)));                
  16.134 -
  16.135 -        CSR_CXBC(s) = tmd.tmd1.bcnt;
  16.136 -        CSR_CXST(s) = ((uint32_t *)&tmd)[1] >> 16;
  16.137 +        CSR_CXBC(s) = s->tmd.tmd1.bcnt;
  16.138 +        CSR_CXST(s) = ((uint32_t *)&(s->tmd))[1] >> 16;
  16.139      } else {
  16.140          CSR_CXBC(s) = CSR_CXST(s) = 0;
  16.141      }
  16.142 @@ -373,14 +353,11 @@ static int pcnet_can_receive(void *opaqu
  16.143      if (CSR_STOP(s) || CSR_SPND(s))
  16.144          return 0;
  16.145          
  16.146 -    if (s->recv_pos > 0)
  16.147 -        return 0;
  16.148 -
  16.149      pcnet_rdte_poll(s);
  16.150      if (!(CSR_CRST(s) & 0x8000)) {
  16.151          return 0;
  16.152      }
  16.153 -    return sizeof(s->buffer)-16;
  16.154 +    return sizeof(s->rx_buffer)-16;
  16.155  }
  16.156  
  16.157  #define MIN_BUF_SIZE 60
  16.158 @@ -389,7 +366,7 @@ static void pcnet_receive(void *opaque, 
  16.159  {
  16.160      PCNetState *s = opaque;
  16.161      int is_padr = 0, is_bcast = 0, is_ladr = 0;
  16.162 -    uint8_t buf1[60];
  16.163 +    int pad;
  16.164  
  16.165      if (CSR_DRX(s) || CSR_STOP(s) || CSR_SPND(s) || !size)
  16.166          return;
  16.167 @@ -399,12 +376,10 @@ static void pcnet_receive(void *opaque, 
  16.168  #endif
  16.169  
  16.170      /* if too small buffer, then expand it */
  16.171 -    if (size < MIN_BUF_SIZE) {
  16.172 -        memcpy(buf1, buf, size);
  16.173 -        memset(buf1 + size, 0, MIN_BUF_SIZE - size);
  16.174 -        buf = buf1;
  16.175 -        size = MIN_BUF_SIZE;
  16.176 -    }
  16.177 +    if (size < MIN_BUF_SIZE)
  16.178 +        pad = MIN_BUF_SIZE - size + 4;
  16.179 +    else 
  16.180 +	pad = 4;
  16.181  
  16.182      if (CSR_PROM(s) 
  16.183          || (is_padr=padr_match(s, buf, size)) 
  16.184 @@ -413,124 +388,74 @@ static void pcnet_receive(void *opaque, 
  16.185  
  16.186          pcnet_rdte_poll(s);
  16.187  
  16.188 -        if (!(CSR_CRST(s) & 0x8000) && s->rdra) {
  16.189 -            struct pcnet_RMD rmd;
  16.190 -            int rcvrc = CSR_RCVRC(s)-1,i;
  16.191 -            target_phys_addr_t nrda;
  16.192 -            for (i = CSR_RCVRL(s)-1; i > 0; i--, rcvrc--) {
  16.193 -                if (rcvrc <= 1)
  16.194 -                    rcvrc = CSR_RCVRL(s);
  16.195 -                nrda = s->rdra +
  16.196 -                    (CSR_RCVRL(s) - rcvrc) *
  16.197 -                    (BCR_SWSTYLE(s) ? 16 : 8 );
  16.198 -                RMDLOAD(&rmd, PHYSADDR(s,nrda));                  
  16.199 -                if (rmd.rmd1.own) {                
  16.200 +	if (size > 2000) {
  16.201  #ifdef PCNET_DEBUG_RMD
  16.202 -                    printf("pcnet - scan buffer: RCVRC=%d PREV_RCVRC=%d\n", 
  16.203 -                                rcvrc, CSR_RCVRC(s));
  16.204 +	    printf("pcnet - oversize packet discarded.\n");
  16.205  #endif
  16.206 -                    CSR_RCVRC(s) = rcvrc;
  16.207 -                    pcnet_rdte_poll(s);
  16.208 -                    break;
  16.209 -                }
  16.210 -            }
  16.211 -        }
  16.212 -
  16.213 -        if (!(CSR_CRST(s) & 0x8000)) {
  16.214 +	} else if (!(CSR_CRST(s) & 0x8000)) {
  16.215  #ifdef PCNET_DEBUG_RMD
  16.216              printf("pcnet - no buffer: RCVRC=%d\n", CSR_RCVRC(s));
  16.217  #endif
  16.218              s->csr[0] |= 0x1000; /* Set MISS flag */
  16.219              CSR_MISSC(s)++;
  16.220          } else {
  16.221 -            uint8_t *src = &s->buffer[8];
  16.222 +            uint8_t *src = &s->rx_buffer[8];
  16.223              target_phys_addr_t crda = CSR_CRDA(s);
  16.224 -            struct pcnet_RMD rmd;
  16.225 +            target_phys_addr_t nrda = CSR_NRDA(s);
  16.226 +            target_phys_addr_t nnrda = CSR_NNRD(s);
  16.227              int pktcount = 0;
  16.228 +	    int packet_size = size + pad;
  16.229  
  16.230              memcpy(src, buf, size);
  16.231 -            
  16.232 -            if (!CSR_ASTRP_RCV(s)) {
  16.233 -                uint32_t fcs = ~0;
  16.234 -#if 0            
  16.235 -                uint8_t *p = s->buffer;
  16.236 -                
  16.237 -                ((uint32_t *)p)[0] = ((uint32_t *)p)[1] = 0xaaaaaaaa;
  16.238 -                p[7] = 0xab;
  16.239 -#else
  16.240 -                uint8_t *p = src;
  16.241 -#endif
  16.242 -
  16.243 -                while (size < 46) {
  16.244 -                    src[size++] = 0;
  16.245 -                }
  16.246 -                
  16.247 -                while (p != &src[size]) {
  16.248 -                    CRC(fcs, *p++);
  16.249 -                }
  16.250 -                ((uint32_t *)&src[size])[0] = htonl(fcs);
  16.251 -                size += 4; /* FCS at end of packet */
  16.252 -            } else size += 4;
  16.253 +	    memset(src + size, 0, pad); 
  16.254 +            size += pad;
  16.255  
  16.256  #ifdef PCNET_DEBUG_MATCH
  16.257              PRINT_PKTHDR(buf);
  16.258  #endif
  16.259  
  16.260 -            RMDLOAD(&rmd, PHYSADDR(s,crda));
  16.261 -            /*if (!CSR_LAPPEN(s))*/
  16.262 -                rmd.rmd1.stp = 1;
  16.263 -
  16.264 -#define PCNET_RECV_STORE() do {                                 \
  16.265 -    int count = MIN(4096 - rmd.rmd1.bcnt,size);                 \
  16.266 -    target_phys_addr_t rbadr = PHYSADDR(s, rmd.rmd0.rbadr);     \
  16.267 -    cpu_physical_memory_write(rbadr, src, count);               \
  16.268 -    cpu_physical_memory_set_dirty(rbadr);                       \
  16.269 -    cpu_physical_memory_set_dirty(rbadr+count);                 \
  16.270 -    src += count; size -= count;                                \
  16.271 -    rmd.rmd2.mcnt = count; rmd.rmd1.own = 0;                    \
  16.272 -    RMDSTORE(&rmd, PHYSADDR(s,crda));                           \
  16.273 -    pktcount++;                                                 \
  16.274 -} while (0)
  16.275 +	    s->crmd.rmd1.stp = 1;
  16.276 +	    do {
  16.277 +		int count = MIN(4096 - s->crmd.rmd1.bcnt,size);
  16.278 +		target_phys_addr_t rbadr = PHYSADDR(s, s->crmd.rmd0.rbadr);
  16.279 +		cpu_physical_memory_write(rbadr, src, count);
  16.280 +		cpu_physical_memory_set_dirty(rbadr);
  16.281 +		cpu_physical_memory_set_dirty(rbadr+count);
  16.282 +		src += count; size -= count;
  16.283 +		if (size > 0 && s->nrmd.rmd1.own) {
  16.284 +		    RMDSTORE(&(s->crmd), PHYSADDR(s,crda));
  16.285 +		    crda = nrda;
  16.286 +		    nrda = nnrda;
  16.287 +		    s->crmd = s->nrmd;
  16.288 +		    s->nrmd = s->nnrmd;
  16.289 +		    s->nnrmd.rmd1.own = 0;
  16.290 +		}
  16.291 +		pktcount++;
  16.292 +	    } while (size > 0 && s->crmd.rmd1.own);
  16.293  
  16.294 -            PCNET_RECV_STORE();
  16.295 -            if ((size > 0) && CSR_NRDA(s)) {
  16.296 -                target_phys_addr_t nrda = CSR_NRDA(s);
  16.297 -                RMDLOAD(&rmd, PHYSADDR(s,nrda));
  16.298 -                if (rmd.rmd1.own) {
  16.299 -                    crda = nrda;
  16.300 -                    PCNET_RECV_STORE();
  16.301 -                    if ((size > 0) && (nrda=CSR_NNRD(s))) {
  16.302 -                        RMDLOAD(&rmd, PHYSADDR(s,nrda));
  16.303 -                        if (rmd.rmd1.own) {
  16.304 -                            crda = nrda;
  16.305 -                            PCNET_RECV_STORE();
  16.306 -                        }
  16.307 -                    }
  16.308 -                }                
  16.309 +            if (size == 0) {
  16.310 +                s->crmd.rmd1.enp = 1;
  16.311 +		s->crmd.rmd2.mcnt = packet_size;
  16.312 +                s->crmd.rmd1.pam = !CSR_PROM(s) && is_padr;
  16.313 +                s->crmd.rmd1.lafm = !CSR_PROM(s) && is_ladr;
  16.314 +                s->crmd.rmd1.bam = !CSR_PROM(s) && is_bcast;
  16.315 +            } else {
  16.316 +                s->crmd.rmd1.oflo = 1;
  16.317 +                s->crmd.rmd1.buff = 1;
  16.318 +                s->crmd.rmd1.err = 1;
  16.319              }
  16.320 -
  16.321 -#undef PCNET_RECV_STORE
  16.322 -
  16.323 -            RMDLOAD(&rmd, PHYSADDR(s,crda));
  16.324 -            if (size == 0) {
  16.325 -                rmd.rmd1.enp = 1;
  16.326 -                rmd.rmd1.pam = !CSR_PROM(s) && is_padr;
  16.327 -                rmd.rmd1.lafm = !CSR_PROM(s) && is_ladr;
  16.328 -                rmd.rmd1.bam = !CSR_PROM(s) && is_bcast;
  16.329 -            } else {
  16.330 -                rmd.rmd1.oflo = 1;
  16.331 -                rmd.rmd1.buff = 1;
  16.332 -                rmd.rmd1.err = 1;
  16.333 -            }
  16.334 -            RMDSTORE(&rmd, PHYSADDR(s,crda));
  16.335 +            RMDSTORE(&(s->crmd), PHYSADDR(s,crda));
  16.336              s->csr[0] |= 0x0400;
  16.337 +	    s->crmd = s->nrmd;
  16.338 +	    s->nrmd = s->nnrmd;
  16.339 +	    s->nnrmd.rmd1.own = 0;
  16.340  
  16.341  #ifdef PCNET_DEBUG
  16.342              printf("RCVRC=%d CRDA=0x%08x BLKS=%d\n", 
  16.343                  CSR_RCVRC(s), PHYSADDR(s,CSR_CRDA(s)), pktcount);
  16.344  #endif
  16.345  #ifdef PCNET_DEBUG_RMD
  16.346 -            PRINT_RMD(&rmd);
  16.347 +            PRINT_RMD(&s->crmd);
  16.348  #endif        
  16.349  
  16.350              while (pktcount--) {
  16.351 @@ -551,80 +476,88 @@ static void pcnet_receive(void *opaque, 
  16.352  
  16.353  static void pcnet_transmit(PCNetState *s)
  16.354  {
  16.355 -    target_phys_addr_t xmit_cxda = 0;
  16.356 +    target_phys_addr_t start_addr = 0;
  16.357 +    struct pcnet_TMD start_tmd;
  16.358      int count = CSR_XMTRL(s)-1;
  16.359 -    s->xmit_pos = -1;
  16.360 +    int xmit_pos = 0;
  16.361 +    int len;
  16.362 +
  16.363      
  16.364      if (!CSR_TXON(s)) {
  16.365          s->csr[0] &= ~0x0008;
  16.366          return;
  16.367      }
  16.368      
  16.369 -    txagain:
  16.370 -    if (pcnet_tdte_poll(s)) {
  16.371 -        struct pcnet_TMD tmd;
  16.372 -
  16.373 -        TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s)));                
  16.374 +    while (pcnet_tdte_poll(s)) {
  16.375  
  16.376  #ifdef PCNET_DEBUG_TMD
  16.377          printf("  TMDLOAD 0x%08x\n", PHYSADDR(s,CSR_CXDA(s)));
  16.378 -        PRINT_TMD(&tmd);
  16.379 +        PRINT_TMD(&(s->tmd));
  16.380  #endif
  16.381 -        if (tmd.tmd1.stp) {
  16.382 -            s->xmit_pos = 0;                
  16.383 -            if (!tmd.tmd1.enp) {
  16.384 -                cpu_physical_memory_read(PHYSADDR(s, tmd.tmd0.tbadr),
  16.385 -                        s->buffer, 4096 - tmd.tmd1.bcnt);
  16.386 -                s->xmit_pos += 4096 - tmd.tmd1.bcnt;
  16.387 -            } 
  16.388 -            xmit_cxda = PHYSADDR(s,CSR_CXDA(s));
  16.389 -        }
  16.390 -        if (tmd.tmd1.enp && (s->xmit_pos >= 0)) {
  16.391 -            cpu_physical_memory_read(PHYSADDR(s, tmd.tmd0.tbadr),
  16.392 -                    s->buffer + s->xmit_pos, 4096 - tmd.tmd1.bcnt);
  16.393 -            s->xmit_pos += 4096 - tmd.tmd1.bcnt;
  16.394 -
  16.395 -	    tmd.tmd1.own = 0;
  16.396 -	    TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));
  16.397 -
  16.398 -#ifdef PCNET_DEBUG
  16.399 -            printf("pcnet_transmit size=%d\n", s->xmit_pos);
  16.400 -#endif            
  16.401 -            if (CSR_LOOP(s))
  16.402 -                pcnet_receive(s, s->buffer, s->xmit_pos);
  16.403 -            else
  16.404 -                qemu_send_packet(s->nd, s->buffer, s->xmit_pos);
  16.405 -
  16.406 -            s->csr[0] &= ~0x0008;   /* clear TDMD */
  16.407 -            s->csr[4] |= 0x0004;    /* set TXSTRT */
  16.408 -            s->xmit_pos = -1;
  16.409 -        } else {
  16.410 -	    tmd.tmd1.own = 0;
  16.411 -	    TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s)));
  16.412 -	}
  16.413 -        if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && tmd.tmd1.ltint))
  16.414 -            s->csr[0] |= 0x0200;    /* set TINT */
  16.415 -
  16.416 -        if (CSR_XMTRC(s)<=1)
  16.417 +	len = 4096 - s->tmd.tmd1.bcnt;
  16.418 +        if (CSR_XMTRC(s) <= 1)
  16.419              CSR_XMTRC(s) = CSR_XMTRL(s);
  16.420          else
  16.421              CSR_XMTRC(s)--;
  16.422 -        if (count--)
  16.423 -            goto txagain;
  16.424  
  16.425 -    } else 
  16.426 -    if (s->xmit_pos >= 0) {
  16.427 -        struct pcnet_TMD tmd;
  16.428 -        TMDLOAD(&tmd, PHYSADDR(s,xmit_cxda));                
  16.429 -        tmd.tmd2.buff = tmd.tmd2.uflo = tmd.tmd1.err = 1;
  16.430 -        tmd.tmd1.own = 0;
  16.431 -        TMDSTORE(&tmd, PHYSADDR(s,xmit_cxda));
  16.432 +	/* handle start followed by start */
  16.433 +        if (s->tmd.tmd1.stp && start_addr) {
  16.434 +	    TMDSTORE(&start_tmd, start_addr);
  16.435 +	    start_addr = 0;
  16.436 +	    xmit_pos = 0;
  16.437 +	}
  16.438 +	if ((xmit_pos + len) < sizeof(s->tx_buffer)) {
  16.439 +	    cpu_physical_memory_read(PHYSADDR(s, s->tmd.tmd0.tbadr),
  16.440 +			s->tx_buffer + xmit_pos, len);
  16.441 +	    xmit_pos += len;
  16.442 +	} else {
  16.443 +	    s->tmd.tmd2.buff = s->tmd.tmd2.uflo = s->tmd.tmd1.err = 1;
  16.444 +	    TMDSTORE(&(s->tmd), PHYSADDR(s,CSR_CXDA(s)));
  16.445 +	    if (start_addr == PHYSADDR(s,CSR_CXDA(s)))
  16.446 +	    	start_addr = 0;		/* don't clear own bit twice */
  16.447 +	    continue;
  16.448 +	}
  16.449 +        if (s->tmd.tmd1.stp) {
  16.450 +	    if (s->tmd.tmd1.enp) {
  16.451 +		if (CSR_LOOP(s))
  16.452 +		    pcnet_receive(s, s->tx_buffer, xmit_pos);
  16.453 +		else
  16.454 +		    qemu_send_packet(s->nd, s->tx_buffer, xmit_pos);
  16.455 +
  16.456 +		s->csr[4] |= 0x0008;    /* set TXSTRT */
  16.457 +		TMDSTORE(&(s->tmd), PHYSADDR(s,CSR_CXDA(s)));
  16.458 +		xmit_pos = 0;
  16.459 +		count--;
  16.460 +	    } else {
  16.461 +	        start_tmd = s->tmd;
  16.462 +		start_addr = PHYSADDR(s,CSR_CXDA(s));
  16.463 +	    }
  16.464 +        } else if (s->tmd.tmd1.enp) {
  16.465 +	    TMDSTORE(&(s->tmd), PHYSADDR(s,CSR_CXDA(s)));
  16.466 +	    if (start_addr) {
  16.467 +		TMDSTORE(&start_tmd, start_addr);
  16.468 +	    }
  16.469 +	    start_addr = 0;
  16.470 +	    xmit_pos = 0;
  16.471 +	    count--;
  16.472 +
  16.473 +        } else {
  16.474 +	    TMDSTORE(&(s->tmd), PHYSADDR(s,CSR_CXDA(s)));
  16.475 +	}
  16.476 +        if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && s->tmd.tmd1.ltint))
  16.477 +            s->csr[0] |= 0x0200;    /* set TINT */
  16.478 +
  16.479 +        if (count <= 0)
  16.480 +            break;
  16.481 +
  16.482 +    }
  16.483 +    if (start_addr) {
  16.484 +        start_tmd.tmd2.buff = start_tmd.tmd2.uflo = start_tmd.tmd1.err = 1;
  16.485 +        TMDSTORE(&start_tmd, PHYSADDR(s,start_addr));
  16.486          s->csr[0] |= 0x0200;    /* set TINT */
  16.487          if (!CSR_DXSUFLO(s)) {
  16.488              s->csr[0] &= ~0x0010;
  16.489 -        } else
  16.490 -        if (count--)
  16.491 -          goto txagain;
  16.492 +        }
  16.493      }
  16.494  }
  16.495  
    17.1 --- a/tools/ioemu/hw/pcnet.h	Tue Mar 28 11:51:06 2006 +0100
    17.2 +++ b/tools/ioemu/hw/pcnet.h	Tue Mar 28 11:52:47 2006 +0100
    17.3 @@ -177,6 +177,26 @@ struct pcnet_RMD {
    17.4      } rmd3;    
    17.5  };
    17.6  
    17.7 +typedef struct PCNetState_st PCNetState;
    17.8 +
    17.9 +struct PCNetState_st {
   17.10 +    PCIDevice dev;
   17.11 +    NetDriverState *nd;
   17.12 +    int mmio_io_addr, rap, isr, lnkst;
   17.13 +    target_phys_addr_t rdra, tdra;
   17.14 +    uint8_t prom[16];
   17.15 +    uint16_t csr[128];
   17.16 +    uint16_t bcr[32];
   17.17 +    uint64_t timer;
   17.18 +    int recv_pos;
   17.19 +    uint8_t tx_buffer[2048];
   17.20 +    uint8_t rx_buffer[2048];
   17.21 +    struct pcnet_TMD tmd;
   17.22 +    struct pcnet_RMD crmd;
   17.23 +    struct pcnet_RMD nrmd;
   17.24 +    struct pcnet_RMD nnrmd;
   17.25 +};
   17.26 +
   17.27  
   17.28  #define PRINT_TMD(T) printf(    \
   17.29          "TMD0 : TBADR=0x%08x\n" \
   17.30 @@ -230,18 +250,17 @@ static inline void pcnet_tmd_load(PCNetS
   17.31          cpu_physical_memory_read(addr+4, (void *)&tmd->tmd1, 4);
   17.32          cpu_physical_memory_read(addr, (void *)&tmd->tmd0, 4);
   17.33      } else {
   17.34 -        uint32_t xda[4];
   17.35 -        cpu_physical_memory_read(addr,
   17.36 -                (void *)&xda[0], sizeof(xda));
   17.37 -        ((uint32_t *)tmd)[0] = xda[2];
   17.38 -        ((uint32_t *)tmd)[1] = xda[1];
   17.39 -        ((uint32_t *)tmd)[2] = xda[0];
   17.40 -        ((uint32_t *)tmd)[3] = xda[3];
   17.41 +        uint32_t xda[2];
   17.42 +        cpu_physical_memory_read(addr+4, (void *)&xda[0], sizeof(xda));
   17.43 +        ((uint32_t *)tmd)[0] = xda[1];
   17.44 +        ((uint32_t *)tmd)[1] = xda[0];
   17.45 +        ((uint32_t *)tmd)[2] = 0;
   17.46      }
   17.47  }
   17.48  
   17.49  static inline void pcnet_tmd_store(PCNetState *s, struct pcnet_TMD *tmd, target_phys_addr_t addr)
   17.50  {
   17.51 +    tmd->tmd1.own = 0;
   17.52      cpu_physical_memory_set_dirty(addr);
   17.53      if (!BCR_SWSTYLE(s)) {
   17.54          uint16_t xda[4];
   17.55 @@ -259,13 +278,10 @@ static inline void pcnet_tmd_store(PCNet
   17.56              cpu_physical_memory_write(addr+8, (void *)&tmd->tmd2, 4);
   17.57              cpu_physical_memory_write(addr+4, (void *)&tmd->tmd1, 4);
   17.58          } else {
   17.59 -            uint32_t xda[4];
   17.60 +            uint32_t xda[2];
   17.61              xda[0] = ((uint32_t *)tmd)[2];
   17.62              xda[1] = ((uint32_t *)tmd)[1];
   17.63 -            xda[2] = ((uint32_t *)tmd)[0];
   17.64 -            xda[3] = ((uint32_t *)tmd)[3];
   17.65 -            cpu_physical_memory_write(addr,
   17.66 -                    (void *)&xda[0], sizeof(xda));
   17.67 +            cpu_physical_memory_write(addr, (void *)&xda[0], sizeof(xda));
   17.68          }
   17.69          cpu_physical_memory_set_dirty(addr+15);
   17.70      }
   17.71 @@ -286,22 +302,21 @@ static inline void pcnet_rmd_load(PCNetS
   17.72      }
   17.73      else
   17.74      if (BCR_SWSTYLE(s) != 3) {
   17.75 -        rmd->rmd2.zeros = 0;
   17.76 +        ((uint32_t *)rmd)[2] = 0;
   17.77          cpu_physical_memory_read(addr+4, (void *)&rmd->rmd1, 4);
   17.78          cpu_physical_memory_read(addr, (void *)&rmd->rmd0, 4);
   17.79      } else {
   17.80 -        uint32_t rda[4];
   17.81 -        cpu_physical_memory_read(addr,
   17.82 -                (void *)&rda[0], sizeof(rda));
   17.83 -        ((uint32_t *)rmd)[0] = rda[2];
   17.84 -        ((uint32_t *)rmd)[1] = rda[1];
   17.85 -        ((uint32_t *)rmd)[2] = rda[0];
   17.86 -        ((uint32_t *)rmd)[3] = rda[3];
   17.87 +        uint32_t rda[2];
   17.88 +        cpu_physical_memory_read(addr+4, (void *)&rda[0], sizeof(rda));
   17.89 +        ((uint32_t *)rmd)[0] = rda[1];
   17.90 +        ((uint32_t *)rmd)[1] = rda[0];
   17.91 +        ((uint32_t *)rmd)[2] = 0;
   17.92      }
   17.93  }
   17.94  
   17.95  static inline void pcnet_rmd_store(PCNetState *s, struct pcnet_RMD *rmd, target_phys_addr_t addr)
   17.96  {
   17.97 +    rmd->rmd1.own = 0;
   17.98      cpu_physical_memory_set_dirty(addr);
   17.99      if (!BCR_SWSTYLE(s)) {
  17.100          uint16_t rda[4];                        \
  17.101 @@ -319,13 +334,10 @@ static inline void pcnet_rmd_store(PCNet
  17.102              cpu_physical_memory_write(addr+8, (void *)&rmd->rmd2, 4);
  17.103              cpu_physical_memory_write(addr+4, (void *)&rmd->rmd1, 4);
  17.104          } else {
  17.105 -            uint32_t rda[4];
  17.106 +            uint32_t rda[2];
  17.107              rda[0] = ((uint32_t *)rmd)[2];
  17.108              rda[1] = ((uint32_t *)rmd)[1];
  17.109 -            rda[2] = ((uint32_t *)rmd)[0];
  17.110 -            rda[3] = ((uint32_t *)rmd)[3];
  17.111 -            cpu_physical_memory_write(addr,
  17.112 -                    (void *)&rda[0], sizeof(rda));
  17.113 +            cpu_physical_memory_write(addr, (void *)&rda[0], sizeof(rda));
  17.114          }
  17.115          cpu_physical_memory_set_dirty(addr+15);
  17.116      }
  17.117 @@ -340,79 +352,16 @@ static inline void pcnet_rmd_store(PCNet
  17.118  
  17.119  #define RMDSTORE(RMD,ADDR) pcnet_rmd_store(s,RMD,ADDR)
  17.120  
  17.121 -#if 1
  17.122 -
  17.123 -#define CHECK_RMD(ADDR,RES) do {                \
  17.124 -    struct pcnet_RMD rmd;                       \
  17.125 -    RMDLOAD(&rmd,(ADDR));                       \
  17.126 -    (RES) |= (rmd.rmd1.ones != 15);             \
  17.127 -} while (0)
  17.128 -
  17.129 -#define CHECK_TMD(ADDR,RES) do {                \
  17.130 -    struct pcnet_TMD tmd;                       \
  17.131 -    TMDLOAD(&tmd,(ADDR));                       \
  17.132 -    (RES) |= (tmd.tmd1.ones != 15);             \
  17.133 +#define CHECK_RMD(RMD,ADDR,RES) do {            \
  17.134 +    RMDLOAD((RMD),(ADDR));                      \
  17.135 +    (RES) |= ((RMD)->rmd1.ones != 15);          \
  17.136  } while (0)
  17.137  
  17.138 -#else
  17.139 -
  17.140 -#define CHECK_RMD(ADDR,RES) do {                \
  17.141 -    switch (BCR_SWSTYLE(s)) {                   \
  17.142 -    case 0x00:                                  \
  17.143 -        do {                                    \
  17.144 -            uint16_t rda[4];                    \
  17.145 -            cpu_physical_memory_read((ADDR),    \
  17.146 -                (void *)&rda[0], sizeof(rda));  \
  17.147 -            (RES) |= (rda[2] & 0xf000)!=0xf000; \
  17.148 -            (RES) |= (rda[3] & 0xf000)!=0x0000; \
  17.149 -        } while (0);                            \
  17.150 -        break;                                  \
  17.151 -    case 0x01:                                  \
  17.152 -    case 0x02:                                  \
  17.153 -        do {                                    \
  17.154 -            uint32_t rda[4];                    \
  17.155 -            cpu_physical_memory_read((ADDR),    \
  17.156 -                (void *)&rda[0], sizeof(rda)); \
  17.157 -            (RES) |= (rda[1] & 0x0000f000L)!=0x0000f000L; \
  17.158 -            (RES) |= (rda[2] & 0x0000f000L)!=0x00000000L; \
  17.159 -        } while (0);                            \
  17.160 -        break;                                  \
  17.161 -    case 0x03:                                  \
  17.162 -        do {                                    \
  17.163 -            uint32_t rda[4];                    \
  17.164 -            cpu_physical_memory_read((ADDR),    \
  17.165 -                (void *)&rda[0], sizeof(rda)); \
  17.166 -            (RES) |= (rda[0] & 0x0000f000L)!=0x00000000L; \
  17.167 -            (RES) |= (rda[1] & 0x0000f000L)!=0x0000f000L; \
  17.168 -        } while (0);                            \
  17.169 -        break;                                  \
  17.170 -    }                                           \
  17.171 +#define CHECK_TMD(ADDR,RES) do {            \
  17.172 +    TMDLOAD(&(s->tmd),(ADDR));                       \
  17.173 +    (RES) |= (s->tmd.tmd1.ones != 15);             \
  17.174  } while (0)
  17.175  
  17.176 -#define CHECK_TMD(ADDR,RES) do {                \
  17.177 -    switch (BCR_SWSTYLE(s)) {                   \
  17.178 -    case 0x00:                                  \
  17.179 -        do {                                    \
  17.180 -            uint16_t xda[4];                    \
  17.181 -            cpu_physical_memory_read((ADDR),    \
  17.182 -                (void *)&xda[0], sizeof(xda));  \
  17.183 -            (RES) |= (xda[2] & 0xf000)!=0xf000;\
  17.184 -        } while (0);                            \
  17.185 -        break;                                  \
  17.186 -    case 0x01:                                  \
  17.187 -    case 0x02:                                  \
  17.188 -    case 0x03:                                  \
  17.189 -        do {                                    \
  17.190 -            uint32_t xda[4];                    \
  17.191 -            cpu_physical_memory_read((ADDR),    \
  17.192 -                (void *)&xda[0], sizeof(xda));  \
  17.193 -            (RES) |= (xda[1] & 0x0000f000L)!=0x0000f000L; \
  17.194 -        } while (0);                            \
  17.195 -        break;                                  \
  17.196 -    }                                           \
  17.197 -} while (0)
  17.198 -
  17.199 -#endif
  17.200  
  17.201  #define PRINT_PKTHDR(BUF) do {                  \
  17.202      struct ether_header *hdr = (void *)(BUF);   \
    18.1 --- a/tools/libxc/Makefile	Tue Mar 28 11:51:06 2006 +0100
    18.2 +++ b/tools/libxc/Makefile	Tue Mar 28 11:52:47 2006 +0100
    18.3 @@ -21,16 +21,12 @@ SRCS       += xc_private.c
    18.4  SRCS       += xc_sedf.c
    18.5  SRCS       += xc_tbuf.c
    18.6  
    18.7 -ifeq ($(XEN_TARGET_ARCH),x86_32)
    18.8 +ifeq ($(patsubst x86%,x86,$(XEN_TARGET_ARCH)),x86)
    18.9  SRCS       += xc_ptrace.c
   18.10  SRCS       += xc_ptrace_core.c
   18.11  SRCS       += xc_pagetab.c
   18.12  endif
   18.13  
   18.14 -ifeq ($(XEN_TARGET_ARCH),x86_64)
   18.15 -SRCS       += xc_pagetab.c
   18.16 -endif
   18.17 -
   18.18  BUILD_SRCS :=
   18.19  BUILD_SRCS += xc_linux_build.c
   18.20  BUILD_SRCS += xc_load_bin.c
    19.1 --- a/tools/libxc/xc_ptrace.c	Tue Mar 28 11:51:06 2006 +0100
    19.2 +++ b/tools/libxc/xc_ptrace.c	Tue Mar 28 11:52:47 2006 +0100
    19.3 @@ -38,9 +38,6 @@ static char *ptrace_names[] = {
    19.4  };
    19.5  #endif
    19.6  
    19.7 -/* XXX application state */
    19.8 -static long                     nr_pages = 0;
    19.9 -static unsigned long           *page_array = NULL;
   19.10  static int                      current_domid = -1;
   19.11  static int                      current_isfile;
   19.12  
   19.13 @@ -196,6 +193,60 @@ map_domain_va_pae(
   19.14      return (void *)((unsigned long)v | (va & (PAGE_SIZE - 1)));
   19.15  }
   19.16  
   19.17 +#ifdef __x86_64__
   19.18 +static void *
   19.19 +map_domain_va(
   19.20 +    int xc_handle,
   19.21 +    int cpu,
   19.22 +    void *guest_va,
   19.23 +    int perm)
   19.24 +{
   19.25 +    unsigned long l3p, l2p, l1p, p, va = (unsigned long)guest_va;
   19.26 +    uint64_t *l4, *l3, *l2, *l1;
   19.27 +    static void *v;
   19.28 +
   19.29 +    if ((ctxt[cpu].ctrlreg[4] & 0x20) == 0 ) /* legacy ia32 mode */
   19.30 +        return map_domain_va_pae(xc_handle, cpu, guest_va, perm);
   19.31 +
   19.32 +    if (fetch_regs(xc_handle, cpu, NULL))
   19.33 +        return NULL;
   19.34 +
   19.35 +    l4 = xc_map_foreign_range(
   19.36 +        xc_handle, current_domid, PAGE_SIZE, PROT_READ, ctxt[cpu].ctrlreg[3] >> PAGE_SHIFT);
   19.37 +    if ( l4 == NULL )
   19.38 +        return NULL;
   19.39 +
   19.40 +    l3p = l4[l4_table_offset(va)] >> PAGE_SHIFT;
   19.41 +    l3 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l3p);
   19.42 +    if ( l3 == NULL )
   19.43 +        return NULL;
   19.44 +
   19.45 +    l2p = l3[l3_table_offset(va)] >> PAGE_SHIFT;
   19.46 +    l2 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, PROT_READ, l2p);
   19.47 +    if ( l2 == NULL )
   19.48 +        return NULL;
   19.49 +
   19.50 +    l1p = l2[l2_table_offset(va)] >> PAGE_SHIFT;
   19.51 +    l1 = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, l1p);
   19.52 +    if ( l1 == NULL )
   19.53 +        return NULL;
   19.54 +
   19.55 +    p = l1[l1_table_offset(va)] >> PAGE_SHIFT;
   19.56 +    if ( v != NULL )
   19.57 +        munmap(v, PAGE_SIZE);
   19.58 +    v = xc_map_foreign_range(xc_handle, current_domid, PAGE_SIZE, perm, p);
   19.59 +    if ( v == NULL )
   19.60 +        return NULL;
   19.61 +
   19.62 +    return (void *)((unsigned long)v | (va & (PAGE_SIZE - 1)));
   19.63 +}
   19.64 +#endif
   19.65 +
   19.66 +#ifdef __i386__
   19.67 +/* XXX application state */
   19.68 +static long                     nr_pages = 0;
   19.69 +static unsigned long           *page_array = NULL;
   19.70 +
   19.71  static void *
   19.72  map_domain_va(
   19.73      int xc_handle,
   19.74 @@ -216,15 +267,18 @@ map_domain_va(
   19.75      static unsigned long  page_phys[MAX_VIRT_CPUS];
   19.76      static unsigned long *page_virt[MAX_VIRT_CPUS];    
   19.77      static int            prev_perm[MAX_VIRT_CPUS];
   19.78 -    static enum { MODE_UNKNOWN, MODE_32, MODE_PAE } mode;
   19.79 +    static enum { MODE_UNKNOWN, MODE_32, MODE_PAE, MODE_64 } mode;
   19.80  
   19.81      if ( mode == MODE_UNKNOWN )
   19.82      {
   19.83          xen_capabilities_info_t caps;
   19.84          (void)xc_version(xc_handle, XENVER_capabilities, caps);
   19.85 -        mode = MODE_32;
   19.86 -        if ( strstr(caps, "_x86_32p") )
   19.87 +        if ( strstr(caps, "-x86_64") )
   19.88 +            mode = MODE_64;
   19.89 +        else if ( strstr(caps, "-x86_32p") )
   19.90              mode = MODE_PAE;
   19.91 +        else if ( strstr(caps, "-x86_32") ) 
   19.92 +            mode = MODE_32;
   19.93      }
   19.94  
   19.95      if ( mode == MODE_PAE )
   19.96 @@ -304,6 +358,8 @@ map_domain_va(
   19.97      return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
   19.98  }
   19.99  
  19.100 +#endif
  19.101 +
  19.102  static int 
  19.103  __xc_waitdomain(
  19.104      int xc_handle,
    20.1 --- a/tools/libxc/xc_ptrace.h	Tue Mar 28 11:51:06 2006 +0100
    20.2 +++ b/tools/libxc/xc_ptrace.h	Tue Mar 28 11:52:47 2006 +0100
    20.3 @@ -10,6 +10,96 @@
    20.4  #define PDRSHIFT        22
    20.5  #define PSL_T  0x00000100 /* trace enable bit */
    20.6  
    20.7 +#ifdef __x86_64__
    20.8 +struct gdb_regs
    20.9 +{
   20.10 +  unsigned long r15;
   20.11 +  unsigned long r14;
   20.12 +  unsigned long r13;
   20.13 +  unsigned long r12;
   20.14 +  unsigned long rbp;
   20.15 +  unsigned long rbx;
   20.16 +  unsigned long r11;
   20.17 +  unsigned long r10;
   20.18 +  unsigned long r9;
   20.19 +  unsigned long r8;
   20.20 +  unsigned long rax;
   20.21 +  unsigned long rcx;
   20.22 +  unsigned long rdx;
   20.23 +  unsigned long rsi;
   20.24 +  unsigned long rdi;
   20.25 +  unsigned long orig_rax;
   20.26 +  unsigned long rip;
   20.27 +  unsigned long xcs;
   20.28 +  unsigned long eflags;
   20.29 +  unsigned long rsp;
   20.30 +  unsigned long xss;
   20.31 +  unsigned long fs_base;
   20.32 +  unsigned long gs_base;
   20.33 +  unsigned long xds;
   20.34 +  unsigned long xes;
   20.35 +  unsigned long xfs;
   20.36 +  unsigned long xgs;
   20.37 +};
   20.38 +
   20.39 +#define SET_PT_REGS(pt, xc)                     \
   20.40 +{                                               \
   20.41 +    pt.r8 = xc.r8;                              \
   20.42 +    pt.r9 = xc.r9;                              \
   20.43 +    pt.r10 = xc.r10;                            \
   20.44 +    pt.r11 = xc.r11;                            \
   20.45 +    pt.r12 = xc.r12;                            \
   20.46 +    pt.r13 = xc.r13;                            \
   20.47 +    pt.r14 = xc.r14;                            \
   20.48 +    pt.r15 = xc.r15;                            \
   20.49 +    pt.rbx = xc.rbx;                            \
   20.50 +    pt.rcx = xc.rcx;                            \
   20.51 +    pt.rdx = xc.rdx;                            \
   20.52 +    pt.rsi = xc.rsi;                            \
   20.53 +    pt.rdi = xc.rdi;                            \
   20.54 +    pt.rbp = xc.rbp;                            \
   20.55 +    pt.rax = xc.rax;                            \
   20.56 +    pt.rip = xc.rip;                            \
   20.57 +    pt.xcs = xc.cs;                             \
   20.58 +    pt.eflags = xc.eflags;                      \
   20.59 +    pt.rsp = xc.rsp;                            \
   20.60 +    pt.xss = xc.ss;                             \
   20.61 +    pt.xes = xc.es;                             \
   20.62 +    pt.xds = xc.ds;                             \
   20.63 +    pt.xfs = xc.fs;                             \
   20.64 +    pt.xgs = xc.gs;                             \
   20.65 +}
   20.66 +
   20.67 +#define SET_XC_REGS(pt, xc)                     \
   20.68 +{                                               \
   20.69 +    xc.r8 = pt->r8;                             \
   20.70 +    xc.r9 = pt->r9;                             \
   20.71 +    xc.r10 = pt->r10;                           \
   20.72 +    xc.r11 = pt->r11;                           \
   20.73 +    xc.r12 = pt->r12;                           \
   20.74 +    xc.r13 = pt->r13;                           \
   20.75 +    xc.r14 = pt->r14;                           \
   20.76 +    xc.r15 = pt->r15;                           \
   20.77 +    xc.rbx = pt->rbx;                           \
   20.78 +    xc.rcx = pt->rcx;                           \
   20.79 +    xc.rdx = pt->rdx;                           \
   20.80 +    xc.rsi = pt->rsi;                           \
   20.81 +    xc.rdi = pt->rdi;                           \
   20.82 +    xc.rbp = pt->rbp;                           \
   20.83 +    xc.rax = pt->rax;                           \
   20.84 +    xc.rip = pt->rip;                           \
   20.85 +    xc.cs = pt->xcs;                            \
   20.86 +    xc.eflags = pt->eflags;                     \
   20.87 +    xc.rsp = pt->rsp;                           \
   20.88 +    xc.ss = pt->xss;                            \
   20.89 +    xc.es = pt->xes;                            \
   20.90 +    xc.ds = pt->xds;                            \
   20.91 +    xc.fs = pt->xfs;                            \
   20.92 +    xc.gs = pt->xgs;                            \
   20.93 +}
   20.94 +
   20.95 +#elif __i386__
   20.96 +
   20.97  struct gdb_regs {
   20.98      long ebx; /* 0 */
   20.99      long ecx; /* 4 */
  20.100 @@ -30,8 +120,6 @@ struct gdb_regs {
  20.101      int  xss;    /* 64 */
  20.102  };
  20.103  
  20.104 -
  20.105 -#define printval(x) printf("%s = %lx\n", #x, (long)x);
  20.106  #define SET_PT_REGS(pt, xc)                     \
  20.107  {                                               \
  20.108      pt.ebx = xc.ebx;                            \
  20.109 @@ -71,7 +159,9 @@ struct gdb_regs {
  20.110      xc.fs = pt->xfs;                            \
  20.111      xc.gs = pt->xgs;                            \
  20.112  }
  20.113 +#endif
  20.114  
  20.115 +#define printval(x) printf("%s = %lx\n", #x, (long)x);
  20.116  #define vtopdi(va) ((va) >> PDRSHIFT)
  20.117  #define vtopti(va) (((va) >> PAGE_SHIFT) & 0x3ff)
  20.118  #endif
    21.1 --- a/tools/python/xen/xend/XendError.py	Tue Mar 28 11:51:06 2006 +0100
    21.2 +++ b/tools/python/xen/xend/XendError.py	Tue Mar 28 11:52:47 2006 +0100
    21.3 @@ -19,6 +19,10 @@ from xmlrpclib import Fault
    21.4  
    21.5  import XendClient
    21.6  
    21.7 +class XendInvalidDomain(Fault):
    21.8 +    def __init__(self, value):
    21.9 +        Fault.__init__(self, XendClient.ERROR_INVALID_DOMAIN, value)
   21.10 +
   21.11  class XendError(Fault):
   21.12      
   21.13      def __init__(self, value):
    22.1 --- a/tools/python/xen/xend/server/XMLRPCServer.py	Tue Mar 28 11:51:06 2006 +0100
    22.2 +++ b/tools/python/xen/xend/server/XMLRPCServer.py	Tue Mar 28 11:52:47 2006 +0100
    22.3 @@ -23,35 +23,21 @@ from xen.xend import XendDomain, XendDom
    22.4  from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
    22.5  
    22.6  from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN
    22.7 +from xen.xend.XendError import *
    22.8  
    22.9  def lookup(domid):
   22.10 -    try:
   22.11 -        return XendDomain.instance().domain_lookup_by_name_or_id(domid)
   22.12 -    except exn:
   22.13 -        log.exception(exn)
   22.14 -        raise exn
   22.15 +    info = XendDomain.instance().domain_lookup_by_name_or_id(domid)
   22.16 +    if not info:
   22.17 +        raise XendInvalidDomain(str(domid))
   22.18 +    return info
   22.19  
   22.20  def dispatch(domid, fn, args):
   22.21      info = lookup(domid)
   22.22 -    if info:
   22.23 -        try:
   22.24 -            return getattr(info, fn)(*args)
   22.25 -        except exn:
   22.26 -            log.exception(exn)
   22.27 -            raise exn
   22.28 -    else:
   22.29 -        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
   22.30 +    return getattr(info, fn)(*args)
   22.31  
   22.32  def domain(domid):
   22.33      info = lookup(domid)
   22.34 -    if info:
   22.35 -        try:
   22.36 -            return info.sxpr()
   22.37 -        except exn:
   22.38 -            log.exception(exn)
   22.39 -            raise exn
   22.40 -    else:
   22.41 -        raise xmlrpclib.Fault(ERROR_INVALID_DOMAIN, domid)
   22.42 +    return info.sxpr()
   22.43  
   22.44  def domains(detail=1):
   22.45      if detail < 1:
   22.46 @@ -90,7 +76,7 @@ class XMLRPCServer:
   22.47          if self.use_tcp:
   22.48              # bind to something fixed for now as we may eliminate
   22.49              # tcp support completely.
   22.50 -            self.server = TCPXMLRPCServer(("localhost", 8005, False))
   22.51 +            self.server = TCPXMLRPCServer(("localhost", 8005), logRequests=False)
   22.52          else:
   22.53              self.server = UnixXMLRPCServer(XML_RPC_SOCKET, False)
   22.54  
    23.1 --- a/tools/python/xen/xm/main.py	Tue Mar 28 11:51:06 2006 +0100
    23.2 +++ b/tools/python/xen/xm/main.py	Tue Mar 28 11:52:47 2006 +0100
    23.3 @@ -1102,12 +1102,6 @@ def main(argv=sys.argv):
    23.4              else:
    23.5                  err("Error connecting to xend: %s." % ex[1])
    23.6              sys.exit(1)
    23.7 -        except xmlrpclib.ProtocolError, ex:
    23.8 -            if os.geteuid() != 0:
    23.9 -                err("Most commands need root access.  Please try again as root.")
   23.10 -            else:
   23.11 -                err("Error connecting to xend: %s." % ex.errmsg)
   23.12 -            sys.exit(1)
   23.13          except SystemExit:
   23.14              sys.exit(1)
   23.15          except xmlrpclib.Fault, ex:
    24.1 --- a/tools/xentrace/Makefile	Tue Mar 28 11:51:06 2006 +0100
    24.2 +++ b/tools/xentrace/Makefile	Tue Mar 28 11:52:47 2006 +0100
    24.3 @@ -6,7 +6,7 @@ INSTALL_DATA	= $(INSTALL) -m0644
    24.4  XEN_ROOT=../..
    24.5  include $(XEN_ROOT)/tools/Rules.mk
    24.6  
    24.7 -CFLAGS  += -Werror
    24.8 +CFLAGS  += -Werror -D_LARGEFILE64_SOURCE
    24.9  
   24.10  CFLAGS  += -I $(XEN_XC)
   24.11  CFLAGS  += -I $(XEN_LIBXC)
    25.1 --- a/tools/xentrace/formats	Tue Mar 28 11:51:06 2006 +0100
    25.2 +++ b/tools/xentrace/formats	Tue Mar 28 11:52:47 2006 +0100
    25.3 @@ -16,6 +16,6 @@ 0x00080001	CPU%(cpu)d      %(tsc)d		VMX_
    25.4  0x00080002	CPU%(cpu)d      %(tsc)d		VMX_VECTOR		[ domid = 0x%(1)08x, eip = 0x%(2)08x, vector = 0x%(3)08x ]
    25.5  0x00080003	CPU%(cpu)d      %(tsc)d		VMX_INT			[ domid = 0x%(1)08x, trap = 0x%(2)08x, va = 0x%(3)08x ]
    25.6  
    25.7 -0x00090001      CPU%(cpu)d      %(tsc)d         VMENTRY                 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x
    25.8 -0x00090002      CPU%(cpu)d      %(tsc)d         VMEXIT                  0x%(1)08x 0x%(2)08x 0x%(3)08x 
    25.9 +0x00081001      CPU%(cpu)d      %(tsc)d         VMEXIT                  0x%(1)08x 0x%(2)08x 0x%(3)08x 
   25.10 +0x00081002      CPU%(cpu)d      %(tsc)d         VMENTRY                 0x%(1)08x 0x%(2)08x 0x%(3)08x 0x%(4)08x 0x%(5)08x
   25.11  
    26.1 --- a/tools/xentrace/xentrace.c	Tue Mar 28 11:51:06 2006 +0100
    26.2 +++ b/tools/xentrace/xentrace.c	Tue Mar 28 11:52:47 2006 +0100
    26.3 @@ -498,7 +498,7 @@ int main(int argc, char **argv)
    26.4      }
    26.5  
    26.6      if ( opts.outfile )
    26.7 -        outfd = open(opts.outfile, O_WRONLY | O_CREAT);
    26.8 +        outfd = open(opts.outfile, O_WRONLY | O_CREAT | O_LARGEFILE, 0644);
    26.9  
   26.10      if(outfd < 0)
   26.11      {
    27.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Mar 28 11:51:06 2006 +0100
    27.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Mar 28 11:52:47 2006 +0100
    27.3 @@ -728,6 +728,8 @@ static void svm_relinquish_guest_resourc
    27.4  
    27.5      for_each_vcpu ( d, v )
    27.6      {
    27.7 +        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
    27.8 +            continue;
    27.9  #if 0
   27.10          /* Memory leak by not freeing this. XXXKAF: *Why* is not per core?? */
   27.11          free_host_save_area(v->arch.hvm_svm.host_save_area);
    28.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Mar 28 11:51:06 2006 +0100
    28.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Mar 28 11:52:47 2006 +0100
    28.3 @@ -89,6 +89,8 @@ static void vmx_relinquish_guest_resourc
    28.4  
    28.5      for_each_vcpu ( d, v )
    28.6      {
    28.7 +        if ( !test_bit(_VCPUF_initialised, &v->vcpu_flags) )
    28.8 +            continue;
    28.9          vmx_request_clear_vmcs(v);
   28.10          destroy_vmcs(&v->arch.hvm_vmx);
   28.11          free_monitor_pagetable(v);
   28.12 @@ -988,7 +990,7 @@ static void vmx_io_instruction(struct cp
   28.13          port = (exit_qualification >> 16) & 0xFFFF;
   28.14      else
   28.15          port = regs->edx & 0xffff;
   28.16 -    TRACE_VMEXIT(2, port);
   28.17 +    TRACE_VMEXIT(1, port);
   28.18      size = (exit_qualification & 7) + 1;
   28.19      dir = test_bit(3, &exit_qualification); /* direction */
   28.20  
   28.21 @@ -1913,6 +1915,7 @@ static inline void vmx_vmexit_do_extint(
   28.22  
   28.23      vector &= 0xff;
   28.24      local_irq_disable();
   28.25 +    TRACE_VMEXIT(1,vector);
   28.26  
   28.27      switch(vector) {
   28.28      case LOCAL_TIMER_VECTOR:
   28.29 @@ -2042,7 +2045,6 @@ asmlinkage void vmx_vmexit_handler(struc
   28.30  
   28.31      {
   28.32          __vmread(GUEST_RIP, &eip);
   28.33 -        TRACE_3D(TRC_VMX_VMEXIT, v->domain->domain_id, eip, exit_reason);
   28.34          TRACE_VMEXIT(0,exit_reason);
   28.35      }
   28.36  
   28.37 @@ -2066,7 +2068,6 @@ asmlinkage void vmx_vmexit_handler(struc
   28.38          TRACE_VMEXIT(1,vector);
   28.39          perfc_incra(cause_vector, vector);
   28.40  
   28.41 -        TRACE_3D(TRC_VMX_VECTOR, v->domain->domain_id, eip, vector);
   28.42          switch (vector) {
   28.43  #ifdef XEN_DEBUGGER
   28.44          case TRAP_debug:
   28.45 @@ -2250,7 +2251,7 @@ asmlinkage void vmx_load_cr2(void)
   28.46  
   28.47  asmlinkage void vmx_trace_vmentry (void)
   28.48  {
   28.49 -    TRACE_5D(TRC_VMENTRY,
   28.50 +    TRACE_5D(TRC_VMX_VMENTRY,
   28.51               trace_values[smp_processor_id()][0],
   28.52               trace_values[smp_processor_id()][1],
   28.53               trace_values[smp_processor_id()][2],
   28.54 @@ -2266,7 +2267,7 @@ asmlinkage void vmx_trace_vmentry (void)
   28.55  
   28.56  asmlinkage void vmx_trace_vmexit (void)
   28.57  {
   28.58 -    TRACE_3D(TRC_VMEXIT,0,0,0);
   28.59 +    TRACE_3D(TRC_VMX_VMEXIT,0,0,0);
   28.60      return;
   28.61  }
   28.62  
    29.1 --- a/xen/arch/x86/mm.c	Tue Mar 28 11:51:06 2006 +0100
    29.2 +++ b/xen/arch/x86/mm.c	Tue Mar 28 11:52:47 2006 +0100
    29.3 @@ -3351,8 +3351,9 @@ int ptwr_do_page_fault(struct domain *d,
    29.4       * permissions in page directories by writing back to the linear mapping.
    29.5       */
    29.6      if ( (flags = l1e_get_flags(pte) & WRPT_PTE_FLAGS) == WRPT_PTE_FLAGS )
    29.7 -        return !__put_user(
    29.8 -            pte.l1, &linear_pg_table[l1_linear_offset(addr)].l1);
    29.9 +        return __put_user(
   29.10 +            pte.l1, &linear_pg_table[l1_linear_offset(addr)].l1) ?
   29.11 +            0 : EXCRET_not_a_fault;
   29.12  
   29.13      /* We are looking only for read-only mappings of p.t. pages. */
   29.14      if ( ((flags | _PAGE_RW) != WRPT_PTE_FLAGS) ||
    30.1 --- a/xen/arch/x86/shadow.c	Tue Mar 28 11:51:06 2006 +0100
    30.2 +++ b/xen/arch/x86/shadow.c	Tue Mar 28 11:52:47 2006 +0100
    30.3 @@ -1807,6 +1807,16 @@ static int resync_all(struct domain *d, 
    30.4                    entry_has_changed(
    30.5                        guest_pt[i], snapshot_pt[i], PAGE_FLAG_MASK) )
    30.6                  {
    30.7 +
    30.8 +                    unsigned long gpfn;
    30.9 +
   30.10 +                    gpfn = entry_get_pfn(guest_pt[i]);
   30.11 +                    /*
   30.12 +                     * Looks like it's longer a page table.
   30.13 +                     */
   30.14 +                    if ( unlikely(gpfn != (gpfn & PGT_mfn_mask)) )
   30.15 +                        continue;
   30.16 +
   30.17                      need_flush |= validate_entry_change(
   30.18                          d, &guest_pt[i], &shadow_pt[i],
   30.19                          shadow_type_to_level(stype));
   30.20 @@ -1851,6 +1861,14 @@ static int resync_all(struct domain *d, 
   30.21                  {
   30.22  #ifndef GUEST_PGENTRY_32
   30.23                      l4_pgentry_t *shadow4 = shadow;
   30.24 +                    unsigned long gpfn;
   30.25 +
   30.26 +                    gpfn = l4e_get_pfn(new_root_e);
   30.27 +                    /*
   30.28 +                     * Looks like it's longer a page table.
   30.29 +                     */
   30.30 +                    if ( unlikely(gpfn != (gpfn & PGT_mfn_mask)) )
   30.31 +                        continue;
   30.32  
   30.33                      if ( d->arch.ops->guest_paging_levels == PAGING_L4 ) 
   30.34                      {
   30.35 @@ -1894,7 +1912,7 @@ static int resync_all(struct domain *d, 
   30.36          unmap_domain_page(snapshot);
   30.37          unmap_domain_page(guest);
   30.38  
   30.39 -        if ( unlikely(unshadow) )
   30.40 +        if ( unlikely(unshadow && stype == PGT_root_page_table) )
   30.41          {
   30.42              for_each_vcpu(d, v)
   30.43                  if(smfn == pagetable_get_pfn(v->arch.shadow_table))
    31.1 --- a/xen/arch/x86/traps.c	Tue Mar 28 11:51:06 2006 +0100
    31.2 +++ b/xen/arch/x86/traps.c	Tue Mar 28 11:52:47 2006 +0100
    31.3 @@ -620,6 +620,46 @@ static int fixup_page_fault(unsigned lon
    31.4      return 0;
    31.5  }
    31.6  
    31.7 +static int spurious_page_fault(unsigned long addr, struct cpu_user_regs *regs)
    31.8 +{
    31.9 +    struct vcpu   *v = current;
   31.10 +    struct domain *d = v->domain;
   31.11 +    int            rc;
   31.12 +
   31.13 +    /*
   31.14 +     * The only possible reason for a spurious page fault not to be picked
   31.15 +     * up already is that a page directory was unhooked by writable page table
   31.16 +     * logic and then reattached before the faulting VCPU could detect it.
   31.17 +     */
   31.18 +    if ( is_idle_domain(d) ||               /* no ptwr in idle domain       */
   31.19 +         IN_HYPERVISOR_RANGE(addr) ||       /* no ptwr on hypervisor addrs  */
   31.20 +         shadow_mode_enabled(d) ||          /* no ptwr logic in shadow mode */
   31.21 +         ((regs->error_code & 0x1d) != 0) ) /* simple not-present fault?    */
   31.22 +        return 0;
   31.23 +
   31.24 +    LOCK_BIGLOCK(d);
   31.25 +
   31.26 +    /*
   31.27 +     * The page directory could have been detached again while we weren't
   31.28 +     * holding the per-domain lock. Detect that and fix up if it's the case.
   31.29 +     */
   31.30 +    if ( unlikely(d->arch.ptwr[PTWR_PT_ACTIVE].l1va) &&
   31.31 +         unlikely(l2_linear_offset(addr) ==
   31.32 +                  d->arch.ptwr[PTWR_PT_ACTIVE].l2_idx) )
   31.33 +    {
   31.34 +        ptwr_flush(d, PTWR_PT_ACTIVE);
   31.35 +        rc = 1;
   31.36 +    }
   31.37 +    else
   31.38 +    {
   31.39 +        /* Okay, walk the page tables. Only check for not-present faults.*/
   31.40 +        rc = __spurious_page_fault(addr);
   31.41 +    }
   31.42 +
   31.43 +    UNLOCK_BIGLOCK(d);
   31.44 +    return rc;
   31.45 +}
   31.46 +
   31.47  /*
   31.48   * #PF error code:
   31.49   *  Bit 0: Protection violation (=1) ; Page not present (=0)
   31.50 @@ -644,6 +684,13 @@ asmlinkage int do_page_fault(struct cpu_
   31.51  
   31.52      if ( unlikely(!guest_mode(regs)) )
   31.53      {
   31.54 +        if ( spurious_page_fault(addr, regs) )
   31.55 +        {
   31.56 +            DPRINTK("Spurious fault in domain %u:%u at addr %lx\n",
   31.57 +                    current->domain->domain_id, current->vcpu_id, addr);
   31.58 +            return EXCRET_not_a_fault;
   31.59 +        }
   31.60 +
   31.61          if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
   31.62          {
   31.63              perfc_incrc(copy_user_faults);
   31.64 @@ -658,7 +705,7 @@ asmlinkage int do_page_fault(struct cpu_
   31.65          panic("CPU%d FATAL PAGE FAULT\n"
   31.66                "[error_code=%04x]\n"
   31.67                "Faulting linear address: %p\n",
   31.68 -              smp_processor_id(), regs->error_code, addr);
   31.69 +              smp_processor_id(), regs->error_code, _p(addr));
   31.70      }
   31.71  
   31.72      propagate_page_fault(addr, regs->error_code);
    32.1 --- a/xen/arch/x86/x86_32/traps.c	Tue Mar 28 11:51:06 2006 +0100
    32.2 +++ b/xen/arch/x86/x86_32/traps.c	Tue Mar 28 11:52:47 2006 +0100
    32.3 @@ -70,38 +70,77 @@ void show_registers(struct cpu_user_regs
    32.4  
    32.5  void show_page_walk(unsigned long addr)
    32.6  {
    32.7 -    unsigned long mfn = read_cr3() >> PAGE_SHIFT;
    32.8 -    intpte_t *ptab, ent;
    32.9 -    unsigned long pfn; 
   32.10 +    unsigned long pfn, mfn = read_cr3() >> PAGE_SHIFT;
   32.11 +#ifdef CONFIG_X86_PAE
   32.12 +    l3_pgentry_t l3e, *l3t;
   32.13 +#endif
   32.14 +    l2_pgentry_t l2e, *l2t;
   32.15 +    l1_pgentry_t l1e, *l1t;
   32.16  
   32.17      printk("Pagetable walk from %08lx:\n", addr);
   32.18  
   32.19  #ifdef CONFIG_X86_PAE
   32.20 -    ptab = map_domain_page(mfn);
   32.21 -    ent  = ptab[l3_table_offset(addr)];
   32.22 -    pfn  = get_gpfn_from_mfn((u32)(ent >> PAGE_SHIFT)); 
   32.23 -    printk(" L3 = %"PRIpte" %08lx\n", ent, pfn);
   32.24 -    unmap_domain_page(ptab);
   32.25 -    if ( !(ent & _PAGE_PRESENT) )
   32.26 +    l3t = map_domain_page(mfn);
   32.27 +    l3e = l3t[l3_table_offset(addr)];
   32.28 +    mfn = l3e_get_pfn(l3e);
   32.29 +    pfn = get_gpfn_from_mfn(mfn);
   32.30 +    printk(" L3 = %"PRIpte" %08lx\n", l3e_get_intpte(l3e), pfn);
   32.31 +    unmap_domain_page(l3t);
   32.32 +    if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) )
   32.33          return;
   32.34 -    mfn = ent >> PAGE_SHIFT;
   32.35  #endif
   32.36  
   32.37 -    ptab = map_domain_page(mfn);
   32.38 -    ent  = ptab[l2_table_offset(addr)];
   32.39 -    pfn  = get_gpfn_from_mfn((u32)(ent >> PAGE_SHIFT));
   32.40 -    printk("  L2 = %"PRIpte" %08lx %s\n", ent, pfn, 
   32.41 -           (ent & _PAGE_PSE) ? "(PSE)" : "");
   32.42 -    unmap_domain_page(ptab);
   32.43 -    if ( !(ent & _PAGE_PRESENT) || (ent & _PAGE_PSE) )
   32.44 +    l2t = map_domain_page(mfn);
   32.45 +    l2e = l2t[l2_table_offset(addr)];
   32.46 +    mfn = l2e_get_pfn(l2e);
   32.47 +    pfn = get_gpfn_from_mfn(mfn);
   32.48 +    printk("  L2 = %"PRIpte" %08lx %s\n", l2e_get_intpte(l2e), pfn, 
   32.49 +           (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : "");
   32.50 +    unmap_domain_page(l2t);
   32.51 +    if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ||
   32.52 +         (l2e_get_flags(l2e) & _PAGE_PSE) )
   32.53          return;
   32.54 -    mfn = ent >> PAGE_SHIFT;
   32.55  
   32.56 -    ptab = map_domain_page(ent >> PAGE_SHIFT);
   32.57 -    ent  = ptab[l1_table_offset(addr)];
   32.58 -    pfn  = get_gpfn_from_mfn((u32)(ent >> PAGE_SHIFT));
   32.59 -    printk("   L1 = %"PRIpte" %08lx\n", ent, pfn);
   32.60 -    unmap_domain_page(ptab);
   32.61 +    l1t = map_domain_page(mfn);
   32.62 +    l1e = l1t[l1_table_offset(addr)];
   32.63 +    mfn = l1e_get_pfn(l1e);
   32.64 +    pfn = get_gpfn_from_mfn(mfn);
   32.65 +    printk("   L1 = %"PRIpte" %08lx\n", l1e_get_intpte(l1e), pfn);
   32.66 +    unmap_domain_page(l1t);
   32.67 +}
   32.68 +
   32.69 +int __spurious_page_fault(unsigned long addr)
   32.70 +{
   32.71 +    unsigned long mfn = read_cr3() >> PAGE_SHIFT;
   32.72 +#ifdef CONFIG_X86_PAE
   32.73 +    l3_pgentry_t l3e, *l3t;
   32.74 +#endif
   32.75 +    l2_pgentry_t l2e, *l2t;
   32.76 +    l1_pgentry_t l1e, *l1t;
   32.77 +
   32.78 +#ifdef CONFIG_X86_PAE
   32.79 +    l3t = map_domain_page(mfn);
   32.80 +    l3e = l3t[l3_table_offset(addr)];
   32.81 +    mfn = l3e_get_pfn(l3e);
   32.82 +    unmap_domain_page(l3t);
   32.83 +    if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) )
   32.84 +        return 0;
   32.85 +#endif
   32.86 +
   32.87 +    l2t = map_domain_page(mfn);
   32.88 +    l2e = l2t[l2_table_offset(addr)];
   32.89 +    mfn = l2e_get_pfn(l2e);
   32.90 +    unmap_domain_page(l2t);
   32.91 +    if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) )
   32.92 +        return 0;
   32.93 +    if ( l2e_get_flags(l2e) & _PAGE_PSE )
   32.94 +        return 1;
   32.95 +
   32.96 +    l1t = map_domain_page(mfn);
   32.97 +    l1e = l1t[l1_table_offset(addr)];
   32.98 +    mfn = l1e_get_pfn(l1e);
   32.99 +    unmap_domain_page(l1t);
  32.100 +    return !!(l1e_get_flags(l1e) & _PAGE_PRESENT);
  32.101  }
  32.102  
  32.103  #define DOUBLEFAULT_STACK_SIZE 1024
    33.1 --- a/xen/arch/x86/x86_64/traps.c	Tue Mar 28 11:51:06 2006 +0100
    33.2 +++ b/xen/arch/x86/x86_64/traps.c	Tue Mar 28 11:52:47 2006 +0100
    33.3 @@ -70,31 +70,79 @@ void show_registers(struct cpu_user_regs
    33.4  
    33.5  void show_page_walk(unsigned long addr)
    33.6  {
    33.7 -    unsigned long page = read_cr3();
    33.8 -    
    33.9 +    unsigned long pfn, mfn = read_cr3() >> PAGE_SHIFT;
   33.10 +    l4_pgentry_t l4e, *l4t;
   33.11 +    l3_pgentry_t l3e, *l3t;
   33.12 +    l2_pgentry_t l2e, *l2t;
   33.13 +    l1_pgentry_t l1e, *l1t;
   33.14 +
   33.15      printk("Pagetable walk from %016lx:\n", addr);
   33.16  
   33.17 -    page &= PAGE_MASK;
   33.18 -    page = ((unsigned long *) __va(page))[l4_table_offset(addr)];
   33.19 -    printk(" L4 = %016lx\n", page);
   33.20 -    if ( !(page & _PAGE_PRESENT) )
   33.21 +    l4t = mfn_to_virt(mfn);
   33.22 +    l4e = l4t[l4_table_offset(addr)];
   33.23 +    mfn = l4e_get_pfn(l4e);
   33.24 +    pfn = get_gpfn_from_mfn(mfn);
   33.25 +    printk(" L4 = %"PRIpte" %016lx\n", l4e_get_intpte(l4e), pfn);
   33.26 +    if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) )
   33.27          return;
   33.28  
   33.29 -    page &= PAGE_MASK;
   33.30 -    page = ((unsigned long *) __va(page))[l3_table_offset(addr)];
   33.31 -    printk("  L3 = %016lx\n", page);
   33.32 -    if ( !(page & _PAGE_PRESENT) )
   33.33 +    l3t = mfn_to_virt(mfn);
   33.34 +    l3e = l3t[l3_table_offset(addr)];
   33.35 +    mfn = l3e_get_pfn(l3e);
   33.36 +    pfn = get_gpfn_from_mfn(mfn);
   33.37 +    printk("  L3 = %"PRIpte" %016lx\n", l3e_get_intpte(l3e), pfn);
   33.38 +    if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) )
   33.39          return;
   33.40  
   33.41 -    page &= PAGE_MASK;
   33.42 -    page = ((unsigned long *) __va(page))[l2_table_offset(addr)];
   33.43 -    printk("   L2 = %016lx %s\n", page, (page & _PAGE_PSE) ? "(2MB)" : "");
   33.44 -    if ( !(page & _PAGE_PRESENT) || (page & _PAGE_PSE) )
   33.45 +    l2t = mfn_to_virt(mfn);
   33.46 +    l2e = l2t[l2_table_offset(addr)];
   33.47 +    mfn = l2e_get_pfn(l2e);
   33.48 +    pfn = get_gpfn_from_mfn(mfn);
   33.49 +    printk("   L2 = %"PRIpte" %016lx %s\n", l2e_get_intpte(l2e), pfn,
   33.50 +           (l2e_get_flags(l2e) & _PAGE_PSE) ? "(PSE)" : "");
   33.51 +    if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) ||
   33.52 +         (l2e_get_flags(l2e) & _PAGE_PSE) )
   33.53          return;
   33.54  
   33.55 -    page &= PAGE_MASK;
   33.56 -    page = ((unsigned long *) __va(page))[l1_table_offset(addr)];
   33.57 -    printk("    L1 = %016lx\n", page);
   33.58 +    l1t = mfn_to_virt(mfn);
   33.59 +    l1e = l1t[l1_table_offset(addr)];
   33.60 +    mfn = l1e_get_pfn(l1e);
   33.61 +    pfn = get_gpfn_from_mfn(mfn);
   33.62 +    printk("    L1 = %"PRIpte" %016lx\n", l1e_get_intpte(l1e), pfn);
   33.63 +}
   33.64 +
   33.65 +int __spurious_page_fault(unsigned long addr)
   33.66 +{
   33.67 +    unsigned long mfn = read_cr3() >> PAGE_SHIFT;
   33.68 +    l4_pgentry_t l4e, *l4t;
   33.69 +    l3_pgentry_t l3e, *l3t;
   33.70 +    l2_pgentry_t l2e, *l2t;
   33.71 +    l1_pgentry_t l1e, *l1t;
   33.72 +
   33.73 +    l4t = mfn_to_virt(mfn);
   33.74 +    l4e = l4t[l4_table_offset(addr)];
   33.75 +    mfn = l4e_get_pfn(l4e);
   33.76 +    if ( !(l4e_get_flags(l4e) & _PAGE_PRESENT) )
   33.77 +        return 0;
   33.78 +
   33.79 +    l3t = mfn_to_virt(mfn);
   33.80 +    l3e = l3t[l3_table_offset(addr)];
   33.81 +    mfn = l3e_get_pfn(l3e);
   33.82 +    if ( !(l3e_get_flags(l3e) & _PAGE_PRESENT) )
   33.83 +        return 0;
   33.84 +
   33.85 +    l2t = mfn_to_virt(mfn);
   33.86 +    l2e = l2t[l2_table_offset(addr)];
   33.87 +    mfn = l2e_get_pfn(l2e);
   33.88 +    if ( !(l2e_get_flags(l2e) & _PAGE_PRESENT) )
   33.89 +        return 0;
   33.90 +    if ( l2e_get_flags(l2e) & _PAGE_PSE )
   33.91 +        return 1;
   33.92 +
   33.93 +    l1t = mfn_to_virt(mfn);
   33.94 +    l1e = l1t[l1_table_offset(addr)];
   33.95 +    mfn = l1e_get_pfn(l1e);
   33.96 +    return !!(l1e_get_flags(l1e) & _PAGE_PRESENT);
   33.97  }
   33.98  
   33.99  asmlinkage void double_fault(void);
    34.1 --- a/xen/common/page_alloc.c	Tue Mar 28 11:51:06 2006 +0100
    34.2 +++ b/xen/common/page_alloc.c	Tue Mar 28 11:52:47 2006 +0100
    34.3 @@ -219,8 +219,6 @@ unsigned long alloc_boot_pages(unsigned 
    34.4  #define pfn_dom_zone_type(_pfn)                                 \
    34.5      (((_pfn) <= MAX_DMADOM_PFN) ? MEMZONE_DMADOM : MEMZONE_DOM)
    34.6  
    34.7 -/* Up to 2^20 pages can be allocated at once. */
    34.8 -#define MAX_ORDER 20
    34.9  static struct list_head heap[NR_ZONES][MAX_ORDER+1];
   34.10  
   34.11  static unsigned long avail[NR_ZONES];
    35.1 --- a/xen/include/asm-x86/processor.h	Tue Mar 28 11:51:06 2006 +0100
    35.2 +++ b/xen/include/asm-x86/processor.h	Tue Mar 28 11:52:47 2006 +0100
    35.3 @@ -524,6 +524,7 @@ extern always_inline void prefetchw(cons
    35.4  void show_stack(struct cpu_user_regs *regs);
    35.5  void show_registers(struct cpu_user_regs *regs);
    35.6  void show_page_walk(unsigned long addr);
    35.7 +int __spurious_page_fault(unsigned long addr);
    35.8  asmlinkage void fatal_trap(int trapnr, struct cpu_user_regs *regs);
    35.9  
   35.10  extern void mtrr_ap_init(void);
    36.1 --- a/xen/include/public/trace.h	Tue Mar 28 11:51:06 2006 +0100
    36.2 +++ b/xen/include/public/trace.h	Tue Mar 28 11:52:47 2006 +0100
    36.3 @@ -24,7 +24,6 @@
    36.4  #define TRC_VMXTIMER 0x00082000   /* VMX timer trace           */
    36.5  #define TRC_VMXINT   0x00084000   /* VMX interrupt trace       */
    36.6  #define TRC_VMXIO    0x00088000   /* VMX io emulation trace  */
    36.7 -#define TRC_VMEXIT_HANDLER    0x00090000   /* VMX handler trace  */
    36.8  
    36.9  /* Trace events per class */
   36.10  
   36.11 @@ -50,15 +49,12 @@
   36.12  
   36.13  /* trace events per subclass */
   36.14  #define TRC_VMX_VMEXIT          (TRC_VMXEXIT + 1)
   36.15 -#define TRC_VMX_VECTOR          (TRC_VMXEXIT + 2)
   36.16 +#define TRC_VMX_VMENTRY         (TRC_VMXEXIT + 2)
   36.17  
   36.18  #define TRC_VMX_TIMER_INTR      (TRC_VMXTIMER + 1)
   36.19  
   36.20  #define TRC_VMX_INT             (TRC_VMXINT + 1)
   36.21  
   36.22 -#define TRC_VMEXIT              (TRC_VMEXIT_HANDLER + 1)
   36.23 -#define TRC_VMENTRY             (TRC_VMEXIT_HANDLER + 2)
   36.24 -
   36.25  
   36.26  /* This structure represents a single trace buffer record. */
   36.27  struct t_rec {
    37.1 --- a/xen/include/xen/lib.h	Tue Mar 28 11:51:06 2006 +0100
    37.2 +++ b/xen/include/xen/lib.h	Tue Mar 28 11:52:47 2006 +0100
    37.3 @@ -47,7 +47,8 @@ extern void debugtrace_printk(const char
    37.4  #define printk(_f , _a...) printf( _f , ## _a )
    37.5  extern void printf(const char *format, ...)
    37.6      __attribute__ ((format (printf, 1, 2)));
    37.7 -extern void panic(const char *format, ...);
    37.8 +extern void panic(const char *format, ...)
    37.9 +    __attribute__ ((format (printf, 1, 2)));
   37.10  extern long vm_assist(struct domain *, unsigned int, unsigned int);
   37.11  
   37.12  /* vsprintf.c */
    38.1 --- a/xen/include/xen/mm.h	Tue Mar 28 11:51:06 2006 +0100
    38.2 +++ b/xen/include/xen/mm.h	Tue Mar 28 11:52:47 2006 +0100
    38.3 @@ -68,6 +68,9 @@ unsigned long avail_domheap_pages(void);
    38.4  
    38.5  #define ALLOC_DOM_DMA 1
    38.6  
    38.7 +/* Up to 2^20 pages can be allocated at once. */
    38.8 +#define MAX_ORDER 20
    38.9 +
   38.10  /* Automatic page scrubbing for dead domains. */
   38.11  extern struct list_head page_scrub_list;
   38.12  #define page_scrub_schedule_work()              \