All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023
@ 2015-10-23  9:43 David Gibson
  2015-10-23  9:43 ` David Gibson
                   ` (22 more replies)
  0 siblings, 23 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

The following changes since commit 6a6739de510706e1d337180d12be74ebbd0c7666:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20151021' into staging (2015-10-22 18:01:53 +0100)

are available in the git repository at:

  git://github.com/dgibson/qemu.git tags/ppc-next-20151023

for you to fetch changes up to 659f7f65561e78d720986d61f3112c54a97b2b96:

  prep: do not use CPU_LOG_IOPORT, convert to tracepoints (2015-10-23 12:38:28 +1100)

Peter,

I meant to send most of these out a week ago, but it appears I got
sidetracked between setting up my final tests and actually sending the
pull request.  I'm hoping we can still merge this now, at the
beginning of the soft freeze.

I am getting a failure on one of the Travis builds for this tree (see,
e.g. https://travis-ci.org/dgibson/dgibson/qemu/jobs/86949030).
However, I don't think it's related to the patches I'm pushing.

Resend, CCing qemu-devel and qemu-ppc.  Sorry for the mixup.

----------------------------------------------------------------
ppc patch queue - 2015-10-23

sPAPR highlights:
  * Allow VFIO devices on the spapr-pci-host-bridge
  * Allow virtio VGA
  * Safer handling of HTAB allocation
  * ibm,pa-features device tree property

non-sPAPR highlights:
  * Categorization of many ppc specific devices in help output
  * Tweaks to MMU type constants

----------------------------------------------------------------
Benjamin Herrenschmidt (2):
      ppc: Add mmu_model defines for arch 2.03 and 2.07
      ppc/spapr: Add "ibm,pa-features" property to the device-tree

Bharata B Rao (2):
      spapr: Allocate HTAB from machine init
      spapr: Abort when HTAB of requested size isn't allocated

David Gibson (4):
      spapr_pci: Allow PCI host bridge DMA window to be configured
      spapr_iommu: Rename vfio_accel parameter
      spapr_iommu: Provide a function to switch a TCE table to allowing VFIO
      spapr_pci: Allow VFIO devices to work on the normal PCI host bridge

Laurent Vivier (10):
      adb: add to input category
      cmd646: add to storage category
      escc: add to input category
      grackle: add to bridge category
      cuda: add to bridge category
      macio-ide: add to storage category
      uninorth: add to bridge category
      macio: add to bridge category
      macio-nvram: add to misc category
      openpic: add to misc category

Paolo Bonzini (1):
      prep: do not use CPU_LOG_IOPORT, convert to tracepoints

Thomas Huth (2):
      spapr: Add "slb-size" property to CPU device tree nodes
      hw/scsi/spapr_vscsi: Remove superfluous memset

 hw/char/escc.c              |  1 +
 hw/ide/cmd646.c             |  1 +
 hw/ide/macio.c              |  1 +
 hw/input/adb.c              |  2 ++
 hw/intc/openpic.c           |  1 +
 hw/intc/openpic_kvm.c       |  1 +
 hw/misc/macio/cuda.c        |  1 +
 hw/misc/macio/macio.c       |  1 +
 hw/nvram/mac_nvram.c        |  1 +
 hw/pci-host/grackle.c       |  2 ++
 hw/pci-host/uninorth.c      |  8 +++++
 hw/ppc/prep.c               | 30 ++----------------
 hw/ppc/spapr.c              | 74 ++++++++++++++++++++++++++++++++++++++++-----
 hw/ppc/spapr_iommu.c        | 38 +++++++++++++++++++++--
 hw/ppc/spapr_pci.c          | 13 ++++++--
 hw/scsi/spapr_vscsi.c       |  1 -
 include/hw/pci-host/spapr.h |  3 +-
 include/hw/ppc/spapr.h      |  6 ++--
 target-ppc/cpu.h            | 11 ++++---
 target-ppc/kvm.c            | 19 +++++++++---
 target-ppc/kvm_ppc.h        |  2 +-
 target-ppc/mmu_helper.c     | 16 +++++-----
 target-ppc/translate.c      |  4 +--
 target-ppc/translate_init.c |  5 +--
 trace-events                |  4 +++
 25 files changed, 179 insertions(+), 67 deletions(-)

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23 12:50   ` Peter Maydell
  2015-10-23  9:43 ` [Qemu-devel] [PULL 01/21] spapr: Allocate HTAB from machine init David Gibson
                   ` (21 subsequent siblings)
  22 siblings, 1 reply; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

The following changes since commit 6a6739de510706e1d337180d12be74ebbd0c7666:

  Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20151021' into staging (2015-10-22 18:01:53 +0100)

are available in the git repository at:

  git://github.com/dgibson/qemu.git tags/ppc-next-20151023

for you to fetch changes up to 659f7f65561e78d720986d61f3112c54a97b2b96:

  prep: do not use CPU_LOG_IOPORT, convert to tracepoints (2015-10-23 12:38:28 +1100)

----------------------------------------------------------------
ppc patch queue - 2015-10-23

sPAPR highlights:
  * Allow VFIO devices on the spapr-pci-host-bridge
  * Allow virtio VGA
  * Safer handling of HTAB allocation
  * ibm,pa-features device tree property

non-sPAPR highlights:
  * Categorization of many ppc specific devices in help output
  * Tweaks to MMU type constants

----------------------------------------------------------------
Benjamin Herrenschmidt (2):
      ppc: Add mmu_model defines for arch 2.03 and 2.07
      ppc/spapr: Add "ibm,pa-features" property to the device-tree

Bharata B Rao (2):
      spapr: Allocate HTAB from machine init
      spapr: Abort when HTAB of requested size isn't allocated

David Gibson (4):
      spapr_pci: Allow PCI host bridge DMA window to be configured
      spapr_iommu: Rename vfio_accel parameter
      spapr_iommu: Provide a function to switch a TCE table to allowing VFIO
      spapr_pci: Allow VFIO devices to work on the normal PCI host bridge

Laurent Vivier (10):
      adb: add to input category
      cmd646: add to storage category
      escc: add to input category
      grackle: add to bridge category
      cuda: add to bridge category
      macio-ide: add to storage category
      uninorth: add to bridge category
      macio: add to bridge category
      macio-nvram: add to misc category
      openpic: add to misc category

Paolo Bonzini (1):
      prep: do not use CPU_LOG_IOPORT, convert to tracepoints

Thomas Huth (2):
      spapr: Add "slb-size" property to CPU device tree nodes
      hw/scsi/spapr_vscsi: Remove superfluous memset

 hw/char/escc.c              |  1 +
 hw/ide/cmd646.c             |  1 +
 hw/ide/macio.c              |  1 +
 hw/input/adb.c              |  2 ++
 hw/intc/openpic.c           |  1 +
 hw/intc/openpic_kvm.c       |  1 +
 hw/misc/macio/cuda.c        |  1 +
 hw/misc/macio/macio.c       |  1 +
 hw/nvram/mac_nvram.c        |  1 +
 hw/pci-host/grackle.c       |  2 ++
 hw/pci-host/uninorth.c      |  8 +++++
 hw/ppc/prep.c               | 30 ++----------------
 hw/ppc/spapr.c              | 74 ++++++++++++++++++++++++++++++++++++++++-----
 hw/ppc/spapr_iommu.c        | 38 +++++++++++++++++++++--
 hw/ppc/spapr_pci.c          | 13 ++++++--
 hw/scsi/spapr_vscsi.c       |  1 -
 include/hw/pci-host/spapr.h |  3 +-
 include/hw/ppc/spapr.h      |  6 ++--
 target-ppc/cpu.h            | 11 ++++---
 target-ppc/kvm.c            | 19 +++++++++---
 target-ppc/kvm_ppc.h        |  2 +-
 target-ppc/mmu_helper.c     | 16 +++++-----
 target-ppc/translate.c      |  4 +--
 target-ppc/translate_init.c |  5 +--
 trace-events                |  4 +++
 25 files changed, 179 insertions(+), 67 deletions(-)

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 01/21] spapr: Allocate HTAB from machine init
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
  2015-10-23  9:43 ` David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 02/21] spapr: Abort when HTAB of requested size isn't allocated David Gibson
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	Bharata B Rao, David Gibson

