Skip to contentSkip to conversation

pc, pci, virtio: fixes, features

GIT PULL Michael S. Tsirkin 2 participants 8 messages Apr 27, 2018

lore
Share & tools
lore
#0 lore raw

The following changes since commit 4743c23509a51bd4ee85cc272287a41917d1be35:

Update version for v2.12.0 release (2018-04-24 16:44:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to fb6fd86f712c73a40fbe0c6be86d4635239b1304:

virtio-balloon: add hugetlb page allocation counts (2018-04-27 06:25:27 +0300)

----------------------------------------------------------------
pc, pci, virtio: fixes, features

A bugfix that just missed 2.12, a new PCI,
and a new virtio balloon stat.

----------------------------------------------------------------
Gerd Hoffmann (1):
allocate pci id for mdpy

Jonathan Helman (1):
virtio-balloon: add hugetlb page allocation counts

Peter Xu (1):
intel-iommu: send PSI always when notify_unmap set

Zihan Yang (1):
hw/pci-host/q35: Replace hardcoded value with macro

 docs/specs/pci-ids.txt                          |  1 +
 docs/virtio-balloon-stats.txt                   |  2 ++
 include/hw/pci/pci.h                            |  1 +
 include/standard-headers/linux/virtio_balloon.h |  4 ++-
 hw/i386/intel_iommu.c                           | 42 ++++++++++++++++++-------
 hw/pci-host/q35.c                               | 17 ++++++----
 hw/virtio/virtio-balloon.c                      |  2 ++
 7 files changed, 50 insertions(+), 19 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 2/4] hw/pci-host/q35: Replace hardcoded value with macro

From: Zihan Yang <[email protected]>

During smram region initialization some addresses are hardcoded, replace them with macro to be more clear to readers.

Previous patch forgets about one value and exceeds the line limit of 90 characters. The v2 breaks a few long lines

---
 hw/pci-host/q35.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
hw/pci-host/q35.c +11 -6
index a36a119..02f9576 100644
@@ -535,13 +535,15 @@ static void mch_realize(PCIDevice *d, Error **errp)
 
     /* if *disabled* show SMRAM to all CPUs */
     memory_region_init_alias(&mch->smram_region, OBJECT(mch), "smram-region",
-                             mch->pci_address_space, 0xa0000, 0x20000);
-    memory_region_add_subregion_overlap(mch->system_memory, 0xa0000,
+                             mch->pci_address_space, MCH_HOST_BRIDGE_SMRAM_C_BASE,
+                             MCH_HOST_BRIDGE_SMRAM_C_SIZE);
+    memory_region_add_subregion_overlap(mch->system_memory, MCH_HOST_BRIDGE_SMRAM_C_BASE,
                                         &mch->smram_region, 1);
     memory_region_set_enabled(&mch->smram_region, true);
 
     memory_region_init_alias(&mch->open_high_smram, OBJECT(mch), "smram-open-high",
-                             mch->ram_memory, 0xa0000, 0x20000);
+                             mch->ram_memory, MCH_HOST_BRIDGE_SMRAM_C_BASE,
+                             MCH_HOST_BRIDGE_SMRAM_C_SIZE);
     memory_region_add_subregion_overlap(mch->system_memory, 0xfeda0000,
                                         &mch->open_high_smram, 1);
     memory_region_set_enabled(&mch->open_high_smram, false);
@@ -550,11 +552,14 @@ static void mch_realize(PCIDevice *d, Error **errp)
     memory_region_init(&mch->smram, OBJECT(mch), "smram", 1ull << 32);
     memory_region_set_enabled(&mch->smram, true);
     memory_region_init_alias(&mch->low_smram, OBJECT(mch), "smram-low",
-                             mch->ram_memory, 0xa0000, 0x20000);
+                             mch->ram_memory, MCH_HOST_BRIDGE_SMRAM_C_BASE,
+                             MCH_HOST_BRIDGE_SMRAM_C_SIZE);
     memory_region_set_enabled(&mch->low_smram, true);
