]> git.proxmox.com Git - qemu.git/commitdiff
Merge remote-tracking branch 'mst/tags/for_anthony' into staging
authorAnthony Liguori <anthony@codemonkey.ws>
Tue, 3 Sep 2013 17:31:07 +0000 (12:31 -0500)
committerAnthony Liguori <anthony@codemonkey.ws>
Tue, 3 Sep 2013 17:31:07 +0000 (12:31 -0500)
pc,pci,virtio fixes and cleanups

This includes pc and pci cleanups and enhancements,
and a virtio bugfix for level interrupts.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
# gpg: Signature made Sun 01 Sep 2013 03:15:36 AM CDT using RSA key ID D28D5469
# gpg: Can't check signature: public key not found

# By Michael S. Tsirkin (3) and others
# Via Michael S. Tsirkin
* mst/tags/for_anthony:
  virtio_pci: fix level interrupts with irqfd
  pc: reduce duplication, fix PIIX descriptions
  hw: Clean up bogus default boot order
  pci: add config space access traces
  pc: fix regression for 64 bit PCI memory
  pci: Introduce helper to retrieve a PCI device's DMA address space

Message-id: 1378023590-11109-1-git-send-email-mst@redhat.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>
14 files changed:
1  2 
hw/arm/spitz.c
hw/arm/stellaris.c
hw/openrisc/openrisc_sim.c
hw/pci-host/q35.c
hw/pci/pci.c
hw/ppc/ppc405_boards.c
hw/ppc/spapr.c
hw/ppc/virtex_ml507.c
hw/s390x/s390-virtio-ccw.c
hw/sparc64/sun4u.c
hw/virtio/virtio-pci.c
include/hw/pci/pci.h
trace-events
vl.c

diff --combined hw/arm/spitz.c
index 9b9ce95c5aeb6d06943ac6965044dc2715a2757f,a532cf6038947f7fb464f4dcd3b962b9e0457f2e..ba172835ebff9fe579f2511435388146fdc75b48
@@@ -393,7 -393,7 +393,7 @@@ static void spitz_keyboard_tick(void *o
              s->fifopos = 0;
      }
  
 -    qemu_mod_timer(s->kbdtimer, qemu_get_clock_ns(vm_clock) +
 +    timer_mod(s->kbdtimer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
                     get_ticks_per_sec() / 32);
  }
  