From: Bharata B Rao <bharata@linux.vnet.ibm.com>

Allocate HTAB from ppc_spapr_init() so that we can abort the guest
if requested HTAB size is't allocated by the host. However retain the
htab reset call in spapr_reset_htab() so that HTAB gets reset (and
not allocated) during machine reset.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 3852ad1..998a77b 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -979,7 +979,7 @@ static void emulate_spapr_hypercall(PowerPCCPU *cpu)
 #define CLEAN_HPTE(_hpte)  ((*(uint64_t *)(_hpte)) &= tswap64(~HPTE64_V_HPTE_DIRTY))
 #define DIRTY_HPTE(_hpte)  ((*(uint64_t *)(_hpte)) |= tswap64(HPTE64_V_HPTE_DIRTY))
 
-static void spapr_reset_htab(sPAPRMachineState *spapr)
+static void spapr_alloc_htab(sPAPRMachineState *spapr)
 {
     long shift;
     int index;
@@ -994,18 +994,37 @@ static void spapr_reset_htab(sPAPRMachineState *spapr)
         /* Kernel handles htab, we don't need to allocate one */
         spapr->htab_shift = shift;
         kvmppc_kern_htab = true;
+    } else {
+        /* Allocate htab */
+        spapr->htab = qemu_memalign(HTAB_SIZE(spapr), HTAB_SIZE(spapr));
+
+        /* And clear it */
+        memset(spapr->htab, 0, HTAB_SIZE(spapr));
+
+        for (index = 0; index < HTAB_SIZE(spapr) / HASH_PTE_SIZE_64; index++) {
+            DIRTY_HPTE(HPTE(spapr->htab, index));
+        }
+    }
+}
+
+/*
+ * Clear HTAB entries during reset.
+ *
+ * If host kernel has allocated HTAB, KVM_PPC_ALLOCATE_HTAB ioctl is
+ * used to clear HTAB. Otherwise QEMU-allocated HTAB is cleared manually.
+ */
+static void spapr_reset_htab(sPAPRMachineState *spapr)
+{
+    long shift;
+    int index;
 
+    shift = kvmppc_reset_htab(spapr->htab_shift);
+    if (shift > 0) {
         /* Tell readers to update their file descriptor */
         if (spapr->htab_fd >= 0) {
             spapr->htab_fd_stale = true;
         }
     } else {
-        if (!spapr->htab) {
-            /* Allocate an htab if we don't yet have one */
-            spapr->htab = qemu_memalign(HTAB_SIZE(spapr), HTAB_SIZE(spapr));
-        }
-
-        /* And clear it */
         memset(spapr->htab, 0, HTAB_SIZE(spapr));
 
         for (index = 0; index < HTAB_SIZE(spapr) / HASH_PTE_SIZE_64; index++) {
@@ -1710,6 +1729,7 @@ static void ppc_spapr_init(MachineState *machine)
         }
         spapr->htab_shift++;
     }
+    spapr_alloc_htab(spapr);
 
     /* Set up Interrupt Controller before we create the VCPUs */
     spapr->icp = xics_system_init(machine,
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 02/21] spapr: Abort when HTAB of requested size isn't allocated
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
  2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 01/21] spapr: Allocate HTAB from machine init David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 03/21] spapr: Add "slb-size" property to CPU device tree nodes David Gibson
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	Bharata B Rao, David Gibson

From: Bharata B Rao <bharata@linux.vnet.ibm.com>

Terminate the guest when HTAB of requested size isn't allocated by
the host.

When memory hotplug is attempted on a guest that has booted with
less than requested HTAB size, the guest kernel will not be able
to gracefully fail the hotplug request. This patch will ensure that
we never end up in a situation where memory hotplug fails due to
less than requested HTAB size.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 998a77b..f90f592 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -992,6 +992,10 @@ static void spapr_alloc_htab(sPAPRMachineState *spapr)
 
     if (shift > 0) {
         /* Kernel handles htab, we don't need to allocate one */
+        if (shift != spapr->htab_shift) {
+            error_setg(&error_abort, "Failed to allocate HTAB of requested size, try with smaller maxmem");
+        }
+
         spapr->htab_shift = shift;
         kvmppc_kern_htab = true;
     } else {
@@ -1020,6 +1024,10 @@ static void spapr_reset_htab(sPAPRMachineState *spapr)
 
     shift = kvmppc_reset_htab(spapr->htab_shift);
     if (shift > 0) {
+        if (shift != spapr->htab_shift) {
+            error_setg(&error_abort, "Requested HTAB allocation failed during reset");
+        }
+
         /* Tell readers to update their file descriptor */
         if (spapr->htab_fd >= 0) {
             spapr->htab_fd_stale = true;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 03/21] spapr: Add "slb-size" property to CPU device tree nodes
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (2 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 02/21] spapr: Abort when HTAB of requested size isn't allocated David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 04/21] spapr_pci: Allow PCI host bridge DMA window to be configured David Gibson
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

From: Thomas Huth <thuth@redhat.com>

According to a commit message in the Linux kernel (see here
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=b60c31d85a2a
for example), the name of the property that carries the information
about the number of SLB entries should be called "slb-size", and
not "ibm,slb-size". The Linux kernel can deal with both names, but
to be on the safe side we should support the official name, too.

[Now that LoPAPR is public, the relevant requirement can be found in
section C.6.1.8 --dwg]

Signed-off-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index f90f592..3ba1e90 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -625,6 +625,7 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
 
     _FDT((fdt_setprop_cell(fdt, offset, "timebase-frequency", tbfreq)));
     _FDT((fdt_setprop_cell(fdt, offset, "clock-frequency", cpufreq)));
+    _FDT((fdt_setprop_cell(fdt, offset, "slb-size", env->slb_nr)));
     _FDT((fdt_setprop_cell(fdt, offset, "ibm,slb-size", env->slb_nr)));
     _FDT((fdt_setprop_string(fdt, offset, "status", "okay")));
     _FDT((fdt_setprop(fdt, offset, "64-bit", NULL, 0)));
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 04/21] spapr_pci: Allow PCI host bridge DMA window to be configured
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (3 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 03/21] spapr: Add "slb-size" property to CPU device tree nodes David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 05/21] spapr_iommu: Rename vfio_accel parameter David Gibson
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

At present the PCI host bridge (PHB) for the pseries machine type has a
fixed DMA window from 0..1GB (in PCI address space) which is mapped to real
memory via the PAPR paravirtualized IOMMU.

For better support of VFIO devices, we're going to want to allow for
different configurations of the DMA window.