-    memory_region_add_subregion(&mch->smram, 0xa0000, &mch->low_smram);
+    memory_region_add_subregion(&mch->smram, MCH_HOST_BRIDGE_SMRAM_C_BASE,
+                                &mch->low_smram);
     memory_region_init_alias(&mch->high_smram, OBJECT(mch), "smram-high",
-                             mch->ram_memory, 0xa0000, 0x20000);
+                             mch->ram_memory, MCH_HOST_BRIDGE_SMRAM_C_BASE,
+                             MCH_HOST_BRIDGE_SMRAM_C_SIZE);
     memory_region_set_enabled(&mch->high_smram, true);
     memory_region_add_subregion(&mch->smram, 0xfeda0000, &mch->high_smram);
 
Signature · 1 line
MST
#2 lore raw

[Qemu-devel] [PULL 1/4] intel-iommu: send PSI always when notify_unmap set

In reply to Michael S. Tsirkin

From: Peter Xu <[email protected]>

During IOVA page table walk, there is a special case when:

- notify_unmap is set, meanwhile
- entry is invalid

In the past, we skip the entry always. This is not correct. We should send UNMAP notification to registered notifiers in this case. Otherwise some stall pages will still be mapped in the host even if L1 guest unmapped them already.

Without this patch, nested device assignment to L2 guests might dump some errors like:

qemu-system-x86_64: VFIO_MAP_DMA: -17
qemu-system-x86_64: vfio_dma_map(0x557305420c30, 0xad000, 0x1000,

                    0x7f89a920d000) = -17 (File exists)

To fix this, we need to apply this patch to L1 QEMU (L2 QEMU is not affected by this problem).

---
 hw/i386/intel_iommu.c | 42 ++++++++++++++++++++++++++++++------------
 1 file changed, 30 insertions(+), 12 deletions(-)