@@@ -485,7 -485,7 +485,7 @@@ static void spitz_keyboard_register(PXA
          qdev_connect_gpio_out(cpu->gpio, spitz_gpio_key_strobe[i],
                  qdev_get_gpio_in(dev, i));
  
 -    qemu_mod_timer(s->kbdtimer, qemu_get_clock_ns(vm_clock));
 +    timer_mod(s->kbdtimer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
  
      qemu_add_kbd_event_handler(spitz_keyboard_handler, s);
  }
@@@ -505,7 -505,7 +505,7 @@@ static int spitz_keyboard_init(SysBusDe
  
      spitz_keyboard_pre_map(s);
  
 -    s->kbdtimer = qemu_new_timer_ns(vm_clock, spitz_keyboard_tick, s);
 +    s->kbdtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, spitz_keyboard_tick, s);
      qdev_init_gpio_in(dev, spitz_keyboard_strobe, SPITZ_KEY_STROBE_NUM);
      qdev_init_gpio_out(dev, s->sense, SPITZ_KEY_SENSE_NUM);
  
@@@ -966,28 -966,24 +966,24 @@@ static QEMUMachine akitapda_machine = 
      .name = "akita",
      .desc = "Akita PDA (PXA270)",
      .init = akita_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static QEMUMachine spitzpda_machine = {
      .name = "spitz",
      .desc = "Spitz PDA (PXA270)",
      .init = spitz_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static QEMUMachine borzoipda_machine = {
      .name = "borzoi",
      .desc = "Borzoi PDA (PXA270)",
      .init = borzoi_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static QEMUMachine terrierpda_machine = {
      .name = "terrier",
      .desc = "Terrier PDA (PXA270)",
      .init = terrier_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static void spitz_machine_init(void)
diff --combined hw/arm/stellaris.c
index 3237b302602c6c8f88e2cd47c5c3094c6e823de1,49be8fd8b429d52a856667b80760cd53b075cd95..3170d69d42dc6229bb9bce4d6d985609000bd606
@@@ -78,14 -78,14 +78,14 @@@ static void gptm_update_irq(gptm_state 
  
  static void gptm_stop(gptm_state *s, int n)
  {
 -    qemu_del_timer(s->timer[n]);
 +    timer_del(s->timer[n]);
  }
  
  static void gptm_reload(gptm_state *s, int n, int reset)
  {
      int64_t tick;
      if (reset)
 -        tick = qemu_get_clock_ns(vm_clock);
 +        tick = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
      else
          tick = s->tick[n];
  
          hw_error("TODO: 16-bit timer mode 0x%x\n", s->mode[n]);
      }
      s->tick[n] = tick;
 -    qemu_mod_timer(s->timer[n], tick);
 +    timer_mod(s->timer[n], tick);
  }
  
  static void gptm_tick(void *opaque)
@@@ -318,8 -318,8 +318,8 @@@ static int stellaris_gptm_init(SysBusDe
      sysbus_init_mmio(sbd, &s->iomem);
  
      s->opaque[0] = s->opaque[1] = s;
 -    s->timer[0] = qemu_new_timer_ns(vm_clock, gptm_tick, &s->opaque[0]);
 -    s->timer[1] = qemu_new_timer_ns(vm_clock, gptm_tick, &s->opaque[1]);
 +    s->timer[0] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[0]);
 +    s->timer[1] = timer_new_ns(QEMU_CLOCK_VIRTUAL, gptm_tick, &s->opaque[1]);
      vmstate_register(dev, -1, &vmstate_stellaris_gptm, s);
      return 0;
  }
@@@ -1348,14 -1348,12 +1348,12 @@@ static QEMUMachine lm3s811evb_machine 
      .name = "lm3s811evb",
      .desc = "Stellaris LM3S811EVB",
      .init = lm3s811evb_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static QEMUMachine lm3s6965evb_machine = {
      .name = "lm3s6965evb",
      .desc = "Stellaris LM3S6965EVB",
      .init = lm3s6965evb_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static void stellaris_machine_init(void)
index 28fa41d64ef3cbf805b3189259f00d27719d3253,2a2d077acfa261388d2d2b957cc9ef2c2908124c..8e1af8bf2e9dcce8116ff3113724541af4bcbfe2
@@@ -86,8 -86,9 +86,8 @@@ static void cpu_openrisc_load_kernel(ra
                      kernel_filename);
              exit(1);
          }
 +        cpu->env.pc = entry;
      }
 -
 -    cpu->env.pc = entry;
  }
  
  static void openrisc_sim_init(QEMUMachineInitArgs *args)
@@@ -138,7 -139,6 +138,6 @@@ static QEMUMachine openrisc_sim_machin
      .init = openrisc_sim_init,
      .max_cpus = 1,
      .is_default = 1,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static void openrisc_sim_machine_init(void)
diff --combined hw/pci-host/q35.c
index e7d9712535c853dd82fe10e03e80f0f6da1b3680,4febd24f1266039c075ec64368945583b8e11b5a..54735043b784ac3d478967ebd4486e7e022433e6
@@@ -133,7 -133,7 +133,7 @@@ static void q35_host_initfn(Object *obj
      memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops, phb,
                            "pci-conf-data", 4);
  
 -    object_initialize(&s->mch, TYPE_MCH_PCI_DEVICE);
 +    object_initialize(&s->mch, sizeof(s->mch), TYPE_MCH_PCI_DEVICE);
      object_property_add_child(OBJECT(s), "mch", OBJECT(&s->mch), NULL);
      qdev_prop_set_uint32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
      qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
@@@ -320,6 -320,7 +320,7 @@@ static int mch_init(PCIDevice *d
  {
      int i;
      MCHPCIState *mch = MCH_PCI_DEVICE(d);
+     uint64_t pci_hole64_size;
  
      /* setup pci memory regions */
      memory_region_init_alias(&mch->pci_hole, OBJECT(mch), "pci-hole",
      memory_region_add_subregion(mch->system_memory, mch->below_4g_mem_size,
                                  &mch->pci_hole);
  
+     pci_hole64_size = pci_host_get_hole64_size(mch->pci_hole64_size);
      pc_init_pci64_hole(&mch->pci_info, 0x100000000ULL + mch->above_4g_mem_size,
-                        mch->pci_hole64_size);
+                        pci_hole64_size);
      memory_region_init_alias(&mch->pci_hole_64bit, OBJECT(mch), "pci-hole64",
                               mch->pci_address_space,
                               mch->pci_info.w64.begin,
-                              mch->pci_hole64_size);
-     if (mch->pci_hole64_size) {
+                              pci_hole64_size);
+     if (pci_hole64_size) {
          memory_region_add_subregion(mch->system_memory,
                                      mch->pci_info.w64.begin,
                                      &mch->pci_hole_64bit);
diff --combined hw/pci/pci.c
index e688f4a3426cd46ea63a2a841e2f1a0356ee4e3a,8c33352c9a716aea5ab8249c73f06e2ef0af011e..d00682e1344910dcfbcfb4e6e1d3f8c00035fc75
@@@ -312,13 -312,13 +312,13 @@@ bool pci_bus_is_root(PCIBus *bus
      return !bus->parent_dev;
  }
  
 -void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
 +void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
                           const char *name,
                           MemoryRegion *address_space_mem,
                           MemoryRegion *address_space_io,
                           uint8_t devfn_min, const char *typename)
  {
 -    qbus_create_inplace(bus, typename, parent, name);
 +    qbus_create_inplace(bus, bus_size, typename, parent, name);
      pci_bus_init(bus, parent, name, address_space_mem,
                   address_space_io, devfn_min);
  }
@@@ -812,12 -812,7 +812,7 @@@ static PCIDevice *do_pci_register_devic
      }
  
      pci_dev->bus = bus;
-     if (bus->iommu_fn) {
-         dma_as = bus->iommu_fn(bus, bus->iommu_opaque, devfn);
-     } else {
-         /* FIXME: inherit memory region from bus creator */
-         dma_as = &address_space_memory;
-     }
+     dma_as = pci_device_iommu_address_space(pci_dev);
  
      memory_region_init_alias(&pci_dev->bus_master_enable_region,
                               OBJECT(pci_dev), "bus master",
@@@ -2239,6 -2234,23 +2234,23 @@@ static void pci_device_class_init(Objec
      k->props = pci_props;
  }
  
+ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev)
+ {
+     PCIBus *bus = PCI_BUS(dev->bus);
+     if (bus->iommu_fn) {
+         return bus->iommu_fn(bus, bus->iommu_opaque, dev->devfn);
+     }
+     if (bus->parent_dev) {
+         /** We are ignoring the bus master DMA bit of the bridge
+          *  as it would complicate things such as VFIO for no good reason */
+         return pci_device_iommu_address_space(bus->parent_dev);
+     }
+     return &address_space_memory;
+ }
  void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque)
  {
      bus->iommu_fn = fn;
diff --combined hw/ppc/ppc405_boards.c
index 75b2177c9ca454f67e8e2b2b507dad536694b205,43a83ca7c5bdc51a2178f7016983958167784baf..f1a8f6734acf3f1aa954be533dd5c600435d5163
  #include "hw/timer/m48t59.h"
  #include "hw/block/flash.h"
  #include "sysemu/sysemu.h"
 +#include "sysemu/qtest.h"
  #include "block/block.h"
  #include "hw/boards.h"
  #include "qemu/log.h"
 +#include "qemu/error-report.h"
  #include "hw/loader.h"
  #include "sysemu/blockdev.h"
  #include "exec/address-spaces.h"
@@@ -44,7 -42,7 +44,7 @@@
  
  #define USE_FLASH_BIOS
  
 -#define DEBUG_BOARD_INIT
 +//#define DEBUG_BOARD_INIT
  
  /*****************************************************************************/
  /* PPC405EP reference board (IBM) */
@@@ -254,20 -252,17 +254,20 @@@ static void ref405ep_init(QEMUMachineIn
          if (filename) {
              bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
              g_free(filename);
 +            if (bios_size < 0 || bios_size > BIOS_SIZE) {
 +                error_report("Could not load PowerPC BIOS '%s'", bios_name);
 +                exit(1);
 +            }
 +            bios_size = (bios_size + 0xfff) & ~0xfff;
 +            memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
 +        } else if (!qtest_enabled() || kernel_filename != NULL) {
 +            error_report("Could not load PowerPC BIOS '%s'", bios_name);
 +            exit(1);
          } else {
 +            /* Avoid an uninitialized variable warning */
              bios_size = -1;
          }
 -        if (bios_size < 0 || bios_size > BIOS_SIZE) {
 -            fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
 -                    bios_name);
 -            exit(1);
 -        }
 -        bios_size = (bios_size + 0xfff) & ~0xfff;
          memory_region_set_readonly(bios, true);
 -        memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
      }
      /* Register FPGA */
  #ifdef DEBUG_BOARD_INIT
          bdloc = 0;
      }
  #ifdef DEBUG_BOARD_INIT
 +    printf("bdloc " RAM_ADDR_FMT "\n", bdloc);
      printf("%s: Done\n", __func__);
  #endif
 -    printf("bdloc " RAM_ADDR_FMT "\n", bdloc);
  }
  
  static QEMUMachine ref405ep_machine = {
      .name = "ref405ep",
      .desc = "ref405ep",
      .init = ref405ep_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  /*****************************************************************************/
@@@ -574,17 -568,17 +573,17 @@@ static void taihu_405ep_init(QEMUMachin
          if (filename) {
              bios_size = load_image(filename, memory_region_get_ram_ptr(bios));
              g_free(filename);
 -        } else {
 -            bios_size = -1;
 -        }
 -        if (bios_size < 0 || bios_size > BIOS_SIZE) {
 -            fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n",
 -                    bios_name);
 +            if (bios_size < 0 || bios_size > BIOS_SIZE) {
 +                error_report("Could not load PowerPC BIOS '%s'", bios_name);
 +                exit(1);
 +            }
 +            bios_size = (bios_size + 0xfff) & ~0xfff;
 +            memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
 +        } else if (!qtest_enabled()) {
 +            error_report("Could not load PowerPC BIOS '%s'", bios_name);
              exit(1);
          }
 -        bios_size = (bios_size + 0xfff) & ~0xfff;
          memory_region_set_readonly(bios, true);
 -        memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
      }
      /* Register Linux flash */
      dinfo = drive_get(IF_PFLASH, 0, fl_idx);