Eventually we'll want to allow the guest itself to reconfigure the window
via the PAPR dynamic DMA window interface, but as a preliminary this patch
allows the user to reconfigure the window with new properties on the PHB
device.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/ppc/spapr_pci.c          | 7 +++++--
 include/hw/pci-host/spapr.h | 3 +--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 617b7f3..cb7c351 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1387,7 +1387,7 @@ static void spapr_phb_finish_realize(sPAPRPHBState *sphb, Error **errp)
     sPAPRTCETable *tcet;
     uint32_t nb_table;
 
-    nb_table = SPAPR_PCI_DMA32_SIZE >> SPAPR_TCE_PAGE_SHIFT;
+    nb_table = sphb->dma_win_size >> SPAPR_TCE_PAGE_SHIFT;
     tcet = spapr_tce_new_table(DEVICE(sphb), sphb->dma_liobn,
                                0, SPAPR_TCE_PAGE_SHIFT, nb_table, false);
     if (!tcet) {
@@ -1397,7 +1397,7 @@ static void spapr_phb_finish_realize(sPAPRPHBState *sphb, Error **errp)
     }
 
     /* Register default 32bit DMA window */
-    memory_region_add_subregion(&sphb->iommu_root, 0,
+    memory_region_add_subregion(&sphb->iommu_root, sphb->dma_win_addr,
                                 spapr_tce_get_iommu(tcet));
 }
 
@@ -1430,6 +1430,9 @@ static Property spapr_phb_properties[] = {
                        SPAPR_PCI_IO_WIN_SIZE),
     DEFINE_PROP_BOOL("dynamic-reconfiguration", sPAPRPHBState, dr_enabled,
                      true),
+    /* Default DMA window is 0..1GB */
+    DEFINE_PROP_UINT64("dma_win_addr", sPAPRPHBState, dma_win_addr, 0),
+    DEFINE_PROP_UINT64("dma_win_size", sPAPRPHBState, dma_win_size, 0x40000000),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/include/hw/pci-host/spapr.h b/include/hw/pci-host/spapr.h
index 5322b56..7de5e02 100644
--- a/include/hw/pci-host/spapr.h
+++ b/include/hw/pci-host/spapr.h
@@ -78,6 +78,7 @@ struct sPAPRPHBState {
     MemoryRegion memwindow, iowindow, msiwindow;
 
     uint32_t dma_liobn;
+    hwaddr dma_win_addr, dma_win_size;
     AddressSpace iommu_as;
     MemoryRegion iommu_root;
 
@@ -115,8 +116,6 @@ struct sPAPRPHBVFIOState {
 
 #define SPAPR_PCI_MSI_WINDOW         0x40000000000ULL
 
-#define SPAPR_PCI_DMA32_SIZE         0x40000000
-
 static inline qemu_irq spapr_phb_lsi_qirq(struct sPAPRPHBState *phb, int pin)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 05/21] spapr_iommu: Rename vfio_accel parameter
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (4 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 04/21] spapr_pci: Allow PCI host bridge DMA window to be configured David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 06/21] spapr_iommu: Provide a function to switch a TCE table to allowing VFIO David Gibson
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

The vfio_accel parameter used when creating a new TCE table (guest IOMMU
context) has a confusing name.  What it really means is whether we need the
TCE table created to be able to support VFIO devices.

VFIO is relevant, because when available we use in-kernel acceleration of
the TCE table, but that may not work with VFIO devices because updates to
the table are handled in kernel, bypass qemu and so don't hit qemu's
infrastructure for keeping the VFIO host IOMMU state in sync with the guest
IOMMU state.

Rename the parameter to "need_vfio" throughout.  This is a cosmetic change,
with no impact on the logic.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/ppc/spapr_iommu.c   | 6 +++---
 include/hw/ppc/spapr.h | 4 ++--
 target-ppc/kvm.c       | 4 ++--
 target-ppc/kvm_ppc.h   | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index f61504e..5166cde 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -146,7 +146,7 @@ static int spapr_tce_table_realize(DeviceState *dev)
         tcet->table = kvmppc_create_spapr_tce(tcet->liobn,
                                               window_size,
                                               &tcet->fd,
-                                              tcet->vfio_accel);
+                                              tcet->need_vfio);
     }
 
     if (!tcet->table) {
@@ -172,7 +172,7 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
                                    uint64_t bus_offset,
                                    uint32_t page_shift,
                                    uint32_t nb_table,
-                                   bool vfio_accel)
+                                   bool need_vfio)
 {
     sPAPRTCETable *tcet;
     char tmp[64];
@@ -192,7 +192,7 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
     tcet->bus_offset = bus_offset;
     tcet->page_shift = page_shift;
     tcet->nb_table = nb_table;
-    tcet->vfio_accel = vfio_accel;
+    tcet->need_vfio = need_vfio;
 
     snprintf(tmp, sizeof(tmp), "tce-table-%x", liobn);
     object_property_add_child(OBJECT(owner), tmp, OBJECT(tcet), NULL);
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 56c5b0b..27d65d5 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -563,7 +563,7 @@ struct sPAPRTCETable {
     uint32_t page_shift;
     uint64_t *table;
     bool bypass;
-    bool vfio_accel;
+    bool need_vfio;
     int fd;
     MemoryRegion iommu;
     struct VIOsPAPRDevice *vdev; /* for @bypass migration compatibility only */
@@ -588,7 +588,7 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
                                    uint64_t bus_offset,
                                    uint32_t page_shift,
                                    uint32_t nb_table,
-                                   bool vfio_accel);
+                                   bool need_vfio);
 MemoryRegion *spapr_tce_get_iommu(sPAPRTCETable *tcet);
 int spapr_dma_dt(void *fdt, int node_off, const char *propname,
                  uint32_t liobn, uint64_t window, uint32_t size);
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 38aa927..3db9d2b 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -2070,7 +2070,7 @@ bool kvmppc_spapr_use_multitce(void)
 }
 
 void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd,
-                              bool vfio_accel)
+                              bool need_vfio)
 {
     struct kvm_create_spapr_tce args = {
         .liobn = liobn,
@@ -2084,7 +2084,7 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd,
      * destroying the table, which the upper layers -will- do
      */
     *pfd = -1;
-    if (!cap_spapr_tce || (vfio_accel && !cap_spapr_vfio)) {
+    if (!cap_spapr_tce || (need_vfio && !cap_spapr_vfio)) {
         return NULL;
     }
 
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index 470f6d6..309cbe0 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -36,7 +36,7 @@ int kvmppc_booke_watchdog_enable(PowerPCCPU *cpu);
 off_t kvmppc_alloc_rma(void **rma);
 bool kvmppc_spapr_use_multitce(void);
 void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd,
-                              bool vfio_accel);
+                              bool need_vfio);
 int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
 int kvmppc_reset_htab(int shift_hint);
 uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 06/21] spapr_iommu: Provide a function to switch a TCE table to allowing VFIO
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (5 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 05/21] spapr_iommu: Rename vfio_accel parameter David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 07/21] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge David Gibson
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

Because of the way non-VFIO guest IOMMU operations are KVM accelerated, not
all TCE tables (guest IOMMU contexts) can support VFIO devices.  Currently,
this is decided at creation time.

To support hotplug of VFIO devices, we need to allow a TCE table which
previously didn't allow VFIO devices to be switched so that it can.  This
patch adds an spapr_tce_set_need_vfio() function to do this, by
reallocating the table in userspace if necessary.

