ia64/xen-unstable

changeset 7620:9cdfcecf4968

Merge.

Signed-off-by: Steven Smith, sos22@cam.ac.uk
author sos22@douglas.cl.cam.ac.uk
date Wed Nov 02 17:29:32 2005 +0100 (2005-11-02)
parents 5ffe3f16aa52 4321438e92a7
children 76fbcb25d174
files
line diff
     1.1 --- a/.hgignore	Tue Nov 01 13:38:20 2005 +0100
     1.2 +++ b/.hgignore	Wed Nov 02 17:29:32 2005 +0100
     1.3 @@ -28,6 +28,8 @@
     1.4  ^docs/interface/interface\.css$
     1.5  ^docs/interface/interface\.html$
     1.6  ^docs/interface/labels\.pl$
     1.7 +^docs/man1/
     1.8 +^docs/man5/
     1.9  ^docs/pdf/.*$
    1.10  ^docs/ps/.*$
    1.11  ^docs/user/WARNINGS$
    1.12 @@ -162,6 +164,8 @@
    1.13  ^tools/xenstore/xs_test$
    1.14  ^tools/xenstore/xs_watch_stress$
    1.15  ^tools/xenstore/xsls$
    1.16 +^tools/xentrace/setsize$
    1.17 +^tools/xentrace/tbctl$
    1.18  ^tools/xentrace/xenctx$
    1.19  ^tools/xentrace/xentrace$
    1.20  ^xen/BLOG$
     2.1 --- a/docs/check_pkgs	Tue Nov 01 13:38:20 2005 +0100
     2.2 +++ b/docs/check_pkgs	Wed Nov 02 17:29:32 2005 +0100
     2.3 @@ -1,14 +1,14 @@
     2.4  
     2.5  silent_which ()
     2.6  {
     2.7 -        if ! `which $1 1>/dev/null 2>/dev/null`; then
     2.8 +        which $1 1>/dev/null 2>/dev/null || {
     2.9                  echo "*************************************************"
    2.10                  echo "*************************************************"
    2.11                  echo "* WARNING: Package '$1' is required"
    2.12                  echo "*          to build Xen documentation"
    2.13                  echo "*************************************************"
    2.14                  echo "*************************************************"
    2.15 -        fi
    2.16 +        }
    2.17          which $1 1>/dev/null 2>/dev/null
    2.18  }
    2.19  
     3.1 --- a/docs/man/xmdomain.cfg.pod.5	Tue Nov 01 13:38:20 2005 +0100
     3.2 +++ b/docs/man/xmdomain.cfg.pod.5	Wed Nov 02 17:29:32 2005 +0100
     3.3 @@ -72,6 +72,57 @@ A bare minimal config file example might
     3.4  
     3.5  =item I<builder>
     3.6  
     3.7 +=back 
     3.8 +
     3.9 +=head1 DOMAIN SHUTDOWN OPTIONS
    3.10 +
    3.11 +There are 3 options which control domain shutdown (both planned and
    3.12 +unplanned) under certain events.  The 3 events currently captured are:
    3.13 +
    3.14 +=over 4
    3.15 +
    3.16 +=item I<shutdown>
    3.17 +
    3.18 +Triggered on either an I<xm shutdown> or graceful shutdown from inside
    3.19 +the DomU.
    3.20 +
    3.21 +=item I<reboot>
    3.22 +
    3.23 +Triggered on either an I<xm reboot> or graceful reboot from inside the
    3.24 +DomU.
    3.25 +
    3.26 +=item I<crash>
    3.27 +
    3.28 +Triggered when a DomU goes to the crashed state for any reason.
    3.29 +
    3.30 +=back
    3.31 +
    3.32 +All of them take one of 4 valid states listed below.  
    3.33 +
    3.34 +=over 4
    3.35 +
    3.36 +=item I<destroy>
    3.37 +
    3.38 +The domain will be cleaned up completely.  No attempt at respawning
    3.39 +will occur.  This is what a typical shutdown would look like.
    3.40 +
    3.41 +=item I<restart>
    3.42 +
    3.43 +The domain will be restarted with the same name as the old domain.
    3.44 +This is what a typical reboot would look like.
    3.45 +
    3.46 +=item I<preserve>
    3.47 +
    3.48 +The domain will not be cleaned up at all.  This is often useful for
    3.49 +crash state domains which ensures that enough evidence is to debug the
    3.50 +real issue.
    3.51 +
    3.52 +=item I<rename-restart>
    3.53 +
    3.54 +The old domain will not be cleaned up, but will be renamed so a new
    3.55 +domain can be restarted in it's place.  (TODO: what does this mean for
    3.56 +resources?  What is the renamed name?)
    3.57 +
    3.58  =back
    3.59  
    3.60  =head1 SEE ALSO
     4.1 --- a/docs/src/user/control_software.tex	Tue Nov 01 13:38:20 2005 +0100
     4.2 +++ b/docs/src/user/control_software.tex	Wed Nov 02 17:29:32 2005 +0100
     4.3 @@ -60,7 +60,7 @@ custom variables (for instance, the \pat
     4.4  The available commands are as follows:
     4.5  
     4.6  \begin{description}
     4.7 -\item[set-mem] Request a domain to adjust its memory footprint.
     4.8 +\item[mem-set] Request a domain to adjust its memory footprint.
     4.9  \item[create] Create a new domain.
    4.10  \item[destroy] Kill a domain immediately.
    4.11  \item[list] List running domains.
     5.1 --- a/docs/src/user/domain_mgmt.tex	Tue Nov 01 13:38:20 2005 +0100
     5.2 +++ b/docs/src/user/domain_mgmt.tex	Wed Nov 02 17:29:32 2005 +0100
     5.3 @@ -160,12 +160,12 @@ memory at the request of the administrat
     5.4  \subsection{Setting memory footprints from dom0}
     5.5  
     5.6  The machine administrator can request that a domain alter its memory
     5.7 -footprint using the \path{xm set-mem} command.  For instance, we can
     5.8 +footprint using the \path{xm mem-set} command.  For instance, we can
     5.9  request that our example ttylinux domain reduce its memory footprint
    5.10  to 32 megabytes.
    5.11  
    5.12  \begin{verbatim}
    5.13 -# xm set-mem ttylinux 32
    5.14 +# xm mem-set ttylinux 32
    5.15  \end{verbatim}
    5.16  
    5.17  We can now see the result of this in the output of \path{xm list}:
    5.18 @@ -181,7 +181,7 @@ The domain has responded to the request 
    5.19  can restore the domain to its original size using the command line:
    5.20  
    5.21  \begin{verbatim}
    5.22 -# xm set-mem ttylinux 64
    5.23 +# xm mem-set ttylinux 64
    5.24  \end{verbatim}
    5.25  
    5.26  \subsection{Setting memory footprints from within a domain}
     6.1 --- a/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Tue Nov 01 13:38:20 2005 +0100
     6.2 +++ b/linux-2.6-xen-sparse/arch/xen/i386/kernel/cpu/common.c	Wed Nov 02 17:29:32 2005 +0100
     6.3 @@ -520,7 +520,7 @@ void __init print_cpu_info(struct cpuinf
     6.4  		printk("\n");
     6.5  }
     6.6  
     6.7 -cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
     6.8 +cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
     6.9  
    6.10  /* This is hacky. :)
    6.11   * We're emulating future behavior.
    6.12 @@ -562,7 +562,7 @@ void __init early_cpu_init(void)
    6.13  #endif
    6.14  }
    6.15  
    6.16 -void __init cpu_gdt_init(struct Xgt_desc_struct *gdt_descr)
    6.17 +void __cpuinit cpu_gdt_init(struct Xgt_desc_struct *gdt_descr)
    6.18  {
    6.19  	unsigned long frames[16];
    6.20  	unsigned long va;
    6.21 @@ -585,7 +585,7 @@ void __init cpu_gdt_init(struct Xgt_desc
    6.22   * and IDT. We reload them nevertheless, this function acts as a
    6.23   * 'CPU state barrier', nothing should get across.
    6.24   */
    6.25 -void __init cpu_init (void)
    6.26 +void __cpuinit cpu_init (void)
    6.27  {
    6.28  	int cpu = smp_processor_id();
    6.29  	struct tss_struct * t = &per_cpu(init_tss, cpu);
     7.1 --- a/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Tue Nov 01 13:38:20 2005 +0100
     7.2 +++ b/linux-2.6-xen-sparse/arch/xen/kernel/smpboot.c	Wed Nov 02 17:29:32 2005 +0100
     7.3 @@ -191,10 +191,17 @@ void __init smp_prepare_cpus(unsigned in
     7.4  	int cpu, rc;
     7.5  	struct task_struct *idle;
     7.6  
     7.7 -	if (max_cpus == 0)
     7.8 -		return;
     7.9 +	cpu_data[0] = boot_cpu_data;
    7.10  
    7.11 -	xen_smp_intr_init(0);
    7.12 +	cpu_2_logical_apicid[0] = 0;
    7.13 +	x86_cpu_to_apicid[0] = 0;
    7.14 +
    7.15 +	current_thread_info()->cpu = 0;
    7.16 +	cpu_sibling_map[0] = cpumask_of_cpu(0);
    7.17 +	cpu_core_map[0]    = cpumask_of_cpu(0);
    7.18 +
    7.19 +	if (max_cpus != 0)
    7.20 +		xen_smp_intr_init(0);
    7.21  
    7.22  	for (cpu = 1; cpu < max_cpus; cpu++) {
    7.23  		rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL);
    7.24 @@ -229,16 +236,20 @@ void __init smp_prepare_cpus(unsigned in
    7.25  		make_page_readonly((void *)cpu_gdt_descr[cpu].address);
    7.26  
    7.27  		cpu_set(cpu, cpu_possible_map);
    7.28 +#ifdef CONFIG_HOTPLUG_CPU
    7.29  		if (xen_start_info->flags & SIF_INITDOMAIN)
    7.30  			cpu_set(cpu, cpu_present_map);
    7.31 +#else
    7.32 +		cpu_set(cpu, cpu_present_map);
    7.33 +#endif
    7.34  
    7.35  		vcpu_prepare(cpu);
    7.36  	}
    7.37  
    7.38  	/* Currently, Xen gives no dynamic NUMA/HT info. */
    7.39 -	for (cpu = 0; cpu < NR_CPUS; cpu++) {
    7.40 -		cpus_clear(cpu_sibling_map[cpu]);
    7.41 -		cpus_clear(cpu_core_map[cpu]);
    7.42 +	for (cpu = 1; cpu < NR_CPUS; cpu++) {
    7.43 +		cpu_sibling_map[cpu] = cpumask_of_cpu(cpu);
    7.44 +		cpu_core_map[cpu]    = cpumask_of_cpu(cpu);
    7.45  	}
    7.46  
    7.47  #ifdef CONFIG_X86_IO_APIC
    7.48 @@ -256,18 +267,9 @@ void __devinit smp_prepare_boot_cpu(void
    7.49  	cpu_possible_map = cpumask_of_cpu(0);
    7.50  	cpu_present_map  = cpumask_of_cpu(0);
    7.51  	cpu_online_map   = cpumask_of_cpu(0);
    7.52 -
    7.53 -	cpu_data[0] = boot_cpu_data;
    7.54 -	cpu_2_logical_apicid[0] = 0;
    7.55 -	x86_cpu_to_apicid[0] = 0;
    7.56 +}
    7.57  
    7.58 -	current_thread_info()->cpu = 0;
    7.59 -	cpus_clear(cpu_sibling_map[0]);
    7.60 -	cpu_set(0, cpu_sibling_map[0]);
    7.61 -
    7.62 -	cpus_clear(cpu_core_map[0]);
    7.63 -	cpu_set(0, cpu_core_map[0]);
    7.64 -}
    7.65 +#ifdef CONFIG_HOTPLUG_CPU
    7.66  
    7.67  static void vcpu_hotplug(unsigned int cpu)
    7.68  {
    7.69 @@ -288,11 +290,7 @@ static void vcpu_hotplug(unsigned int cp
    7.70  		cpu_set(cpu, cpu_present_map);
    7.71  		(void)cpu_up(cpu);
    7.72  	} else if (strcmp(state, "offline") == 0) {
    7.73 -#ifdef CONFIG_HOTPLUG_CPU
    7.74  		(void)cpu_down(cpu);
    7.75 -#else
    7.76 -		printk(KERN_INFO "Ignoring CPU%d hotplug request\n", cpu);
    7.77 -#endif
    7.78  	} else {
    7.79  		printk(KERN_ERR "XENBUS: unknown state(%s) on CPU%d\n",
    7.80  		       state, cpu);
    7.81 @@ -342,8 +340,6 @@ static int __init setup_vcpu_hotplug_eve
    7.82  
    7.83  subsys_initcall(setup_vcpu_hotplug_event);
    7.84  
    7.85 -#ifdef CONFIG_HOTPLUG_CPU
    7.86 -
    7.87  int __cpu_disable(void)
    7.88  {
    7.89  	cpumask_t map = cpu_online_map;
     8.1 --- a/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Tue Nov 01 13:38:20 2005 +0100
     8.2 +++ b/linux-2.6-xen-sparse/arch/xen/x86_64/kernel/setup64.c	Wed Nov 02 17:29:32 2005 +0100
     8.3 @@ -35,7 +35,7 @@
     8.4  #endif
     8.5  char x86_boot_params[BOOT_PARAM_SIZE] __initdata = {0,};
     8.6  
     8.7 -cpumask_t cpu_initialized __initdata = CPU_MASK_NONE;
     8.8 +cpumask_t cpu_initialized __cpuinitdata = CPU_MASK_NONE;
     8.9  
    8.10  struct x8664_pda cpu_pda[NR_CPUS] __cacheline_aligned; 
    8.11  
    8.12 @@ -130,7 +130,7 @@ static void switch_pt(void)
    8.13          xen_new_user_pt(__pa(init_level4_user_pgt));
    8.14  }
    8.15  
    8.16 -void __init cpu_gdt_init(struct desc_ptr *gdt_descr)
    8.17 +void __cpuinit cpu_gdt_init(struct desc_ptr *gdt_descr)
    8.18  {
    8.19  	unsigned long frames[16];
    8.20  	unsigned long va;
    8.21 @@ -227,7 +227,7 @@ void syscall_init(void)
    8.22  #endif
    8.23  }
    8.24  
    8.25 -void __init check_efer(void)
    8.26 +void __cpuinit check_efer(void)
    8.27  {
    8.28  	unsigned long efer;
    8.29  
    8.30 @@ -244,7 +244,7 @@ void __init check_efer(void)
    8.31   * 'CPU state barrier', nothing should get across.
    8.32   * A lot of state is already set up in PDA init.
    8.33   */
    8.34 -void __init cpu_init (void)
    8.35 +void __cpuinit cpu_init (void)
    8.36  {
    8.37  #ifdef CONFIG_SMP
    8.38  	int cpu = stack_smp_processor_id();
     9.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Nov 01 13:38:20 2005 +0100
     9.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Wed Nov 02 17:29:32 2005 +0100
     9.3 @@ -458,7 +458,7 @@ static void watch_for_status(struct xenb
     9.4  	node += strlen(watch->node);
     9.5  
     9.6  	/* FIXME: clean up when error on the other end. */
     9.7 -	if (info->connected == BLKIF_STATE_CONNECTED)
     9.8 +	if ((info->connected == BLKIF_STATE_CONNECTED) || info->mi)
     9.9  		return;
    9.10  
    9.11  	err = xenbus_gather(NULL, watch->node,
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/patches/linux-2.6.12/cpu-hotplug-init.patch	Wed Nov 02 17:29:32 2005 +0100
    10.3 @@ -0,0 +1,34 @@
    10.4 +diff -ur linux-2.6.12.orig/include/linux/init.h linux-2.6.12/include/linux/init.h
    10.5 +--- linux-2.6.12.orig/include/linux/init.h	2005-11-01 14:52:28.656025573 +0000
    10.6 ++++ linux-2.6.12/include/linux/init.h	2005-11-01 14:53:28.015791549 +0000
    10.7 +@@ -229,6 +229,18 @@
    10.8 + #define __devexitdata __exitdata
    10.9 + #endif
   10.10 + 
   10.11 ++#ifdef CONFIG_HOTPLUG_CPU
   10.12 ++#define __cpuinit
   10.13 ++#define __cpuinitdata
   10.14 ++#define __cpuexit
   10.15 ++#define __cpuexitdata
   10.16 ++#else
   10.17 ++#define __cpuinit	__init
   10.18 ++#define __cpuinitdata __initdata
   10.19 ++#define __cpuexit __exit
   10.20 ++#define __cpuexitdata	__exitdata
   10.21 ++#endif
   10.22 ++
   10.23 + /* Functions marked as __devexit may be discarded at kernel link time, depending
   10.24 +    on config options.  Newer versions of binutils detect references from
   10.25 +    retained sections to discarded sections and flag an error.  Pointers to
   10.26 +diff -ur linux-2.6.12.orig/arch/x86_64/kernel/i387.c linux-2.6.12/arch/x86_64/kernel/i387.c
   10.27 +--- linux-2.6.12.orig/arch/x86_64/kernel/i387.c	2005-11-01 15:01:58.932991232 +0000
   10.28 ++++ linux-2.6.12/arch/x86_64/kernel/i387.c	2005-11-01 15:02:09.729312416 +0000
   10.29 +@@ -42,7 +42,7 @@
   10.30 +  * Called at bootup to set up the initial FPU state that is later cloned
   10.31 +  * into all processes.
   10.32 +  */
   10.33 +-void __init fpu_init(void)
   10.34 ++void __cpuinit fpu_init(void)
   10.35 + {
   10.36 + 	unsigned long oldcr0 = read_cr0();
   10.37 + 	extern void __bad_fxsave_alignment(void);
    11.1 --- a/tools/console/daemon/io.c	Tue Nov 01 13:38:20 2005 +0100
    11.2 +++ b/tools/console/daemon/io.c	Wed Nov 02 17:29:32 2005 +0100
    11.3 @@ -380,12 +380,21 @@ static void cleanup_domain(struct domain
    11.4  	if (!buffer_empty(&d->buffer))
    11.5  		return;
    11.6  
    11.7 -	if (d->buffer.data)
    11.8 +	if (d->buffer.data) {
    11.9  		free(d->buffer.data);
   11.10 -	d->buffer.data = NULL;
   11.11 -	if (d->tty_fd != -1)
   11.12 +		d->buffer.data = NULL;
   11.13 +	}
   11.14 +
   11.15 +	if (d->tty_fd != -1) {
   11.16  		close(d->tty_fd);
   11.17 -	d->tty_fd = -1;
   11.18 +		d->tty_fd = -1;
   11.19 +	}
   11.20 +
   11.21 +	if (d->conspath) {
   11.22 +		free(d->conspath);
   11.23 +		d->conspath = NULL;
   11.24 +	}
   11.25 +
   11.26  	remove_domain(d);
   11.27  }
   11.28  
    12.1 --- a/tools/console/daemon/main.c	Tue Nov 01 13:38:20 2005 +0100
    12.2 +++ b/tools/console/daemon/main.c	Wed Nov 02 17:29:32 2005 +0100
    12.3 @@ -30,10 +30,14 @@
    12.4  #include "utils.h"
    12.5  #include "io.h"
    12.6  
    12.7 -void usage(char *prg)
    12.8 +static void usage(char *name)
    12.9  {
   12.10 -	fprintf(stderr, 
   12.11 -		"usage: %s [-h] [-V] [-v] [-i]\n", prg);
   12.12 +	printf("Usage: %s [-h] [-V] [-v] [-i]\n", name);
   12.13 +}
   12.14 +
   12.15 +static void version(char *name)
   12.16 +{
   12.17 +	printf("Xen Console Daemon 3.0\n");
   12.18  }
   12.19  
   12.20  int main(int argc, char **argv)
   12.21 @@ -58,7 +62,7 @@ int main(int argc, char **argv)
   12.22  			usage(argv[0]);
   12.23  			exit(0);
   12.24  		case 'V':
   12.25 -			//version(argv[0]);
   12.26 +			version(argv[0]);
   12.27  			exit(0);
   12.28  		case 'v':
   12.29  			syslog_option |= LOG_PERROR;
    13.1 --- a/tools/examples/block-common.sh	Tue Nov 01 13:38:20 2005 +0100
    13.2 +++ b/tools/examples/block-common.sh	Wed Nov 02 17:29:32 2005 +0100
    13.3 @@ -42,10 +42,17 @@ write_dev() {
    13.4    local major
    13.5    local minor
    13.6    local pdev
    13.7 -	
    13.8 +  
    13.9    major=$(stat -L -c %t "$1")
   13.10    minor=$(stat -L -c %T "$1")
   13.11 + 
   13.12 +  if [ -z $major  -o -z $minor ]; then
   13.13 +    fatal "Backend device does not exist"
   13.14 +  fi
   13.15 + 
   13.16    pdev=$(printf "0x%02x%02x" "0x$major" "0x$minor")
   13.17    xenstore_write "$XENBUS_PATH"/physical-device "$pdev" \
   13.18                   "$XENBUS_PATH"/node "$1"
   13.19 +
   13.20 +  success
   13.21  }
    14.1 --- a/tools/examples/vif-bridge	Tue Nov 01 13:38:20 2005 +0100
    14.2 +++ b/tools/examples/vif-bridge	Wed Nov 02 17:29:32 2005 +0100
    14.3 @@ -58,6 +58,7 @@ case "$command" in
    14.4            fatal "brctl addif $bridge $vif failed"
    14.5  
    14.6          ifconfig "$vif" up || fatal "ifconfig $vif up failed"
    14.7 +        success
    14.8          ;;
    14.9      down)
   14.10          # vifs are auto-removed from bridge.
    15.1 --- a/tools/examples/vif-nat	Tue Nov 01 13:38:20 2005 +0100
    15.2 +++ b/tools/examples/vif-nat	Wed Nov 02 17:29:32 2005 +0100
    15.3 @@ -54,3 +54,5 @@ esac
    15.4  ip r ${ipcmd} ${ip} dev ${vif} src ${main_ip}
    15.5  
    15.6  handle_iptable()
    15.7 +
    15.8 +success
    16.1 --- a/tools/examples/vif-route	Tue Nov 01 13:38:20 2005 +0100
    16.2 +++ b/tools/examples/vif-route	Wed Nov 02 17:29:32 2005 +0100
    16.3 @@ -46,3 +46,5 @@ if [ "${ip}" ] ; then
    16.4  fi
    16.5  
    16.6  handle_iptable()
    16.7 +
    16.8 +success
    17.1 --- a/tools/examples/xen-hotplug-common.sh	Tue Nov 01 13:38:20 2005 +0100
    17.2 +++ b/tools/examples/xen-hotplug-common.sh	Wed Nov 02 17:29:32 2005 +0100
    17.3 @@ -30,10 +30,16 @@ log() {
    17.4  }
    17.5  
    17.6  fatal() {
    17.7 +  xenstore_write "$XENBUS_PATH"/hotplug-status error
    17.8    log err "$@"
    17.9    exit 1
   17.10  }
   17.11  
   17.12 +success() {
   17.13 +  # Tell DevController that backend is "connected"
   17.14 +  xenstore_write "$XENBUS_PATH"/hotplug-status connected
   17.15 +}
   17.16 +
   17.17  ##
   17.18  # xenstore_read <path>+
   17.19  #
    18.1 --- a/tools/examples/xend-config.sxp	Tue Nov 01 13:38:20 2005 +0100
    18.2 +++ b/tools/examples/xend-config.sxp	Wed Nov 02 17:29:32 2005 +0100
    18.3 @@ -25,9 +25,6 @@
    18.4  # Port xend should use for the HTTP interface, if xend-http-server is set.
    18.5  #(xend-port            8000)
    18.6  
    18.7 -# Port xend should use for the event interface.  This interface is deprecated.
    18.8 -#(xend-event-port      8001)
    18.9 -
   18.10  # Port xend should use for the relocation interface, if xend-relocation-server
   18.11  # is set.
   18.12  #(xend-relocation-port 8002)
    19.1 --- a/tools/firmware/rombios/rombios.c	Tue Nov 01 13:38:20 2005 +0100
    19.2 +++ b/tools/firmware/rombios/rombios.c	Wed Nov 02 17:29:32 2005 +0100
    19.3 @@ -149,7 +149,7 @@
    19.4  #define BX_SUPPORT_FLOPPY 1
    19.5  #define BX_FLOPPY_ON_CNT 37   /* 2 seconds */
    19.6  #define BX_PCIBIOS       1
    19.7 -#define BX_APM           1
    19.8 +#define BX_APM           0
    19.9  
   19.10  #define BX_USE_ATADRV    1
   19.11  #define BX_ELTORITO_BOOT 1
    20.1 --- a/tools/python/xen/web/connection.py	Tue Nov 01 13:38:20 2005 +0100
    20.2 +++ b/tools/python/xen/web/connection.py	Wed Nov 02 17:29:32 2005 +0100
    20.3 @@ -380,9 +380,6 @@ class SocketConnector:
    20.4          self.state = "disconnected"
    20.5          self.transport = None
    20.6  
    20.7 -    def getDestination(self):
    20.8 -        raise NotImplementedError()
    20.9 -
   20.10      def connectTransport(self):
   20.11          raise NotImplementedError()
   20.12  
    21.1 --- a/tools/python/xen/web/tcp.py	Tue Nov 01 13:38:20 2005 +0100
    21.2 +++ b/tools/python/xen/web/tcp.py	Wed Nov 02 17:29:32 2005 +0100
    21.3 @@ -85,9 +85,6 @@ class TCPConnector(SocketConnector):
    21.4                  raise IOError("unknown service: " + ex)
    21.5          return port
    21.6  
    21.7 -    def getDestination(self):
    21.8 -        return (self.host, self.port)
    21.9 -
   21.10      def connectTransport(self):
   21.11          self.transport = TCPClientConnection(
   21.12              self.host, self.port, self.bindAddress, self)
   21.13 @@ -98,9 +95,6 @@ def listenTCP(port, factory, interface='
   21.14      l.startListening()
   21.15      return l
   21.16  
   21.17 -def SetCloExec(SocketListener):
   21.18 -    SocketListener.setCloExec()
   21.19 -
   21.20  def connectTCP(host, port, factory, timeout=None, bindAddress=None):
   21.21      c = TCPConnector(host, port, factory, timeout=timeout, bindAddress=bindAddress)
   21.22      c.connect()
    22.1 --- a/tools/python/xen/web/unix.py	Tue Nov 01 13:38:20 2005 +0100
    22.2 +++ b/tools/python/xen/web/unix.py	Wed Nov 02 17:29:32 2005 +0100
    22.3 @@ -67,9 +67,6 @@ class UnixConnector(SocketConnector):
    22.4          self.addr = path
    22.5          self.timeout = timeout
    22.6  
    22.7 -    def getDestination(self):
    22.8 -        return self.addr
    22.9 -
   22.10      def connectTransport(self):
   22.11          self.transport = UnixClientConnection(self.addr, self)
   22.12          self.transport.connect(self.timeout)
    23.1 --- a/tools/python/xen/xend/XendCheckpoint.py	Tue Nov 01 13:38:20 2005 +0100
    23.2 +++ b/tools/python/xen/xend/XendCheckpoint.py	Wed Nov 02 17:29:32 2005 +0100
    23.3 @@ -7,9 +7,9 @@
    23.4  
    23.5  import os
    23.6  import re
    23.7 -import select
    23.8  import string
    23.9  import sxp
   23.10 +import threading
   23.11  from struct import pack, unpack, calcsize
   23.12  
   23.13  from xen.util.xpopen import xPopen3
   23.14 @@ -81,6 +81,7 @@ def save(fd, dominfo, live):
   23.15                  log.info("Domain %d suspended.", dominfo.getDomid())
   23.16                  tochild.write("done\n")
   23.17                  tochild.flush()
   23.18 +                log.debug('Written done')
   23.19  
   23.20          forkHelper(cmd, fd, saveInputHandler, False)
   23.21  
   23.22 @@ -176,43 +177,42 @@ def forkHelper(cmd, fd, inputHandler, cl
   23.23      if closeToChild:
   23.24          child.tochild.close()
   23.25  
   23.26 -    lasterr = "error unknown"
   23.27 +    thread = threading.Thread(target = slurp, args = (child.childerr))
   23.28 +    thread.start()
   23.29 +
   23.30      try:
   23.31 -        fds = [child.fromchild.fileno(),
   23.32 -               child.childerr.fileno()]
   23.33 -        p = select.poll()
   23.34 -        map(p.register, fds)
   23.35 -        while len(fds) > 0:
   23.36 -            r = p.poll()
   23.37 -            for (fd, event) in r:
   23.38 -                if event & select.POLLIN:
   23.39 -                    if fd == child.childerr.fileno():
   23.40 -                        lasterr = child.childerr.readline().rstrip()
   23.41 -                        log.error('%s', lasterr)
   23.42 -                    else:
   23.43 -                        l = child.fromchild.readline().rstrip()
   23.44 -                        while l:
   23.45 -                            log.debug('%s', l)
   23.46 -                            inputHandler(l, child.tochild)
   23.47 -                            try:
   23.48 -                                l = child.fromchild.readline().rstrip()
   23.49 -                            except:
   23.50 -                                l = None
   23.51 +        try:
   23.52 +            while 1:
   23.53 +                line = child.fromchild.readline()
   23.54 +                if line == "":
   23.55 +                    break
   23.56 +                else:
   23.57 +                    line = line.rstrip()
   23.58 +                    log.debug('%s', line)
   23.59 +                    inputHandler(line, child.tochild)
   23.60  
   23.61 -                if event & select.POLLERR:
   23.62 -                    raise XendError('Error reading from child process for %s',
   23.63 -                                    cmd)
   23.64 +            thread.join()
   23.65  
   23.66 -                if event & select.POLLHUP:
   23.67 -                    fds.remove(fd)
   23.68 -                    p.unregister(fd)
   23.69 +        except IOError, exn:
   23.70 +            raise XendError('Error reading from child process for %s: %s' %
   23.71 +                            (cmd, exn))
   23.72      finally:
   23.73          child.fromchild.close()
   23.74          child.childerr.close()
   23.75          if not closeToChild:
   23.76              child.tochild.close()
   23.77  
   23.78 -    if child.wait() >> 8 == 127:
   23.79 -        lasterr = "popen failed"
   23.80 -    if child.wait() != 0:
   23.81 -        raise XendError("%s failed: %s" % (string.join(cmd), lasterr))
   23.82 +    status = child.wait()
   23.83 +    if status >> 8 == 127:
   23.84 +        raise XendError("%s failed: popen failed" % string.join(cmd))
   23.85 +    elif status != 0:
   23.86 +        raise XendError("%s failed" % string.join(cmd))
   23.87 +
   23.88 +
   23.89 +def slurp(file):
   23.90 +    while 1:
   23.91 +        line = file.readline()
   23.92 +        if line == "":
   23.93 +            break
   23.94 +        else:
   23.95 +            log.error('%s', line)
    24.1 --- a/tools/python/xen/xend/XendRoot.py	Tue Nov 01 13:38:20 2005 +0100
    24.2 +++ b/tools/python/xen/xend/XendRoot.py	Wed Nov 02 17:29:32 2005 +0100
    24.3 @@ -17,7 +17,7 @@
    24.4  #============================================================================
    24.5  
    24.6  """Xend root class.
    24.7 -Creates the event server and handles configuration.
    24.8 +Creates the servers and handles configuration.
    24.9  
   24.10  Other classes get config variables by importing this module,
   24.11  using instance() to get a XendRoot instance, and then
   24.12 @@ -72,9 +72,6 @@ class XendRoot:
   24.13      """Default port xend serves HTTP at. """
   24.14      xend_port_default         = '8000'
   24.15  
   24.16 -    """Default port xend serves events at. """
   24.17 -    xend_event_port_default   = '8001'
   24.18 -
   24.19      """Default port xend serves relocation at. """
   24.20      xend_relocation_port_default = '8002'
   24.21  
   24.22 @@ -210,21 +207,16 @@ class XendRoot:
   24.23          """
   24.24          return self.get_config_int('xend-port', self.xend_port_default)
   24.25  
   24.26 -    def get_xend_event_port(self):
   24.27 -        """Get the port xend listens at for connection to its event server.
   24.28 -        """
   24.29 -        return self.get_config_int('xend-event-port', self.xend_event_port_default)
   24.30 -
   24.31      def get_xend_relocation_port(self):
   24.32          """Get the port xend listens at for connection to its relocation server.
   24.33          """
   24.34          return self.get_config_int('xend-relocation-port', self.xend_relocation_port_default)
   24.35  
   24.36      def get_xend_address(self):
   24.37 -        """Get the address xend listens at for its HTTP and event ports.
   24.38 +        """Get the address xend listens at for its HTTP port.
   24.39          This defaults to the empty string which allows all hosts to connect.
   24.40          If this is set to 'localhost' only the localhost will be able to connect
   24.41 -        to the HTTP and event ports.
   24.42 +        to the HTTP port.
   24.43          """
   24.44          return self.get_config_value('xend-address', self.xend_address_default)
   24.45  
   24.46 @@ -232,7 +224,7 @@ class XendRoot:
   24.47          """Get the address xend listens at for its relocation server port.
   24.48          This defaults to the empty string which allows all hosts to connect.
   24.49          If this is set to 'localhost' only the localhost will be able to connect
   24.50 -        to the HTTP and event ports.
   24.51 +        to the relocation port.
   24.52          """
   24.53          return self.get_config_value('xend-relocation-address', self.xend_relocation_address_default)
   24.54  
    25.1 --- a/tools/python/xen/xend/server/DevController.py	Tue Nov 01 13:38:20 2005 +0100
    25.2 +++ b/tools/python/xen/xend/server/DevController.py	Wed Nov 02 17:29:32 2005 +0100
    25.3 @@ -16,12 +16,18 @@
    25.4  # Copyright (C) 2005 XenSource Ltd
    25.5  #============================================================================
    25.6  
    25.7 +from threading import Event
    25.8  
    25.9  from xen.xend import sxp
   25.10  from xen.xend.XendError import VmError
   25.11  from xen.xend.XendLogging import log
   25.12 +
   25.13  from xen.xend.xenstore.xstransact import xstransact
   25.14 +from xen.xend.xenstore.xswatch import xswatch
   25.15  
   25.16 +DEVICE_CREATE_TIMEOUT = 120
   25.17 +HOTPLUG_STATUS_NODE = "hotplug-status"
   25.18 +HOTPLUG_STATUS_ERROR = "error"
   25.19  
   25.20  class DevController:
   25.21      """Abstract base class for a device controller.  Device controllers create
   25.22 @@ -54,6 +60,18 @@ class DevController:
   25.23  
   25.24          self.writeDetails(config, devid, back, front)
   25.25  
   25.26 +        status, fn_ret = self.waitForBackend(devid)
   25.27 +        if status:
   25.28 +            self.destroyDevice(devid)
   25.29 +            raise VmError( ("Device %s (%s) could not be connected. "
   25.30 +                            "Hotplug scripts not working") 
   25.31 +                            % (devid, self.deviceClass))
   25.32 +
   25.33 +        elif fn_ret == HOTPLUG_STATUS_ERROR:
   25.34 +            self.destroyDevice(devid)
   25.35 +            raise VmError( ("Device %s (%s) could not be connected. "
   25.36 +                            "Backend device not found!") 
   25.37 +                            % (devid, self.deviceClass))
   25.38          return devid
   25.39  
   25.40  
   25.41 @@ -242,6 +260,29 @@ class DevController:
   25.42          xstransact.Write(frontpath, frontDetails)
   25.43          xstransact.Write(backpath, backDetails)
   25.44  
   25.45 +    def waitForBackend(self,devid):
   25.46 +        ev = Event()
   25.47 +
   25.48 +        def hotplugStatus():
   25.49 +            status = self.readBackend(devid, HOTPLUG_STATUS_NODE)
   25.50 +            if status is not None:
   25.51 +                watch.xs.unwatch(backpath, watch)
   25.52 +                hotplugStatus.value = status
   25.53 +                ev.set()
   25.54 +
   25.55 +        hotplugStatus.value = None
   25.56 +        frontpath = self.frontendPath(devid)
   25.57 +        backpath = xstransact.Read(frontpath, "backend")
   25.58 +
   25.59 +        watch = xswatch(backpath, hotplugStatus)
   25.60 +
   25.61 +        ev.wait(DEVICE_CREATE_TIMEOUT)
   25.62 +        if ev.isSet():
   25.63 +            return (0, hotplugStatus.value)
   25.64 +        else:
   25.65 +            return (-1, hotplugStatus.value)
   25.66 +
   25.67 +
   25.68  
   25.69      def backendPath(self, backdom, devid):
   25.70          """@param backdom [XendDomainInfo] The backend domain info."""
    26.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Tue Nov 01 13:38:20 2005 +0100
    26.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Wed Nov 02 17:29:32 2005 +0100
    26.3 @@ -19,7 +19,6 @@ import xen.lowlevel.xc
    26.4  from xen.xend.server import SrvServer
    26.5  from xen.xend.XendLogging import log
    26.6  
    26.7 -import event
    26.8  import relocate
    26.9  from params import *
   26.10  
   26.11 @@ -273,7 +272,6 @@ class Daemon:
   26.12              log.info("Xend changeset: %s.", xinfo['xen_changeset'])
   26.13              del xc
   26.14  
   26.15 -            event.listenEvent(self)
   26.16              relocate.listenRelocation()
   26.17              servers = SrvServer.create()
   26.18              self.daemonize()
    27.1 --- a/tools/python/xen/xend/server/event.py	Tue Nov 01 13:38:20 2005 +0100
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,196 +0,0 @@
    27.4 -#============================================================================
    27.5 -# This library is free software; you can redistribute it and/or
    27.6 -# modify it under the terms of version 2.1 of the GNU Lesser General Public
    27.7 -# License as published by the Free Software Foundation.
    27.8 -#
    27.9 -# This library is distributed in the hope that it will be useful,
   27.10 -# but WITHOUT ANY WARRANTY; without even the implied warranty of
   27.11 -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   27.12 -# Lesser General Public License for more details.
   27.13 -#
   27.14 -# You should have received a copy of the GNU Lesser General Public
   27.15 -# License along with this library; if not, write to the Free Software
   27.16 -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   27.17 -#============================================================================
   27.18 -# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
   27.19 -# Copyright (C) 2005 XenSource Ltd
   27.20 -#============================================================================
   27.21 -
   27.22 -import sys
   27.23 -import StringIO
   27.24 -
   27.25 -from xen.web import protocol, tcp, unix
   27.26 -
   27.27 -from xen.xend import scheduler
   27.28 -from xen.xend import sxp
   27.29 -from xen.xend import PrettyPrint
   27.30 -from xen.xend.XendError import XendError
   27.31 -from xen.xend import XendLogging
   27.32 -from xen.xend import XendRoot
   27.33 -
   27.34 -
   27.35 -xroot = XendRoot.instance()
   27.36 -
   27.37 -
   27.38 -DEBUG = 0
   27.39 -
   27.40 -class EventProtocol(protocol.Protocol):
   27.41 -    """Asynchronous handler for a connected event socket.
   27.42 -    """
   27.43 -
   27.44 -    def __init__(self, daemon):
   27.45 -        #protocol.Protocol.__init__(self)
   27.46 -        self.daemon = daemon
   27.47 -        # Event queue.
   27.48 -        self.queue = []
   27.49 -        self.parser = sxp.Parser()
   27.50 -        self.pretty = 1
   27.51 -
   27.52 -    def dataReceived(self, data):
   27.53 -        try:
   27.54 -            self.parser.input(data)
   27.55 -            while(self.parser.ready()):
   27.56 -                val = self.parser.get_val()
   27.57 -                res = self.dispatch(val)
   27.58 -                self.send_result(res)
   27.59 -            if self.parser.at_eof():
   27.60 -                self.loseConnection()
   27.61 -        except SystemExit:
   27.62 -            raise
   27.63 -        except:
   27.64 -            self.send_error()
   27.65 -
   27.66 -    def loseConnection(self):
   27.67 -        if self.transport:
   27.68 -            self.transport.loseConnection()
   27.69 -        if self.connected:
   27.70 -            scheduler.now(self.connectionLost)
   27.71 -
   27.72 -    def connectionLost(self, reason=None):
   27.73 -        pass
   27.74 -
   27.75 -    def send_reply(self, sxpr):
   27.76 -        io = StringIO.StringIO()
   27.77 -        if self.pretty:
   27.78 -            PrettyPrint.prettyprint(sxpr, out=io)
   27.79 -        else:
   27.80 -            sxp.show(sxpr, out=io)
   27.81 -        print >> io
   27.82 -        io.seek(0)
   27.83 -        if self.transport:
   27.84 -            return self.transport.write(io.getvalue())
   27.85 -        else:
   27.86 -            return 0
   27.87 -
   27.88 -    def send_result(self, res):
   27.89 -        if res is None:
   27.90 -            resp = ['ok']
   27.91 -        else:
   27.92 -            resp = ['ok', res]
   27.93 -        return self.send_reply(resp)
   27.94 -
   27.95 -    def send_error(self):
   27.96 -        (extype, exval) = sys.exc_info()[:2]
   27.97 -        return self.send_reply(['err',
   27.98 -                                ['type', str(extype)],
   27.99 -                                ['value', str(exval)]])
  27.100 -
  27.101 -    def send_event(self, val):
  27.102 -        return self.send_reply(['event', val[0], val[1]])
  27.103 -
  27.104 -    def queue_event(self, name, v):
  27.105 -        # Despite the name we don't queue the event here.
  27.106 -        # We send it because the transport will queue it.
  27.107 -        self.send_event([name, v])
  27.108 -        
  27.109 -    def opname(self, name):
  27.110 -         return 'op_' + name.replace('.', '_')
  27.111 -
  27.112 -    def operror(self, name, req):
  27.113 -        raise XendError('Invalid operation: ' +name)
  27.114 -
  27.115 -    def dispatch(self, req):
  27.116 -        op_name = sxp.name(req)
  27.117 -        op_method_name = self.opname(op_name)
  27.118 -        op_method = getattr(self, op_method_name, self.operror)
  27.119 -        return op_method(op_name, req)
  27.120 -
  27.121 -    def op_help(self, _1, _2):
  27.122 -        def nameop(x):
  27.123 -            if x.startswith('op_'):
  27.124 -                return x[3:].replace('_', '.')
  27.125 -            else:
  27.126 -                return x
  27.127 -        
  27.128 -        l = [ nameop(k) for k in dir(self) if k.startswith('op_') ]
  27.129 -        return l
  27.130 -
  27.131 -    def op_quit(self, _1, _2):
  27.132 -        self.loseConnection()
  27.133 -
  27.134 -    def op_exit(self, _1, _2):
  27.135 -        sys.exit(0)
  27.136 -
  27.137 -    def op_pretty(self, _1, _2):
  27.138 -        self.pretty = 1
  27.139 -
  27.140 -    def op_info(self, _1, _2):
  27.141 -        val = ['info']
  27.142 -        #val += self.daemon.blkifs()
  27.143 -        #val += self.daemon.netifs()
  27.144 -        #val += self.daemon.usbifs()
  27.145 -        return val
  27.146 -
  27.147 -    def op_trace(self, _, v):
  27.148 -        mode = (v[1] == 'on')
  27.149 -        self.daemon.tracing(mode)
  27.150 -
  27.151 -    def op_log_stderr(self, _, v):
  27.152 -        mode = v[1]
  27.153 -        if mode == 'on':
  27.154 -            XendLogging.addLogStderr()
  27.155 -        else:
  27.156 -            XendLogging.removeLogStderr()
  27.157 -
  27.158 -    def op_domain_ls(self, _1, _2):
  27.159 -        xd = xroot.get_component("xen.xend.XendDomain")
  27.160 -        return xd.list_names()
  27.161 -
  27.162 -    def op_domain_configure(self, _, v):
  27.163 -        domid = sxp.child_value(v, "dom")
  27.164 -        config = sxp.child_value(v, "config")
  27.165 -        if domid is None:
  27.166 -            raise XendError("missing domain id")
  27.167 -        if config is None:
  27.168 -            raise XendError("missing domain config")
  27.169 -        xd = xroot.get_component("xen.xend.XendDomain")
  27.170 -        xd.domain_configure(domid, config)
  27.171 -
  27.172 -    def op_domain_unpause(self, _, v):
  27.173 -        domid = sxp.child_value(v, "dom")
  27.174 -        if domid is None:
  27.175 -            raise XendError("missing domain id")
  27.176 -        xd = xroot.get_component("xen.xend.XendDomain")
  27.177 -        xd.domain_unpause(domid)
  27.178 -
  27.179 -class EventFactory(protocol.ServerFactory):
  27.180 -    """Asynchronous handler for the event server socket.
  27.181 -    """
  27.182 -
  27.183 -    def __init__(self, daemon):
  27.184 -        protocol.ServerFactory.__init__(self)
  27.185 -        self.daemon = daemon
  27.186 -
  27.187 -    def buildProtocol(self, _):
  27.188 -        return EventProtocol(self.daemon)
  27.189 -
  27.190 -def listenEvent(daemon):
  27.191 -    factory = EventFactory(daemon)
  27.192 -    if xroot.get_xend_unix_server():
  27.193 -        path = '/var/lib/xend/event-socket'
  27.194 -        unix.listenUNIX(path, factory)
  27.195 -    if xroot.get_xend_http_server():
  27.196 -        port = xroot.get_xend_event_port()
  27.197 -        interface = xroot.get_xend_address()
  27.198 -        l = tcp.listenTCP(port, factory, interface=interface)
  27.199 -        l.setCloExec()
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/tools/python/xen/xend/tests/__init__.py	Wed Nov 02 17:29:32 2005 +0100
    28.3 @@ -0,0 +1,1 @@
    28.4 + 
    29.1 --- a/tools/python/xen/xm/create.py	Tue Nov 01 13:38:20 2005 +0100
    29.2 +++ b/tools/python/xen/xm/create.py	Wed Nov 02 17:29:32 2005 +0100
    29.3 @@ -376,7 +376,7 @@ gopts.var('sdl', val='',
    29.4            use="""Should the device model use SDL?""")
    29.5  
    29.6  gopts.var('display', val='DISPLAY',
    29.7 -          fn=set_value, default='localhost:0',
    29.8 +          fn=set_value, default=None,
    29.9            use="X11 display to use")
   29.10  
   29.11  
    30.1 --- a/tools/python/xen/xm/main.py	Tue Nov 01 13:38:20 2005 +0100
    30.2 +++ b/tools/python/xen/xm/main.py	Wed Nov 02 17:29:32 2005 +0100
    30.3 @@ -791,6 +791,9 @@ def main(argv=sys.argv):
    30.4              else:
    30.5                  err("Error connecting to xend: %s.  Is xend running?" % ex[1])
    30.6              sys.exit(1)
    30.7 +        except KeyboardInterrupt:
    30.8 +            print "Interrupted."
    30.9 +            sys.exit(1)
   30.10          except IOError:
   30.11              if os.geteuid() != 0:
   30.12                  err("Most commands need root access.  Please try again as root.")
    31.1 --- a/tools/vtpm_manager/manager/vtpm_manager.c	Tue Nov 01 13:38:20 2005 +0100
    31.2 +++ b/tools/vtpm_manager/manager/vtpm_manager.c	Wed Nov 02 17:29:32 2005 +0100
    31.3 @@ -140,12 +140,15 @@ TPM_RESULT VTPM_Create_Service(){
    31.4    TPM_AUTHDATA sharedsecret;
    31.5    
    31.6    TPMTRYRETURN( VTSP_OSAP(vtpm_globals->manager_tcs_handle,
    31.7 -			  TPM_ET_SRK,
    31.8 -			  0, 
    31.9 +			  TPM_ET_KEYHANDLE,
   31.10 +			  TPM_SRK_KEYHANDLE, 
   31.11  			  (const TPM_AUTHDATA*)&vtpm_globals->srk_usage_auth,
   31.12  			  &sharedsecret, 
   31.13  			  &osap) ); 
   31.14 -  
   31.15 +
   31.16 +  osap.fContinueAuthSession = FALSE;
   31.17 + 
   31.18 + 
   31.19    TPMTRYRETURN( VTSP_CreateWrapKey( vtpm_globals->manager_tcs_handle,
   31.20  				    TPM_KEY_BIND,
   31.21  				    (const TPM_AUTHDATA*)&vtpm_globals->storage_key_usage_auth,
    32.1 --- a/tools/vtpm_manager/manager/vtsp.c	Tue Nov 01 13:38:20 2005 +0100
    32.2 +++ b/tools/vtpm_manager/manager/vtsp.c	Wed Nov 02 17:29:32 2005 +0100
    32.3 @@ -180,8 +180,8 @@ TPM_RESULT VTSP_OSAP(const TCS_CONTEXT_H
    32.4    Crypto_GetRandom((BYTE *) &nonceOddOSAP, sizeof(TPM_NONCE) ); 
    32.5    
    32.6    TPMTRYRETURN( TCSP_OSAP(    hContext,
    32.7 -			      TPM_ET_SRK,
    32.8 -			      0, 
    32.9 +			      entityType,
   32.10 +			      entityValue, 
   32.11  			      nonceOddOSAP,
   32.12  			      &auth->AuthHandle, 
   32.13  			      &auth->NonceEven, 
    33.1 --- a/tools/vtpm_manager/util/buffer.h	Tue Nov 01 13:38:20 2005 +0100
    33.2 +++ b/tools/vtpm_manager/util/buffer.h	Wed Nov 02 17:29:32 2005 +0100
    33.3 @@ -37,18 +37,6 @@
    33.4  #include <stddef.h>             // for pointer NULL
    33.5  #include "tcg.h"
    33.6  
    33.7 -// structure to enable use of FMT_SIZE32_DATA in BSG_Unpack
    33.8 -typedef struct pack_buf_t {
    33.9 -  UINT32 size;
   33.10 -  BYTE * data;
   33.11 -} pack_buf_t;
   33.12 -
   33.13 -// and a const version for Pack
   33.14 -typedef struct pack_constbuf_t {
   33.15 -  UINT32 size;
   33.16 -  const BYTE* data;
   33.17 -} pack_constbuf_t;
   33.18 -
   33.19  typedef UINT32 tpm_size_t;
   33.20  
   33.21  // first version, probably will be expanded...
    34.1 --- a/tools/vtpm_manager/util/tcg.h	Tue Nov 01 13:38:20 2005 +0100
    34.2 +++ b/tools/vtpm_manager/util/tcg.h	Wed Nov 02 17:29:32 2005 +0100
    34.3 @@ -191,6 +191,20 @@ typedef struct TCS_AUTH {
    34.4    TPM_AUTHDATA  HMAC;
    34.5  } TCS_AUTH;
    34.6  
    34.7 +// structures for dealing with sizes followed by buffers in all the
    34.8 +// TCG structure.
    34.9 +typedef struct pack_buf_t {
   34.10 +  UINT32 size;
   34.11 +  BYTE * data;
   34.12 +} pack_buf_t;
   34.13 +
   34.14 +typedef struct pack_constbuf_t {
   34.15 +  UINT32 size;
   34.16 +  const BYTE* data;
   34.17 +} pack_constbuf_t;
   34.18 +
   34.19 +
   34.20 +
   34.21  // **************************** CONSTANTS *********************************
   34.22  
   34.23  // BOOL values
    35.1 --- a/tools/xenstat/libxenstat/src/xenstat.c	Tue Nov 01 13:38:20 2005 +0100
    35.2 +++ b/tools/xenstat/libxenstat/src/xenstat.c	Wed Nov 02 17:29:32 2005 +0100
    35.3 @@ -704,7 +704,6 @@ static char *xenstat_get_domain_name(xen
    35.4  {
    35.5  	char path[80];
    35.6  	char *name;
    35.7 -	unsigned int *len;
    35.8  	struct xs_transaction_handle *xstranshandle;
    35.9  
   35.10  	snprintf(path, sizeof(path),"/local/domain/%i/name", domain_id);
   35.11 @@ -715,7 +714,7 @@ static char *xenstat_get_domain_name(xen
   35.12  		exit(1); /* Change this */
   35.13  	}
   35.14  
   35.15 -	name = (char *) xs_read(handle->xshandle, xstranshandle, path, len);
   35.16 +	name = (char *) xs_read(handle->xshandle, xstranshandle, path, NULL);
   35.17  	
   35.18  	xs_transaction_end(handle->xshandle, xstranshandle, false);
   35.19  
    36.1 --- a/tools/xenstore/xs.h	Tue Nov 01 13:38:20 2005 +0100
    36.2 +++ b/tools/xenstore/xs.h	Wed Nov 02 17:29:32 2005 +0100
    36.3 @@ -136,7 +136,7 @@ bool xs_introduce_domain(struct xs_handl
    36.4   */
    36.5  bool xs_release_domain(struct xs_handle *h, unsigned int domid);
    36.6  
    36.7 -/* Query the home path of a domain.
    36.8 +/* Query the home path of a domain.  Call free() after use.
    36.9   */
   36.10  char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
   36.11  
    37.1 --- a/xen/arch/x86/domain.c	Tue Nov 01 13:38:20 2005 +0100
    37.2 +++ b/xen/arch/x86/domain.c	Wed Nov 02 17:29:32 2005 +0100
    37.3 @@ -189,22 +189,22 @@ void dump_pageframe_info(struct domain *
    37.4      {
    37.5          list_for_each_entry ( page, &d->page_list, list )
    37.6          {
    37.7 -            printk("Page %p: mfn=%td, caf=%08x, taf=%" PRtype_info "\n",
    37.8 -                   _p(page_to_phys(page)), page-frame_table, page->count_info,
    37.9 -                   page->u.inuse.type_info);
   37.10 +            printk("Page %p: mfn=%p, caf=%08x, taf=%" PRtype_info "\n",
   37.11 +                   _p(page_to_phys(page)), _p(page - frame_table),
   37.12 +                   page->count_info, page->u.inuse.type_info);
   37.13          }
   37.14      }
   37.15  
   37.16      list_for_each_entry ( page, &d->xenpage_list, list )
   37.17      {
   37.18 -        printk("XenPage %p: mfn=%td, caf=%08x, taf=%" PRtype_info "\n",
   37.19 -               _p(page_to_phys(page)), page-frame_table, page->count_info,
   37.20 -               page->u.inuse.type_info);
   37.21 +        printk("XenPage %p: mfn=%p, caf=%08x, taf=%" PRtype_info "\n",
   37.22 +               _p(page_to_phys(page)), _p(page - frame_table),
   37.23 +               page->count_info, page->u.inuse.type_info);
   37.24      }
   37.25  
   37.26      page = virt_to_page(d->shared_info);
   37.27 -    printk("Shared_info@%p: mfn=%td, caf=%08x, taf=%" PRtype_info "\n",
   37.28 -           _p(page_to_phys(page)), page-frame_table, page->count_info,
   37.29 +    printk("Shared_info@%p: mfn=%p, caf=%08x, taf=%" PRtype_info "\n",
   37.30 +           _p(page_to_phys(page)), _p(page - frame_table), page->count_info,
   37.31             page->u.inuse.type_info);
   37.32  }
   37.33  
   37.34 @@ -408,6 +408,9 @@ int arch_set_info_guest(
   37.35          if ( !pagetable_get_paddr(d->arch.phys_table) )
   37.36              d->arch.phys_table = v->arch.guest_table;
   37.37  
   37.38 +        /* Initialize monitor page table */
   37.39 +        v->arch.monitor_table = mk_pagetable(0);
   37.40 +
   37.41          vmx_final_setup_guest(v);
   37.42      }
   37.43  
    38.1 --- a/xen/arch/x86/shadow.c	Tue Nov 01 13:38:20 2005 +0100
    38.2 +++ b/xen/arch/x86/shadow.c	Wed Nov 02 17:29:32 2005 +0100
    38.3 @@ -1,19 +1,19 @@
    38.4  /******************************************************************************
    38.5 - * arch/x86/shadow_64.c
    38.6 - * 
    38.7 + * arch/x86/shadow.c
    38.8 + *
    38.9   * Copyright (c) 2005 Michael A Fetterman
   38.10   * Based on an earlier implementation by Ian Pratt et al
   38.11 - * 
   38.12 + *
   38.13   * This program is free software; you can redistribute it and/or modify
   38.14   * it under the terms of the GNU General Public License as published by
   38.15   * the Free Software Foundation; either version 2 of the License, or
   38.16   * (at your option) any later version.
   38.17 - * 
   38.18 + *
   38.19   * This program is distributed in the hope that it will be useful,
   38.20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   38.21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   38.22   * GNU General Public License for more details.
   38.23 - * 
   38.24 + *
   38.25   * You should have received a copy of the GNU General Public License
   38.26   * along with this program; if not, write to the Free Software
   38.27   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   38.28 @@ -55,7 +55,6 @@ static void shadow_map_into_current(stru
   38.29      unsigned long va, unsigned int from, unsigned int to);
   38.30  static inline void validate_bl2e_change( struct domain *d,
   38.31      guest_root_pgentry_t *new_gle_p, pgentry_64_t *shadow_l3, int index);
   38.32 -
   38.33  #endif
   38.34  
   38.35  /********
   38.36 @@ -102,7 +101,6 @@ shadow_promote(struct domain *d, unsigne
   38.37          return 1;
   38.38  #endif
   38.39          return 0;
   38.40 -        
   38.41      }
   38.42  
   38.43      // To convert this page to use as a page table, the writable count
   38.44 @@ -228,18 +226,20 @@ alloc_shadow_page(struct domain *d,
   38.45                   */
   38.46                  page = alloc_domheap_pages(NULL, SL1_ORDER, 0);
   38.47                  if (!page)
   38.48 -                    domain_crash_synchronous();
   38.49 +                    goto no_shadow_page;
   38.50  
   38.51                  void *l1_0 = map_domain_page(page_to_pfn(page));
   38.52 -                memset(l1_0,0,PAGE_SIZE);
   38.53 +                memset(l1_0, 0, PAGE_SIZE);
   38.54                  unmap_domain_page(l1_0);
   38.55 +
   38.56                  void *l1_1 = map_domain_page(page_to_pfn(page+1));
   38.57 -                memset(l1_1,0,PAGE_SIZE);
   38.58 +                memset(l1_1, 0, PAGE_SIZE);
   38.59                  unmap_domain_page(l1_1);
   38.60  #else
   38.61                  page = alloc_domheap_page(NULL);
   38.62                  if (!page)
   38.63 -                    domain_crash_synchronous();
   38.64 +                    goto no_shadow_page;
   38.65 +
   38.66                  void *l1 = map_domain_page(page_to_pfn(page));
   38.67                  memset(l1, 0, PAGE_SIZE);
   38.68                  unmap_domain_page(l1);
   38.69 @@ -248,6 +248,9 @@ alloc_shadow_page(struct domain *d,
   38.70              else
   38.71              {
   38.72                  page = alloc_domheap_page(NULL);
   38.73 +                if (!page)
   38.74 +                    goto no_shadow_page;
   38.75 +
   38.76                  void *l1 = map_domain_page(page_to_pfn(page));
   38.77                  memset(l1, 0, PAGE_SIZE);
   38.78                  unmap_domain_page(l1);
   38.79 @@ -255,22 +258,26 @@ alloc_shadow_page(struct domain *d,
   38.80          }
   38.81      }
   38.82      else {
   38.83 +#if CONFIG_PAGING_LEVELS == 2
   38.84          page = alloc_domheap_page(NULL);
   38.85 +#elif CONFIG_PAGING_LEVELS == 3
   38.86 +        if ( psh_type == PGT_l3_shadow )
   38.87 +            page = alloc_domheap_pages(NULL, 0, ALLOC_DOM_DMA);
   38.88 +        else
   38.89 +            page = alloc_domheap_page(NULL);
   38.90 +#elif CONFIG_PAGING_LEVELS == 4
   38.91 +        if ( (psh_type == PGT_l4_shadow) &&
   38.92 +             (d->arch.ops->guest_paging_levels != PAGING_L4) )
   38.93 +            page = alloc_domheap_pages(NULL, 0, ALLOC_DOM_DMA);
   38.94 +        else
   38.95 +            page = alloc_domheap_page(NULL);
   38.96 +#endif
   38.97 +        if (!page)
   38.98 +            goto no_shadow_page;
   38.99 +
  38.100          void *lp = map_domain_page(page_to_pfn(page));
  38.101          memset(lp, 0, PAGE_SIZE);
  38.102          unmap_domain_page(lp);
  38.103 -
  38.104 -    }
  38.105 -    if ( unlikely(page == NULL) )
  38.106 -    {
  38.107 -        printk("Couldn't alloc shadow page! dom%d count=%d\n",
  38.108 -               d->domain_id, d->arch.shadow_page_count);
  38.109 -        printk("Shadow table counts: l1=%d l2=%d hl2=%d snapshot=%d\n",
  38.110 -               perfc_value(shadow_l1_pages), 
  38.111 -               perfc_value(shadow_l2_pages),
  38.112 -               perfc_value(hl2_table_pages),
  38.113 -               perfc_value(snapshot_pages));
  38.114 -        BUG(); /* XXX FIXME: try a shadow flush to free up some memory. */
  38.115      }
  38.116  
  38.117      smfn = page_to_pfn(page);
  38.118 @@ -359,7 +366,7 @@ alloc_shadow_page(struct domain *d,
  38.119  
  38.120      return smfn;
  38.121  
  38.122 -  fail:
  38.123 +fail:
  38.124      FSH_LOG("promotion of pfn=%lx mfn=%lx failed!  external gnttab refs?",
  38.125              gpfn, gmfn);
  38.126      if (psh_type == PGT_l1_shadow)
  38.127 @@ -377,6 +384,20 @@ alloc_shadow_page(struct domain *d,
  38.128      }
  38.129      else
  38.130          free_domheap_page(page);
  38.131 +
  38.132 +    return 0;
  38.133 +
  38.134 +no_shadow_page:
  38.135 +    ASSERT(page == NULL);
  38.136 +    printk("Couldn't alloc shadow page! dom%d count=%d\n",
  38.137 +           d->domain_id, d->arch.shadow_page_count);
  38.138 +    printk("Shadow table counts: l1=%d l2=%d hl2=%d snapshot=%d\n",
  38.139 +           perfc_value(shadow_l1_pages),
  38.140 +           perfc_value(shadow_l2_pages),
  38.141 +           perfc_value(hl2_table_pages),
  38.142 +           perfc_value(snapshot_pages));
  38.143 +    BUG(); /* XXX FIXME: try a shadow flush to free up some memory. */
  38.144 +
  38.145      return 0;
  38.146  }
  38.147  
  38.148 @@ -467,12 +488,12 @@ static unsigned long shadow_l2_table(
  38.149           * We could proactively fill in PDEs for pages that are already
  38.150           * shadowed *and* where the guest PDE has _PAGE_ACCESSED set
  38.151           * (restriction required for coherence of the accessed bit). However,
  38.152 -         * we tried it and it didn't help performance. This is simpler. 
  38.153 +         * we tried it and it didn't help performance. This is simpler.
  38.154           */
  38.155          memset(spl2e, 0, DOMAIN_ENTRIES_PER_L2_PAGETABLE*sizeof(l2_pgentry_t));
  38.156  
  38.157          /* Install hypervisor and 2x linear p.t. mapings. */
  38.158 -        memcpy(&spl2e[DOMAIN_ENTRIES_PER_L2_PAGETABLE], 
  38.159 +        memcpy(&spl2e[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
  38.160                 &idle_pg_table[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
  38.161                 HYPERVISOR_ENTRIES_PER_L2_PAGETABLE * sizeof(l2_pgentry_t));
  38.162  
  38.163 @@ -499,7 +520,7 @@ static unsigned long shadow_l2_table(
  38.164              //
  38.165              if ( !get_shadow_ref(hl2mfn) )
  38.166                  BUG();
  38.167 -            
  38.168 +
  38.169              spl2e[l2_table_offset(LINEAR_PT_VIRT_START)] =
  38.170                  l2e_from_pfn(hl2mfn, __PAGE_HYPERVISOR);
  38.171          }
  38.172 @@ -509,7 +530,7 @@ static unsigned long shadow_l2_table(
  38.173      }
  38.174      else
  38.175      {
  38.176 -        memset(spl2e, 0, L2_PAGETABLE_ENTRIES*sizeof(l2_pgentry_t));        
  38.177 +        memset(spl2e, 0, L2_PAGETABLE_ENTRIES*sizeof(l2_pgentry_t));
  38.178      }
  38.179  
  38.180      unmap_domain_page(spl2e);
  38.181 @@ -520,7 +541,7 @@ static unsigned long shadow_l2_table(
  38.182  #endif
  38.183  
  38.184  static void shadow_map_l1_into_current_l2(unsigned long va)
  38.185 -{ 
  38.186 +{
  38.187      struct vcpu *v = current;
  38.188      struct domain *d = v->domain;
  38.189      l1_pgentry_t *spl1e;
  38.190 @@ -573,7 +594,7 @@ static void shadow_map_l1_into_current_l
  38.191  #if CONFIG_PAGING_LEVELS >=4
  38.192      if (d->arch.ops->guest_paging_levels == PAGING_L2)
  38.193      {
  38.194 -        /* for 32-bit VMX guest on 64-bit host, 
  38.195 +        /* for 32-bit VMX guest on 64-bit host,
  38.196           * need update two L2 entries each time
  38.197           */
  38.198          if ( !get_shadow_ref(sl1mfn))
  38.199 @@ -601,7 +622,7 @@ static void shadow_map_l1_into_current_l
  38.200          l1_pgentry_t sl1e;
  38.201          int index = guest_l1_table_offset(va);
  38.202          int min = 1, max = 0;
  38.203 -        
  38.204 +
  38.205          unsigned long entries, pt_va;
  38.206          l1_pgentry_t tmp_sl1e;
  38.207          guest_l1_pgentry_t tmp_gl1e;//Prepare for double compile
  38.208 @@ -767,7 +788,7 @@ shadow_alloc_oos_entry(struct domain *d)
  38.209  
  38.210          /* Record the allocation block so it can be correctly freed later. */
  38.211          d->arch.out_of_sync_extras_count++;
  38.212 -        *((struct out_of_sync_entry **)&extra[out_of_sync_extra_size]) = 
  38.213 +        *((struct out_of_sync_entry **)&extra[out_of_sync_extra_size]) =
  38.214              d->arch.out_of_sync_extras;
  38.215          d->arch.out_of_sync_extras = &extra[0];
  38.216  
  38.217 @@ -997,7 +1018,7 @@ static int is_out_of_sync(struct vcpu *v
  38.218  {
  38.219      struct domain *d = v->domain;
  38.220  #if defined (__x86_64__)
  38.221 -    unsigned long l2mfn = ((v->arch.flags & TF_kernel_mode)? 
  38.222 +    unsigned long l2mfn = ((v->arch.flags & TF_kernel_mode)?
  38.223                            pagetable_get_pfn(v->arch.guest_table) :
  38.224                            pagetable_get_pfn(v->arch.guest_table_user));
  38.225  #else
  38.226 @@ -1059,7 +1080,7 @@ static int is_out_of_sync(struct vcpu *v
  38.227          return 1;
  38.228  
  38.229      __guest_get_l2e(v, va, &l2e);
  38.230 -    if ( !(guest_l2e_get_flags(l2e) & _PAGE_PRESENT) || 
  38.231 +    if ( !(guest_l2e_get_flags(l2e) & _PAGE_PRESENT) ||
  38.232           (guest_l2e_get_flags(l2e) & _PAGE_PSE))
  38.233          return 0;
  38.234  
  38.235 @@ -1132,7 +1153,7 @@ decrease_writable_pte_prediction(struct 
  38.236  }
  38.237  
  38.238  static int fix_entry(
  38.239 -    struct domain *d, 
  38.240 +    struct domain *d,
  38.241      l1_pgentry_t *pt, u32 *found, int is_l1_shadow, u32 max_refs_to_find)
  38.242  {
  38.243      l1_pgentry_t old = *pt;
  38.244 @@ -1171,19 +1192,19 @@ static u32 remove_all_write_access_in_pt
  38.245      match = l1e_from_pfn(readonly_gmfn, flags);
  38.246  
  38.247      if ( shadow_mode_external(d) ) {
  38.248 -        i = (frame_table[readonly_gmfn].u.inuse.type_info & PGT_va_mask) 
  38.249 +        i = (frame_table[readonly_gmfn].u.inuse.type_info & PGT_va_mask)
  38.250              >> PGT_va_shift;
  38.251  
  38.252          if ( (i >= 0 && i <= L1_PAGETABLE_ENTRIES) &&
  38.253 -             !l1e_has_changed(pt[i], match, flags) && 
  38.254 +             !l1e_has_changed(pt[i], match, flags) &&
  38.255               fix_entry(d, &pt[i], &found, is_l1_shadow, max_refs_to_find) &&
  38.256               !prediction )
  38.257              goto out;
  38.258      }
  38.259 - 
  38.260 +
  38.261      for (i = 0; i < GUEST_L1_PAGETABLE_ENTRIES; i++)
  38.262      {
  38.263 -        if ( unlikely(!l1e_has_changed(pt[i], match, flags)) && 
  38.264 +        if ( unlikely(!l1e_has_changed(pt[i], match, flags)) &&
  38.265               fix_entry(d, &pt[i], &found, is_l1_shadow, max_refs_to_find) )
  38.266              break;
  38.267      }
  38.268 @@ -1232,7 +1253,7 @@ static int remove_all_write_access(
  38.269      }
  38.270  
  38.271      if ( shadow_mode_external(d) ) {
  38.272 -        if (write_refs-- == 0) 
  38.273 +        if (write_refs-- == 0)
  38.274              return 0;
  38.275  
  38.276           // Use the back pointer to locate the shadow page that can contain
  38.277 @@ -1252,7 +1273,7 @@ static int remove_all_write_access(
  38.278          a = &d->arch.shadow_ht[i];
  38.279          while ( a && a->gpfn_and_flags )
  38.280          {
  38.281 -            if ( (a->gpfn_and_flags & PGT_type_mask) == PGT_l1_shadow 
  38.282 +            if ( (a->gpfn_and_flags & PGT_type_mask) == PGT_l1_shadow
  38.283  #if CONFIG_PAGING_LEVELS >= 4
  38.284                || (a->gpfn_and_flags & PGT_type_mask) == PGT_fl1_shadow
  38.285  #endif
  38.286 @@ -1361,10 +1382,10 @@ static int resync_all(struct domain *d, 
  38.287                  if ( (i < min_snapshot) || (i > max_snapshot) ||
  38.288                       guest_l1e_has_changed(guest1[i], snapshot1[i], PAGE_FLAG_MASK) )
  38.289                  {
  38.290 -                    int error; 
  38.291 +                    int error;
  38.292  
  38.293                      error = validate_pte_change(d, guest1[i], &shadow1[i]);
  38.294 -                    if ( error ==  -1 ) 
  38.295 +                    if ( error ==  -1 )
  38.296                          unshadow_l1 = 1;
  38.297                      else {
  38.298                          need_flush |= error;
  38.299 @@ -1451,7 +1472,7 @@ static int resync_all(struct domain *d, 
  38.300              l2_pgentry_t *guest2 = guest;
  38.301              l2_pgentry_t *snapshot2 = snapshot;
  38.302              l1_pgentry_t *shadow2 = shadow;
  38.303 -            
  38.304 +
  38.305              ASSERT(shadow_mode_write_all(d));
  38.306              BUG_ON(!shadow_mode_refcounts(d)); // not yet implemented
  38.307  
  38.308 @@ -1611,7 +1632,7 @@ static void sync_all(struct domain *d)
  38.309               !shadow_get_page_from_l1e(npte, d) )
  38.310              BUG();
  38.311          *ppte = npte;
  38.312 -        set_guest_back_ptr(d, npte, (entry->writable_pl1e) >> PAGE_SHIFT, 
  38.313 +        set_guest_back_ptr(d, npte, (entry->writable_pl1e) >> PAGE_SHIFT,
  38.314                             (entry->writable_pl1e & ~PAGE_MASK)/sizeof(l1_pgentry_t));
  38.315          shadow_put_page_from_l1e(opte, d);
  38.316  
  38.317 @@ -1696,7 +1717,7 @@ static inline int l1pte_write_fault(
  38.318  
  38.319  static inline int l1pte_read_fault(
  38.320      struct domain *d, guest_l1_pgentry_t *gpte_p, l1_pgentry_t *spte_p)
  38.321 -{ 
  38.322 +{
  38.323      guest_l1_pgentry_t gpte = *gpte_p;
  38.324      l1_pgentry_t spte = *spte_p;
  38.325      unsigned long pfn = l1e_get_pfn(gpte);
  38.326 @@ -1738,7 +1759,7 @@ static int shadow_fault_32(unsigned long
  38.327      SH_VVLOG("shadow_fault( va=%lx, code=%lu )",
  38.328               va, (unsigned long)regs->error_code);
  38.329      perfc_incrc(shadow_fault_calls);
  38.330 -    
  38.331 +
  38.332      check_pagetable(v, "pre-sf");
  38.333  
  38.334      /*
  38.335 @@ -1781,7 +1802,7 @@ static int shadow_fault_32(unsigned long
  38.336      }
  38.337  
  38.338      /* Write fault? */
  38.339 -    if ( regs->error_code & 2 )  
  38.340 +    if ( regs->error_code & 2 )
  38.341      {
  38.342          int allow_writes = 0;
  38.343  
  38.344 @@ -1795,7 +1816,7 @@ static int shadow_fault_32(unsigned long
  38.345              else
  38.346              {
  38.347                  /* Write fault on a read-only mapping. */
  38.348 -                SH_VVLOG("shadow_fault - EXIT: wr fault on RO page (%" PRIpte ")", 
  38.349 +                SH_VVLOG("shadow_fault - EXIT: wr fault on RO page (%" PRIpte ")",
  38.350                           l1e_get_intpte(gpte));
  38.351                  perfc_incrc(shadow_fault_bail_ro_mapping);
  38.352                  goto fail;
  38.353 @@ -1855,7 +1876,7 @@ static int shadow_fault_32(unsigned long
  38.354      check_pagetable(v, "post-sf");
  38.355      return EXCRET_fault_fixed;
  38.356  
  38.357 - fail:
  38.358 +fail:
  38.359      shadow_unlock(d);
  38.360      return 0;
  38.361  }
  38.362 @@ -1872,7 +1893,7 @@ static int do_update_va_mapping(unsigned
  38.363      shadow_lock(d);
  38.364  
  38.365      //printk("%s(va=%p, val=%p)\n", __func__, (void *)va, (void *)l1e_get_intpte(val));
  38.366 -        
  38.367 +
  38.368      // This is actually overkill - we don't need to sync the L1 itself,
  38.369      // just everything involved in getting to this L1 (i.e. we need
  38.370      // linear_pg_table[l1_linear_offset(va)] to be in sync)...
  38.371 @@ -1902,7 +1923,7 @@ static int do_update_va_mapping(unsigned
  38.372   * and what it uses to get/maintain that mapping.
  38.373   *
  38.374   * SHADOW MODE:      none         enable         translate         external
  38.375 - * 
  38.376 + *
  38.377   * 4KB things:
  38.378   * guest_vtable    lin_l2     mapped per gl2   lin_l2 via hl2   mapped per gl2
  38.379   * shadow_vtable     n/a         sh_lin_l2       sh_lin_l2      mapped per gl2
  38.380 @@ -1927,7 +1948,7 @@ static void shadow_update_pagetables(str
  38.381  {
  38.382      struct domain *d = v->domain;
  38.383  #if defined (__x86_64__)
  38.384 -    unsigned long gmfn = ((v->arch.flags & TF_kernel_mode)? 
  38.385 +    unsigned long gmfn = ((v->arch.flags & TF_kernel_mode)?
  38.386                            pagetable_get_pfn(v->arch.guest_table) :
  38.387                            pagetable_get_pfn(v->arch.guest_table_user));
  38.388  #else
  38.389 @@ -1983,7 +2004,7 @@ static void shadow_update_pagetables(str
  38.390      /*
  38.391       * arch.shadow_vtable
  38.392       */
  38.393 -    if ( max_mode == SHM_external 
  38.394 +    if ( max_mode == SHM_external
  38.395  #if CONFIG_PAGING_LEVELS >=4
  38.396           || max_mode & SHM_enable
  38.397  #endif
  38.398 @@ -2218,7 +2239,7 @@ static int check_pte(
  38.399                 page_table_page);
  38.400          FAIL("RW2 coherence");
  38.401      }
  38.402 - 
  38.403 +
  38.404      if ( eff_guest_mfn == shadow_mfn )
  38.405      {
  38.406          if ( level > 1 )
  38.407 @@ -2268,7 +2289,7 @@ static int check_l1_table(
  38.408          errors += check_pte(v, p_guest+i, p_shadow+i,
  38.409                              p_snapshot ? p_snapshot+i : NULL,
  38.410                              1, l2_idx, i);
  38.411 - 
  38.412 +
  38.413      unmap_domain_page(p_shadow);
  38.414      unmap_domain_page(p_guest);
  38.415      if ( p_snapshot )
  38.416 @@ -2304,11 +2325,11 @@ static int check_l2_table(
  38.417  
  38.418  #if 0
  38.419      if ( memcmp(&spl2e[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
  38.420 -                &gpl2e[DOMAIN_ENTRIES_PER_L2_PAGETABLE], 
  38.421 +                &gpl2e[DOMAIN_ENTRIES_PER_L2_PAGETABLE],
  38.422                  ((SH_LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT) -
  38.423                   DOMAIN_ENTRIES_PER_L2_PAGETABLE) * sizeof(l2_pgentry_t)) )
  38.424      {
  38.425 -        for ( i = DOMAIN_ENTRIES_PER_L2_PAGETABLE; 
  38.426 +        for ( i = DOMAIN_ENTRIES_PER_L2_PAGETABLE;
  38.427                i < (SH_LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT);
  38.428                i++ )
  38.429              printk("+++ (%d) %lx %lx\n",i,
  38.430 @@ -2316,7 +2337,7 @@ static int check_l2_table(
  38.431          FAILPT("hypervisor entries inconsistent");
  38.432      }
  38.433  
  38.434 -    if ( (l2_pgentry_val(spl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT]) != 
  38.435 +    if ( (l2_pgentry_val(spl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT]) !=
  38.436            l2_pgentry_val(gpl2e[LINEAR_PT_VIRT_START >> L2_PAGETABLE_SHIFT])) )
  38.437          FAILPT("hypervisor linear map inconsistent");
  38.438  #endif
  38.439 @@ -2376,7 +2397,7 @@ static int _check_pagetable(struct vcpu 
  38.440  {
  38.441      struct domain *d = v->domain;
  38.442  #if defined (__x86_64__)
  38.443 -    pagetable_t pt = ((v->arch.flags & TF_kernel_mode)? 
  38.444 +    pagetable_t pt = ((v->arch.flags & TF_kernel_mode)?
  38.445                        pagetable_get_pfn(v->arch.guest_table) :
  38.446                        pagetable_get_pfn(v->arch.guest_table_user));
  38.447  #else
  38.448 @@ -2411,7 +2432,7 @@ static int _check_pagetable(struct vcpu 
  38.449          oos_pdes = 1;
  38.450          ASSERT(ptbase_mfn);
  38.451      }
  38.452 - 
  38.453 +
  38.454      errors += check_l2_table(v, ptbase_mfn, smfn, oos_pdes);
  38.455  
  38.456      gpl2e = (l2_pgentry_t *) map_domain_page(ptbase_mfn);
  38.457 @@ -2542,7 +2563,6 @@ static unsigned long gva_to_gpa_pae(unsi
  38.458   * The code is for 32-bit VMX gues on 64-bit host.
  38.459   * To sync guest L2.
  38.460   */
  38.461 -
  38.462  static inline void
  38.463  validate_bl2e_change(
  38.464    struct domain *d,
  38.465 @@ -2573,7 +2593,6 @@ validate_bl2e_change(
  38.466              entry_from_pfn(sl1mfn + 1, entry_get_flags(sl2_p[sl2_idx]));
  38.467      }
  38.468      unmap_domain_page(sl2_p);
  38.469 -
  38.470  }
  38.471  
  38.472  /*
  38.473 @@ -2606,9 +2625,8 @@ static inline unsigned long init_bl2(l4_
  38.474      }
  38.475  
  38.476      unmap_domain_page(spl4e);
  38.477 +
  38.478      return smfn;
  38.479 -
  38.480 -
  38.481  }
  38.482  
  38.483  static unsigned long shadow_l4_table(
  38.484 @@ -2641,7 +2659,7 @@ static unsigned long shadow_l4_table(
  38.485           * We could proactively fill in PDEs for pages that are already
  38.486           * shadowed *and* where the guest PDE has _PAGE_ACCESSED set
  38.487           * (restriction required for coherence of the accessed bit). However,
  38.488 -         * we tried it and it didn't help performance. This is simpler. 
  38.489 +         * we tried it and it didn't help performance. This is simpler.
  38.490           */
  38.491          memset(spl4e, 0, L4_PAGETABLE_ENTRIES*sizeof(l4_pgentry_t));
  38.492  
  38.493 @@ -2734,7 +2752,7 @@ static int get_shadow_mfn(struct domain 
  38.494      }
  38.495  }
  38.496  
  38.497 -static void shadow_map_into_current(struct vcpu *v, 
  38.498 +static void shadow_map_into_current(struct vcpu *v,
  38.499    unsigned long va, unsigned int from, unsigned int to)
  38.500  {
  38.501      pgentry_64_t gle, sle;
  38.502 @@ -2745,7 +2763,7 @@ static void shadow_map_into_current(stru
  38.503          return;
  38.504      }
  38.505  
  38.506 -    __rw_entry(v, va, &gle, GUEST_ENTRY | GET_ENTRY | to); 
  38.507 +    __rw_entry(v, va, &gle, GUEST_ENTRY | GET_ENTRY | to);
  38.508      ASSERT(entry_get_flags(gle) & _PAGE_PRESENT);
  38.509      gpfn = entry_get_pfn(gle);
  38.510  
  38.511 @@ -2761,7 +2779,7 @@ static void shadow_map_into_current(stru
  38.512  /*
  38.513   * shadow_set_lxe should be put in shadow.h
  38.514   */
  38.515 -static void shadow_set_l2e_64(unsigned long va, l2_pgentry_t sl2e, 
  38.516 +static void shadow_set_l2e_64(unsigned long va, l2_pgentry_t sl2e,
  38.517    int create_l2_shadow, int put_ref_check)
  38.518  {
  38.519      struct vcpu *v = current;
  38.520 @@ -2911,11 +2929,11 @@ static inline int l2e_rw_fault(
  38.521          sl2e = l2e_empty();
  38.522  
  38.523      l1_mfn = ___shadow_status(d, start_gpfn | nx, PGT_fl1_shadow);
  38.524 -    
  38.525 +
  38.526      /* Check the corresponding l2e */
  38.527      if (l1_mfn) {
  38.528          /* Why it is PRESENT?*/
  38.529 -        if ((l2e_get_flags(sl2e) & _PAGE_PRESENT) && 
  38.530 +        if ((l2e_get_flags(sl2e) & _PAGE_PRESENT) &&
  38.531                  l2e_get_pfn(sl2e) == l1_mfn) {
  38.532              ESH_LOG("sl2e PRSENT bit is set: %lx, l1_mfn = %lx\n", l2e_get_pfn(sl2e), l1_mfn);
  38.533          } else {
  38.534 @@ -2962,7 +2980,7 @@ static inline int l2e_rw_fault(
  38.535          sl1e = l1e_from_pfn(mfn, l2e_get_flags(tmp_l2e));
  38.536  
  38.537          if (!rw) {
  38.538 -            if ( shadow_mode_log_dirty(d) || 
  38.539 +            if ( shadow_mode_log_dirty(d) ||
  38.540                !(l2e_get_flags(gl2e) & _PAGE_DIRTY) || mfn_is_page_table(mfn) )
  38.541              {
  38.542                  l1e_remove_flags(sl1e, _PAGE_RW);
  38.543 @@ -3011,7 +3029,7 @@ static inline int l2e_rw_fault(
  38.544   */
  38.545  #if defined( GUEST_PGENTRY_32 )
  38.546  static inline int guest_page_fault(struct vcpu *v,
  38.547 -  unsigned long va, unsigned int error_code, 
  38.548 +  unsigned long va, unsigned int error_code,
  38.549    guest_l2_pgentry_t *gpl2e, guest_l1_pgentry_t *gpl1e)
  38.550  {
  38.551      /* The following check for 32-bit guest on 64-bit host */
  38.552 @@ -3053,7 +3071,7 @@ static inline int guest_page_fault(struc
  38.553  }
  38.554  #else
  38.555  static inline int guest_page_fault(struct vcpu *v,
  38.556 -  unsigned long va, unsigned int error_code, 
  38.557 +  unsigned long va, unsigned int error_code,
  38.558    guest_l2_pgentry_t *gpl2e, guest_l1_pgentry_t *gpl1e)
  38.559  {
  38.560      struct domain *d = v->domain;
  38.561 @@ -3121,7 +3139,7 @@ static int shadow_fault_64(unsigned long
  38.562  
  38.563      perfc_incrc(shadow_fault_calls);
  38.564  
  38.565 -    ESH_LOG("<shadow_fault_64> va=%lx,  rip = %lx, error code = %x\n", 
  38.566 +    ESH_LOG("<shadow_fault_64> va=%lx,  rip = %lx, error code = %x\n",
  38.567              va, regs->eip, regs->error_code);
  38.568  
  38.569      /*
  38.570 @@ -3143,12 +3161,12 @@ static int shadow_fault_64(unsigned long
  38.571              v, va, regs->error_code, &gl2e, &gl1e) ) {
  38.572          goto fail;
  38.573      }
  38.574 -    
  38.575 +
  38.576      if ( unlikely(!(guest_l2e_get_flags(gl2e) & _PAGE_PSE)) ) {
  38.577          /*
  38.578           * Handle 4K pages here
  38.579           */
  38.580 -        
  38.581 +
  38.582          /* Write fault? */
  38.583          if ( regs->error_code & 2 ) {
  38.584              if ( !l1pte_write_fault(v, &gl1e, &sl1e, va) ) {
  38.585 @@ -3171,7 +3189,7 @@ static int shadow_fault_64(unsigned long
  38.586           */
  38.587           if ( unlikely(shadow_mode_log_dirty(d)) )
  38.588              __mark_dirty(d, __gpfn_to_mfn(d, l2e_get_pfn(gl2e)));
  38.589 - 
  38.590 +
  38.591      } else {
  38.592          /*
  38.593           * Handle 2M pages here
  38.594 @@ -3239,7 +3257,7 @@ static unsigned long gva_to_gpa_64(unsig
  38.595  
  38.596      if (guest_page_fault(v, gva, 0, &gl2e, &gl1e))
  38.597          return 0;
  38.598 -    
  38.599 +
  38.600      if (guest_l2e_get_flags(gl2e) & _PAGE_PSE)
  38.601          gpa = guest_l2e_get_paddr(gl2e) + (gva & ((1 << GUEST_L2_PAGETABLE_SHIFT) - 1));
  38.602      else
    39.1 --- a/xen/arch/x86/vmx_platform.c	Tue Nov 01 13:38:20 2005 +0100
    39.2 +++ b/xen/arch/x86/vmx_platform.c	Wed Nov 02 17:29:32 2005 +0100
    39.3 @@ -303,20 +303,20 @@ static void init_instruction(struct inst
    39.4      mmio_inst->flags = 0;
    39.5  }
    39.6  
    39.7 -#define GET_OP_SIZE_FOR_BYTE(op_size)   \
    39.8 -    do {    \
    39.9 -     if (rex)   \
   39.10 -     op_size = BYTE_64;  \
   39.11 - else    \
   39.12 -     op_size = BYTE;  \
   39.13 +#define GET_OP_SIZE_FOR_BYTE(op_size)       \
   39.14 +    do {                                    \
   39.15 +        if (rex)                            \
   39.16 +            op_size = BYTE_64;              \
   39.17 +        else                                \
   39.18 +            op_size = BYTE;                 \
   39.19      } while(0)
   39.20  
   39.21  #define GET_OP_SIZE_FOR_NONEBYTE(op_size)   \
   39.22 -    do {    \
   39.23 -     if (rex & 0x8)   \
   39.24 -     op_size = QUAD;  \
   39.25 - else if (op_size != WORD) \
   39.26 -     op_size = LONG;  \
   39.27 +    do {                                    \
   39.28 +        if (rex & 0x8)                      \
   39.29 +            op_size = QUAD;                 \
   39.30 +        else if (op_size != WORD)           \
   39.31 +            op_size = LONG;                 \
   39.32      } while(0)
   39.33  
   39.34  
   39.35 @@ -398,8 +398,9 @@ static int vmx_decode(unsigned char *opc
   39.36  
   39.37      case 0x20: /* and r8, m8 */
   39.38          instr->instr = INSTR_AND;
   39.39 -        GET_OP_SIZE_FOR_BYTE(instr->op_size);
   39.40 -        return reg_mem(instr->op_size, opcode, instr, rex);
   39.41 +        instr->op_size = BYTE;
   39.42 +        GET_OP_SIZE_FOR_BYTE(size_reg);
   39.43 +        return reg_mem(size_reg, opcode, instr, rex);
   39.44  
   39.45      case 0x21: /* and r32/16, m32/16 */
   39.46          instr->instr = INSTR_AND;
   39.47 @@ -413,8 +414,9 @@ static int vmx_decode(unsigned char *opc
   39.48  
   39.49      case 0x30: /* xor r8, m8 */
   39.50          instr->instr = INSTR_XOR;
   39.51 -        GET_OP_SIZE_FOR_BYTE(instr->op_size);
   39.52 -        return reg_mem(instr->op_size, opcode, instr, rex);
   39.53 +        instr->op_size = BYTE;
   39.54 +        GET_OP_SIZE_FOR_BYTE(size_reg);
   39.55 +        return reg_mem(size_reg, opcode, instr, rex);
   39.56  
   39.57      case 0x31: /* xor r32/16, m32/16 */
   39.58          instr->instr = INSTR_XOR;
   39.59 @@ -592,7 +594,7 @@ static int vmx_decode(unsigned char *opc
   39.60          instr->operand[1] = mk_operand(instr->op_size, index, 0, REGISTER);
   39.61          return DECODE_success;
   39.62  
   39.63 -    case 0xB7: /* movz m16, r32 */
   39.64 +    case 0xB7: /* movz m16/m32, r32/r64 */
   39.65          instr->instr = INSTR_MOVZ;
   39.66          index = get_index(opcode + 1, rex);
   39.67          if (rex & 0x8) {
   39.68 @@ -689,9 +691,9 @@ static void mmio_operands(int type, unsi
   39.69                            struct mmio_op *mmio_opp, struct cpu_user_regs *regs)
   39.70  {
   39.71      unsigned long value = 0;
   39.72 -    int index, size;
   39.73 +    int index, size_reg;
   39.74  
   39.75 -    size = operand_size(inst->operand[0]);
   39.76 +    size_reg = operand_size(inst->operand[0]);
   39.77  
   39.78      mmio_opp->flags = inst->flags;
   39.79      mmio_opp->instr = inst->instr;
   39.80 @@ -701,14 +703,17 @@ static void mmio_operands(int type, unsi
   39.81  
   39.82      if (inst->operand[0] & REGISTER) { /* dest is memory */
   39.83          index = operand_index(inst->operand[0]);
   39.84 -        value = get_reg_value(size, index, 0, regs);
   39.85 +        value = get_reg_value(size_reg, index, 0, regs);
   39.86          send_mmio_req(type, gpa, 1, inst->op_size, value, IOREQ_WRITE, 0);
   39.87      } else if (inst->operand[0] & IMMEDIATE) { /* dest is memory */
   39.88          value = inst->immediate;
   39.89          send_mmio_req(type, gpa, 1, inst->op_size, value, IOREQ_WRITE, 0);
   39.90      } else if (inst->operand[0] & MEMORY) { /* dest is register */
   39.91          /* send the request and wait for the value */
   39.92 -        send_mmio_req(type, gpa, 1, inst->op_size, 0, IOREQ_READ, 0);
   39.93 +        if (inst->instr == INSTR_MOVZ)
   39.94 +            send_mmio_req(type, gpa, 1, size_reg, 0, IOREQ_READ, 0);
   39.95 +        else
   39.96 +            send_mmio_req(type, gpa, 1, inst->op_size, 0, IOREQ_READ, 0);
   39.97      } else {
   39.98          printf("mmio_operands: invalid operand\n");
   39.99          domain_crash_synchronous();
    40.1 --- a/xen/common/trace.c	Tue Nov 01 13:38:20 2005 +0100
    40.2 +++ b/xen/common/trace.c	Wed Nov 02 17:29:32 2005 +0100
    40.3 @@ -260,7 +260,7 @@ void trace(u32 event, unsigned long d1, 
    40.4      }
    40.5  
    40.6      rec = &t_recs[smp_processor_id()][buf->prod % nr_recs];
    40.7 -    rdtscll(rec->cycles);
    40.8 +    rec->cycles  = (u64)get_cycles();
    40.9      rec->event   = event;
   40.10      rec->data[0] = d1;
   40.11      rec->data[1] = d2;
    41.1 --- a/xen/include/asm-x86/time.h	Tue Nov 01 13:38:20 2005 +0100
    41.2 +++ b/xen/include/asm-x86/time.h	Wed Nov 02 17:29:32 2005 +0100
    41.3 @@ -2,6 +2,8 @@
    41.4  #ifndef __X86_TIME_H__
    41.5  #define __X86_TIME_H__
    41.6  
    41.7 +#include <asm/msr.h>
    41.8 +
    41.9  extern int timer_ack;
   41.10  
   41.11  extern void calibrate_tsc_bp(void);
   41.12 @@ -10,4 +12,13 @@ extern void calibrate_tsc_ap(void);
   41.13  struct domain;
   41.14  extern void init_domain_time(struct domain *d);
   41.15  
   41.16 +typedef u64 cycles_t;
   41.17 +
   41.18 +static inline cycles_t get_cycles(void)
   41.19 +{
   41.20 +    cycles_t c;
   41.21 +    rdtscll(c);
   41.22 +    return c;
   41.23 +}
   41.24 +
   41.25  #endif /* __X86_TIME_H__ */