[IA64] Don't share privregs with hvm domain
authorAlex Williamson <alex.williamson@hp.com>
Mon, 22 Oct 2007 18:26:53 +0000 (12:26 -0600)
committerAlex Williamson <alex.williamson@hp.com>
Mon, 22 Oct 2007 18:26:53 +0000 (12:26 -0600)
Don't share privregs with hvm domain and twist IA64 xen dump core format
slightly.  Xen shares privregs pages with IA64 HVM domain for xm dump-core
to dump the pages.  However sharing the page allows hvm guest domain
peek/destroy the page contents that might cause xen crash.  And the xen
dump core file doesn't need privregs page because cpu context should be
obtained from vcpu context in case of IA64 HVM domain.

Although this patch modify xen dump core format, current crash utility
(at least crash 4.0-4.7) doesn't look into .xen_ia64_mmapped_regs section
and I don't know any other tools to understand xen dump core file.
So this format modification doesn't cause incompatibility issue.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
docs/misc/dump-core-format.txt
tools/libxc/xc_core.c
tools/libxc/xc_core_ia64.c
xen/arch/ia64/vmx/vmx_init.c
xen/arch/ia64/xen/domain.c
xen/include/asm-ia64/domain.h
xen/include/public/arch-ia64.h

index aa32d810d877653dcdff20a440d058131ed579fb..bc1842c7472104684d411939f5c7a87b0e48500f 100644 (file)
@@ -127,8 +127,10 @@ Currently the following sections are defined. Some sections are optional.
                 This section stores the array of mapped_regs_t.
                 The size of array is stored in xch_nr_vcpus member of header
                 note descriptor in .note.Xen note section.
-                This section is ia64 specific and must exist for ia64 domain.
-                This section must not exist for non-ia64 domain.
+                This section is ia64 specific and must exist for ia64 PV 
+                domain.
+                This section must not exist for non-ia64 domain or ia64 HVM
+                domain.
 
 
 note section
@@ -237,3 +239,5 @@ Currently only (major, minor) = (0, 1) is used.
 - EI_CLASS member of elf header was changed to ELFCLASS64 independent of
   architecture. This is mainly for x86_32pae.
   The format version isn't bumped because analysis tools can distinguish it.
+- .xen_ia64_mapped_regs section was made only for ia64 PV domain.
+  In case of IA64 HVM domain, this section doesn't exist.
index a939e95c7587b5dd4fbe318b9c1ba83009ef3ba7..edcf67cfc07ac4fb029b1e41b5d919309814e180 100644 (file)
@@ -32,7 +32,7 @@
  *  |.xen_prstatus                                           |
  *  |       vcpu_guest_context_t[nr_vcpus]                   |
  *  +--------------------------------------------------------+
- *  |.xen_ia64_mmapped_regs if ia64                          |
+ *  |.xen_ia64_mmapped_regs if ia64 pv                       |
  *  |       mmapped_regs_t[nr_vcpus]                         |
  *  +--------------------------------------------------------+
  *  |.xen_shared_info if possible                            |
index 443578a0a8ff82b078321b81f62bf8066afddc3f..bd233cd1a69d9bd5911743b1fcd1bdc21a6fc51f 100644 (file)
@@ -312,6 +312,10 @@ xc_core_arch_context_get(struct xc_core_arch_context* arch_ctxt,
                          int xc_handle, uint32_t domid)
 {
     mapped_regs_t* mapped_regs;
+
+    if ( ctxt->privregs_pfn == VGC_PRIVREGS_HVM )
+        return 0;       /* VTi domain case */
+
     if ( ctxt->privregs_pfn == INVALID_P2M_ENTRY )
     {
         PERROR("Could not get mmapped privregs gmfn");
@@ -340,6 +344,13 @@ xc_core_arch_context_get_shdr(struct xc_core_arch_context *arch_ctxt,
     int sts = -1;
     Elf64_Shdr *shdr;
 
+    if ( arch_ctxt->nr_vcpus == 0 )
+    {
+        /* VTi domain case */
+        *filesz = 0;
+        return 0;       
+    }
+
     /* mmapped priv regs */
     shdr = xc_core_shdr_get(sheaders);
     if ( shdr == NULL )
index f29f9cfe301f3bad0cd2d727abd474d09e27f575..a1f03b64d17fcca7e7ac43d28d9bce3bf206dc65 100644 (file)
@@ -309,7 +309,6 @@ vmx_final_setup_guest(struct vcpu *v)
                return -ENOMEM;
 
        v->arch.privregs = (mapped_regs_t *)vpd;
-       vcpu_share_privregs_with_guest(v);
        vpd->vpd_low.virt_env_vaddr = vm_buffer;
     
        v->domain->arch.vmx_platform.gos_type = OS_UNKNOWN;
index 8a8d2cd74bfdba768bf560f5103b9eeeaa8b289d..f8e3bff5ebcd3e34bdd8afb0864383eca84f4a29 100644 (file)
@@ -470,7 +470,7 @@ int vcpu_initialise(struct vcpu *v)
        return 0;
 }
 
-void vcpu_share_privregs_with_guest(struct vcpu *v)
+static void vcpu_share_privregs_with_guest(struct vcpu *v)
 {
        struct domain *d = v->domain;
        int i, order = get_order_from_shift(XMAPPEDREGS_SHIFT); 
@@ -939,8 +939,11 @@ void arch_get_info_guest(struct vcpu *v, vcpu_guest_context_u c)
                c.nat->regs.rbs_rnat &= ~((1UL << bottom_slot) - 1);
        }
 
-       c.nat->privregs_pfn = get_gpfn_from_mfn
-               (virt_to_maddr(v->arch.privregs) >> PAGE_SHIFT);
+       if (VMX_DOMAIN(v))
+               c.nat->privregs_pfn = VGC_PRIVREGS_HVM;
+       else
+               c.nat->privregs_pfn = get_gpfn_from_mfn(
+                       virt_to_maddr(v->arch.privregs) >> PAGE_SHIFT);
 
        for (i = 0; i < IA64_NUM_DBG_REGS; i++) {
                if (VMX_DOMAIN(v)) {
index 7d2b5be64a056f1020dcedfb81b7a1857a669040..68e5256f048af72fd61b80d3d3b29b554e57bb48 100644 (file)
@@ -20,7 +20,6 @@ struct tlb_track;
 
 struct vcpu;
 extern void relinquish_vcpu_resources(struct vcpu *v);
-extern void vcpu_share_privregs_with_guest(struct vcpu *v);
 extern int vcpu_late_initialise(struct vcpu *v);
 
 /* given a current domain metaphysical address, return the physical address */
index d65a48631a3776962ffe970a64408c5747739482..511998bca00ede6eeccd949b23788f925975d0ae 100644 (file)
@@ -427,6 +427,11 @@ struct vcpu_guest_context {
     struct vcpu_guest_context_regs regs;
 
     unsigned long event_callback_ip;
+
+    /* xen doesn't share privregs pages with hvm domain so that this member
+     * doesn't make sense for hvm domain.
+     * ~0UL is already used for INVALID_P2M_ENTRY. */
+#define VGC_PRIVREGS_HVM       (~(-2UL))
     unsigned long privregs_pfn;
 };
 typedef struct vcpu_guest_context vcpu_guest_context_t;