@@@ -655,7 -649,6 +654,6 @@@ static QEMUMachine taihu_machine = 
      .name = "taihu",
      .desc = "taihu",
      .init = taihu_405ep_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static void ppc405_machine_init(void)
diff --combined hw/ppc/spapr.c
index 04f0ee3da129830ed095360b0f2d60e7a7a3af8e,3a2b3812889fc2539286aea92e7fc46ca7de46ef..279b88af97046db03869b13a536a0daf53d0d72a
@@@ -88,9 -88,6 +88,9 @@@ int spapr_allocate_irq(int hint, bool l
  
      if (hint) {
          irq = hint;
 +        if (hint >= spapr->next_irq) {
 +            spapr->next_irq = hint + 1;
 +        }
          /* FIXME: we should probably check for collisions somehow */
      } else {
          irq = spapr->next_irq++;
      return irq;
  }
  
 -/* Allocate block of consequtive IRQs, returns a number of the first */
 -int spapr_allocate_irq_block(int num, bool lsi)
 +/*
 + * Allocate block of consequtive IRQs, returns a number of the first.
 + * If msi==true, aligns the first IRQ number to num.
 + */
 +int spapr_allocate_irq_block(int num, bool lsi, bool msi)
  {
      int first = -1;
 -    int i;
 +    int i, hint = 0;
 +
 +    /*
 +     * MSIMesage::data is used for storing VIRQ so
 +     * it has to be aligned to num to support multiple
 +     * MSI vectors. MSI-X is not affected by this.
 +     * The hint is used for the first IRQ, the rest should
 +     * be allocated continously.
 +     */
 +    if (msi) {
 +        assert((num == 1) || (num == 2) || (num == 4) ||
 +               (num == 8) || (num == 16) || (num == 32));
 +        hint = (spapr->next_irq + num - 1) & ~(num - 1);
 +    }
  
      for (i = 0; i < num; ++i) {
          int irq;
  
 -        irq = spapr_allocate_irq(0, lsi);
 +        irq = spapr_allocate_irq(hint, lsi);
          if (!irq) {
              return -1;
          }
  
          if (0 == i) {
              first = irq;
 +            hint = 0;
          }
  
          /* If the above doesn't create a consecutive block then that's
@@@ -282,7 -262,7 +282,7 @@@ static void *spapr_create_fdt_skel(cons
      uint32_t start_prop = cpu_to_be32(initrd_base);
      uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
      char hypertas_prop[] = "hcall-pft\0hcall-term\0hcall-dabr\0hcall-interrupt"
 -        "\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk";
 +        "\0hcall-tce\0hcall-vio\0hcall-splpar\0hcall-bulk\0hcall-set-mode";
      char qemu_hypertas_prop[] = "hcall-memop1";
      uint32_t refpoints[] = {cpu_to_be32(0x4), cpu_to_be32(0x4)};
      uint32_t interrupt_server_ranges_prop[] = {0, cpu_to_be32(smp_cpus)};
@@@ -809,7 -789,7 +809,7 @@@ static void htab_save_first_pass(QEMUFi
  {
      int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;
      int index = spapr->htab_save_index;
 -    int64_t starttime = qemu_get_clock_ns(rt_clock);
 +    int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
  
      assert(spapr->htab_first_pass);
  
              qemu_put_buffer(f, HPTE(spapr->htab, chunkstart),
                              HASH_PTE_SIZE_64 * n_valid);
  
 -            if ((qemu_get_clock_ns(rt_clock) - starttime) > max_ns) {
 +            if ((qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
                  break;
              }
          }
@@@ -861,7 -841,7 +861,7 @@@ static int htab_save_later_pass(QEMUFil
      int htabslots = HTAB_SIZE(spapr) / HASH_PTE_SIZE_64;
      int examined = 0, sent = 0;
      int index = spapr->htab_save_index;
 -    int64_t starttime = qemu_get_clock_ns(rt_clock);
 +    int64_t starttime = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
  
      assert(!spapr->htab_first_pass);
  
                              HASH_PTE_SIZE_64 * n_valid);
              sent += index - chunkstart;
  
 -            if (!final && (qemu_get_clock_ns(rt_clock) - starttime) > max_ns) {
 +            if (!final && (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - starttime) > max_ns) {
                  break;
              }
          }
@@@ -1091,7 -1071,7 +1091,7 @@@ static void ppc_spapr_init(QEMUMachineI
      const char *kernel_filename = args->kernel_filename;
      const char *kernel_cmdline = args->kernel_cmdline;
      const char *initrd_filename = args->initrd_filename;
-     const char *boot_device = args->boot_device;
+     const char *boot_device = args->boot_order;
      PowerPCCPU *cpu;
      CPUPPCState *env;
      PCIHostState *phb;
      spapr_create_nvram(spapr);
  
      /* Set up PCI */
 +    spapr_pci_msi_init(spapr, SPAPR_PCI_MSI_WINDOW);
      spapr_pci_rtas_init();
  
      phb = spapr_create_phb(spapr, 0);
@@@ -1346,7 -1325,7 +1346,7 @@@ static QEMUMachine spapr_machine = 
      .block_default_type = IF_SCSI,
      .max_cpus = MAX_CPUS,
      .no_parallel = 1,
-     .boot_order = NULL,
+     .default_boot_order = NULL,
  };
  
  static void spapr_machine_init(void)
diff --combined hw/ppc/virtex_ml507.c
index e9468b1b25bda42faa2cb2738e0f5058b962cbe0,7250f512ea848c172f9775d350555a5860d096ec..fcfa678344abad59e922bc26b9d90380f08bf33e
@@@ -141,31 -141,22 +141,31 @@@ static int xilinx_load_device_tree(hwad
  {
      char *path;
      int fdt_size;
 -    void *fdt;
 +    void *fdt = NULL;
      int r;
 +    const char *dtb_filename;
  
 -    /* Try the local "ppc.dtb" override.  */
 -    fdt = load_device_tree("ppc.dtb", &fdt_size);
 -    if (!fdt) {
 -        path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
 -        if (path) {
 -            fdt = load_device_tree(path, &fdt_size);
 -            g_free(path);
 +    dtb_filename = qemu_opt_get(qemu_get_machine_opts(), "dtb");
 +    if (dtb_filename) {
 +        fdt = load_device_tree(dtb_filename, &fdt_size);
 +        if (!fdt) {
 +            error_report("Error while loading device tree file '%s'",
 +                dtb_filename);
          }
 +    } else {
 +        /* Try the local "ppc.dtb" override.  */
 +        fdt = load_device_tree("ppc.dtb", &fdt_size);
          if (!fdt) {
 -            return 0;
 +            path = qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FILE);
 +            if (path) {
 +                fdt = load_device_tree(path, &fdt_size);
 +                g_free(path);
 +            }
          }
      }
 -
 +    if (!fdt) {
 +        return 0;
 +    }
      r = qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", kernel_cmdline);
      if (r < 0)
          fprintf(stderr, "couldn't set /chosen/bootargs\n");
@@@ -254,7 -245,6 +254,6 @@@ static QEMUMachine virtex_machine = 
      .name = "virtex-ml507",
      .desc = "Xilinx Virtex ML507 reference design",
      .init = virtex_init,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static void virtex_machine_init(void)
index 8fd46a92c9d7d26b796d96f87a29b9c1c775ba67,e2681a63e65bf4f2e20f30113e217463c952c5e9..733d988871b74b322fc64d7184b91c397d4212df
  #include "css.h"
  #include "virtio-ccw.h"
  
 +void io_subsystem_reset(void)
 +{
 +    DeviceState *css, *sclp;
 +
 +    css = DEVICE(object_resolve_path_type("", "virtual-css-bridge", NULL));
 +    if (css) {
 +        qdev_reset_all(css);
 +    }
 +    sclp = DEVICE(object_resolve_path_type("",
 +                  "s390-sclp-event-facility", NULL));
 +    if (sclp) {
 +        qdev_reset_all(sclp);
 +    }
 +}
 +
  static int virtio_ccw_hcall_notify(const uint64_t *args)
  {
      uint64_t subch_id = args[0];
@@@ -141,7 -126,6 +141,6 @@@ static QEMUMachine ccw_machine = 
      .no_sdcard = 1,
      .use_sclp = 1,
      .max_cpus = 255,
-     DEFAULT_MACHINE_OPTIONS,
  };
  
  static void ccw_machine_init(void)
diff --combined hw/sparc64/sun4u.c
index 9da083310c2dca4ad65f120cf2d6af8cbf5c7309,e7a489387c7ad3cea87675ec4d8273f484577b1e..6f271d9cfc6d306e25a4b39635bd71eecedde506
@@@ -363,7 -363,7 +363,7 @@@ void cpu_put_timer(QEMUFile *f, CPUTime
      qemu_put_be64s(f, &s->disabled_mask);
      qemu_put_sbe64s(f, &s->clock_offset);
  
 -    qemu_put_timer(f, s->qtimer);
 +    timer_put(f, s->qtimer);
  }
  
  void cpu_get_timer(QEMUFile *f, CPUTimer *s)
      qemu_get_be64s(f, &s->disabled_mask);
      qemu_get_sbe64s(f, &s->clock_offset);
  
 -    qemu_get_timer(f, s->qtimer);
 +    timer_get(f, s->qtimer);
  }
  
  static CPUTimer *cpu_timer_create(const char *name, SPARCCPU *cpu,
      timer->disabled_mask = disabled_mask;
  
      timer->disabled = 1;
 -    timer->clock_offset = qemu_get_clock_ns(vm_clock);
 +    timer->clock_offset = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
  
 -    timer->qtimer = qemu_new_timer_ns(vm_clock, cb, cpu);
 +    timer->qtimer = timer_new_ns(QEMU_CLOCK_VIRTUAL, cb, cpu);
  
      return timer;
  }
  static void cpu_timer_reset(CPUTimer *timer)
  {
      timer->disabled = 1;
 -    timer->clock_offset = qemu_get_clock_ns(vm_clock);
 +    timer->clock_offset = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
  
 -    qemu_del_timer(timer->qtimer);
 +    timer_del(timer->qtimer);
  }
  
  static void main_cpu_reset(void *opaque)
@@@ -495,7 -495,7 +495,7 @@@ void cpu_tick_set_count(CPUTimer *timer
      uint64_t real_count = count & ~timer->disabled_mask;
      uint64_t disabled_bit = count & timer->disabled_mask;
  
 -    int64_t vm_clock_offset = qemu_get_clock_ns(vm_clock) -
 +    int64_t vm_clock_offset = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) -
                      cpu_to_timer_ticks(real_count, timer->frequency);
  
      TIMER_DPRINTF("%s set_count count=0x%016lx (%s) p=%p\n",
  uint64_t cpu_tick_get_count(CPUTimer *timer)
  {
      uint64_t real_count = timer_to_cpu_ticks(
 -                    qemu_get_clock_ns(vm_clock) - timer->clock_offset,
 +                    qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) - timer->clock_offset,
                      timer->frequency);
  
      TIMER_DPRINTF("%s get_count count=0x%016lx (%s) p=%p\n",
  
  void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit)
  {
 -    int64_t now = qemu_get_clock_ns(vm_clock);
 +    int64_t now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
  
      uint64_t real_limit = limit & ~timer->disabled_mask;
      timer->disabled = (limit & timer->disabled_mask) ? 1 : 0;
      if (!real_limit) {
          TIMER_DPRINTF("%s set_limit limit=ZERO - not starting timer\n",
                  timer->name);
 -        qemu_del_timer(timer->qtimer);
 +        timer_del(timer->qtimer);
      } else if (timer->disabled) {
 -        qemu_del_timer(timer->qtimer);
 +        timer_del(timer->qtimer);
      } else {
 -        qemu_mod_timer(timer->qtimer, expires);
 +        timer_mod(timer->qtimer, expires);
      }
  }
  
@@@ -881,7 -881,7 +881,7 @@@ static void sun4uv_init(MemoryRegion *a
                                      &kernel_addr, &kernel_entry);
  
      sun4u_NVRAM_set_params(nvram, NVRAM_SIZE, "Sun4u", args->ram_size,
-                            args->boot_device,
+                            args->boot_order,
                             kernel_addr, kernel_size,
                             args->kernel_cmdline,
                             initrd_addr, initrd_size,
      }
      fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr);
      fw_cfg_add_i64(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size);
-     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, args->boot_device[0]);
+     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, args->boot_order[0]);
  
      fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_WIDTH, graphic_width);
      fw_cfg_add_i16(fw_cfg, FW_CFG_SPARC64_HEIGHT, graphic_height);
@@@ -969,7 -969,7 +969,7 @@@ static QEMUMachine sun4u_machine = 
      .init = sun4u_init,
      .max_cpus = 1, // XXX for now
      .is_default = 1,
-     DEFAULT_MACHINE_OPTIONS,
+     .default_boot_order = "c",
  };
  
  static QEMUMachine sun4v_machine = {
      .desc = "Sun4v platform",
      .init = sun4v_init,
      .max_cpus = 1, // XXX for now
-     DEFAULT_MACHINE_OPTIONS,
+     .default_boot_order = "c",
  };
  
  static QEMUMachine niagara_machine = {
      .desc = "Sun4v platform, Niagara",
      .init = niagara_init,
      .max_cpus = 1, // XXX for now
-     DEFAULT_MACHINE_OPTIONS,
+     .default_boot_order = "c",
  };
  
  static void sun4u_register_types(void)
