1. 15 12月, 2015 1 次提交
    • G
      fw_cfg: amend callback behavior spec to once per select · 3bef7e8a
      Gabriel L. Somlo 提交于
      Currently, the fw_cfg internal API specifies that if an item was set up
      with a read callback, the callback must be run each time a byte is read
      from the item. This behavior is both wasteful (most items do not have a
      read callback set), and impractical for bulk transfers (e.g., DMA read).
      
      At the time of this writing, the only items configured with a callback
      are "/etc/table-loader", "/etc/acpi/tables", and "/etc/acpi/rsdp". They
      all share the same callback functions: virt_acpi_build_update() on ARM
      (in hw/arm/virt-acpi-build.c), and acpi_build_update() on i386 (in
      hw/i386/acpi.c). Both of these callbacks are one-shot (i.e. they return
      without doing anything at all after the first time they are invoked with
      a given build_state; since build_state is also shared across all three
      items mentioned above, the callback only ever runs *once*, the first
      time either of the listed items is read).
      
      This patch amends the specification for fw_cfg_add_file_callback() to
      state that any available read callback will only be invoked once each
      time the item is selected. This change has no practical effect on the
      current behavior of QEMU, and it enables us to significantly optimize
      the behavior of fw_cfg reads during guest firmware setup, eliminating
      a large amount of redundant callback checks and invocations.
      
      Cc: Laszlo Ersek <lersek@redhat.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Marc Marí <markmb@redhat.com>
      Signed-off-by: NGabriel Somlo <somlo@cmu.edu>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Message-id: 1446733972-1602-3-git-send-email-somlo@cmu.edu
      Signed-off-by: NGerd Hoffmann <kraxel@redhat.com>
      3bef7e8a
  2. 19 10月, 2015 2 次提交
  3. 11 9月, 2015 1 次提交
  4. 10 6月, 2015 4 次提交
  5. 25 3月, 2015 1 次提交
    • G
      fw_cfg: factor out initialization of FW_CFG_ID (rev. number) · 3a5c76ba
      Gabriel L. Somlo 提交于
      The fw_cfg documentation says this of the revision key (0x0001, FW_CFG_ID):
      
      > A 32-bit little-endian unsigned int, this item is used as an interface
      > revision number, and is currently set to 1 by all QEMU architectures
      > which expose a fw_cfg device.
      
      arm/virt doesn't.  It could be argued that that's an error in
      "hw/arm/virt.c"; on the other hand, all of the other fw_cfg providing
      boards set the interface version to 1 manually, despite the device
      coming from the same, shared implementation. Therefore, instead of
      adding
      
          fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
      
      to arm/virt, consolidate all such existing calls in the fw_cfg
      initialization code.
      Signed-off-by: NGabriel Somlo <somlo@cmu.edu>
      Message-Id: <1426789244-26318-1-git-send-email-somlo@cmu.edu>
      Reviewed-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      3a5c76ba
  6. 19 3月, 2015 1 次提交
    • S
      Fix remaining warnings from Sparse (void return) · e7ae771f
      Stefan Weil 提交于
      Sparse report:
      
      hw/display/vga.c:2000:5: warning: returning void-valued expression
      hw/intc/arm_gic.c:707:9: warning: returning void-valued expression
      hw/intc/etraxfs_pic.c:138:9: warning: returning void-valued expression
      hw/nvram/fw_cfg.c:475:5: warning: returning void-valued expression
      hw/timer/a9gtimer.c:124:5: warning: returning void-valued expression
      hw/tpm/tpm_tis.c:794:5: warning: returning void-valued expression
      hw/usb/hcd-musb.c:558:9: warning: returning void-valued expression
      hw/usb/hcd-musb.c:776:13: warning: returning void-valued expression
      hw/usb/hcd-musb.c:867:5: warning: returning void-valued expression
      hw/usb/hcd-musb.c:932:5: warning: returning void-valued expression
      include/qom/cpu.h:584:5: warning: returning void-valued expression
      monitor.c:4686:13: warning: returning void-valued expression
      monitor.c:4690:13: warning: returning void-valued expression
      
      Cc: Edgar E. Iglesias <edgar.iglesias@gmail.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Andreas Färber <afaerber@suse.de>
      Cc: Luiz Capitulino <lcapitulino@redhat.com>
      Signed-off-by: NStefan Weil <sw@weilnetz.de>
      Signed-off-by: NMichael Tokarev <mjt@tls.msk.ru>
      e7ae771f
  7. 16 1月, 2015 1 次提交
    • L
      fw_cfg: fix endianness in fw_cfg_data_mem_read() / _write() · 36b62ae6
      Laszlo Ersek 提交于
      (1) Let's contemplate what device endianness means, for a memory mapped
      device register (independently of QEMU -- that is, on physical hardware).
      
      It determines the byte order that the device will put on the data bus when
      the device is producing a *numerical value* for the CPU. This byte order
      may differ from the CPU's own byte order, therefore when software wants to
      consume the *numerical value*, it may have to swap the byte order first.
      
      For example, suppose we have a device that exposes in a 2-byte register
      the number of sheep we have to count before falling asleep. If the value
      is decimal 37 (0x0025), then a big endian register will produce [0x00,
      0x25], while a little endian register will produce [0x25, 0x00].
      
      If the device register is big endian, but the CPU is little endian, the
      numerical value will read as 0x2500 (decimal 9472), which software has to
      byte swap before use.
      
      However... if we ask the device about who stole our herd of sheep, and it
      answers "XY", then the byte representation coming out of the register must
      be [0x58, 0x59], regardless of the device register's endianness for
      numeric values. And, software needs to copy these bytes into a string
      field regardless of the CPU's own endianness.
      
      (2) QEMU's device register accessor functions work with *numerical values*
      exclusively, not strings:
      
      The emulated register's read accessor function returns the numerical value
      (eg. 37 decimal, 0x0025) as a *host-encoded* uint64_t. QEMU translates
      this value for the guest to the endianness of the emulated device register
      (which is recorded in MemoryRegionOps.endianness). Then guest code must
      translate the numerical value from device register to guest CPU
      endianness, before including it in any computation (see (1)).
      
      (3) However, the data register of the fw_cfg device shall transfer strings
      *only* -- that is, opaque blobs. Interpretation of any given blob is
      subject to further agreement -- it can be an integer in an independently
      determined byte order, or a genuine string, or an array of structs of
      integers (in some byte order) and fixed size strings, and so on.
      
      Because register emulation in QEMU is integer-preserving, not
      string-preserving (see (2)), we have to jump through a few hoops.
      
      (3a) We defined the memory mapped fw_cfg data register as
      DEVICE_BIG_ENDIAN.
      
      The particular choice is not really relevant -- we picked BE only for
      consistency with the control register, which *does* transfer integers --
      but our choice affects how we must host-encode values from fw_cfg strings.
      
      (3b) Since we want the fw_cfg string "XY" to appear as the [0x58, 0x59]
      array on the data register, *and* we picked DEVICE_BIG_ENDIAN, we must
      compose the host (== C language) value 0x5859 in the read accessor
      function.
      
      (3c) When the guest performs the read access, the immediate uint16_t value
      will be 0x5958 (in LE guests) and 0x5859 (in BE guests). However, the
      uint16_t value does not matter. The only thing that matters is the byte
      pattern [0x58, 0x59], which the guest code must copy into the target
      string *without* any byte-swapping.
      
      (4) Now I get to explain where I screwed up. :(
      
      When we decided for big endian *integer* representation in the MMIO data
      register -- see (3a) --, I mindlessly added an indiscriminate
      byte-swizzling step to the (little endian) guest firmware.
      
      This was a grave error -- it violates (3c) --, but I didn't realize it. I
      only saw that the code I otherwise intended for fw_cfg_data_mem_read():
      
          value = 0;
          for (i = 0; i < size; ++i) {
              value = (value << 8) | fw_cfg_read(s);
          }
      
      didn't produce the expected result in the guest.
      
      In true facepalm style, instead of blaming my guest code (which violated
      (3c)), I blamed my host code (which was correct). Ultimately, I coded
      ldX_he_p() into fw_cfg_data_mem_read(), because that happened to work.
      
      Obviously (...in retrospect) that was wrong. Only because my host happened
      to be LE, ldX_he_p() composed the (otherwise incorrect) host value 0x5958
      from the fw_cfg string "XY". And that happened to compensate for the bogus
      indiscriminate byte-swizzling in my guest code.
      
      Clearly the current code leaks the host endianness through to the guest,
      which is wrong. Any device should work the same regardless of host
      endianness.
      
      The solution is to compose the host-endian representation (2) of the big
      endian interpretation (3a, 3b) of the fw_cfg string, and to drop the wrong
      byte-swizzling in the guest (3c).
      
      Brown paper bag time for me.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Message-id: 1420024880-15416-1-git-send-email-lersek@redhat.com
      Reviewed-by: NPeter Maydell <peter.maydell@linaro.org>
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      36b62ae6
  8. 23 12月, 2014 6 次提交
    • L
      fw_cfg_mem: expose the "data_width" property with fw_cfg_init_mem_wide() · 6c87e3d5
      Laszlo Ersek 提交于
      We rebase fw_cfg_init_mem() to the new function for compatibility with
      current callers.
      
      The behavior of the (big endian) multi-byte data reads is best shown
      with a qtest session.  Here, we are reading the first six bytes of
      the UUID
      
          $ arm-softmmu/qemu-system-arm -M virt -machine accel=qtest \
               -qtest stdio -uuid 4600cb32-38ec-4b2f-8acb-81c6ea54f2d8
      >>> writew 0x9020008 0x0200
      <<< OK
      >>> readl 0x9020000
      <<< OK 0x000000004600cb32
      
      Remember this is big endian.  On big endian machines, it is stored
      directly as 0x46 0x00 0xcb 0x32.
      
      On a little endian machine, we have to first swap it, so that it becomes
      0x32cb0046.  When written to memory, it becomes 0x46 0x00 0xcb 0x32
      again.
      
      Reading byte-by-byte works too, of course:
      
      >>> readb 0x9020000
      <<< OK 0x0000000000000038
      >>> readb 0x9020000
      <<< OK 0x00000000000000ec
      
      Here only a single byte is read at a time, so they are read in order
      similar to the 1-byte data port that is already in PPC and SPARC
      machines.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1419250305-31062-8-git-send-email-pbonzini@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      6c87e3d5
    • L
      fw_cfg_mem: introduce the "data_width" property · cfaadf0e
      Laszlo Ersek 提交于
      The "data_width" property is capable of changing the maximum valid access
      size to the MMIO data register, and resizes the memory region similarly,
      at device realization time.
      
      The default value of "data_memwidth" is set so that we don't yet diverge
      from "fw_cfg_data_mem_ops".
      
      Most of the fw_cfg_mem users will stick with the default, and for them we
      should continue using the statically allocated "fw_cfg_data_mem_ops". This
      is beneficial for debugging because gdb can resolve pointers referencing
      static objects to the names of those objects.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1419250305-31062-7-git-send-email-pbonzini@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      cfaadf0e
    • L
      fw_cfg_mem: flip ctl_mem_ops and data_mem_ops to DEVICE_BIG_ENDIAN · d789c845
      Laszlo Ersek 提交于
      The standalone selector port (fw_cfg_ctl_mem_ops) is only used by big
      endian guests to date (*), hence this change doesn't regress them. Paolo
      and Alex have suggested / requested an explicit DEVICE_BIG_ENDIAN setting
      here, for clarity.
      
      (*) git grep -l fw_cfg_init_mem
      
          hw/nvram/fw_cfg.c
          hw/ppc/mac_newworld.c
          hw/ppc/mac_oldworld.c
          hw/sparc/sun4m.c
          include/hw/nvram/fw_cfg.h
      
      The standalone data port (fw_cfg_data_mem_ops) has max_access_size 1 (for
      now), hence changing its endianness doesn't change behavior for existing
      guest code.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1419250305-31062-5-git-send-email-pbonzini@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      d789c845
    • L
      fw_cfg_mem: max access size and region size are the same for data register · 86099db3
      Laszlo Ersek 提交于
      Make it clear that the maximum access size to the MMIO data register
      determines the full size of the memory region.
      
      Currently the max access size is 1.
      
      This patch doesn't change behavior.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1419250305-31062-4-git-send-email-pbonzini@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      86099db3
    • L
      fw_cfg: move boards to fw_cfg_init_io() / fw_cfg_init_mem() · 66708822
      Laszlo Ersek 提交于
      This allows us to drop the fw_cfg_init() shim and to enforce the possible
      mappings at compile time.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1419250305-31062-3-git-send-email-pbonzini@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      66708822
    • L
      fw_cfg: hard separation between the MMIO and I/O port mappings · 5712db6a
      Laszlo Ersek 提交于
      We are going to introduce a wide data register for fw_cfg, but only for
      the MMIO mapped device. The wide data register will also require the
      tightening of endiannesses.
      
      However we don't want to touch the I/O port mapped fw_cfg device at all.
      
      Currently QEMU provides a single fw_cfg device type that can handle both
      I/O port and MMIO mapping. This flexibility is not actually exploited by
      any board in the tree, but it renders restricting the above changes to
      MMIO very hard.
      
      Therefore, let's derive two classes from TYPE_FW_CFG: TYPE_FW_CFG_IO and
      TYPE_FW_CFG_MEM.
      
      TYPE_FW_CFG_IO incorporates the base I/O port and the related combined
      MemoryRegion. (NB: all boards in the tree that use the I/O port mapped
      flavor opt for the combined mapping; that is, when the data port overlays
      the high address byte of the selector port. Therefore we can drop the
      capability to map those I/O ports separately.)
      
      TYPE_FW_CFG_MEM incorporates the base addresses for the MMIO selector and
      data registers, and their respective MemoryRegions.
      
      The "realize" and "props" class members are specific to each new derived
      class, and become unused for the base class. The base class retains the
      "reset" member and the "vmsd" member, because the reset functionality and
      the set of migrated data are not specific to the mapping.
      
      The new functions fw_cfg_init_io() and fw_cfg_init_mem() expose the
      possible mappings in separation. For now fw_cfg_init() is retained as a
      compatibility shim that enforces the above assumptions.
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Message-id: 1419250305-31062-2-git-send-email-pbonzini@redhat.com
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      5712db6a
  9. 10 12月, 2014 1 次提交
  10. 26 11月, 2014 1 次提交
  11. 15 10月, 2014 1 次提交
  12. 16 6月, 2014 1 次提交
  13. 20 3月, 2014 1 次提交
  14. 15 2月, 2014 1 次提交
  15. 23 12月, 2013 2 次提交
    • M
      sysbus: Set cannot_instantiate_with_device_add_yet · 837d3716
      Markus Armbruster 提交于
      device_add plugs devices into suitable bus.  For "real" buses, that
      actually connects the device.  For sysbus, the connections need to be
      made separately, and device_add can't do that.  The device would be
      left unconnected, and could not possibly work.
      
      Quite a few, but not all sysbus devices already set
      cannot_instantiate_with_device_add_yet in their class init function.
      
      Set it in their abstract base's class init function
      sysbus_device_class_init(), and remove the now redundant assignments
      from device class init functions.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel.a@redhat.com>
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      837d3716
    • M
      qdev: Replace no_user by cannot_instantiate_with_device_add_yet · efec3dd6
      Markus Armbruster 提交于
      In an ideal world, machines can be built by wiring devices together
      with configuration, not code.  Unfortunately, that's not the world we
      live in right now.  We still have quite a few devices that need to be
      wired up by code.  If you try to device_add such a device, it'll fail
      in sometimes mysterious ways.  If you're lucky, you get an
      unmysterious immediate crash.
      
      To protect users from such badness, DeviceClass member no_user used to
      make device models unavailable with -device / device_add, but that
      regressed in commit 18b6dade.  The device model is still omitted from
      help, but is available anyway.
      
      Attempts to fix the regression have been rejected with the argument
      that the purpose of no_user isn't clear, and it's prone to misuse.
      
      This commit clarifies no_user's purpose.  Anthony suggested to rename
      it cannot_instantiate_with_device_add_yet_due_to_internal_bugs, which
      I shorten somewhat to keep checkpatch happy.  While there, make it
      bool.
      
      Every use of cannot_instantiate_with_device_add_yet gets a FIXME
      comment asking for rationale.  The next few commits will clean them
      all up, either by providing a rationale, or by getting rid of the use.
      
      With that done, the regression fix is hopefully acceptable.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarcel Apfelbaum <marcel.a@redhat.com>
      Signed-off-by: NAndreas Färber <afaerber@suse.de>
      efec3dd6
  16. 14 10月, 2013 1 次提交
  17. 08 8月, 2013 1 次提交
  18. 23 7月, 2013 2 次提交
  19. 04 7月, 2013 2 次提交
  20. 02 6月, 2013 2 次提交
  21. 22 5月, 2013 1 次提交
  22. 30 4月, 2013 1 次提交
  23. 09 4月, 2013 2 次提交
  24. 01 3月, 2013 1 次提交
    • P
      hw: include hw header files with full paths · 83c9f4ca
      Paolo Bonzini 提交于
      Done with this script:
      
      cd hw
      for i in `find . -name '*.h' | sed 's/^..//'`; do
        echo '\,^#.*include.*["<]'$i'[">], s,'$i',hw/&,'
      done | sed -i -f - `find . -type f`
      
      This is so that paths remain valid as files are moved.
      
      Instead, files in hw/dataplane are referenced with the relative path.
      We know they are not going to move to include/, and they are the only
      include files that are in subdirectories _and_ move.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      83c9f4ca
  25. 27 1月, 2013 1 次提交
  26. 26 1月, 2013 1 次提交