direct-io.hg

changeset 14323:ca7cd6752cc2

dump-core: store .xen_p2m or .xen_pfn section in pfn ascending order.
So far the order isn't specified and may be random in theory.
But sorted array is requested by crash utility for efficient search.

Fortunately it is the case except ia64 full virtualized domain.
Update document such that those array must be sorted and fix the ia64
full virtualized domain case.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author kfraser@localhost.localdomain
date Fri Mar 09 18:33:36 2007 +0000 (2007-03-09)
parents 2d4df044d7de
children 188bab059272
files docs/misc/dump-core-format.txt tools/libxc/xc_core_ia64.c tools/libxc/xc_ptrace_core.c
line diff
     1.1 --- a/docs/misc/dump-core-format.txt	Fri Mar 09 18:32:20 2007 +0000
     1.2 +++ b/docs/misc/dump-core-format.txt	Fri Mar 09 18:33:36 2007 +0000
     1.3 @@ -80,8 +80,7 @@ Currently the following sections are def
     1.4                          gmfn:   machine physical frame number
     1.5                  The size of arrays is stored in xch_nr_pages member of header
     1.6                  note descriptor in .note.Xen note section.
     1.7 -                There is no rule about the order. Analysis tools must no rely
     1.8 -                on its order.
     1.9 +                The entryies are stored in pfn-ascending order.
    1.10                  This section must exist when the domain is non auto
    1.11                  translated physmap mode. Currently x86 paravirtualized domain.
    1.12  
    1.13 @@ -94,8 +93,7 @@ Currently the following sections are def
    1.14                  in .xen_pages section.
    1.15                  The size of arrays is stored in xch_nr_pages member of header
    1.16                  note descriptor in .note.Xen note section.
    1.17 -                There is no rule about the order. Analysis tools must no rely
    1.18 -                on its order.
    1.19 +                The entries are stored in ascending order.
    1.20                  This section must exist when the domain is auto translated
    1.21                  physmap mode. Currently x86 full virtualized domain and
    1.22                  ia64 domain.
    1.23 @@ -226,6 +224,8 @@ Currently only (major, minor) = (0, 1) i
    1.24  [When the format is changed, it would be described here.]
    1.25  
    1.26  (0, 1) update
    1.27 +- .xen_p2m, .xen_pfn section
    1.28 +  Arrays must be in pfn ascending order for efficient looking up.
    1.29  - EI_CLASS member of elf header was changed to ELFCLASS64 independent of
    1.30    architecture. This is mainly for x86_32pae.
    1.31    The format version isn't bumped because analysis tools can distinguish it.
     2.1 --- a/tools/libxc/xc_core_ia64.c	Fri Mar 09 18:32:20 2007 +0000
     2.2 +++ b/tools/libxc/xc_core_ia64.c	Fri Mar 09 18:33:36 2007 +0000
     2.3 @@ -22,6 +22,28 @@
     2.4  #include "xc_core.h"
     2.5  #include "xc_efi.h"
     2.6  #include "xc_dom.h"
     2.7 +#include <inttypes.h>
     2.8 +
     2.9 +static int
    2.10 +xc_memory_map_cmp(const void *lhs__, const void *rhs__)
    2.11 +{
    2.12 +    const struct xc_core_memory_map *lhs =
    2.13 +        (const struct xc_core_memory_map *)lhs__;
    2.14 +    const struct xc_core_memory_map *rhs =
    2.15 +        (const struct xc_core_memory_map *)rhs__;
    2.16 +
    2.17 +    if (lhs->addr < rhs->addr)
    2.18 +        return -1;
    2.19 +    if (lhs->addr > rhs->addr)
    2.20 +        return 1;
    2.21 +
    2.22 +    /* memory map overlap isn't allowed. complain */
    2.23 +    DPRINTF("duplicated addresses are detected "
    2.24 +            "(0x%" PRIx64 ", 0x%" PRIx64 "), "
    2.25 +            "(0x%" PRIx64 ", 0x%" PRIx64 ")\n",
    2.26 +            lhs->addr, lhs->size, rhs->addr, rhs->size);
    2.27 +    return 0;
    2.28 +}
    2.29  
    2.30  int
    2.31  xc_core_arch_auto_translated_physmap(const xc_dominfo_t *info)
    2.32 @@ -111,6 +133,7 @@ memory_map_get_old_hvm(int xc_handle, xc
    2.33      }
    2.34      *mapp = map;
    2.35      *nr_entries = i;
    2.36 +    qsort(map, *nr_entries, sizeof(map[0]), &xc_memory_map_cmp);
    2.37      return 0;
    2.38  
    2.39  out:
    2.40 @@ -196,6 +219,7 @@ xc_core_arch_memory_map_get(int xc_handl
    2.41      ret = 0;
    2.42  out:
    2.43      munmap(memmap_info, PAGE_SIZE);
    2.44 +    qsort(map, *nr_entries, sizeof(map[0]), &xc_memory_map_cmp);
    2.45      return ret;
    2.46      
    2.47  old:
     3.1 --- a/tools/libxc/xc_ptrace_core.c	Fri Mar 09 18:32:20 2007 +0000
     3.2 +++ b/tools/libxc/xc_ptrace_core.c	Fri Mar 09 18:33:36 2007 +0000
     3.3 @@ -390,7 +390,6 @@ map_gmfn_to_offset_elf(unsigned long gmf
     3.4  {
     3.5      /* 
     3.6       * linear search
     3.7 -     * There is no gurantee that those tables are sorted.
     3.8       */
     3.9      unsigned long i;
    3.10      if (current_is_auto_translated_physmap) {