diff --combined hw/virtio/virtio-pci.c
index 14fd65e3745627b79f28ea33c3cc3f6609a81617,41b96cef1ee4f370487956f32efebc0242478b54..482580259848e656ee38ae1ab3e0a775864ce42c
@@@ -92,8 -92,7 +92,8 @@@
  /* HACK for virtio to determine if it's running a big endian guest */
  bool virtio_is_big_endian(void);
  
 -static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev);
 +static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
 +                               VirtIOPCIProxy *dev);
  
  /* virtio device */
  /* DeviceState to VirtIOPCIProxy. For use off data-path. TODO: use QOM. */
@@@ -509,7 -508,7 +509,7 @@@ static int kvm_virtio_pci_irqfd_use(Vir
      VirtQueue *vq = virtio_get_queue(proxy->vdev, queue_no);
      EventNotifier *n = virtio_queue_get_guest_notifier(vq);
      int ret;
 -    ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, irqfd->virq);
 +    ret = kvm_irqchip_add_irqfd_notifier(kvm_state, n, NULL, irqfd->virq);
      return ret;
  }
  
@@@ -800,8 -799,7 +800,7 @@@ static int virtio_pci_set_guest_notifie
              break;
          }
  
-         r = virtio_pci_set_guest_notifier(d, n, assign,
-                                           kvm_msi_via_irqfd_enabled());
+         r = virtio_pci_set_guest_notifier(d, n, assign, with_irqfd);
          if (r < 0) {
              goto assign_error;
          }
