Skip to content
Snippets Groups Projects
  1. Jun 20, 2016
  2. Mar 22, 2016
  3. Feb 22, 2016
  4. Feb 04, 2016
    • Peter Maydell's avatar
      all: Clean up includes · d38ea87a
      Peter Maydell authored
      
      Clean up includes so that osdep.h is included first and headers
      which it implies are not included manually.
      
      This commit was created with scripts/clean-includes.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
      d38ea87a
  5. Jan 15, 2016
  6. Jun 22, 2015
  7. Nov 02, 2014
    • Gonglei (Arei)'s avatar
      dump: Fix dump-guest-memory termination and use-after-close · 08a655be
      Gonglei (Arei) authored
      
      dump_iterate() dumps blocks in a loop.  Eventually, get_next_block()
      returns "no more".  We then call dump_completed().  But we neglect to
      break the loop!  Broken in commit 4c7e251a.
      
      Because of that, we dump the last block again.  This attempts to write
      to s->fd, which fails if we're lucky.  The error makes dump_iterate()
      return failure.  It's the only way it can ever return.
      
      Theoretical: if we're not so lucky, something else has opened something
      for writing and got the same fd.  dump_iterate() then keeps looping,
      messing up the something else's output, until a write fails, or the
      process mercifully terminates.
      
      The obvious fix is to restore the return lost in commit 4c7e251a.  But
      the root cause of the bug is needlessly opaque loop control.  Replace it
      by a clean do ... while loop.
      
      This makes the badly chosen return values of get_next_block() more
      visible.  Cleaning that up is outside the scope of this bug fix.
      
      Signed-off-by: default avatarGonglei <arei.gonglei@huawei.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
      08a655be
  8. Oct 23, 2014
  9. Aug 18, 2014
  10. Jun 16, 2014
  11. Jun 11, 2014
    • Laszlo Ersek's avatar
      dump: simplify get_len_buf_out() · b87ef351
      Laszlo Ersek authored
      
      We can (and should) rely on the fact that s->flag_compress is exactly one
      of DUMP_DH_COMPRESSED_ZLIB, DUMP_DH_COMPRESSED_LZO, and
      DUMP_DH_COMPRESSED_SNAPPY.
      
      This is ensured by the QMP schema and dump_init() in combination.
      
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      b87ef351
    • Laszlo Ersek's avatar
      dump: hoist lzo_init() from get_len_buf_out() to dump_init() · c998acb0
      Laszlo Ersek authored
      
      qmp_dump_guest_memory()
        dump_init()
          lzo_init() <---------+
        create_kdump_vmcore()  |
          write_dump_pages()   |
            get_len_buf_out()  |
              lzo_init() ------+
      
      This patch doesn't change the fact that lzo_init() is called for every
      LZO-compressed dump, but it makes get_len_buf_out() more focused (single
      responsibility).
      
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      c998acb0
    • Laszlo Ersek's avatar
      dump: select header bitness based on ELF class, not ELF architecture · 24aeeace
      Laszlo Ersek authored
      
      The specific ELF architecture (d_machine) carries Too Much Information
      (TM) for deciding between create_header32() and create_header64(), use
      "d_class" instead (ELFCLASS32 vs. ELFCLASS64).
      
      This change adapts write_dump_header() to write_elf_loads(), dump_begin()
      etc. that also rely on the ELF class of the target for bitness selection.
      
      Considering the current targets that support dumping, cpu_get_dump_info()
      works as follows:
      - target-s390x/arch_dump.c: (EM_S390, ELFCLASS64) only
      - target-ppc/arch_dump.c (EM_PPC64, ELFCLASS64) only
      - target-i386/arch_dump.c: sets (EM_X86_64, ELFCLASS64) vs. (EM_386,
        ELFCLASS32) keying off the same Long Mode Active flag.
      
      Hence no observable change.
      
      Approximately-suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      24aeeace
    • Laszlo Ersek's avatar
      dump: eliminate DumpState.page_size ("guest's page size") · 2f859f80
      Laszlo Ersek authored
      
      Use TARGET_PAGE_SIZE and ~TARGET_PAGE_MASK instead.
      
      "DumpState.page_size" has type "size_t", whereas TARGET_PAGE_SIZE has type
      "int". TARGET_PAGE_MASK is of type "int" and has negative value. The patch
      affects the implicit type conversions as follows:
      
      - create_header32() and create_header64(): assigned to "block_size", which
        has type "uint32_t". No change.
      
      - get_next_page(): "block->target_start", "block->target_end" and "addr"
        have type "hwaddr" (uint64_t).
      
        Before the patch,
        - if "size_t" was "uint64_t", then no additional conversion was done as
          part of the usual arithmetic conversions,
        - If "size_t" was "uint32_t", then it was widened to uint64_t as part of
          the usual arithmetic conversions,
        for the remainder and addition operators.
      
        After the patch,
        - "~TARGET_PAGE_MASK" expands to  ~~((1 << TARGET_PAGE_BITS) - 1). It
          has type "int" and positive value (only least significant bits set).
          That's converted (widened) to "uint64_t" for the bit-ands. No visible
          change.
        - The same holds for the (addr + TARGET_PAGE_SIZE) addition.
      
      - write_dump_pages():
        - TARGET_PAGE_SIZE passed as argument to a bunch of functions that all
          have prototypes. No change.
      
        - When incrementing "offset_data" (of type "off_t"): given that we never
          build for ILP32_OFF32 (see "-D_FILE_OFFSET_BITS=64" in configure),
          "off_t" is always "int64_t", and we only need to consider:
          - ILP32_OFFBIG: "size_t" is "uint32_t".
            - before: int64_t += uint32_t. Page size converted to int64_t for
              the addition.
            - after:  int64_t += int32_t. No change.
          - LP64_OFF64: "size_t" is "uint64_t".
            - before: int64_t += uint64_t. Offset converted to uint64_t for the
              addition, then the uint64_t result is converted to int64_t for
              storage.
            - after:  int64_t += int32_t. Same as the ILP32_OFFBIG/after case.
              No visible change.
      
        - (size_out < s->page_size) comparisons, and (size_out = s->page_size)
          assignment:
          - before: "size_out" is of type "size_t", no implicit conversion for
                    either operator.
          - after: TARGET_PAGE_SIZE (of type "int" and positive value) is
                   converted to "size_t" (for the relop because the latter is
                   one of "uint32_t" and "uint64_t"). No visible change.
      
      - dump_init():
        - DIV_ROUND_UP(DIV_ROUND_UP(s->max_mapnr, CHAR_BIT), s->page_size): The
          innermost "DumpState.max_mapnr" field has type uint64_t, which
          propagates through all implicit conversions at hand:
      
          #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
      
          regardless of the page size macro argument's type. In the outer macro
          replacement, the page size is converted from uint32_t and int32_t
          alike to uint64_t.
      
        - (tmp * s->page_size) multiplication: "tmp" has size "uint64_t"; the
          RHS is converted to that type from uint32_t and int32_t just the same
          if it's not uint64_t to begin with.
      
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      2f859f80
    • Laszlo Ersek's avatar
      dump: eliminate DumpState.page_shift ("guest's page shift") · 22227f12
      Laszlo Ersek authored
      
      Just use TARGET_PAGE_BITS.
      
      "DumpState.page_shift" used to have type "uint32_t", while the replacement
      TARGET_PAGE_BITS has type "int". Since "DumpState.page_shift" was only
      used as bit shift counts in the paddr_to_pfn() and pfn_to_paddr() macros,
      this is safe.
      
      Suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      22227f12
    • Laszlo Ersek's avatar
      dump: simplify write_start_flat_header() · 92ba1401
      Laszlo Ersek authored
      
      Currently, the function
      - defines and populates an auto variable of type MakedumpfileHeader
      - allocates and zeroes a buffer of size MAX_SIZE_MDF_HEADER (4096)
      - copies the former into the latter (covering an initial portion of the
        latter)
      
      Fill in the MakedumpfileHeader structure in its final place (the alignment
      is OK because the structure lives at the address returned by g_malloc0()).
      
      Approximately-suggested-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      92ba1401
    • Laszlo Ersek's avatar
      dump: fill in the flat header signature more pleasingly to the eye · ae3f88f6
      Laszlo Ersek authored
      
      The "mh.signature" array field has size 16, and is zeroed by the preceding
      memset(). MAKEDUMPFILE_SIGNATURE expands to a string literal with string
      length 12 (size 13). There's no need to measure the length of
      MAKEDUMPFILE_SIGNATURE at runtime, nor for the extra zero-filling of
      "mh.signature" with strncpy().
      
      Use memcpy() with MIN(sizeof, sizeof) for robustness (which is an integer
      constant expression, evaluable at compile time.)
      
      Approximately-suggested-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
      ae3f88f6
  12. May 09, 2014
  13. Feb 28, 2014
Loading