direct-io.hg

changeset 7694:f544934dd0b6

merge
author Michael.Fetterman@cl.cam.ac.uk
date Tue Nov 08 13:30:05 2005 +0100 (2005-11-08)
parents 055efdd6b7c5 c665ab5a6b44
children 6e2225934d84
files tools/python/xen/xm/create.py
line diff
     1.1 --- a/.hgignore	Tue Nov 08 03:35:25 2005 +0100
     1.2 +++ b/.hgignore	Tue Nov 08 13:30:05 2005 +0100
     1.3 @@ -17,9 +17,9 @@
     1.4  ^docs/.*\.pdf$
     1.5  ^docs/.*\.ps$
     1.6  ^docs/.*\.toc$
     1.7 +^docs/api/.*$
     1.8  ^docs/figs/xenserver\.eps$
     1.9  ^docs/html/.*$
    1.10 -^docs/api/.*$
    1.11  ^docs/interface/WARNINGS$
    1.12  ^docs/interface/images\.pl$
    1.13  ^docs/interface/images\.tex$
    1.14 @@ -47,9 +47,9 @@
    1.15  ^extras/mini-os/h/xen-public$
    1.16  ^extras/mini-os/mini-os\..*$
    1.17  ^install/.*$
    1.18 +^linux-[^/]*-xen/.*$
    1.19  ^linux-[^/]*-xen0/.*$
    1.20  ^linux-[^/]*-xenU/.*$
    1.21 -^linux-[^/]*-xen/.*$
    1.22  ^linux-[^/]*\.patch$
    1.23  ^mkddbxen$
    1.24  ^netbsd-[^/]*-tools/.*$
    1.25 @@ -62,6 +62,7 @@
    1.26  ^patches/tmp/.*$
    1.27  ^pristine-.*$
    1.28  ^ref-.*$
    1.29 +^tools/.*/TAGS$
    1.30  ^tools/.*/build/lib.*/.*\.py$
    1.31  ^tools/blktap/Makefile\.smh$
    1.32  ^tools/blktap/blkcow$
    1.33 @@ -71,37 +72,37 @@
    1.34  ^tools/blktap/blkgnbd$
    1.35  ^tools/blktap/blkimg$
    1.36  ^tools/blktap/bstest$
    1.37 -^tools/blktap/vdi\.dot$
    1.38 -^tools/blktap/vdi\.ps$
    1.39 +^tools/blktap/parallax/blockstored$
    1.40 +^tools/blktap/parallax/parallax$
    1.41  ^tools/blktap/parallax/vdi_create$
    1.42  ^tools/blktap/parallax/vdi_fill$
    1.43  ^tools/blktap/parallax/vdi_list$
    1.44  ^tools/blktap/parallax/vdi_snap$
    1.45 +^tools/blktap/parallax/vdi_snap_delete$
    1.46  ^tools/blktap/parallax/vdi_snap_list$
    1.47 -^tools/blktap/parallax/vdi_snap_delete$
    1.48  ^tools/blktap/parallax/vdi_tree$
    1.49  ^tools/blktap/parallax/vdi_validate$
    1.50 -^tools/blktap/parallax/parallax$
    1.51 -^tools/blktap/parallax/blockstored$
    1.52  ^tools/blktap/ublkback/ublkback$
    1.53 +^tools/blktap/vdi\.dot$
    1.54 +^tools/blktap/vdi\.ps$
    1.55  ^tools/blktap/xen/.*$
    1.56  ^tools/check/\..*$
    1.57 +^tools/console/xenconsole$
    1.58  ^tools/console/xenconsoled$
    1.59 -^tools/console/xenconsole$
    1.60 +^tools/debugger/gdb/gdb-6\.2\.1-linux-i386-xen/.*$
    1.61 +^tools/debugger/gdb/gdb-6\.2\.1/.*$
    1.62  ^tools/debugger/gdb/gdb-6\.2\.1\.tar\.bz2$
    1.63 -^tools/debugger/gdb/gdb-6\.2\.1/.*$
    1.64 -^tools/debugger/gdb/gdb-6\.2\.1-linux-i386-xen/.*$
    1.65 -^tools/debugger/pdb/pdb$
    1.66 +^tools/debugger/pdb/._bcdi/.*$
    1.67  ^tools/debugger/pdb/linux-[0-9.]*-module/.*\.ko$
    1.68  ^tools/debugger/pdb/linux-[0-9.]*-module/.*\.mod.c$
    1.69 +^tools/debugger/pdb/linux-[0-9.]*-module/.tmp_versions/.*$
    1.70  ^tools/debugger/pdb/linux-[0-9.]*-module/\..*\.cmd$
    1.71 -^tools/debugger/pdb/linux-[0-9.]*-module/.tmp_versions/.*$
    1.72 -^tools/debugger/pdb/._bcdi/.*$
    1.73 -^tools/firmware/acpi/acpigen$
    1.74 +^tools/debugger/pdb/pdb$
    1.75 +^tools/firmware/.*/biossums$
    1.76  ^tools/firmware/.*\.bin$
    1.77  ^tools/firmware/.*\.sym$
    1.78 -^tools/firmware/.*/biossums$
    1.79  ^tools/firmware/.*bios/.*bios.*\.txt$
    1.80 +^tools/firmware/acpi/acpigen$
    1.81  ^tools/firmware/rombios/BIOS-bochs-latest$
    1.82  ^tools/firmware/rombios/_rombios_\.c$
    1.83  ^tools/firmware/rombios/rombios\.s$
    1.84 @@ -120,20 +121,20 @@
    1.85  ^tools/libxc/xen/.*$
    1.86  ^tools/misc/cpuperf/cpuperf-perfcntr$
    1.87  ^tools/misc/cpuperf/cpuperf-xen$
    1.88 +^tools/misc/lomount/lomount$
    1.89  ^tools/misc/mbootpack/bin2c$
    1.90  ^tools/misc/mbootpack/bootsect$
    1.91  ^tools/misc/mbootpack/bzimage_header\.c$
    1.92  ^tools/misc/mbootpack/mbootpack$
    1.93  ^tools/misc/mbootpack/setup$
    1.94  ^tools/misc/miniterm/miniterm$
    1.95 -^tools/misc/lomount/lomount$
    1.96  ^tools/misc/xc_shadow$
    1.97  ^tools/misc/xen_cpuperf$
    1.98  ^tools/misc/xenperf$
    1.99 +^tools/pygrub/build/.*$
   1.100 +^tools/python/build/.*$
   1.101  ^tools/security/secpol_tool$
   1.102  ^tools/security/xen/.*$
   1.103 -^tools/pygrub/build/.*$
   1.104 -^tools/python/build/.*$
   1.105  ^tools/tests/test_x86_emulator$
   1.106  ^tools/vnet/gc$
   1.107  ^tools/vnet/gc.*/.*$
   1.108 @@ -141,8 +142,8 @@
   1.109  ^tools/vnet/vnet-module/\..*\.cmd$
   1.110  ^tools/vnet/vnet-module/\.tmp_versions/.*$
   1.111  ^tools/vnet/vnet-module/vnet_module\.mod\..*$
   1.112 +^tools/vtpm/tpm_emulator-.*\.tar\.gz$
   1.113  ^tools/vtpm/tpm_emulator/.*$
   1.114 -^tools/vtpm/tpm_emulator-.*\.tar\.gz$
   1.115  ^tools/vtpm/vtpm/.*$
   1.116  ^tools/vtpm_manager/manager/vtpm_managerd$
   1.117  ^tools/xcutils/xc_restore$
   1.118 @@ -150,13 +151,13 @@
   1.119  ^tools/xenstat/xentop/xentop$
   1.120  ^tools/xenstore/testsuite/tmp/.*$
   1.121  ^tools/xenstore/xen$
   1.122 -^tools/xenstore/xenstored$
   1.123 -^tools/xenstore/xenstored_test$
   1.124  ^tools/xenstore/xenstore-exists$
   1.125  ^tools/xenstore/xenstore-list$
   1.126  ^tools/xenstore/xenstore-read$
   1.127  ^tools/xenstore/xenstore-rm$
   1.128  ^tools/xenstore/xenstore-write$
   1.129 +^tools/xenstore/xenstored$
   1.130 +^tools/xenstore/xenstored_test$
   1.131  ^tools/xenstore/xs_crashme$
   1.132  ^tools/xenstore/xs_random$
   1.133  ^tools/xenstore/xs_stress$
     2.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Tue Nov 08 03:35:25 2005 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_32	Tue Nov 08 13:30:05 2005 +0100
     2.3 @@ -1,7 +1,7 @@
     2.4  #
     2.5  # Automatically generated make config: don't edit
     2.6 -# Linux kernel version: 2.6.12-xen0
     2.7 -# Wed Aug  3 09:54:56 2005
     2.8 +# Linux kernel version: 2.6.12.6-xen0
     2.9 +# Mon Nov  7 17:22:05 2005
    2.10  #
    2.11  CONFIG_XEN=y
    2.12  CONFIG_ARCH_XEN=y
    2.13 @@ -151,11 +151,9 @@ CONFIG_X86_IO_APIC=y
    2.14  CONFIG_X86_UP_APIC=y
    2.15  CONFIG_X86_UP_IOAPIC=y
    2.16  CONFIG_PCI=y
    2.17 -# CONFIG_PCI_GOBIOS is not set
    2.18  # CONFIG_PCI_GOMMCONFIG is not set
    2.19  # CONFIG_PCI_GODIRECT is not set
    2.20  CONFIG_PCI_GOANY=y
    2.21 -CONFIG_PCI_BIOS=y
    2.22  CONFIG_PCI_DIRECT=y
    2.23  CONFIG_PCI_MMCONFIG=y
    2.24  # CONFIG_PCIEPORTBUS is not set
    2.25 @@ -540,7 +538,7 @@ CONFIG_IP_NF_MATCH_IPRANGE=m
    2.26  # CONFIG_IP_NF_MATCH_STATE is not set
    2.27  # CONFIG_IP_NF_MATCH_CONNTRACK is not set
    2.28  # CONFIG_IP_NF_MATCH_OWNER is not set
    2.29 -CONFIG_IP_NF_MATCH_PHYSDEV=y
    2.30 +CONFIG_IP_NF_MATCH_PHYSDEV=m
    2.31  # CONFIG_IP_NF_MATCH_ADDRTYPE is not set
    2.32  # CONFIG_IP_NF_MATCH_REALM is not set
    2.33  # CONFIG_IP_NF_MATCH_SCTP is not set
     3.1 --- a/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Tue Nov 08 03:35:25 2005 +0100
     3.2 +++ b/linux-2.6-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Tue Nov 08 13:30:05 2005 +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.12.4-xen0
     3.7 -# Mon Aug 15 18:57:19 2005
     3.8 +# Linux kernel version: 2.6.12.6-xen0
     3.9 +# Mon Nov  7 17:24:18 2005
    3.10  #
    3.11  CONFIG_XEN=y
    3.12  CONFIG_ARCH_XEN=y
    3.13 @@ -92,6 +92,7 @@ CONFIG_X86_GOOD_APIC=y
    3.14  # CONFIG_PREEMPT is not set
    3.15  CONFIG_MICROCODE=y
    3.16  # CONFIG_X86_CPUID is not set
    3.17 +CONFIG_SWIOTLB=y
    3.18  # CONFIG_NUMA is not set
    3.19  # CONFIG_MTRR is not set
    3.20  CONFIG_X86_LOCAL_APIC=y
    3.21 @@ -122,7 +123,6 @@ CONFIG_X86_XEN_GENAPIC=y
    3.22  # CONFIG_X86_MSR is not set
    3.23  # CONFIG_GART_IOMMU is not set
    3.24  CONFIG_DUMMY_IOMMU=y
    3.25 -CONFIG_SWIOTLB=y
    3.26  # CONFIG_X86_MCE is not set
    3.27  
    3.28  #
    3.29 @@ -480,7 +480,7 @@ CONFIG_IP_NF_MATCH_IPRANGE=m
    3.30  # CONFIG_IP_NF_MATCH_STATE is not set
    3.31  # CONFIG_IP_NF_MATCH_CONNTRACK is not set
    3.32  # CONFIG_IP_NF_MATCH_OWNER is not set
    3.33 -CONFIG_IP_NF_MATCH_PHYSDEV=y
    3.34 +CONFIG_IP_NF_MATCH_PHYSDEV=m
    3.35  # CONFIG_IP_NF_MATCH_ADDRTYPE is not set
    3.36  # CONFIG_IP_NF_MATCH_REALM is not set
    3.37  # CONFIG_IP_NF_MATCH_SCTP is not set
     4.1 --- a/tools/libxc/Makefile	Tue Nov 08 03:35:25 2005 +0100
     4.2 +++ b/tools/libxc/Makefile	Tue Nov 08 13:30:05 2005 +0100
     4.3 @@ -13,7 +13,6 @@ XEN_ROOT = ../..
     4.4  include $(XEN_ROOT)/tools/Rules.mk
     4.5  
     4.6  SRCS       :=
     4.7 -BUILD_SRCS :=
     4.8  SRCS       += xc_bvtsched.c
     4.9  SRCS       += xc_core.c
    4.10  SRCS       += xc_domain.c
    4.11 @@ -24,25 +23,27 @@ SRCS       += xc_physdev.c
    4.12  SRCS       += xc_private.c
    4.13  SRCS       += xc_sedf.c
    4.14  SRCS       += xc_tbuf.c
    4.15 +
    4.16 +ifeq ($(XEN_TARGET_ARCH),x86_32)
    4.17 +SRCS       += xc_ptrace.c
    4.18 +SRCS       += xc_ptrace_core.c
    4.19 +endif
    4.20 +
    4.21 +BUILD_SRCS :=
    4.22  BUILD_SRCS += xc_linux_build.c
    4.23  BUILD_SRCS += xc_load_bin.c
    4.24  BUILD_SRCS += xc_load_elf.c
    4.25 +BUILD_SRCS += xg_private.c
    4.26  
    4.27  ifeq ($(XEN_TARGET_ARCH),ia64)
    4.28  BUILD_SRCS += xc_ia64_stubs.c
    4.29  else
    4.30 -ifeq ($(XEN_TARGET_ARCH),x86_32)
    4.31 -SRCS       += xc_ptrace.c
    4.32 -SRCS       += xc_ptrace_core.c
    4.33 -endif
    4.34  BUILD_SRCS += xc_load_aout9.c
    4.35  BUILD_SRCS += xc_linux_restore.c
    4.36  BUILD_SRCS += xc_linux_save.c
    4.37  BUILD_SRCS += xc_vmx_build.c
    4.38  endif
    4.39  
    4.40 -BUILD_SRCS += xg_private.c
    4.41 -
    4.42  CFLAGS   += -Wall
    4.43  CFLAGS   += -Werror
    4.44  CFLAGS   += -O3
    4.45 @@ -105,7 +106,7 @@ install: build
    4.46  .PHONY: TAGS clean rpm install all
    4.47  
    4.48  TAGS:
    4.49 -	etags -t $(SRCS) *.h
    4.50 +	etags -t *.c *.h
    4.51  
    4.52  clean:
    4.53  	rm -rf *.a *.so* *.o *.opic *.rpm $(LIB) *~ $(DEPS) xen
     5.1 --- a/tools/libxc/xc_linux_build.c	Tue Nov 08 03:35:25 2005 +0100
     5.2 +++ b/tools/libxc/xc_linux_build.c	Tue Nov 08 13:30:05 2005 +0100
     5.3 @@ -549,11 +549,10 @@ static int setup_guest(int xc_handle,
     5.4          rc = setup_pg_tables_pae(xc_handle, dom, ctxt,
     5.5                                   dsi.v_start, v_end,
     5.6                                   page_array, vpt_start, vpt_end);
     5.7 -    else {
     5.8 +    else
     5.9          rc = setup_pg_tables(xc_handle, dom, ctxt,
    5.10                               dsi.v_start, v_end,
    5.11                               page_array, vpt_start, vpt_end);
    5.12 -    }
    5.13  #endif
    5.14  #if defined(__x86_64__)
    5.15      rc = setup_pg_tables_64(xc_handle, dom, ctxt,
    5.16 @@ -671,8 +670,10 @@ static int setup_guest(int xc_handle,
    5.17      return 0;
    5.18  
    5.19   error_out:
    5.20 -    free(mmu);
    5.21 -    free(page_array);
    5.22 +    if ( mmu != NULL )
    5.23 +        free(mmu);
    5.24 +    if ( page_array != NULL )
    5.25 +        free(page_array);
    5.26      return -1;
    5.27  }
    5.28  #endif
    5.29 @@ -726,7 +727,7 @@ int xc_linux_build(int xc_handle,
    5.30  
    5.31      if ( mlock(&st_ctxt, sizeof(st_ctxt) ) )
    5.32      {   
    5.33 -        PERROR("xc_linux_build: ctxt mlock failed");
    5.34 +        PERROR("%s: ctxt mlock failed", __func__);
    5.35          return 1;
    5.36      }
    5.37  
    5.38 @@ -767,7 +768,8 @@ int xc_linux_build(int xc_handle,
    5.39          close(initrd_fd);
    5.40      if ( initrd_gfd )
    5.41          gzclose(initrd_gfd);
    5.42 -    free(image);
    5.43 +    if ( image != NULL )
    5.44 +        free(image);
    5.45  
    5.46  #ifdef __ia64__
    5.47      /* based on new_thread in xen/arch/ia64/domain.c */
    5.48 @@ -856,7 +858,8 @@ int xc_linux_build(int xc_handle,
    5.49          gzclose(initrd_gfd);
    5.50      else if ( initrd_fd >= 0 )
    5.51          close(initrd_fd);
    5.52 -    free(image);
    5.53 +    if ( image != NULL )
    5.54 +        free(image);
    5.55  
    5.56      return -1;
    5.57  }
     6.1 --- a/tools/python/xen/xm/create.py	Tue Nov 08 03:35:25 2005 +0100
     6.2 +++ b/tools/python/xen/xm/create.py	Tue Nov 08 13:30:05 2005 +0100
     6.3 @@ -756,7 +756,7 @@ def choose_vnc_display():
     6.4  vncpid = None
     6.5  
     6.6  def spawn_vnc(display):
     6.7 -    vncargs = (["vncviewer" + "-log", "*:stdout:0",
     6.8 +    vncargs = (["vncviewer", "-log", "*:stdout:0",
     6.9              "-listen", "%d" % (VNC_BASE_PORT + display) ])
    6.10      global vncpid    
    6.11      vncpid = os.spawnvp(os.P_NOWAIT, "vncviewer", vncargs)
     7.1 --- a/xen/acm/acm_core.c	Tue Nov 08 03:35:25 2005 +0100
     7.2 +++ b/xen/acm/acm_core.c	Tue Nov 08 13:30:05 2005 +0100
     7.3 @@ -254,7 +254,10 @@ acm_init_domain_ssid(domid_t id, ssidref
     7.4          return ACM_NULL_POINTER_ERROR;
     7.5      }
     7.6      if ((ssid = xmalloc(struct acm_ssid_domain)) == NULL)
     7.7 +    {
     7.8 +        put_domain(subj);
     7.9          return ACM_INIT_SSID_ERROR;
    7.10 +    }
    7.11  
    7.12      ssid->datatype       = DOMAIN;
    7.13      ssid->subject        = subj;
     8.1 --- a/xen/arch/x86/audit.c	Tue Nov 08 03:35:25 2005 +0100
     8.2 +++ b/xen/arch/x86/audit.c	Tue Nov 08 13:30:05 2005 +0100
     8.3 @@ -412,7 +412,7 @@ int audit_adjust_pgtables(struct domain 
     8.4          for_each_vcpu(d, v)
     8.5          {
     8.6              if ( pagetable_get_paddr(v->arch.guest_table) )
     8.7 -                adjust(&frame_table[pagetable_get_pfn(v->arch.guest_table)], 1);
     8.8 +                adjust(&frame_table[pagetable_get_pfn(v->arch.guest_table)], !shadow_mode_refcounts(d));
     8.9              if ( pagetable_get_paddr(v->arch.shadow_table) )
    8.10                  adjust(&frame_table[pagetable_get_pfn(v->arch.shadow_table)], 0);
    8.11              if ( v->arch.monitor_shadow_ref )
     9.1 --- a/xen/arch/x86/dom0_ops.c	Tue Nov 08 03:35:25 2005 +0100
     9.2 +++ b/xen/arch/x86/dom0_ops.c	Tue Nov 08 13:30:05 2005 +0100
     9.3 @@ -263,6 +263,7 @@ long arch_do_dom0_op(dom0_op_t *op, dom0
     9.4          if ( unlikely(num > 1024) )
     9.5          {
     9.6              ret = -E2BIG;
     9.7 +            put_domain(d);
     9.8              break;
     9.9          }
    9.10  
    10.1 --- a/xen/arch/x86/mm.c	Tue Nov 08 03:35:25 2005 +0100
    10.2 +++ b/xen/arch/x86/mm.c	Tue Nov 08 13:30:05 2005 +0100
    10.3 @@ -507,7 +507,7 @@ get_page_from_l2e(
    10.4          l2e_get_pfn(l2e), PGT_l1_page_table | vaddr, d);
    10.5  
    10.6  #if CONFIG_PAGING_LEVELS == 2
    10.7 -    if (!rc)
    10.8 +    if ( unlikely(!rc) )
    10.9          rc = get_linear_pagetable(l2e, pfn, d);
   10.10  #endif
   10.11      return rc;
   10.12 @@ -540,7 +540,7 @@ get_page_from_l3e(
   10.13          l3e_get_pfn(l3e),
   10.14          PGT_l2_page_table | vaddr, d);
   10.15  #if CONFIG_PAGING_LEVELS == 3
   10.16 -    if (!rc)
   10.17 +    if ( unlikely(!rc) )
   10.18          rc = get_linear_pagetable(l3e, pfn, d);
   10.19  #endif
   10.20      return rc;
   10.21 @@ -575,9 +575,9 @@ get_page_from_l4e(
   10.22          PGT_l3_page_table | vaddr, d);
   10.23  
   10.24      if ( unlikely(!rc) )
   10.25 -        return get_linear_pagetable(l4e, pfn, d);
   10.26 -
   10.27 -    return 1;
   10.28 +        rc = get_linear_pagetable(l4e, pfn, d);
   10.29 +
   10.30 +    return rc;
   10.31  }
   10.32  
   10.33  #endif /* 4 level */
    11.1 --- a/xen/arch/x86/shadow.c	Tue Nov 08 03:35:25 2005 +0100
    11.2 +++ b/xen/arch/x86/shadow.c	Tue Nov 08 13:30:05 2005 +0100
    11.3 @@ -37,9 +37,11 @@
    11.4  
    11.5  extern void free_shadow_pages(struct domain *d);
    11.6  
    11.7 +#if 0 // this code has not been updated for 32pae & 64 bit modes
    11.8  #if SHADOW_DEBUG
    11.9  static void mark_shadows_as_reflecting_snapshot(struct domain *d, unsigned long gpfn);
   11.10  #endif
   11.11 +#endif
   11.12  
   11.13  #if CONFIG_PAGING_LEVELS == 3
   11.14  #include <asm/shadow_64.h>
   11.15 @@ -898,9 +900,11 @@ mark_mfn_out_of_sync(struct vcpu *v, uns
   11.16      entry->snapshot_mfn = shadow_make_snapshot(d, gpfn, mfn);
   11.17      entry->writable_pl1e = -1;
   11.18  
   11.19 +#if 0 // this code has not been updated for 32pae & 64 bit modes
   11.20  #if SHADOW_DEBUG
   11.21      mark_shadows_as_reflecting_snapshot(d, gpfn);
   11.22  #endif
   11.23 +#endif
   11.24  
   11.25      // increment guest's ref count to represent the entry in the
   11.26      // full shadow out-of-sync list.
   11.27 @@ -1317,18 +1321,17 @@ static int resync_all(struct domain *d, 
   11.28  
   11.29          if ( !smfn )
   11.30          {
   11.31 +            // For heavy weight shadows: no need to update refcounts if
   11.32 +            // there's no shadow page.
   11.33 +            //
   11.34              if ( shadow_mode_refcounts(d) )
   11.35                  continue;
   11.36  
   11.37 -            // For light weight shadows, even when no shadow page exists,
   11.38 -            // we need to resync the refcounts to the new contents of the
   11.39 -            // guest page.
   11.40 -            // This only applies when we have writable page tables.
   11.41 +            // For light weight shadows: only need up resync the refcounts to
   11.42 +            // the new contents of the guest page iff this it has the right
   11.43 +            // page type.
   11.44              //
   11.45 -            if ( !shadow_mode_write_all(d) &&
   11.46 -                 !((stype == PGT_l1_shadow) &&
   11.47 -                   VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) )
   11.48 -                // Page is not writable -- no resync necessary
   11.49 +            if ( stype != ( pfn_to_page(entry->gmfn)->u.inuse.type_info & PGT_type_mask) )
   11.50                  continue;
   11.51          }
   11.52  
   11.53 @@ -1365,8 +1368,8 @@ static int resync_all(struct domain *d, 
   11.54              guest_l1_pgentry_t *snapshot1 = snapshot;
   11.55              int unshadow_l1 = 0;
   11.56  
   11.57 -            ASSERT(VM_ASSIST(d, VMASST_TYPE_writable_pagetables) ||
   11.58 -                   shadow_mode_write_all(d));
   11.59 +            ASSERT(shadow_mode_write_l1(d) ||
   11.60 +                   shadow_mode_write_all(d) || shadow_mode_wr_pt_pte(d));
   11.61  
   11.62              if ( !shadow_mode_refcounts(d) )
   11.63                  revalidate_l1(d, (l1_pgentry_t *)guest1, (l1_pgentry_t *)snapshot1);
   11.64 @@ -1427,7 +1430,7 @@ static int resync_all(struct domain *d, 
   11.65              l2_pgentry_t *shadow2 = shadow;
   11.66              l2_pgentry_t *snapshot2 = snapshot;
   11.67  
   11.68 -            ASSERT(shadow_mode_write_all(d));
   11.69 +            ASSERT(shadow_mode_write_all(d) || shadow_mode_wr_pt_pte(d));
   11.70              BUG_ON(!shadow_mode_refcounts(d)); // not yet implemented
   11.71  
   11.72              changed = 0;
   11.73 @@ -1473,7 +1476,7 @@ static int resync_all(struct domain *d, 
   11.74              l2_pgentry_t *snapshot2 = snapshot;
   11.75              l1_pgentry_t *shadow2 = shadow;
   11.76  
   11.77 -            ASSERT(shadow_mode_write_all(d));
   11.78 +            ASSERT(shadow_mode_write_all(d) || shadow_mode_wr_pt_pte(d));
   11.79              BUG_ON(!shadow_mode_refcounts(d)); // not yet implemented
   11.80  
   11.81              changed = 0;
   11.82 @@ -1822,8 +1825,13 @@ static int shadow_fault_32(unsigned long
   11.83                  goto fail;
   11.84              }
   11.85          }
   11.86 -
   11.87 -        if ( !l1pte_write_fault(v, &gpte, &spte, va) )
   11.88 +        else if ( unlikely(!shadow_mode_wr_pt_pte(d) && mfn_is_page_table(l1e_get_pfn(gpte))) )
   11.89 +        {
   11.90 +            SH_LOG("l1pte_write_fault: no write access to page table page");
   11.91 +            domain_crash_synchronous();
   11.92 +        }
   11.93 +
   11.94 +        if ( unlikely(!l1pte_write_fault(v, &gpte, &spte, va)) )
   11.95          {
   11.96              SH_VVLOG("shadow_fault - EXIT: l1pte_write_fault failed");
   11.97              perfc_incrc(write_fault_bail);
   11.98 @@ -2072,6 +2080,7 @@ static void shadow_update_pagetables(str
   11.99  /************************************************************************/
  11.100  /************************************************************************/
  11.101  
  11.102 +#if 0 // this code has not been updated for 32pae & 64 bit modes
  11.103  #if SHADOW_DEBUG
  11.104  
  11.105  // The following is entirely for _check_pagetable()'s benefit.
  11.106 @@ -2118,8 +2127,8 @@ mark_shadows_as_reflecting_snapshot(stru
  11.107  // BUG: these are not SMP safe...
  11.108  static int sh_l2_present;
  11.109  static int sh_l1_present;
  11.110 -char * sh_check_name;
  11.111 -int shadow_status_noswap;
  11.112 +static char *sh_check_name;
  11.113 +// int shadow_status_noswap; // declared in shadow32.c
  11.114  
  11.115  #define v2m(_v, _adr) ({                                                     \
  11.116      unsigned long _a  = (unsigned long)(_adr);                               \
  11.117 @@ -2218,11 +2227,11 @@ static int check_pte(
  11.118  
  11.119      guest_writable =
  11.120          (l1e_get_flags(eff_guest_pte) & _PAGE_RW) ||
  11.121 -        (VM_ASSIST(d, VMASST_TYPE_writable_pagetables) && (level == 1) && mfn_out_of_sync(eff_guest_mfn));
  11.122 +        (shadow_mode_write_l1(d) && (level == 1) && mfn_out_of_sync(eff_guest_mfn));
  11.123  
  11.124      if ( (l1e_get_flags(shadow_pte) & _PAGE_RW ) && !guest_writable )
  11.125      {
  11.126 -        printk("eff_guest_pfn=%lx eff_guest_mfn=%lx shadow_mfn=%lx t=0x%08x page_table_page=%d\n",
  11.127 +        printk("eff_guest_pfn=%lx eff_guest_mfn=%lx shadow_mfn=%lx t=0x%08lx page_table_page=%d\n",
  11.128                 eff_guest_pfn, eff_guest_mfn, shadow_mfn,
  11.129                 frame_table[eff_guest_mfn].u.inuse.type_info,
  11.130                 page_table_page);
  11.131 @@ -2233,7 +2242,7 @@ static int check_pte(
  11.132           (l1e_get_flags(shadow_pte) & _PAGE_RW ) &&
  11.133           !(guest_writable && (l1e_get_flags(eff_guest_pte) & _PAGE_DIRTY)) )
  11.134      {
  11.135 -        printk("eff_guest_pfn=%lx eff_guest_mfn=%lx shadow_mfn=%lx t=0x%08x page_table_page=%d\n",
  11.136 +        printk("eff_guest_pfn=%lx eff_guest_mfn=%lx shadow_mfn=%lx t=0x%08lx page_table_page=%d\n",
  11.137                 eff_guest_pfn, eff_guest_mfn, shadow_mfn,
  11.138                 frame_table[eff_guest_mfn].u.inuse.type_info,
  11.139                 page_table_page);
  11.140 @@ -2393,13 +2402,12 @@ static int check_l2_table(
  11.141  }
  11.142  #undef FAILPT
  11.143  
  11.144 -static int _check_pagetable(struct vcpu *v, char *s)
  11.145 +int _check_pagetable(struct vcpu *v, char *s)
  11.146  {
  11.147      struct domain *d = v->domain;
  11.148  #if defined (__x86_64__)
  11.149      pagetable_t pt = ((v->arch.flags & TF_kernel_mode)?
  11.150 -                      pagetable_get_pfn(v->arch.guest_table) :
  11.151 -                      pagetable_get_pfn(v->arch.guest_table_user));
  11.152 +                      v->arch.guest_table : v->arch.guest_table_user);
  11.153  #else
  11.154      pagetable_t pt = v->arch.guest_table;
  11.155  #endif
  11.156 @@ -2539,6 +2547,7 @@ int _check_all_pagetables(struct vcpu *v
  11.157  }
  11.158  
  11.159  #endif // SHADOW_DEBUG
  11.160 +#endif // this code has not been updated for 32pae & 64 bit modes
  11.161  
  11.162  #if CONFIG_PAGING_LEVELS == 3
  11.163  static unsigned long shadow_l3_table(
    12.1 --- a/xen/arch/x86/shadow32.c	Tue Nov 08 03:35:25 2005 +0100
    12.2 +++ b/xen/arch/x86/shadow32.c	Tue Nov 08 13:30:05 2005 +0100
    12.3 @@ -624,6 +624,14 @@ static void free_shadow_pages(struct dom
    12.4      // under us...  First, collect the list of pinned pages, then
    12.5      // free them.
    12.6      //
    12.7 +    // FIXME: it would be good to just free all the pages referred to in
    12.8 +    // the hash table without going through each of them to decrement their
    12.9 +    // reference counts.  In shadow_mode_refcount(), we've gotta do the hard
   12.10 +    // work, but only for L1 shadows.  If we're not in refcount mode, then
   12.11 +    // there's no real hard work to do at all.  Need to be careful with the
   12.12 +    // writable_pte_predictions and snapshot entries in the hash table, but
   12.13 +    // that's about it.
   12.14 +    //
   12.15      for ( i = 0; i < shadow_ht_buckets; i++ )
   12.16      {
   12.17          u32 count;
   12.18 @@ -634,17 +642,51 @@ static void free_shadow_pages(struct dom
   12.19              continue;
   12.20  
   12.21          count = 0;
   12.22 -        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
   12.23 -            if ( MFN_PINNED(x->smfn) )
   12.24 -                count++;
   12.25 +
   12.26 +        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
   12.27 +	    /* Skip entries that are writable_pred) */
   12.28 +	    switch(x->gpfn_and_flags & PGT_type_mask){
   12.29 +		case PGT_l1_shadow:
   12.30 +		case PGT_l2_shadow:
   12.31 +		case PGT_l3_shadow:
   12.32 +		case PGT_l4_shadow:
   12.33 +		case PGT_hl2_shadow:
   12.34 +		    if ( MFN_PINNED(x->smfn) )
   12.35 +			count++;
   12.36 +		    break;
   12.37 +		case PGT_snapshot:
   12.38 +		case PGT_writable_pred:
   12.39 +		    break;
   12.40 +		default:
   12.41 +		    BUG();
   12.42 +
   12.43 +	    }
   12.44 +	}
   12.45 +
   12.46          if ( !count )
   12.47              continue;
   12.48  
   12.49          mfn_list = xmalloc_array(unsigned long, count);
   12.50          count = 0;
   12.51 -        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next )
   12.52 -            if ( MFN_PINNED(x->smfn) )
   12.53 -                mfn_list[count++] = x->smfn;
   12.54 +        for ( x = &d->arch.shadow_ht[i]; x != NULL; x = x->next ) {
   12.55 +	    /* Skip entries that are writable_pred) */
   12.56 +	    switch(x->gpfn_and_flags & PGT_type_mask){
   12.57 +		case PGT_l1_shadow:
   12.58 +		case PGT_l2_shadow:
   12.59 +		case PGT_l3_shadow:
   12.60 +		case PGT_l4_shadow:
   12.61 +		case PGT_hl2_shadow:
   12.62 +		    if ( MFN_PINNED(x->smfn) )
   12.63 +			mfn_list[count++] = x->smfn;
   12.64 +		    break;
   12.65 +		case PGT_snapshot:
   12.66 +		case PGT_writable_pred:
   12.67 +		    break;
   12.68 +		default:
   12.69 +		    BUG();
   12.70 +
   12.71 +	    }
   12.72 +	}
   12.73  
   12.74          while ( count )
   12.75          {
   12.76 @@ -779,6 +821,7 @@ set_p2m_entry(struct domain *d, unsigned
   12.77      unsigned long va = pfn << PAGE_SHIFT;
   12.78  
   12.79      ASSERT(tabpfn != 0);
   12.80 +    ASSERT(shadow_lock_is_acquired(d));
   12.81  
   12.82      l2 = map_domain_page_with_cache(tabpfn, l2cache);
   12.83      l2e = l2[l2_table_offset(va)];
   12.84 @@ -2037,7 +2080,12 @@ free_writable_pte_predictions(struct dom
   12.85          while ( count )
   12.86          {
   12.87              count--;
   12.88 +            /* delete_shadow_status() may do a shadow_audit(), so we need to
   12.89 +             * keep an accurate count of writable_pte_predictions to keep it
   12.90 +             * happy.
   12.91 +             */
   12.92              delete_shadow_status(d, gpfn_list[count], 0, PGT_writable_pred);
   12.93 +            perfc_decr(writable_pte_predictions);
   12.94          }
   12.95  
   12.96          xfree(gpfn_list);
   12.97 @@ -2273,18 +2321,17 @@ static int resync_all(struct domain *d, 
   12.98  
   12.99          if ( !smfn )
  12.100          {
  12.101 +            // For heavy weight shadows: no need to update refcounts if
  12.102 +            // there's no shadow page.
  12.103 +            //
  12.104              if ( shadow_mode_refcounts(d) )
  12.105                  continue;
  12.106  
  12.107 -            // For light weight shadows, even when no shadow page exists,
  12.108 -            // we need to resync the refcounts to the new contents of the
  12.109 -            // guest page.
  12.110 -            // This only applies when we have writable page tables.
  12.111 +            // For light weight shadows: only need up resync the refcounts to
  12.112 +            // the new contents of the guest page iff this it has the right
  12.113 +            // page type.
  12.114              //
  12.115 -            if ( !shadow_mode_write_all(d) &&
  12.116 -                 !((stype == PGT_l1_shadow) &&
  12.117 -                   VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) )
  12.118 -                // Page is not writable -- no resync necessary
  12.119 +            if ( stype != ( pfn_to_page(entry->gmfn)->u.inuse.type_info & PGT_type_mask) )
  12.120                  continue;
  12.121          }
  12.122  
  12.123 @@ -2312,8 +2359,8 @@ static int resync_all(struct domain *d, 
  12.124              l1_pgentry_t *snapshot1 = snapshot;
  12.125              int unshadow_l1 = 0;
  12.126  
  12.127 -            ASSERT(VM_ASSIST(d, VMASST_TYPE_writable_pagetables) ||
  12.128 -                   shadow_mode_write_all(d));
  12.129 +            ASSERT(shadow_mode_write_l1(d) ||
  12.130 +                   shadow_mode_write_all(d) || shadow_mode_wr_pt_pte(d));
  12.131  
  12.132              if ( !shadow_mode_refcounts(d) )
  12.133                  revalidate_l1(d, guest1, snapshot1);
  12.134 @@ -2380,7 +2427,7 @@ static int resync_all(struct domain *d, 
  12.135              l2_pgentry_t *shadow2 = shadow;
  12.136              l2_pgentry_t *snapshot2 = snapshot;
  12.137  
  12.138 -            ASSERT(shadow_mode_write_all(d));
  12.139 +            ASSERT(shadow_mode_write_all(d) || shadow_mode_wr_pt_pte(d));
  12.140              BUG_ON(!shadow_mode_refcounts(d)); // not yet implemented
  12.141  
  12.142              changed = 0;
  12.143 @@ -2426,7 +2473,7 @@ static int resync_all(struct domain *d, 
  12.144              l2_pgentry_t *snapshot2 = snapshot;
  12.145              l1_pgentry_t *shadow2 = shadow;
  12.146              
  12.147 -            ASSERT(shadow_mode_write_all(d));
  12.148 +            ASSERT(shadow_mode_write_all(d) || shadow_mode_wr_pt_pte(d));
  12.149              BUG_ON(!shadow_mode_refcounts(d)); // not yet implemented
  12.150  
  12.151              changed = 0;
  12.152 @@ -2619,8 +2666,13 @@ int shadow_fault(unsigned long va, struc
  12.153                  goto fail;
  12.154              }
  12.155          }
  12.156 -
  12.157 -        if ( !l1pte_write_fault(v, &gpte, &spte, va) )
  12.158 +        else if ( unlikely(!shadow_mode_wr_pt_pte(d) && mfn_is_page_table(l1e_get_pfn(gpte))) )
  12.159 +        {
  12.160 +            SH_LOG("l1pte_write_fault: no write access to page table page");
  12.161 +            domain_crash_synchronous();
  12.162 +        }
  12.163 +
  12.164 +        if ( unlikely(!l1pte_write_fault(v, &gpte, &spte, va)) )
  12.165          {
  12.166              SH_VVLOG("shadow_fault - EXIT: l1pte_write_fault failed");
  12.167              perfc_incrc(write_fault_bail);
  12.168 @@ -2954,7 +3006,7 @@ mark_shadows_as_reflecting_snapshot(stru
  12.169  // BUG: these are not SMP safe...
  12.170  static int sh_l2_present;
  12.171  static int sh_l1_present;
  12.172 -char * sh_check_name;
  12.173 +static char *sh_check_name;
  12.174  int shadow_status_noswap;
  12.175  
  12.176  #define v2m(_v, _adr) ({                                                     \
  12.177 @@ -3054,7 +3106,7 @@ static int check_pte(
  12.178  
  12.179      guest_writable =
  12.180          (l1e_get_flags(eff_guest_pte) & _PAGE_RW) ||
  12.181 -        (VM_ASSIST(d, VMASST_TYPE_writable_pagetables) && (level == 1) && mfn_out_of_sync(eff_guest_mfn));
  12.182 +        (shadow_mode_write_l1(d) && (level == 1) && mfn_out_of_sync(eff_guest_mfn));
  12.183  
  12.184      if ( (l1e_get_flags(shadow_pte) & _PAGE_RW ) && !guest_writable )
  12.185      {
    13.1 --- a/xen/arch/x86/vmx.c	Tue Nov 08 03:35:25 2005 +0100
    13.2 +++ b/xen/arch/x86/vmx.c	Tue Nov 08 13:30:05 2005 +0100
    13.3 @@ -79,7 +79,7 @@ void vmx_final_setup_guest(struct vcpu *
    13.4           * the shared 1:1 page table initially. It shouldn't hurt */
    13.5          shadow_mode_enable(v->domain,
    13.6                             SHM_enable|SHM_refcounts|
    13.7 -                           SHM_translate|SHM_external);
    13.8 +                           SHM_translate|SHM_external|SHM_wr_pt_pte);
    13.9      }
   13.10  
   13.11      vmx_switch_on = 1;
    14.1 --- a/xen/include/asm-x86/page.h	Tue Nov 08 03:35:25 2005 +0100
    14.2 +++ b/xen/include/asm-x86/page.h	Tue Nov 08 13:30:05 2005 +0100
    14.3 @@ -271,6 +271,9 @@ extern void paging_init(void);
    14.4  #define _PAGE_PAT      0x080U
    14.5  #define _PAGE_PSE      0x080U
    14.6  #define _PAGE_GLOBAL   0x100U
    14.7 +#define _PAGE_AVAIL0   0x200U
    14.8 +#define _PAGE_AVAIL1   0x400U
    14.9 +#define _PAGE_AVAIL2   0x800U
   14.10  #define _PAGE_AVAIL    0xE00U
   14.11  
   14.12  #define __PAGE_HYPERVISOR \
    15.1 --- a/xen/include/asm-x86/shadow.h	Tue Nov 08 03:35:25 2005 +0100
    15.2 +++ b/xen/include/asm-x86/shadow.h	Tue Nov 08 13:30:05 2005 +0100
    15.3 @@ -45,15 +45,21 @@
    15.4  #define SHM_write_all (1<<2) /* allow write access to all guest pt pages,
    15.5                                  regardless of pte write permissions */
    15.6  #define SHM_log_dirty (1<<3) /* enable log dirty mode */
    15.7 -#define SHM_translate (1<<4) /* do p2m tranaltion on guest tables */
    15.8 -#define SHM_external  (1<<5) /* external page table, not used by Xen */
    15.9 +#define SHM_translate (1<<4) /* Xen does p2m translation, not guest */
   15.10 +#define SHM_external  (1<<5) /* Xen does not steal address space from the
   15.11 +                                domain for its own booking; requires VT or
   15.12 +                                similar mechanisms */
   15.13 +#define SHM_wr_pt_pte (1<<6) /* guest allowed to set PAGE_RW bit in PTEs which
   15.14 +                                point to page table pages. */
   15.15  
   15.16  #define shadow_mode_enabled(_d)   ((_d)->arch.shadow_mode)
   15.17  #define shadow_mode_refcounts(_d) ((_d)->arch.shadow_mode & SHM_refcounts)
   15.18 +#define shadow_mode_write_l1(_d)  (VM_ASSIST(_d, VMASST_TYPE_writable_pagetables))
   15.19  #define shadow_mode_write_all(_d) ((_d)->arch.shadow_mode & SHM_write_all)
   15.20  #define shadow_mode_log_dirty(_d) ((_d)->arch.shadow_mode & SHM_log_dirty)
   15.21  #define shadow_mode_translate(_d) ((_d)->arch.shadow_mode & SHM_translate)
   15.22  #define shadow_mode_external(_d)  ((_d)->arch.shadow_mode & SHM_external)
   15.23 +#define shadow_mode_wr_pt_pte(_d) ((_d)->arch.shadow_mode & SHM_wr_pt_pte)
   15.24  
   15.25  #define shadow_linear_pg_table ((l1_pgentry_t *)SH_LINEAR_PT_VIRT_START)
   15.26  #define __shadow_linear_l2_table ((l2_pgentry_t *)(SH_LINEAR_PT_VIRT_START + \
   15.27 @@ -324,8 +330,7 @@ struct out_of_sync_entry {
   15.28  
   15.29  #if SHADOW_DEBUG
   15.30  extern int shadow_status_noswap;
   15.31 -#define _SHADOW_REFLECTS_SNAPSHOT ( 9)
   15.32 -#define SHADOW_REFLECTS_SNAPSHOT  (1u << _SHADOW_REFLECTS_SNAPSHOT)
   15.33 +#define SHADOW_REFLECTS_SNAPSHOT _PAGE_AVAIL0
   15.34  #endif
   15.35  
   15.36  #ifdef VERBOSE
   15.37 @@ -1474,7 +1479,8 @@ static inline void set_shadow_status(
   15.38              if ( stype != PGT_writable_pred )
   15.39                  BUG(); // we should never replace entries into the hash table
   15.40              x->smfn = smfn;
   15.41 -            put_page(pfn_to_page(gmfn)); // already had a ref...
   15.42 +            if ( stype != PGT_writable_pred )
   15.43 +                put_page(pfn_to_page(gmfn)); // already had a ref...
   15.44              goto done;
   15.45          }
   15.46  
   15.47 @@ -1656,14 +1662,18 @@ shadow_mode_page_writable(unsigned long 
   15.48           (type == PGT_writable_page) )
   15.49          type = shadow_max_pgtable_type(d, gpfn, NULL);
   15.50  
   15.51 -    if ( VM_ASSIST(d, VMASST_TYPE_writable_pagetables) &&
   15.52 -         (type == PGT_l1_page_table) &&
   15.53 -         (va < HYPERVISOR_VIRT_START) &&
   15.54 -         KERNEL_MODE(v, regs) )
   15.55 -        return 1;
   15.56 -
   15.57 -    if ( shadow_mode_write_all(d) &&
   15.58 -         type && (type <= PGT_l4_page_table) &&
   15.59 +    // Strange but true: writable page tables allow kernel-mode access
   15.60 +    // to L1 page table pages via write-protected PTEs...  Similarly, write 
   15.61 +    // access to all page table pages is granted for shadow_mode_write_all
   15.62 +    // clients.
   15.63 +    //
   15.64 +    if ( ((shadow_mode_write_l1(d) && (type == PGT_l1_page_table)) ||
   15.65 +          (shadow_mode_write_all(d) && type && (type <= PGT_l4_page_table))) &&
   15.66 +         ((va < HYPERVISOR_VIRT_START)
   15.67 +#if defined(__x86_64__)
   15.68 +          || (va >= HYPERVISOR_VIRT_END)
   15.69 +#endif
   15.70 +             ) &&
   15.71           KERNEL_MODE(v, regs) )
   15.72          return 1;
   15.73