@@@ -919,7 -917,7 +918,7 @@@ static void virtio_9p_pci_class_init(Ob
  static void virtio_9p_pci_instance_init(Object *obj)
  {
      V9fsPCIState *dev = VIRTIO_9P_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_9P);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_9P);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  }
  
@@@ -987,7 -985,7 +986,7 @@@ static int virtio_pci_init(PCIDevice *p
  {
      VirtIOPCIProxy *dev = VIRTIO_PCI(pci_dev);
      VirtioPCIClass *k = VIRTIO_PCI_GET_CLASS(pci_dev);
 -    virtio_pci_bus_new(&dev->bus, dev);
 +    virtio_pci_bus_new(&dev->bus, sizeof(dev->bus), dev);
      if (k->init != NULL) {
          return k->init(dev);
      }
@@@ -1079,7 -1077,7 +1078,7 @@@ static void virtio_blk_pci_class_init(O
  static void virtio_blk_pci_instance_init(Object *obj)
  {
      VirtIOBlkPCI *dev = VIRTIO_BLK_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_BLK);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BLK);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  }
  
@@@ -1149,7 -1147,7 +1148,7 @@@ static void virtio_scsi_pci_class_init(
  static void virtio_scsi_pci_instance_init(Object *obj)
  {
      VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SCSI);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  }
  
@@@ -1206,7 -1204,7 +1205,7 @@@ static void vhost_scsi_pci_class_init(O
  static void vhost_scsi_pci_instance_init(Object *obj)
  {
      VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VHOST_SCSI);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  }
  
@@@ -1287,7 -1285,7 +1286,7 @@@ static void virtio_balloon_pci_class_in
  static void virtio_balloon_pci_instance_init(Object *obj)
  {
      VirtIOBalloonPCI *dev = VIRTIO_BALLOON_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_BALLOON);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_BALLOON);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  
      object_property_add(obj, "guest-stats", "guest statistics",
@@@ -1373,7 -1371,7 +1372,7 @@@ static void virtio_serial_pci_class_ini
  static void virtio_serial_pci_instance_init(Object *obj)
  {
      VirtIOSerialPCI *dev = VIRTIO_SERIAL_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SERIAL);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SERIAL);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  }
  