Currently this doesn't allow the KVM acceleration to be re-enabled if all
the VFIO devices are removed.  That's an optimization for another time.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/ppc/spapr_iommu.c   | 32 ++++++++++++++++++++++++++++++++
 include/hw/ppc/spapr.h |  2 ++
 2 files changed, 34 insertions(+)

diff --git a/hw/ppc/spapr_iommu.c b/hw/ppc/spapr_iommu.c
index 5166cde..ed28565 100644
--- a/hw/ppc/spapr_iommu.c
+++ b/hw/ppc/spapr_iommu.c
@@ -168,6 +168,38 @@ static int spapr_tce_table_realize(DeviceState *dev)
     return 0;
 }
 
+void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool need_vfio)
+{
+    size_t table_size = tcet->nb_table * sizeof(uint64_t);
+    void *newtable;
+
+    if (need_vfio == tcet->need_vfio) {
+        /* Nothing to do */
+        return;
+    }
+
+    if (!need_vfio) {
+        /* FIXME: We don't support transition back to KVM accelerated
+         * TCEs yet */
+        return;
+    }
+
+    tcet->need_vfio = true;
+
+    if (tcet->fd < 0) {
+        /* Table is already in userspace, nothing to be do */
+        return;
+    }
+
+    newtable = g_malloc(table_size);
+    memcpy(newtable, tcet->table, table_size);
+
+    kvmppc_remove_spapr_tce(tcet->table, tcet->fd, tcet->nb_table);
+
+    tcet->fd = -1;
+    tcet->table = newtable;
+}
+
 sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
                                    uint64_t bus_offset,
                                    uint32_t page_shift,
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 27d65d5..5baa906 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -589,6 +589,8 @@ sPAPRTCETable *spapr_tce_new_table(DeviceState *owner, uint32_t liobn,
                                    uint32_t page_shift,
                                    uint32_t nb_table,
                                    bool need_vfio);
+void spapr_tce_set_need_vfio(sPAPRTCETable *tcet, bool need_vfio);
+
 MemoryRegion *spapr_tce_get_iommu(sPAPRTCETable *tcet);
 int spapr_dma_dt(void *fdt, int node_off, const char *propname,
                  uint32_t liobn, uint64_t window, uint32_t size);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 07/21] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (6 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 06/21] spapr_iommu: Provide a function to switch a TCE table to allowing VFIO David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 08/21] hw/scsi/spapr_vscsi: Remove superfluous memset David Gibson
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

The core VFIO infrastructure more or less allows VFIO devices to work
on any normal guest PCI host bridge (PHB) without extra logic.
However, the "spapr-pci-host-bridge" device (as opposed to the special
"spapr-pci-vfio-host-bridge" device) breaks this by using a partially
KVM accelerated implementation of the guest kernel IOMMU which won't
work with VFIO devices, without additional kernel support.

This patch allows VFIO devices to work on the spapr-pci-host-bridge,
by having it switch off KVM TCE acceleration when a VFIO device is
added to the PHB (either on startup, or by hotplug).

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/ppc/spapr_pci.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index cb7c351..55fa8db 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1083,6 +1083,12 @@ static void spapr_phb_add_pci_device(sPAPRDRConnector *drc,
     void *fdt = NULL;
     int fdt_start_offset = 0, fdt_size;
 
+    if (object_dynamic_cast(OBJECT(pdev), "vfio-pci")) {
+        sPAPRTCETable *tcet = spapr_tce_find_by_liobn(phb->dma_liobn);
+
+        spapr_tce_set_need_vfio(tcet, true);
+    }
+
     if (dev->hotplugged) {
         fdt = create_device_tree(&fdt_size);
         fdt_start_offset = spapr_create_pci_child_dt(phb, pdev, fdt, 0);
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 08/21] hw/scsi/spapr_vscsi: Remove superfluous memset
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (7 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 07/21] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 09/21] ppc: Add mmu_model defines for arch 2.03 and 2.07 David Gibson
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	Paolo Bonzini, David Gibson

From: Thomas Huth <thuth@redhat.com>

g_malloc0 already clears the memory, so no need for
the additional memset here.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Alexander Graf <agraf@suse.de>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/scsi/spapr_vscsi.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/scsi/spapr_vscsi.c b/hw/scsi/spapr_vscsi.c
index 891424f..f4f5140 100644
--- a/hw/scsi/spapr_vscsi.c
+++ b/hw/scsi/spapr_vscsi.c
@@ -750,7 +750,6 @@ static void vscsi_report_luns(VSCSIState *s, vscsi_req *req)
     len = n+8;
 
     resp_data = g_malloc0(len);
-    memset(resp_data, 0, len);
     stl_be_p(resp_data, n);
     i = found_lun0 ? 8 : 16;
     QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 09/21] ppc: Add mmu_model defines for arch 2.03 and 2.07
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (8 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 08/21] hw/scsi/spapr_vscsi: Remove superfluous memset David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 10/21] ppc/spapr: Add "ibm, pa-features" property to the device-tree David Gibson
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

This removes unused POWERPC_MMU_2_06a/POWERPC_MMU_2_06d.

This replaces POWERPC_MMU_64B with POWERPC_MMU_2_03 for POWER5+ to be
more explicit about the version of the PowerISA supported.

This defines POWERPC_MMU_2_07 and uses it for the POWER8 CPU family.
This will not have an immediate effect now but it will in the following
patch.

This should cause no behavioural change.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[aik: rebased, changed commit log]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 target-ppc/cpu.h            | 10 +++++-----
 target-ppc/kvm.c            |  8 +++++---
 target-ppc/mmu_helper.c     | 16 ++++++++--------
 target-ppc/translate.c      |  4 ++--
 target-ppc/translate_init.c |  4 ++--
 5 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 98ce5a7..69d8cf6 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -117,14 +117,14 @@ enum powerpc_mmu_t {
 #define POWERPC_MMU_AMR      0x00040000
     /* 64 bits PowerPC MMU                                     */
     POWERPC_MMU_64B        = POWERPC_MMU_64 | 0x00000001,
+    /* Architecture 2.03 and later (has LPCR) */
+    POWERPC_MMU_2_03       = POWERPC_MMU_64 | 0x00000002,
     /* Architecture 2.06 variant                               */
     POWERPC_MMU_2_06       = POWERPC_MMU_64 | POWERPC_MMU_1TSEG
                              | POWERPC_MMU_AMR | 0x00000003,
-    /* Architecture 2.06 "degraded" (no 1T segments)           */
-    POWERPC_MMU_2_06a      = POWERPC_MMU_64 | POWERPC_MMU_AMR
-                             | 0x00000003,
-    /* Architecture 2.06 "degraded" (no 1T segments or AMR)    */
-    POWERPC_MMU_2_06d      = POWERPC_MMU_64 | 0x00000003,
+    /* Architecture 2.07 variant                               */
+    POWERPC_MMU_2_07       = POWERPC_MMU_64 | POWERPC_MMU_1TSEG
+                             | POWERPC_MMU_AMR | 0x00000004,
 #endif /* defined(TARGET_PPC64) */
 };
 
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index 3db9d2b..b4af75d 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -259,7 +259,8 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu,
             info->flags |= KVM_PPC_1T_SEGMENTS;
         }
 