hw/i386/intel_iommu.c +30 -12
index fb31de9..b359efd 100644
@@ -722,6 +722,15 @@ static int vtd_iova_to_slpte(VTDContextEntry *ce, uint64_t iova, bool is_write,
 
 typedef int (*vtd_page_walk_hook)(IOMMUTLBEntry *entry, void *private);
 
+static int vtd_page_walk_one(IOMMUTLBEntry *entry, int level,
+                             vtd_page_walk_hook hook_fn, void *private)
+{
+    assert(hook_fn);
+    trace_vtd_page_walk_one(level, entry->iova, entry->translated_addr,
+                            entry->addr_mask, entry->perm);
+    return hook_fn(entry, private);
+}
+
 /**
  * vtd_page_walk_level - walk over specific level for IOVA range
  *
@@ -781,28 +790,37 @@ static int vtd_page_walk_level(dma_addr_t addr, uint64_t start,
          */
         entry_valid = read_cur | write_cur;
 
+        entry.target_as = &address_space_memory;
+        entry.iova = iova & subpage_mask;
+        entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur);
+        entry.addr_mask = ~subpage_mask;
+
         if (vtd_is_last_slpte(slpte, level)) {
-            entry.target_as = &address_space_memory;
-            entry.iova = iova & subpage_mask;
             /* NOTE: this is only meaningful if entry_valid == true */
             entry.translated_addr = vtd_get_slpte_addr(slpte, aw);
-            entry.addr_mask = ~subpage_mask;
-            entry.perm = IOMMU_ACCESS_FLAG(read_cur, write_cur);
             if (!entry_valid && !notify_unmap) {
                 trace_vtd_page_walk_skip_perm(iova, iova_next);
                 goto next;
             }
-            trace_vtd_page_walk_one(level, entry.iova, entry.translated_addr,
-                                    entry.addr_mask, entry.perm);
-            if (hook_fn) {
-                ret = hook_fn(&entry, private);
-                if (ret < 0) {
-                    return ret;
-                }
+            ret = vtd_page_walk_one(&entry, level, hook_fn, private);
+            if (ret < 0) {
+                return ret;
             }
         } else {
             if (!entry_valid) {
-                trace_vtd_page_walk_skip_perm(iova, iova_next);
+                if (notify_unmap) {
+                    /*
+                     * The whole entry is invalid; unmap it all.
+                     * Translated address is meaningless, zero it.
+                     */
+                    entry.translated_addr = 0x0;
+                    ret = vtd_page_walk_one(&entry, level, hook_fn, private);
+                    if (ret < 0) {
+                        return ret;
+                    }
+                } else {
+                    trace_vtd_page_walk_skip_perm(iova, iova_next);
+                }
                 goto next;
             }
             ret = vtd_page_walk_level(vtd_get_slpte_addr(slpte, aw), iova,
Signature · 1 line
MST
#3 lore raw

[Qemu-devel] [PULL 3/4] allocate pci id for mdpy

In reply to Michael S. Tsirkin

From: Gerd Hoffmann <[email protected]>

mdpy is a sample pci device for vfio-mdev. Not (yet) merged upstream, patch available here:

https://www.kraxel.org/cgit/linux/commit/?h=vfio-sample-display&id=6fd86cff3d7df38ab89625b16fdd6434b1c18749

---
 docs/specs/pci-ids.txt | 1 +
 include/hw/pci/pci.h   | 1 +
 2 files changed, 2 insertions(+)
docs/specs/pci-ids.txt +1 -0
index bb99a02..4d53e5c 100644
@@ -62,6 +62,7 @@ PCI devices (other than virtio):
 1b36:000a  PCI-PCI bridge (multiseat)
 1b36:000b  PCIe Expander Bridge (-device pxb-pcie)
 1b36:000d  PCI xhci usb host adapter
+1b36:000f  mdpy (mdev sample device), linux/samples/vfio-mdev/mdpy.c
 
 All these devices are documented in docs/specs.
 
include/hw/pci/pci.h +1 -0
index a9c3ee5..990d6fc 100644
@@ -101,6 +101,7 @@ extern bool pci_available;
 #define PCI_DEVICE_ID_REDHAT_PCIE_RP     0x000c
 #define PCI_DEVICE_ID_REDHAT_XHCI        0x000d
 #define PCI_DEVICE_ID_REDHAT_PCIE_BRIDGE 0x000e
+#define PCI_DEVICE_ID_REDHAT_MDPY        0x000f
 #define PCI_DEVICE_ID_REDHAT_QXL         0x0100
 
 #define FMT_PCIBUS                      PRIx64
Signature · 1 line
MST
#4 lore raw

[Qemu-devel] [PULL 4/4] virtio-balloon: add hugetlb page allocation counts

In reply to Michael S. Tsirkin

From: Jonathan Helman <[email protected]>

qemu should read and report hugetlb page allocation counts exported in the following kernel patch:

commit 4c3ca37c4a4394978fd0f005625f6064ed2b9a64
Author: Jonathan Helman <[email protected]>
Date: Mon Mar 19 11:00:35 2018 -0700

virtio_balloon: export hugetlb page allocation counts

Export the number of successful and failed hugetlb page allocations via the virtio balloon driver. These 2 counts come directly from the vm_events HTLB_BUDDY_PGALLOC and HTLB_BUDDY_PGALLOC_FAIL.

---
 docs/virtio-balloon-stats.txt                   | 2 ++
 include/standard-headers/linux/virtio_balloon.h | 4 +++-
 hw/virtio/virtio-balloon.c                      | 2 ++
 3 files changed, 7 insertions(+), 1 deletion(-)
docs/virtio-balloon-stats.txt +2 -0
index 7a66d25..9985e1d 100644
@@ -34,6 +34,8 @@ which will return a dictionary containing:
       - stat-total-memory
       - stat-available-memory
       - stat-disk-caches
+      - stat-htlb-pgalloc
+      - stat-htlb-pgfail
 
   o A key named last-update, which contains the last stats update
     timestamp in seconds. Since this timestamp is generated by the host,
include/standard-headers/linux/virtio_balloon.h +3 -1
index 7b0a41b..e446805 100644
@@ -53,7 +53,9 @@ struct virtio_balloon_config {
 #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
 #define VIRTIO_BALLOON_S_AVAIL    6   /* Available memory as in /proc */
 #define VIRTIO_BALLOON_S_CACHES   7   /* Disk caches */
-#define VIRTIO_BALLOON_S_NR       8
+#define VIRTIO_BALLOON_S_HTLB_PGALLOC  8  /* Hugetlb page allocations */
+#define VIRTIO_BALLOON_S_HTLB_PGFAIL   9  /* Hugetlb page allocation failures */
+#define VIRTIO_BALLOON_S_NR       10
 
 /*
  * Memory statistics structure.
hw/virtio/virtio-balloon.c +2 -0
index f456cea..1f7a87f 100644
@@ -52,6 +52,8 @@ static const char *balloon_stat_names[] = {
    [VIRTIO_BALLOON_S_MEMTOT] = "stat-total-memory",
    [VIRTIO_BALLOON_S_AVAIL] = "stat-available-memory",
    [VIRTIO_BALLOON_S_CACHES] = "stat-disk-caches",
+   [VIRTIO_BALLOON_S_HTLB_PGALLOC] = "stat-htlb-pgalloc",
+   [VIRTIO_BALLOON_S_HTLB_PGFAIL] = "stat-htlb-pgfail",
    [VIRTIO_BALLOON_S_NR] = NULL
 };
 
Signature · 1 line
MST
#5 lore raw
In reply to Michael S. Tsirkin
Quoted 15 lines · Michael S. Tsirkin

The following changes since commit 4743c23509a51bd4ee85cc272287a41917d1be35:

Update version for v2.12.0 release (2018-04-24 16:44:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to fb6fd86f712c73a40fbe0c6be86d4635239b1304:

virtio-balloon: add hugetlb page allocation counts (2018-04-27 06:25:27 +0300)

----------------------------------------------------------------
pc, pci, virtio: fixes, features

Quoted 7 lines

A bugfix that just missed 2.12, a new PCI,
and a new virtio balloon stat.

Peter Xu (1):
intel-iommu: send PSI always when notify_unmap set

This patch is still missing:
* a clear description of when the bug applies and its severity
* a cc:stable marking

Please can you fix that and resend?

thanks
-- PMM

#6 lore raw
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Michael S. Tsirkin

The following changes since commit 4743c23509a51bd4ee85cc272287a41917d1be35:

Update version for v2.12.0 release (2018-04-24 16:44:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to fb6fd86f712c73a40fbe0c6be86d4635239b1304:

virtio-balloon: add hugetlb page allocation counts (2018-04-27 06:25:27 +0300)

----------------------------------------------------------------
pc, pci, virtio: fixes, features

A bugfix that just missed 2.12, a new PCI,
and a new virtio balloon stat.

Quoted 7 lines
Quoted 4 lines

Peter Xu (1):
intel-iommu: send PSI always when notify_unmap set

This patch is still missing:
* a clear description of when the bug applies and its severity

I'm still working on that. Do we want to defer merging until we have that?

Quoted 1 line

* a cc:stable marking

Will do.

Quoted 4 lines

Please can you fix that and resend?

thanks
-- PMM

#7 lore raw
Quoted 28 lines · Michael S. Tsirkin
Quoted 19 lines · Peter Maydell
Quoted 18 lines · Michael S. Tsirkin

The following changes since commit 4743c23509a51bd4ee85cc272287a41917d1be35:

Update version for v2.12.0 release (2018-04-24 16:44:55 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream

for you to fetch changes up to fb6fd86f712c73a40fbe0c6be86d4635239b1304:

virtio-balloon: add hugetlb page allocation counts (2018-04-27 06:25:27 +0300)

----------------------------------------------------------------
pc, pci, virtio: fixes, features

A bugfix that just missed 2.12, a new PCI,
and a new virtio balloon stat.

Quoted 7 lines
Quoted 4 lines

Peter Xu (1):
intel-iommu: send PSI always when notify_unmap set

This patch is still missing:
* a clear description of when the bug applies and its severity

Quoted 6 lines

I'm still working on that. Do we want to defer merging until we have that?

Quoted 1 line

* a cc:stable marking

Will do.

I guess if we've cc:'d stable that will be sufficient to flag it to interested parties, and we can advertise it more widely via other channels if it turns out to require it, once we have that info.

thanks
-- PMM