@@@ -1432,7 -1430,7 +1431,7 @@@ static void virtio_net_pci_class_init(O
  static void virtio_net_pci_instance_init(Object *obj)
  {
      VirtIONetPCI *dev = VIRTIO_NET_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_NET);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_NET);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
  }
  
@@@ -1488,7 -1486,7 +1487,7 @@@ static void virtio_rng_pci_class_init(O
  static void virtio_rng_initfn(Object *obj)
  {
      VirtIORngPCI *dev = VIRTIO_RNG_PCI(obj);
 -    object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_RNG);
 +    object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_RNG);
      object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
      object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
                               (Object **)&dev->vdev.conf.rng, NULL);
@@@ -1505,14 -1503,13 +1504,14 @@@ static const TypeInfo virtio_rng_pci_in
  
  /* virtio-pci-bus */
  
 -static void virtio_pci_bus_new(VirtioBusState *bus, VirtIOPCIProxy *dev)
 +static void virtio_pci_bus_new(VirtioBusState *bus, size_t bus_size,
 +                               VirtIOPCIProxy *dev)
  {
      DeviceState *qdev = DEVICE(dev);
      BusState *qbus;
      char virtio_bus_name[] = "virtio-bus";
  
 -    qbus_create_inplace((BusState *)bus, TYPE_VIRTIO_PCI_BUS, qdev,
 +    qbus_create_inplace(bus, bus_size, TYPE_VIRTIO_PCI_BUS, qdev,
                          virtio_bus_name);
      qbus = BUS(bus);
      qbus->allow_hotplug = 1;
diff --combined include/hw/pci/pci.h
index 051b6edcb9ba83d398946deb5df0abfeae96cd2c,2374aa95ba48acd741501b02db26ed0c1f7db139..37979aa723725727ae04842225588a1846aa4844
@@@ -348,7 -348,7 +348,7 @@@ typedef int (*pci_hotplug_fn)(DeviceSta
  
  bool pci_bus_is_express(PCIBus *bus);
  bool pci_bus_is_root(PCIBus *bus);
 -void pci_bus_new_inplace(PCIBus *bus, DeviceState *parent,
 +void pci_bus_new_inplace(PCIBus *bus, size_t bus_size, DeviceState *parent,
                           const char *name,
                           MemoryRegion *address_space_mem,
                           MemoryRegion *address_space_io,
@@@ -405,6 -405,7 +405,7 @@@ void pci_device_deassert_intx(PCIDevic
  
  typedef AddressSpace *(*PCIIOMMUFunc)(PCIBus *, void *, int);
  
+ AddressSpace *pci_device_iommu_address_space(PCIDevice *dev);
  void pci_setup_iommu(PCIBus *bus, PCIIOMMUFunc fn, void *opaque);
  
  static inline void
diff --combined trace-events
index aaad3560f495d23609fbd6c815d203a5c14c0576,9d1d1df89d96117827633729007280b77dfe22ae..3e988669a3019d9d56e7d92cc6b620d819afb722
@@@ -1133,11 -1133,6 +1133,11 @@@ xics_ics_write_xive(int nr, int srcno, 
  xics_ics_reject(int nr, int srcno) "reject irq %#x [src %d]"
  xics_ics_eoi(int nr) "ics_eoi: irq %#x"
  
 +# hw/ppc/spapr_iommu.c
 +spapr_iommu_put(uint64_t liobn, uint64_t ioba, uint64_t tce, uint64_t ret) "liobn=%"PRIx64" ioba=0x%"PRIx64" tce=0x%"PRIx64" ret=%"PRId64
 +spapr_iommu_xlate(uint64_t liobn, uint64_t ioba, uint64_t tce, unsigned perm, unsigned pgsize) "liobn=%"PRIx64" 0x%"PRIx64" -> 0x%"PRIx64" perm=%u mask=%x"
 +spapr_iommu_new_table(uint64_t liobn, void *tcet, void *table, int fd) "liobn=%"PRIx64" tcet=%p table=%p fd=%d"
 +
  # util/hbitmap.c
  hbitmap_iter_skip_words(const void *hb, void *hbi, uint64_t pos, unsigned long cur) "hb %p hbi %p pos %"PRId64" cur 0x%lx"
  hbitmap_reset(void *hb, uint64_t start, uint64_t count, uint64_t sbit, uint64_t ebit) "hb %p items %"PRIu64",%"PRIu64" bits %"PRIu64"..%"PRIu64
@@@ -1181,3 -1176,7 +1181,7 @@@ object_class_dynamic_cast_assert(const 
  # hw/xen/xen_pvdevice.c
  xen_pv_mmio_read(uint64_t addr) "WARNING: read from Xen PV Device MMIO space (address %"PRIx64")"
  xen_pv_mmio_write(uint64_t addr) "WARNING: write to Xen PV Device MMIO space (address %"PRIx64")"
+ # hw/pci/pci_host.c
+ pci_cfg_read(const char *dev, unsigned devid, unsigned fnid, unsigned offs, unsigned val) "%s %02u:%u @0x%x -> 0x%x"
+ pci_cfg_write(const char *dev, unsigned devid, unsigned fnid, unsigned offs, unsigned val) "%s %02u:%u @0x%x <- 0x%x"
diff --combined vl.c
index dfbc071eefcdaae6203b3731a6b75bd96b286c6e,2624c0faacc9cb3039d938ebe06f3b6da14984f3..b4b119a8853a52d9281574088f349bfd5f3aed46
--- 1/vl.c
--- 2/vl.c
+++ b/vl.c
@@@ -196,7 -196,7 +196,7 @@@ NICInfo nd_table[MAX_NICS]
  int autostart;
  static int rtc_utc = 1;
  static int rtc_date_offset = -1; /* -1 means no change */
 -QEMUClock *rtc_clock;
 +QEMUClockType rtc_clock;
  int vga_interface_type = VGA_NONE;
  static int full_screen = 0;
  static int no_frame = 0;
@@@ -805,11 -805,11 +805,11 @@@ static void configure_rtc(QemuOpts *opt
      value = qemu_opt_get(opts, "clock");
      if (value) {
          if (!strcmp(value, "host")) {
 -            rtc_clock = host_clock;
 +            rtc_clock = QEMU_CLOCK_HOST;
          } else if (!strcmp(value, "rt")) {
 -            rtc_clock = rt_clock;
 +            rtc_clock = QEMU_CLOCK_REALTIME;
          } else if (!strcmp(value, "vm")) {
 -            rtc_clock = vm_clock;
 +            rtc_clock = QEMU_CLOCK_VIRTUAL;
          } else {
              fprintf(stderr, "qemu: invalid option value '%s'\n", value);
              exit(1);
@@@ -2393,7 -2393,7 +2393,7 @@@ static int chardev_init_func(QemuOpts *
  
      qemu_chr_new_from_opts(opts, NULL, &local_err);
      if (error_is_set(&local_err)) {
 -        fprintf(stderr, "%s\n", error_get_pretty(local_err));
 +        error_report("%s", error_get_pretty(local_err));
          error_free(local_err);
          return -1;
      }
@@@ -2965,7 -2965,7 +2965,7 @@@ int main(int argc, char **argv, char **
      runstate_init();
  
      init_clocks();
 -    rtc_clock = host_clock;
 +    rtc_clock = QEMU_CLOCK_HOST;
  
      qemu_cache_utils_init(envp);
  
                  old_param = 1;
                  break;
              case QEMU_OPTION_clock:
 -                configure_alarms(optarg);
 +                /* Clock options no longer exist.  Keep this option for
 +                 * backward compatibility.
 +                 */
                  break;
              case QEMU_OPTION_startdate:
                  configure_rtc_date_offset(optarg, 1);
      kernel_cmdline = qemu_opt_get(machine_opts, "append");
  
      if (!boot_order) {
-         boot_order = machine->boot_order;
+         boot_order = machine->default_boot_order;
      }
      opts = qemu_opts_find(qemu_find_opts("boot-opts"), NULL);
      if (opts) {
      qdev_machine_init();
  
      QEMUMachineInitArgs args = { .ram_size = ram_size,
-                                  .boot_device = boot_order,
+                                  .boot_order = boot_order,
                                   .kernel_filename = kernel_filename,
                                   .kernel_cmdline = kernel_cmdline,
                                   .initrd_filename = initrd_filename,
          vnc_display_init(ds);
          vnc_display_open(ds, vnc_display, &local_err);
          if (local_err != NULL) {
 -            fprintf(stderr, "Failed to start VNC server on `%s': %s\n",
 -                    vnc_display, error_get_pretty(local_err));
 +            error_report("Failed to start VNC server on `%s': %s",
 +                         vnc_display, error_get_pretty(local_err));
              error_free(local_err);
              exit(1);
          }
          Error *local_err = NULL;
          qemu_start_incoming_migration(incoming, &local_err);
          if (local_err) {
 -            fprintf(stderr, "-incoming %s: %s\n", incoming, error_get_pretty(local_err));
 +            error_report("-incoming %s: %s", incoming,
 +                         error_get_pretty(local_err));
              error_free(local_err);
              exit(1);
          }