-        if (env->mmu_model == POWERPC_MMU_2_06) {
+        if (env->mmu_model == POWERPC_MMU_2_06 ||
+            env->mmu_model == POWERPC_MMU_2_07) {
             info->slb_size = 32;
         } else {
             info->slb_size = 64;
@@ -272,8 +273,9 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu,
         info->sps[i].enc[0].pte_enc = 0;
         i++;
 
-        /* 64K on MMU 2.06 */
-        if (env->mmu_model == POWERPC_MMU_2_06) {
+        /* 64K on MMU 2.06 and later */
+        if (env->mmu_model == POWERPC_MMU_2_06 ||
+            env->mmu_model == POWERPC_MMU_2_07) {
             info->sps[i].page_shift = 16;
             info->sps[i].slb_enc = 0x110;
             info->sps[i].enc[0].page_shift = 16;
diff --git a/target-ppc/mmu_helper.c b/target-ppc/mmu_helper.c
index 527c6ad..e52d0e5 100644
--- a/target-ppc/mmu_helper.c
+++ b/target-ppc/mmu_helper.c
@@ -1293,9 +1293,9 @@ void dump_mmu(FILE *f, fprintf_function cpu_fprintf, CPUPPCState *env)
         break;
 #if defined(TARGET_PPC64)
     case POWERPC_MMU_64B:
+    case POWERPC_MMU_2_03:
     case POWERPC_MMU_2_06:
-    case POWERPC_MMU_2_06a:
-    case POWERPC_MMU_2_06d:
+    case POWERPC_MMU_2_07:
         dump_slb(f, cpu_fprintf, env);
         break;
 #endif
@@ -1433,9 +1433,9 @@ hwaddr ppc_cpu_get_phys_page_debug(CPUState *cs, vaddr addr)
     switch (env->mmu_model) {
 #if defined(TARGET_PPC64)
     case POWERPC_MMU_64B:
+    case POWERPC_MMU_2_03:
     case POWERPC_MMU_2_06:
-    case POWERPC_MMU_2_06a:
-    case POWERPC_MMU_2_06d:
+    case POWERPC_MMU_2_07:
         return ppc_hash64_get_phys_page_debug(env, addr);
 #endif
 
@@ -1937,9 +1937,9 @@ void ppc_tlb_invalidate_all(CPUPPCState *env)
     case POWERPC_MMU_601:
 #if defined(TARGET_PPC64)
     case POWERPC_MMU_64B:
+    case POWERPC_MMU_2_03:
     case POWERPC_MMU_2_06:
-    case POWERPC_MMU_2_06a:
-    case POWERPC_MMU_2_06d:
+    case POWERPC_MMU_2_07:
 #endif /* defined(TARGET_PPC64) */
         tlb_flush(CPU(cpu), 1);
         break;
@@ -2011,9 +2011,9 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_ulong addr)
         break;
 #if defined(TARGET_PPC64)
     case POWERPC_MMU_64B:
+    case POWERPC_MMU_2_03:
     case POWERPC_MMU_2_06:
-    case POWERPC_MMU_2_06a:
-    case POWERPC_MMU_2_06d:
+    case POWERPC_MMU_2_07:
         /* tlbie invalidate TLBs for all segments */
         /* XXX: given the fact that there are too many segments to invalidate,
          *      and we still don't have a tlb_flush_mask(env, n, mask) in QEMU,
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index c2bc1a7..453509a 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -11327,9 +11327,9 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf,
     case POWERPC_MMU_SOFT_74xx:
 #if defined(TARGET_PPC64)
     case POWERPC_MMU_64B:
+    case POWERPC_MMU_2_03:
     case POWERPC_MMU_2_06:
-    case POWERPC_MMU_2_06a:
-    case POWERPC_MMU_2_06d:
+    case POWERPC_MMU_2_07:
 #endif
         cpu_fprintf(f, " SDR1 " TARGET_FMT_lx "   DAR " TARGET_FMT_lx
                        "  DSISR " TARGET_FMT_lx "\n", env->spr[SPR_SDR1],
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index b541473..2adbb63 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -8019,7 +8019,7 @@ POWERPC_FAMILY(POWER5P)(ObjectClass *oc, void *data)
                     (1ull << MSR_DR) |
                     (1ull << MSR_PMM) |
                     (1ull << MSR_RI);
-    pcc->mmu_model = POWERPC_MMU_64B;
+    pcc->mmu_model = POWERPC_MMU_2_03;
 #if defined(CONFIG_SOFTMMU)
     pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
 #endif
@@ -8243,7 +8243,7 @@ POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data)
                     (1ull << MSR_PMM) |
                     (1ull << MSR_RI) |
                     (1ull << MSR_LE);
-    pcc->mmu_model = POWERPC_MMU_2_06;
+    pcc->mmu_model = POWERPC_MMU_2_07;
 #if defined(CONFIG_SOFTMMU)
     pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault;
 #endif
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 10/21] ppc/spapr: Add "ibm, pa-features" property to the device-tree
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (9 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 09/21] ppc: Add mmu_model defines for arch 2.03 and 2.07 David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 11/21] adb: add to input category David Gibson
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc, David Gibson

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>

LoPAPR defines a "ibm,pa-features" per-CPU device tree property which
describes extended features of the Processor Architecture.

This adds the property to the device tree. At the moment this is the
copy of what pHyp advertises except "I=1 (cache inhibited) Large Pages"
which is enabled for TCG and disabled when running under HV KVM host
with 4K system page size.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[aik: rebased, changed commit log, moved ci_large_pages initialization,
renamed pa_features arrays]
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c              | 31 +++++++++++++++++++++++++++++++
 target-ppc/cpu.h            |  1 +
 target-ppc/kvm.c            |  7 +++++++
 target-ppc/translate_init.c |  1 +
 4 files changed, 40 insertions(+)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 3ba1e90..e1202ce 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -597,6 +597,24 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
     uint32_t vcpus_per_socket = smp_threads * smp_cores;
     uint32_t pft_size_prop[] = {0, cpu_to_be32(spapr->htab_shift)};
 
+    /* Note: we keep CI large pages off for now because a 64K capable guest
+     * provisioned with large pages might otherwise try to map a qemu
+     * framebuffer (or other kind of memory mapped PCI BAR) using 64K pages
+     * even if that qemu runs on a 4k host.
+     *
+     * We can later add this bit back when we are confident this is not
+     * an issue (!HV KVM or 64K host)
+     */
+    uint8_t pa_features_206[] = { 6, 0,
+        0xf6, 0x1f, 0xc7, 0x00, 0x80, 0xc0 };
+    uint8_t pa_features_207[] = { 24, 0,
+        0xf6, 0x1f, 0xc7, 0xc0, 0x80, 0xf0,
+        0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
+        0x80, 0x00, 0x80, 0x00, 0x80, 0x00 };
+    uint8_t *pa_features;
+    size_t pa_size;
+
     _FDT((fdt_setprop_cell(fdt, offset, "reg", index)));
     _FDT((fdt_setprop_string(fdt, offset, "device_type", "cpu")));
 
@@ -663,6 +681,19 @@ static void spapr_populate_cpu_dt(CPUState *cs, void *fdt, int offset,
                           page_sizes_prop, page_sizes_prop_size)));
     }
 
+    /* Do the ibm,pa-features property, adjust it for ci-large-pages */
+    if (env->mmu_model == POWERPC_MMU_2_06) {
+        pa_features = pa_features_206;
+        pa_size = sizeof(pa_features_206);
+    } else /* env->mmu_model == POWERPC_MMU_2_07 */ {
+        pa_features = pa_features_207;
+        pa_size = sizeof(pa_features_207);
+    }
+    if (env->ci_large_pages) {
+        pa_features[3] |= 0x20;
+    }
+    _FDT((fdt_setprop(fdt, offset, "ibm,pa-features", pa_features, pa_size)));
+
     _FDT((fdt_setprop_cell(fdt, offset, "ibm,chip-id",
                            cs->cpu_index / vcpus_per_socket)));
 
diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h
index 69d8cf6..b34aed6 100644
--- a/target-ppc/cpu.h
+++ b/target-ppc/cpu.h
@@ -1073,6 +1073,7 @@ struct CPUPPCState {
     uint64_t insns_flags2;
 #if defined(TARGET_PPC64)
     struct ppc_segment_page_sizes sps;
+    bool ci_large_pages;
 #endif
 
 #if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index b4af75d..ac70f08 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -414,6 +414,13 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu)
     /* Convert to QEMU form */
     memset(&env->sps, 0, sizeof(env->sps));
 
+    /* If we have HV KVM, we need to forbid CI large pages if our
+     * host page size is smaller than 64K.
+     */
+    if (smmu_info.flags & KVM_PPC_PAGE_SIZES_REAL) {
+        env->ci_large_pages = getpagesize() >= 0x10000;
+    }
+
     /*
      * XXX This loop should be an entry wide AND of the capabilities that
      *     the selected CPU has with the capabilities that KVM supports.
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 2adbb63..4934c80 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -7864,6 +7864,7 @@ static void init_proc_book3s_64(CPUPPCState *env, int version)
         gen_spr_book3s_ids(env);
         gen_spr_amr(env);
         gen_spr_book3s_purr(env);
+        env->ci_large_pages = true;
         break;
     default:
         g_assert_not_reached();
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 11/21] adb: add to input category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (10 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 10/21] ppc/spapr: Add "ibm, pa-features" property to the device-tree David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 12/21] cmd646: add to storage category David Gibson
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

The Apple Desktop Bus is used to connect a keyboard and a mouse,
so add it to the input category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/input/adb.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/input/adb.c b/hw/input/adb.c
index a18eea2..09eead9 100644
--- a/hw/input/adb.c
+++ b/hw/input/adb.c
@@ -362,6 +362,7 @@ static void adb_kbd_class_init(ObjectClass *oc, void *data)
 
     akc->parent_realize = dc->realize;
     dc->realize = adb_kbd_realizefn;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 
     adc->devreq = adb_kbd_request;
     dc->reset = adb_kbd_reset;
@@ -566,6 +567,7 @@ static void adb_mouse_class_init(ObjectClass *oc, void *data)
 
     amc->parent_realize = dc->realize;
     dc->realize = adb_mouse_realizefn;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 
     adc->devreq = adb_mouse_request;
     dc->reset = adb_mouse_reset;
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 12/21] cmd646: add to storage category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (11 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 11/21] adb: add to input category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 13/21] escc: add to input category David Gibson
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

cmd646 is an IDE controller, so add it to the
storage category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ide/cmd646.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index 66fb9d9..27f3da2 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -417,6 +417,7 @@ static void cmd646_ide_class_init(ObjectClass *klass, void *data)
     k->config_read = cmd646_pci_config_read;
     k->config_write = cmd646_pci_config_write;
     dc->props = cmd646_ide_properties;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo cmd646_ide_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 13/21] escc: add to input category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (12 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 12/21] cmd646: add to storage category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 14/21] grackle: add to bridge category David Gibson
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

ESCC is a serial port controller, so add it
to the input category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/char/escc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/char/escc.c b/hw/char/escc.c
index ba653ef..9816154 100644
--- a/hw/char/escc.c
+++ b/hw/char/escc.c
@@ -1035,6 +1035,7 @@ static void escc_class_init(ObjectClass *klass, void *data)
     dc->reset = escc_reset;
     dc->vmsd = &vmstate_escc;
     dc->props = escc_properties;
+    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
 }
 
 static const TypeInfo escc_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 14/21] grackle: add to bridge category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (13 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 13/21] escc: add to input category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 15/21] cuda: " David Gibson
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

Grackle is the PCI host controller of oldworld powermac,
so add it to the bridge category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/pci-host/grackle.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c
index bfe707a..ea31b72 100644
--- a/hw/pci-host/grackle.c
+++ b/hw/pci-host/grackle.c
@@ -146,8 +146,10 @@ static const TypeInfo grackle_pci_info = {
 static void pci_grackle_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     k->init = pci_grackle_init_device;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo grackle_pci_host_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 15/21] cuda: add to bridge category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (14 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 14/21] grackle: add to bridge category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 16/21] macio-ide: add to storage category David Gibson
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

Cuda is a bridge between PowerMac system bus and the ADB controller,
real-time clock, pram and the power management unit.

So add it to the bridge category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/misc/macio/cuda.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 5d7043e..0fd75b3 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -738,6 +738,7 @@ static void cuda_class_init(ObjectClass *oc, void *data)
     dc->reset = cuda_reset;
     dc->vmsd = &vmstate_cuda;
     dc->props = cuda_properties;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo cuda_type_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 16/21] macio-ide: add to storage category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (15 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 15/21] cuda: " David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 17/21] uninorth: add to bridge category David Gibson
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

macio-ide is an IDE controller, so add it
to the storage category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ide/macio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index 66ac2ba..893c9b9 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -590,6 +590,7 @@ static void macio_ide_class_init(ObjectClass *oc, void *data)
     dc->realize = macio_ide_realizefn;
     dc->reset = macio_ide_reset;
     dc->vmsd = &vmstate_pmac;
+    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
 }
 
 static const TypeInfo macio_ide_type_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 17/21] uninorth: add to bridge category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (16 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 16/21] macio-ide: add to storage category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 18/21] macio: " David Gibson
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

Uninorth is the mac99 PCI host controller, so add
it to the bridge category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/pci-host/uninorth.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c
index f0144eb..215b64f 100644
--- a/hw/pci-host/uninorth.c
+++ b/hw/pci-host/uninorth.c
@@ -446,8 +446,10 @@ static const TypeInfo unin_internal_pci_host_info = {
 static void pci_unin_main_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     sbc->init = pci_unin_main_init_device;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_main_info = {
@@ -460,8 +462,10 @@ static const TypeInfo pci_unin_main_info = {
 static void pci_u3_agp_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     sbc->init = pci_u3_agp_init_device;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_u3_agp_info = {
@@ -474,8 +478,10 @@ static const TypeInfo pci_u3_agp_info = {
 static void pci_unin_agp_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     sbc->init = pci_unin_agp_init_device;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_agp_info = {
@@ -488,8 +494,10 @@ static const TypeInfo pci_unin_agp_info = {
 static void pci_unin_internal_class_init(ObjectClass *klass, void *data)
 {
     SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
+    DeviceClass *dc = DEVICE_CLASS(klass);
 
     sbc->init = pci_unin_internal_init_device;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo pci_unin_internal_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 18/21] macio: add to bridge category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (17 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 17/21] uninorth: add to bridge category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 19/21] macio-nvram: add to misc category David Gibson
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

macio is a bridge between the PCI bus and the Mac nvram,
IDE controller and PIC, so add it to the bridge category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/misc/macio/macio.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index c661f86..adb990e 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -393,6 +393,7 @@ static void macio_class_init(ObjectClass *klass, void *data)
     k->vendor_id = PCI_VENDOR_ID_APPLE;
     k->class_id = PCI_CLASS_OTHERS << 8;
     dc->props = macio_properties;
+    set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
 }
 
 static const TypeInfo macio_oldworld_type_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 19/21] macio-nvram: add to misc category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (18 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 18/21] macio: " David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 20/21] openpic: " David Gibson
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

The macio nvram is a non volatile RAM, so add it
the misc category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/nvram/mac_nvram.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c
index d35f8a3..9f16566 100644
--- a/hw/nvram/mac_nvram.c
+++ b/hw/nvram/mac_nvram.c
@@ -123,6 +123,7 @@ static void macio_nvram_class_init(ObjectClass *oc, void *data)
     dc->reset = macio_nvram_reset;
     dc->vmsd = &vmstate_macio_nvram;
     dc->props = macio_nvram_properties;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo macio_nvram_type_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 20/21] openpic: add to misc category
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (19 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 19/21] macio-nvram: add to misc category David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23  9:43 ` [Qemu-devel] [PULL 21/21] prep: do not use CPU_LOG_IOPORT, convert to tracepoints David Gibson
  2015-10-23 13:56 ` [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 Michael Roth
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	David Gibson, Laurent Vivier

From: Laurent Vivier <laurent@vivier.eu>

openpic is a programmable interrupt controller, so
add it to the misc category.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/intc/openpic.c     | 1 +
 hw/intc/openpic_kvm.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/hw/intc/openpic.c b/hw/intc/openpic.c
index 14ab0e3..bfcf155 100644
--- a/hw/intc/openpic.c
+++ b/hw/intc/openpic.c
@@ -1643,6 +1643,7 @@ static void openpic_class_init(ObjectClass *oc, void *data)
     dc->props = openpic_properties;
     dc->reset = openpic_reset;
     dc->vmsd = &vmstate_openpic;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo openpic_info = {
diff --git a/hw/intc/openpic_kvm.c b/hw/intc/openpic_kvm.c
index f7cac58..649f476 100644
--- a/hw/intc/openpic_kvm.c
+++ b/hw/intc/openpic_kvm.c
@@ -275,6 +275,7 @@ static void kvm_openpic_class_init(ObjectClass *oc, void *data)
     dc->realize = kvm_openpic_realize;
     dc->props = kvm_openpic_properties;
     dc->reset = kvm_openpic_reset;
+    set_bit(DEVICE_CATEGORY_MISC, dc->categories);
 }
 
 static const TypeInfo kvm_openpic_info = {
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [Qemu-devel] [PULL 21/21] prep: do not use CPU_LOG_IOPORT, convert to tracepoints
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (20 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 20/21] openpic: " David Gibson
@ 2015-10-23  9:43 ` David Gibson
  2015-10-23 13:56 ` [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 Michael Roth
  22 siblings, 0 replies; 25+ messages in thread
From: David Gibson @ 2015-10-23  9:43 UTC (permalink / raw)
  To: peter.maydell
  Cc: lvivier, thuth, qemu-devel, aik, agraf, mdroth, qemu-ppc,
	Paolo Bonzini, David Gibson

From: Paolo Bonzini <pbonzini@redhat.com>

These messages are disabled by default; a perfect usecase for tracepoints.
Convert them over.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/prep.c | 30 +++---------------------------
 trace-events  |  4 ++++
 2 files changed, 7 insertions(+), 27 deletions(-)

diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index d95222b..5ad28f7 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -42,11 +42,9 @@
 #include "sysemu/arch_init.h"
 #include "sysemu/qtest.h"
 #include "exec/address-spaces.h"
+#include "trace.h"
 #include "elf.h"
 
-//#define HARD_DEBUG_PPC_IO
-//#define DEBUG_PPC_IO
-
 /* SMP is not enabled, for now */
 #define MAX_CPUS 1
 
@@ -57,26 +55,6 @@
 #define KERNEL_LOAD_ADDR 0x01000000
 #define INITRD_LOAD_ADDR 0x01800000
 
-#if defined (HARD_DEBUG_PPC_IO) && !defined (DEBUG_PPC_IO)
-#define DEBUG_PPC_IO
-#endif
-
-#if defined (HARD_DEBUG_PPC_IO)
-#define PPC_IO_DPRINTF(fmt, ...)                         \
-do {                                                     \
-    if (qemu_loglevel_mask(CPU_LOG_IOPORT)) {            \
-        qemu_log("%s: " fmt, __func__ , ## __VA_ARGS__); \
-    } else {                                             \
-        printf("%s : " fmt, __func__ , ## __VA_ARGS__);  \
-    }                                                    \
-} while (0)
-#elif defined (DEBUG_PPC_IO)
-#define PPC_IO_DPRINTF(fmt, ...) \
-qemu_log_mask(CPU_LOG_IOPORT, fmt, ## __VA_ARGS__)
-#else
-#define PPC_IO_DPRINTF(fmt, ...) do { } while (0)
-#endif
-
 /* Constants for devices init */
 static const int ide_iobase[2] = { 0x1f0, 0x170 };
 static const int ide_iobase2[2] = { 0x3f6, 0x376 };
@@ -199,8 +177,7 @@ static void PREP_io_800_writeb (void *opaque, uint32_t addr, uint32_t val)
 {
     sysctrl_t *sysctrl = opaque;
 
-    PPC_IO_DPRINTF("0x%08" PRIx32 " => 0x%02" PRIx32 "\n",
-                   addr - PPC_IO_BASE, val);
+    trace_prep_io_800_writeb(addr - PPC_IO_BASE, val);
     switch (addr) {
     case 0x0092:
         /* Special port 92 */
@@ -327,8 +304,7 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
         printf("ERROR: unaffected IO port: %04" PRIx32 " read\n", addr);
         break;
     }
-    PPC_IO_DPRINTF("0x%08" PRIx32 " <= 0x%02" PRIx32 "\n",
-                   addr - PPC_IO_BASE, retval);
+    trace_prep_io_800_readb(addr - PPC_IO_BASE, retval);
 
     return retval;
 }
diff --git a/trace-events b/trace-events
index f237c7f..bdfe79f 100644
--- a/trace-events
+++ b/trace-events
@@ -1383,6 +1383,10 @@ spapr_iommu_new_table(uint64_t liobn, void *tcet, void *table, int fd) "liobn=%"
 # hw/ppc/ppc.c
 ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "adjusted from 0x%"PRIx64" to 0x%"PRIx64", diff %"PRId64" (%"PRId64"s)"
 
+# hw/ppc/prep.c
+prep_io_800_writeb(uint32_t addr, uint32_t val) "0x%08" PRIx32 " => 0x%02" PRIx32
+prep_io_800_readb(uint32_t addr, uint32_t retval) "0x%08" PRIx32 " <= 0x%02" PRIx32
+
 # 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
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023
  2015-10-23  9:43 ` David Gibson
@ 2015-10-23 12:50   ` Peter Maydell
  0 siblings, 0 replies; 25+ messages in thread
From: Peter Maydell @ 2015-10-23 12:50 UTC (permalink / raw)
  To: David Gibson
  Cc: Laurent Vivier, Thomas Huth, QEMU Developers,
	Alexey Kardashevskiy, Alexander Graf, Michael Roth, qemu-ppc

On 23 October 2015 at 10:43, David Gibson <david@gibson.dropbear.id.au> wrote:
> The following changes since commit 6a6739de510706e1d337180d12be74ebbd0c7666:
>
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20151021' into staging (2015-10-22 18:01:53 +0100)
>
> are available in the git repository at:
>
>   git://github.com/dgibson/qemu.git tags/ppc-next-20151023
>
> for you to fetch changes up to 659f7f65561e78d720986d61f3112c54a97b2b96:
>
>   prep: do not use CPU_LOG_IOPORT, convert to tracepoints (2015-10-23 12:38:28 +1100)
>
> ----------------------------------------------------------------
> ppc patch queue - 2015-10-23

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023
  2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
                   ` (21 preceding siblings ...)
  2015-10-23  9:43 ` [Qemu-devel] [PULL 21/21] prep: do not use CPU_LOG_IOPORT, convert to tracepoints David Gibson
@ 2015-10-23 13:56 ` Michael Roth
  22 siblings, 0 replies; 25+ messages in thread
From: Michael Roth @ 2015-10-23 13:56 UTC (permalink / raw)
  To: David Gibson, peter.maydell
  Cc: lvivier, thuth, aik, agraf, qemu-devel, qemu-ppc

Quoting David Gibson (2015-10-23 04:43:11)
> The following changes since commit 6a6739de510706e1d337180d12be74ebbd0c7666:
> 
>   Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20151021' into staging (2015-10-22 18:01:53 +0100)
> 
> are available in the git repository at:
> 
>   git://github.com/dgibson/qemu.git tags/ppc-next-20151023
> 
> for you to fetch changes up to 659f7f65561e78d720986d61f3112c54a97b2b96:
> 
>   prep: do not use CPU_LOG_IOPORT, convert to tracepoints (2015-10-23 12:38:28 +1100)
> 
> Peter,
> 
> I meant to send most of these out a week ago, but it appears I got
> sidetracked between setting up my final tests and actually sending the
> pull request.  I'm hoping we can still merge this now, at the
> beginning of the soft freeze.
> 
> I am getting a failure on one of the Travis builds for this tree (see,
> e.g. https://travis-ci.org/dgibson/dgibson/qemu/jobs/86949030).

That's probably the qga-test unit test failure:

  http://mid.gmane.org/<1445359759-7575-1-git-send-email-mdroth@linux.vnet.ibm.com>

Sending a pull shortly.

> However, I don't think it's related to the patches I'm pushing.
> 
> Resend, CCing qemu-devel and qemu-ppc.  Sorry for the mixup.
> 
> ----------------------------------------------------------------
> ppc patch queue - 2015-10-23
> 
> sPAPR highlights:
>   * Allow VFIO devices on the spapr-pci-host-bridge
>   * Allow virtio VGA
>   * Safer handling of HTAB allocation
>   * ibm,pa-features device tree property
> 
> non-sPAPR highlights:
>   * Categorization of many ppc specific devices in help output
>   * Tweaks to MMU type constants
> 
> ----------------------------------------------------------------
> Benjamin Herrenschmidt (2):
>       ppc: Add mmu_model defines for arch 2.03 and 2.07
>       ppc/spapr: Add "ibm,pa-features" property to the device-tree
> 
> Bharata B Rao (2):
>       spapr: Allocate HTAB from machine init
>       spapr: Abort when HTAB of requested size isn't allocated
> 
> David Gibson (4):
>       spapr_pci: Allow PCI host bridge DMA window to be configured
>       spapr_iommu: Rename vfio_accel parameter
>       spapr_iommu: Provide a function to switch a TCE table to allowing VFIO
>       spapr_pci: Allow VFIO devices to work on the normal PCI host bridge
> 
> Laurent Vivier (10):
>       adb: add to input category
>       cmd646: add to storage category
>       escc: add to input category
>       grackle: add to bridge category
>       cuda: add to bridge category
>       macio-ide: add to storage category
>       uninorth: add to bridge category
>       macio: add to bridge category
>       macio-nvram: add to misc category
>       openpic: add to misc category
> 
> Paolo Bonzini (1):
>       prep: do not use CPU_LOG_IOPORT, convert to tracepoints
> 
> Thomas Huth (2):
>       spapr: Add "slb-size" property to CPU device tree nodes
>       hw/scsi/spapr_vscsi: Remove superfluous memset
> 
>  hw/char/escc.c              |  1 +
>  hw/ide/cmd646.c             |  1 +
>  hw/ide/macio.c              |  1 +
>  hw/input/adb.c              |  2 ++
>  hw/intc/openpic.c           |  1 +
>  hw/intc/openpic_kvm.c       |  1 +
>  hw/misc/macio/cuda.c        |  1 +
>  hw/misc/macio/macio.c       |  1 +
>  hw/nvram/mac_nvram.c        |  1 +
>  hw/pci-host/grackle.c       |  2 ++
>  hw/pci-host/uninorth.c      |  8 +++++
>  hw/ppc/prep.c               | 30 ++----------------
>  hw/ppc/spapr.c              | 74 ++++++++++++++++++++++++++++++++++++++++-----
>  hw/ppc/spapr_iommu.c        | 38 +++++++++++++++++++++--
>  hw/ppc/spapr_pci.c          | 13 ++++++--
>  hw/scsi/spapr_vscsi.c       |  1 -
>  include/hw/pci-host/spapr.h |  3 +-
>  include/hw/ppc/spapr.h      |  6 ++--
>  target-ppc/cpu.h            | 11 ++++---
>  target-ppc/kvm.c            | 19 +++++++++---
>  target-ppc/kvm_ppc.h        |  2 +-
>  target-ppc/mmu_helper.c     | 16 +++++-----
>  target-ppc/translate.c      |  4 +--
>  target-ppc/translate_init.c |  5 +--
>  trace-events                |  4 +++
>  25 files changed, 179 insertions(+), 67 deletions(-)
> 

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-10-23 13:56 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-23  9:43 [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 David Gibson
2015-10-23  9:43 ` David Gibson
2015-10-23 12:50   ` Peter Maydell
2015-10-23  9:43 ` [Qemu-devel] [PULL 01/21] spapr: Allocate HTAB from machine init David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 02/21] spapr: Abort when HTAB of requested size isn't allocated David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 03/21] spapr: Add "slb-size" property to CPU device tree nodes David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 04/21] spapr_pci: Allow PCI host bridge DMA window to be configured David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 05/21] spapr_iommu: Rename vfio_accel parameter David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 06/21] spapr_iommu: Provide a function to switch a TCE table to allowing VFIO David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 07/21] spapr_pci: Allow VFIO devices to work on the normal PCI host bridge David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 08/21] hw/scsi/spapr_vscsi: Remove superfluous memset David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 09/21] ppc: Add mmu_model defines for arch 2.03 and 2.07 David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 10/21] ppc/spapr: Add "ibm, pa-features" property to the device-tree David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 11/21] adb: add to input category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 12/21] cmd646: add to storage category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 13/21] escc: add to input category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 14/21] grackle: add to bridge category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 15/21] cuda: " David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 16/21] macio-ide: add to storage category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 17/21] uninorth: add to bridge category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 18/21] macio: " David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 19/21] macio-nvram: add to misc category David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 20/21] openpic: " David Gibson
2015-10-23  9:43 ` [Qemu-devel] [PULL 21/21] prep: do not use CPU_LOG_IOPORT, convert to tracepoints David Gibson
2015-10-23 13:56 ` [Qemu-devel] [PULL 00/21] ppc-next-20151023 queue 20151023 Michael Roth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.