Skip to content
Snippets Groups Projects
  1. Sep 19, 2017
  2. Sep 07, 2017
    • Peter Maydell's avatar
      boards.h: Define new flag ignore_memory_transaction_failures · ed860129
      Peter Maydell authored
      
      Define a new MachineClass field ignore_memory_transaction_failures.
      If this is flag is true then the CPU will ignore memory transaction
      failures which should cause the CPU to take an exception due to an
      access to an unassigned physical address; the transaction will
      instead return zero (for a read) or be ignored (for a write).  This
      should be set only by legacy board models which rely on the old
      RAZ/WI behaviour for handling devices that QEMU does not yet model.
      New board models should instead use "unimplemented-device" for all
      memory ranges where the guest will attempt to probe for a device that
      QEMU doesn't implement and a stub device is required.
      
      We need this for ARM boards, where we're about to implement support for
      generating external aborts on memory transaction failures. Too many
      of our legacy board models rely on the RAZ/WI behaviour and we
      would break currently working guests when their "probe for device"
      code provoked an external abort rather than a RAZ.
      
      Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      Reviewed-by: default avatarAlistair Francis <alistair.francis@xilinx.com>
      Message-id: 1504626814-23124-2-git-send-email-peter.maydell@linaro.org
      ed860129
  3. Sep 04, 2017
  4. Sep 01, 2017
  5. Aug 09, 2017
  6. Aug 07, 2017
  7. Jul 31, 2017
  8. Jul 17, 2017
    • Eduardo Habkost's avatar
      qom: Fix ambiguous path detection when ambiguous=NULL · ebcc479e
      Eduardo Habkost authored
      
      object_resolve_path*() ambiguous path detection breaks when
      ambiguous==NULL and the object tree have 3 objects of the same type and
      only 2 of them are under the same parent.  e.g.:
      
       /container/obj1 (TYPE_FOO)
       /container/obj2 (TYPE_FOO)
       /obj2 (TYPE_FOO)
      
      With the above tree, object_resolve_path_type("", TYPE_FOO, NULL) will
      incorrectly return /obj2, because the search inside "/container" will
      return NULL, and the match at "/obj2" won't be detected as ambiguous.
      
      Fix that by always calling object_resolve_partial_path() with a non-NULL
      ambiguous parameter.
      
      Test case included.
      
      Reported-by: default avatarIgor Mammedov <imammedo@redhat.com>
      Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170707213052.13087-3-ehabkost@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      ebcc479e
    • Lluís Vilanova's avatar
      trace: Allocate cpu->trace_dstate in place · d01c05c9
      Lluís Vilanova authored
      
      There's little point in dynamically allocating the bitmap if we
      know at compile-time the max number of events we want to support.
      Thus, make room in the struct for the bitmap, which will make things
      easier later: this paves the way for upcoming changes, in which
      we'll use a u32 to fully capture cpu->trace_dstate.
      
      This change also increases performance by saving a dereference and
      improving locality--note that this is important since upcoming work
      makes reading this bitmap fairly common.
      
      Signed-off-by: default avatarEmilio G. Cota <cota@braap.org>
      Reviewed-by: default avatarLluís Vilanova <vilanova@ac.upc.edu>
      Signed-off-by: default avatarLluís Vilanova <vilanova@ac.upc.edu>
      Message-id: 149915725977.6295.15069969323605305641.stgit@frigg.lan
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      d01c05c9
  9. Jul 14, 2017
  10. Jul 04, 2017
  11. Jun 30, 2017
    • Emilio G. Cota's avatar
      tcg: consistently access cpu->tb_jmp_cache atomically · f3ced3c5
      Emilio G. Cota authored
      
      Some code paths can lead to atomic accesses racing with memset()
      on cpu->tb_jmp_cache, which can result in torn reads/writes
      and is undefined behaviour in C11.
      
      These torn accesses are unlikely to show up as bugs, but from code
      inspection they seem possible. For example, tb_phys_invalidate does:
          /* remove the TB from the hash list */
          h = tb_jmp_cache_hash_func(tb->pc);
          CPU_FOREACH(cpu) {
              if (atomic_read(&cpu->tb_jmp_cache[h]) == tb) {
                  atomic_set(&cpu->tb_jmp_cache[h], NULL);
              }
          }
      Here atomic_set might race with a concurrent memset (such as the
      ones scheduled via "unsafe" async work, e.g. tlb_flush_page) and
      therefore we might end up with a torn pointer (or who knows what,
      because we are under undefined behaviour).
      
      This patch converts parallel accesses to cpu->tb_jmp_cache to use
      atomic primitives, thereby bringing these accesses back to defined
      behaviour. The price to pay is to potentially execute more instructions
      when clearing cpu->tb_jmp_cache, but given how infrequently they happen
      and the small size of the cache, the performance impact I have measured
      is within noise range when booting debian-arm.
      
      Note that under "safe async" work (e.g. do_tb_flush) we could use memset
      because no other vcpus are running. However I'm keeping these accesses
      atomic as well to keep things simple and to avoid confusing analysis
      tools such as ThreadSanitizer.
      
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Signed-off-by: default avatarEmilio G. Cota <cota@braap.org>
      Message-Id: <1497486973-25845-1-git-send-email-cota@braap.org>
      Signed-off-by: default avatarRichard Henderson <rth@twiddle.net>
      f3ced3c5
  12. Jun 20, 2017
  13. Jun 19, 2017
  14. Jun 06, 2017
    • Michael Roth's avatar
      monitor: fix object_del for command-line-created objects · c645d5ac
      Michael Roth authored
      
      Currently objects specified on the command-line are only partially
      cleaned up when 'object_del' is issued in either HMP or QMP: the
      object itself is fully finalized, but the QemuOpts are not removed.
      This results in the following behavior:
      
        x86_64-softmmu/qemu-system-x86_64 -monitor stdio \
          -object memory-backend-ram,id=ram1,size=256M
      
        QEMU 2.7.91 monitor - type 'help' for more information
        (qemu) object_del ram1
        (qemu) object_del ram1
        object 'ram1' not found
        (qemu) object_add memory-backend-ram,id=ram1,size=256M
        Duplicate ID 'ram1' for object
        Try "help object_add" for more information
      
      which can be an issue for use-cases like memory hotplug.
      
      This happens on the HMP side because hmp_object_add() attempts to
      create a temporary QemuOpts entry with ID 'ram1', which ends up
      conflicting with the command-line-created entry, since it was never
      cleaned up during the previous hmp_object_del() call.
      
      We address this by adding a check in user_creatable_del(), which
      is called by both qmp_object_del() and hmp_object_del() to handle
      the actual object cleanup, to determine whether an option group entry
      matching the object's ID is present and removing it if it is.
      
      Note that qmp_object_add() never attempts to create a temporary
      QemuOpts entry, so it does not encounter the duplicate ID error,
      which is why this isn't generally visible in libvirt.
      
      Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Cc: Daniel Berrange <berrange@redhat.com>
      Cc: qemu-stable@nongnu.org
      Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: default avatarDaniel P. Berrange <berrange@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1496531612-22166-3-git-send-email-mdroth@linux.vnet.ibm.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      c645d5ac
  15. May 17, 2017
    • Eduardo Habkost's avatar
      qdev: Replace cannot_instantiate_with_device_add_yet with !user_creatable · e90f2a8c
      Eduardo Habkost authored
      
      cannot_instantiate_with_device_add_yet was introduced by commit
      efec3dd6 to replace no_user. It was
      supposed to be a temporary measure.
      
      When it was introduced, we had 54
      cannot_instantiate_with_device_add_yet=true lines in the code.
      Today (3 years later) this number has not shrunk: we now have
      57 cannot_instantiate_with_device_add_yet=true lines. I think it
      is safe to say it is not a temporary measure, and we won't see
      the flag go away soon.
      
      Instead of a long field name that misleads people to believe it
      is temporary, replace it a shorter and less misleading field:
      user_creatable.
      
      Except for code comments, changes were generated using the
      following Coccinelle patch:
      
        @@
        expression DC;
        @@
        (
        -DC->cannot_instantiate_with_device_add_yet = false;
        +DC->user_creatable = true;
        |
        -DC->cannot_instantiate_with_device_add_yet = true;
        +DC->user_creatable = false;
        )
      
        @@
        typedef ObjectClass;
        expression dc;
        identifier class, data;
        @@
         static void device_class_init(ObjectClass *class, void *data)
         {
         ...
         dc->hotpluggable = true;
        +dc->user_creatable = true;
         ...
         }
      
        @@
        @@
         struct DeviceClass {
         ...
        -bool cannot_instantiate_with_device_add_yet;
        +bool user_creatable;
         ...
        }
      
        @@
        expression DC;
        @@
        (
        -!DC->cannot_instantiate_with_device_add_yet
        +DC->user_creatable
        |
        -DC->cannot_instantiate_with_device_add_yet
        +!DC->user_creatable
        )
      
      Cc: Alistair Francis <alistair.francis@xilinx.com>
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Marcel Apfelbaum <marcel@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Cc: Peter Maydell <peter.maydell@linaro.org>
      Cc: Thomas Huth <thuth@redhat.com>
      Acked-by: default avatarAlistair Francis <alistair.francis@xilinx.com>
      Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
      Reviewed-by: default avatarMarcel Apfelbaum <marcel@redhat.com>
      Acked-by: default avatarMarcel Apfelbaum <marcel@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      Message-Id: <20170503203604.31462-2-ehabkost@redhat.com>
      [ehabkost: kept "TODO remove once we're there" comment]
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
      e90f2a8c
  16. May 12, 2017
    • Anthony Xu's avatar
      trace: add sanity check · 5651743c
      Anthony Xu authored
      
      If trace backend is set to TRACE_NOP, trace_get_vcpu_event_count
      returns 0, cause bitmap_new call abort.
      
      The abort can be triggered as follows:
      
        $ ./configure --enable-trace-backend=nop --target-list=x86_64-softmmu
        $ gdb ./x86_64-softmmu/qemu-system-x86_64 -M q35,accel=kvm -m 1G
        (gdb) bt
        #0  0x00007ffff04e25f7 in raise () from /lib64/libc.so.6
        #1  0x00007ffff04e3ce8 in abort () from /lib64/libc.so.6
        #2  0x00005555559de905 in bitmap_new (nbits=<optimized out>)
            at /home/root/git/qemu2.git/include/qemu/bitmap.h:96
        #3  cpu_common_initfn (obj=0x555556621d30) at qom/cpu.c:399
        #4  0x0000555555a11869 in object_init_with_type (obj=0x555556621d30, ti=0x55555656bbb0) at qom/object.c:341
        #5  0x0000555555a11869 in object_init_with_type (obj=0x555556621d30, ti=0x55555656bd30) at qom/object.c:341
        #6  0x0000555555a11efc in object_initialize_with_type (data=data@entry=0x555556621d30, size=76560,
            type=type@entry=0x55555656bd30) at qom/object.c:376
        #7  0x0000555555a12061 in object_new_with_type (type=0x55555656bd30) at qom/object.c:484
        #8  0x0000555555a121c5 in object_new (typename=typename@entry=0x555556550340 "qemu64-x86_64-cpu")
            at qom/object.c:494
        #9  0x00005555557f6e3d in pc_new_cpu (typename=typename@entry=0x555556550340 "qemu64-x86_64-cpu", apic_id=0,
            errp=errp@entry=0x5555565391b0 <error_fatal>) at /home/root/git/qemu2.git/hw/i386/pc.c:1101
        #10 0x00005555557fa33e in pc_cpus_init (pcms=pcms@entry=0x5555565f9690)
            at /home/root/git/qemu2.git/hw/i386/pc.c:1184
        #11 0x00005555557fe0f6 in pc_q35_init (machine=0x5555565f9690) at /home/root/git/qemu2.git/hw/i386/pc_q35.c:121
        #12 0x000055555574fbad in main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4562
      
      Signed-off-by: default avatarAnthony Xu <anthony.xu@intel.com>
      Message-id: 1494369432-15418-1-git-send-email-anthony.xu@intel.com
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      5651743c
  17. May 04, 2017
  18. Mar 23, 2017
  19. Mar 22, 2017
    • Eric Blake's avatar
      qom: Avoid unvisited 'id'/'qom-type' in user_creatable_add_opts · 9a6d1acb
      Eric Blake authored
      
      A regression in commit 15c2f669 caused us to silently ignore
      excess input to the QemuOpts visitor.  Later, commit ea4641
      accidentally abused that situation, by removing "qom-type" and
      "id" from the corresponding QDict but leaving them defined in
      the QemuOpts, when using the pair of containers to create a
      user-defined object. Note that since we are already traversing
      two separate items (a QDict and a QemuOpts), we are already
      able to flag bogus arguments, as in:
      
      $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio -object memory-backend-ram,id=mem1,size=4k,bogus=huh
      qemu-system-x86_64: -object memory-backend-ram,id=mem1,size=4k,bogus=huh: Property '.bogus' not found
      
      So the only real concern is that when we re-enable strict checking
      in the QemuOpts visitor, we do not want to start flagging the two
      leftover keys as unvisited.  Rearrange the code to clean out the
      QemuOpts listing in advance, rather than removing items from the
      QDict.  Since "qom-type" is usually an automatic implicit default,
      we don't have to restore it (this does mean that once instantiated,
      QemuOpts is not necessarily an accurate representation of the
      original command line - but this is not the first place to do that);
      however "id" has to be put back (requiring us to cast away a const).
      
      [As a side note, hmp_object_add() turns a QDict into a QemuOpts,
      then calls user_creatable_add_opts() which converts QemuOpts into
      a new QDict. There are probably a lot of wasteful conversions like
      this, but cleaning them up is a much bigger task than the immediate
      regression fix.]
      
      CC: qemu-stable@nongnu.org
      Signed-off-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <20170322144525.18964-3-eblake@redhat.com>
      Tested-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      9a6d1acb
  20. Mar 05, 2017
    • Markus Armbruster's avatar
      qapi: Drop unused non-strict qobject input visitor · 048abb7b
      Markus Armbruster authored
      
      The split between tests/test-qobject-input-visitor.c and
      tests/test-qobject-input-strict.c now makes less sense than ever.  The
      next commit will take care of that.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-20-git-send-email-armbru@redhat.com>
      048abb7b
    • Markus Armbruster's avatar
      qom: Make object_property_set_qobject()'s input visitor strict · 05601ed2
      Markus Armbruster authored
      
      Commit 240f64b6 made all qobject input visitors created outside tests
      strict, except for the one in object_property_set_qobject().  That one
      was left behind only because Eric couldn't spare the time to figure
      out whether making it strict would break anything, with a TODO
      comment.  Time to resolve it.
      
      Strict makes a difference only for otherwise successful visits of QAPI
      structs or unions.  Let's examine what the callers of
      object_property_set_qobject() visit:
      
      * object_property_set_str(), object_property_set_bool(),
        object_property_set_int() visit a QString, QBool, QInt,
        respectively.  Strictness can't matter.
      
      * qmp_qom_set visits its @value argument.  Comes straight from QMP and
        can be anything ('any' in the QAPI schema).  Strictness matters when
        the property's set() method visits a struct or union QAPI type.
      
        No such methods exist, thus switching to strict can't break
        anything.
      
        If we acquire such methods in the future, we'll *want* the visitor
        to be strict, so that unexpected members get rejected as they should
        be.
      
      Switch to strict.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-18-git-send-email-armbru@redhat.com>
      05601ed2
  21. Feb 24, 2017
    • Jan Kiszka's avatar
      tcg: drop global lock during TCG code execution · 8d04fb55
      Jan Kiszka authored
      
      This finally allows TCG to benefit from the iothread introduction: Drop
      the global mutex while running pure TCG CPU code. Reacquire the lock
      when entering MMIO or PIO emulation, or when leaving the TCG loop.
      
      We have to revert a few optimization for the current TCG threading
      model, namely kicking the TCG thread in qemu_mutex_lock_iothread and not
      kicking it in qemu_cpu_kick. We also need to disable RAM block
      reordering until we have a more efficient locking mechanism at hand.
      
      Still, a Linux x86 UP guest and my Musicpal ARM model boot fine here.
      These numbers demonstrate where we gain something:
      
      20338 jan       20   0  331m  75m 6904 R   99  0.9   0:50.95 qemu-system-arm
      20337 jan       20   0  331m  75m 6904 S   20  0.9   0:26.50 qemu-system-arm
      
      The guest CPU was fully loaded, but the iothread could still run mostly
      independent on a second core. Without the patch we don't get beyond
      
      32206 jan       20   0  330m  73m 7036 R   82  0.9   1:06.00 qemu-system-arm
      32204 jan       20   0  330m  73m 7036 S   21  0.9   0:17.03 qemu-system-arm
      
      We don't benefit significantly, though, when the guest is not fully
      loading a host CPU.
      
      Signed-off-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
      Message-Id: <1439220437-23957-10-git-send-email-fred.konrad@greensocs.com>
      [FK: Rebase, fix qemu_devices_reset deadlock, rm address_space_* mutex]
      Signed-off-by: default avatarKONRAD Frederic <fred.konrad@greensocs.com>
      [EGC: fixed iothread lock for cpu-exec IRQ handling]
      Signed-off-by: default avatarEmilio G. Cota <cota@braap.org>
      [AJB: -smp single-threaded fix, clean commit msg, BQL fixes]
      Signed-off-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarRichard Henderson <rth@twiddle.net>
      Reviewed-by: default avatarPranith Kumar <bobby.prani@gmail.com>
      [PM: target-arm changes]
      Acked-by: default avatarPeter Maydell <peter.maydell@linaro.org>
      8d04fb55
  22. Feb 22, 2017
  23. Feb 16, 2017
  24. Feb 07, 2017
  25. Jan 31, 2017
  26. Jan 27, 2017
  27. Jan 24, 2017
  28. Jan 19, 2017
  29. Jan 16, 2017
  30. Jan 13, 2017
Loading