706 Commits

Author SHA1 Message Date
Chen Qun
19a7a3c4d7 spec: Update release version with !204
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-09-26 16:28:48 +08:00
Chen Qun
37d0d9e897 spec: Update patch and changelog with !204 fix CVE-2021-3748 !204
virtio-net: fix use after unmap/free for sg

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-09-26 16:28:36 +08:00
Chen Qun
d22f4b0b0c virtio-net: fix use after unmap/free for sg
When mergeable buffer is enabled, we try to set the num_buffers after
the virtqueue elem has been unmapped. This will lead several issues,
E.g a use after free when the descriptor has an address which belongs
to the non direct access region. In this case we use bounce buffer
that is allocated during address_space_map() and freed during
address_space_unmap().

Fixing this by storing the elems temporarily in an array and delay the
unmap after we set the the num_buffers.

This addresses CVE-2021-3748.

Reported-by: Alexander Bulekov <alxndr@bu.edu>
Fixes: fbe78f4f55c6 ("virtio-net support")
Cc: qemu-stable@nongnu.org
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: imxcc <xingchaochao@huawei.com>
2021-09-26 16:28:35 +08:00
openeuler-ci-bot
9b3e5f5993 !375 Automatically generate code patches with openeuler !199
From: @kuhnchen18
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-09-16 07:13:21 +00:00
Chen Qun
0aee04daf1 spec: Update release version with !199
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-09-16 11:27:46 +08:00
Chen Qun
5edc11eb3b spec: Update patch and changelog with !199 fix CVE-2021-3713 !199
uas: add stream number sanity checks.

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-09-16 11:27:41 +08:00
Chen Qun
61768948c9 uas: add stream number sanity checks.
The device uses the guest-supplied stream number unchecked, which can
lead to guest-triggered out-of-band access to the UASDevice->data3 and
UASDevice->status3 fields.  Add the missing checks.

Fixes: CVE-2021-3713
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reported-by: Chen Zhe <chenzhe@huawei.com>
Reported-by: Tan Jingguo <tanjingguo@huawei.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210818120505.1258262-2-kraxel@redhat.com>
2021-09-16 11:27:41 +08:00
openeuler-ci-bot
ff8228c763 !371 Automatically generate code patches with openeuler !195
From: @kuhnchen18
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-09-15 01:12:15 +00:00
Chen Qun
df900e5923 spec: Update release version with !195
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-09-14 21:28:11 +08:00
Chen Qun
b87fe562da spec: Update patch and changelog with !195 vfio/common: Add address alignment check in vfio_listener_region_del !195
vfio/common: Add address alignment check in vfio_listener_region_del

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-09-14 21:28:09 +08:00
Chen Qun
d8c06892e0 vfio/common: Add address alignment check in vfio_listener_region_del
Both vfio_listener_region_add and vfio_listener_region_del have
reference counting operations on ram section->mr. If the 'iova'
and 'llend' of the ram section do not pass the alignment
check, the ram section should not be mapped or unmapped. It means
that the reference counting should not be changed.

However, the address alignment check is missing in
vfio_listener_region_del. This makes memory_region_unref will
be unconditional called and causes unintended problems in some
scenarios.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-09-14 21:28:09 +08:00
openeuler-ci-bot
a0baaba962 !369 Automatically generate code patches with openeuler !192
From: @kuhnchen18
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-09-09 01:20:10 +00:00
Chen Qun
333296b131 spec: Update release version with !192
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-09-08 11:27:55 +08:00
Chen Qun
5f67e5fb45 spec: Update patch and changelog with !192 vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section !192
vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-09-08 11:27:53 +08:00
Chen Qun
01187ec9bc vfio/common: Fix incorrect address alignment in vfio_dma_map_ram_section
The 'iova' will be passed to host kernel for mapping with the
HPA. It is related to the host page size. So TARGET_PAGE_ALIGN
should be replaced by REAL_HOST_PAGE_ALIGN. In the case of
large granularity (64K), it may return early when map MMIO RAM
section. And because of the inconsistency with
vfio_dma_unmap_ram_section, it may cause 'assert(qrange)'
in vfio_dma_unmap.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
Signed-off-by: Zenghui Yu <yuzenghui@huawei.com>
2021-09-08 11:27:53 +08:00
openeuler-ci-bot
f7f5af3a7a !360 Modify the bad date in spec file that caused compile error.
From: @tom0392
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-08-31 09:12:30 +00:00
tangzhongrui
81ad349e4d Modify the bad date in spec file that caused compile error.
Signed-off-by:  Zhongrui Tang <tangzhongrui@cmss.chinamobile.com>
2021-08-31 13:59:24 +08:00
openeuler-ci-bot
0bfd6f8287 !359 删除spec文件中changelog有重复且日期乱序的记录
From: @tom0392
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-08-31 03:30:39 +00:00
tangzhongrui
710fa3214a Modify the spec file to specify the package version of zstd and zstd-devel that qemu depends on.
Signed-off-by:  Zhongrui Tang <tangzhongrui@cmss.chinamobile.com>
2021-08-30 17:01:21 +08:00
tangzhongrui
29a47b91a6 Remove duplicate and disorderly changelogs which will cause compilation errors.
Signed-off-by:  Zhongrui Tang <tangzhongrui@cmss.chinamobile.com>
2021-08-30 16:51:48 +08:00
openeuler-ci-bot
2a25f30bbe !354 【SP1分支同步】block_curl: add bolck_curl package
From: @lijiajie128
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-08-20 02:27:12 +00:00
Jiajie Li
0978d96786 block_curl: add bolck_curl package
Signed-off-by: Jiajie Li <lijiajie11@huawei.com>
2021-08-19 13:43:41 +08:00
openeuler-ci-bot
d60ae9a499 !349 Automatically generate code patches with openeuler !185
From: @kuhnchen18
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-08-16 10:45:43 +00:00
Chen Qun
0e5958c788 spec: Update release version with !185
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-08-16 11:29:58 +08:00
Chen Qun
ce72a2174d spec: Update patch and changelog with !185 fix CVE-2021-3682 #I45H4H !185
usbredir: fix free call

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-08-16 11:29:37 +08:00
Chen Qun
47c21ec4a9 usbredir: fix free call
data might point into the middle of a larger buffer, there is a separate
free_on_destroy pointer passed into bufp_alloc() to handle that.  It is
only used in the normal workflow though, not when dropping packets due
to the queue being full.  Fix that.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/491
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20210722072756.647673-1-kraxel@redhat.com>
Signed-off-by: imxcc <xingchaochao@huawei.com>
2021-08-16 11:29:37 +08:00
openeuler-ci-bot
d1cc9da786 !346 Automatically generate code patches with openeuler !183
From: @kuhnchen18
Reviewed-by: @imxcc
Signed-off-by: @imxcc
2021-08-05 07:54:15 +00:00
Chen Qun
216918bb04 spec: Update release version with !183
increase release verison by one

Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
b94d8926ee spec: Update patch and changelog with !183 Support VFIO migration manual clear interface & vSMMUv3/pSMMUv3 2 stage VFIO integration & Support migration in SMMUv3 nested mode !183
vfio: Support host translation granule size
vfio/migrate: Move switch of dirty tracking into vfio_memory_listener
vfio: Fix unregister SaveVMHandler in vfio_migration_finalize
migration/ram: Reduce unnecessary rate limiting
migration/ram: Optimize ram_save_host_page()
qdev/monitors: Fix reundant error_setg of qdev_add_device
linux-headers: update against 5.10 and manual clear vfio dirty log series
vfio: Maintain DMA mapping range for the container
vfio/migration: Add support for manual clear vfio dirty log
hw/arm/smmuv3: Support 16K translation granule
hw/arm/smmuv3: Set the restoration priority of the vSMMUv3 explicitly
hw/vfio/common: trace vfio_connect_container operations
update-linux-headers: Import iommu.h
vfio.h and iommu.h header update against 5.10
memory: Add new fields in IOTLBEntry
hw/arm/smmuv3: Improve stage1 ASID invalidation
hw/arm/smmu-common: Allow domain invalidation for NH_ALL/NSNH_ALL
memory: Add IOMMU_ATTR_VFIO_NESTED IOMMU memory region attribute
memory: Add IOMMU_ATTR_MSI_TRANSLATE IOMMU memory region attribute
memory: Introduce IOMMU Memory Region inject_faults API
iommu: Introduce generic header
pci: introduce PCIPASIDOps to PCIDevice
vfio: Force nested if iommu requires it
vfio: Introduce hostwin_from_range helper
vfio: Introduce helpers to DMA map/unmap a RAM section
vfio: Set up nested stage mappings
vfio: Pass stage 1 MSI bindings to the host
vfio: Helper to get IRQ info including capabilities
vfio/pci: Register handler for iommu fault
vfio/pci: Set up the DMA FAULT region
vfio/pci: Implement the DMA fault handler
hw/arm/smmuv3: Advertise MSI_TRANSLATE attribute
hw/arm/smmuv3: Store the PASID table GPA in the translation config
hw/arm/smmuv3: Fill the IOTLBEntry arch_id on NH_VA invalidation
hw/arm/smmuv3: Fill the IOTLBEntry leaf field on NH_VA invalidation
hw/arm/smmuv3: Pass stage 1 configurations to the host
hw/arm/smmuv3: Implement fault injection
hw/arm/smmuv3: Allow MAP notifiers
pci: Add return_page_response pci ops
vfio/pci: Implement return_page_response page response callback
vfio/common: Avoid unmap ram section at vfio_listener_region_del() in nested mode
vfio: Introduce helpers to mark dirty pages of a RAM section
vfio: Add vfio_prereg_listener_log_sync in nested stage
vfio: Add vfio_prereg_listener_log_clear to re-enable mark dirty pages
vfio: Add vfio_prereg_listener_global_log_start/stop in nested stage
hw/arm/smmuv3: Post-load stage 1 configurations to the host

Signed-off-by: Chen Qun<kuhn.chenqun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
b06e551676 hw/arm/smmuv3: Post-load stage 1 configurations to the host
In nested mode, we call the set_pasid_table() callback on each
STE update to pass the guest stage 1 configuration to the host
and apply it at physical level.

In the case of live migration, we need to manually call the
set_pasid_table() to load the guest stage 1 configurations to
the host. If this operation fails, the migration fails.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
7644dd1549 vfio: Add vfio_prereg_listener_global_log_start/stop in nested stage
In nested mode, we set up the stage 2 and stage 1 separately. In my
opinion, vfio_memory_prereg_listener is used for stage 2 and
vfio_memory_listener is used for stage 1. So it feels weird to call
the global_log_start/stop interface in vfio_memory_listener to switch
dirty tracking, although this won't cause any errors. Add
global_log_start/stop interface in vfio_memory_prereg_listener
can separate stage 2 from stage 1.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
38c3954435 vfio: Add vfio_prereg_listener_log_clear to re-enable mark dirty pages
When tracking dirty pages, we just need to pay attention to stage 2
mappings. Legacy vfio_listener_log_clear cannot be used in nested
stage. This patch adds vfio_prereg_listener_log_clear to re-enable
dirty pages in nested mode.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
eae456de7c vfio: Add vfio_prereg_listener_log_sync in nested stage
In nested mode, we set up the stage 2 (gpa->hpa)and stage 1
(giova->gpa) separately by vfio_prereg_listener_region_add()
and vfio_listener_region_add(). So when marking dirty pages
we just need to pay attention to stage 2 mappings.

Legacy vfio_listener_log_sync cannot be used in nested stage.
This patch adds vfio_prereg_listener_log_sync to mark dirty
pages in nested mode.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
e4d4275433 vfio: Introduce helpers to mark dirty pages of a RAM section
Extract part of the code from vfio_sync_dirty_bitmap to form a
new helper, which allows to mark dirty pages of a RAM section.
This helper will be called for nested stage.

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
48e4f1552b vfio/common: Avoid unmap ram section at vfio_listener_region_del() in nested mode
The ram section will be unmapped at vfio_prereg_listener_region_del()
in nested mode. So let's avoid unmap ram section at
vfio_listener_region_dev().

Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
518ab37de3 vfio/pci: Implement return_page_response page response callback
This patch implements the page response path. The
response is written into the page response ring buffer and then
update header's head index is updated. This path is not used
by this series. It is introduced here as a POC for vSVA/ARM
integration.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
2117b42cb1 pci: Add return_page_response pci ops
Add a new PCI operation that allows to return page responses
to registered VFIO devices

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
c2ecdaca13 hw/arm/smmuv3: Allow MAP notifiers
We now have all bricks to support nested paging. This
uses MAP notifiers to map the MSIs. So let's allow MAP
notifiers to be registered.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
b81289b550 hw/arm/smmuv3: Implement fault injection
We convert iommu_fault structs received from the kernel
into the data struct used by the emulation code and record
the evnts into the virtual event queue.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
1e1a34cb30 hw/arm/smmuv3: Pass stage 1 configurations to the host
In case PASID PciOps are set for the device we call
the set_pasid_table() callback on each STE update.

This allows to pass the guest stage 1 configuration
to the host and apply it at physical level.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
bcfe3f1d19 hw/arm/smmuv3: Fill the IOTLBEntry leaf field on NH_VA invalidation
Let's propagate the leaf attribute throughout the invalidation path.
This hint is used to reduce the scope of the invalidations to the
last level of translation. Not enforcing it induces large performance
penalties in nested mode.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
4b4532b880 hw/arm/smmuv3: Fill the IOTLBEntry arch_id on NH_VA invalidation
When the guest invalidates one S1 entry, it passes the asid.
When propagating this invalidation downto the host, the asid
information also must be passed. So let's fill the arch_id field
introduced for that purpose and accordingly set the flags to
indicate its presence.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
cf3014ddc1 hw/arm/smmuv3: Store the PASID table GPA in the translation config
For VFIO integration we will need to pass the Context Descriptor (CD)
table GPA to the host. The CD table is also referred to as the PASID
table. Its GPA corresponds to the s1ctrptr field of the Stream Table
Entry. So let's decode and store it in the configuration structure.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
a782347b03 hw/arm/smmuv3: Advertise MSI_TRANSLATE attribute
The SMMUv3 has the peculiarity to translate MSI
transactionss. let's advertise the corresponding
attribute.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
93c6df7e5a vfio/pci: Implement the DMA fault handler
Whenever the eventfd is triggered, we retrieve the DMA fault(s)
from the mmapped fault region and inject them in the iommu
memory region.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
58476d1b47 vfio/pci: Set up the DMA FAULT region
Set up the fault region which is composed of the actual fault
queue (mmappable) and a header used to handle it. The fault
queue is mmapped.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
98dfb30ca5 vfio/pci: Register handler for iommu fault
We use the new extended IRQ VFIO_IRQ_TYPE_NESTED type and
VFIO_IRQ_SUBTYPE_DMA_FAULT subtype to set/unset
a notifier for physical DMA faults. The associated eventfd is
triggered, in nested mode, whenever a fault is detected at IOMMU
physical level.

The actual handler will be implemented in subsequent patches.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
f4fce522f0 vfio: Helper to get IRQ info including capabilities
As done for vfio regions, add helpers to retrieve irq info
including their optional capabilities.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:28 +08:00
Chen Qun
d159b4edba vfio: Pass stage 1 MSI bindings to the host
We register the stage1 MSI bindings when enabling the vectors
and we unregister them on msi disable.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:27 +08:00
Chen Qun
39db503d4d vfio: Set up nested stage mappings
In nested mode, legacy vfio_iommu_map_notify cannot be used as
there is no "caching" mode and we do not trap on map.

On Intel, vfio_iommu_map_notify was used to DMA map the RAM
through the host single stage.

With nested mode, we need to setup the stage 2 and the stage 1
separately. This patch introduces a prereg_listener to setup
the stage 2 mapping.

The stage 1 mapping, owned by the guest, is passed to the host
when the guest invalidates the stage 1 configuration, through
a dedicated PCIPASIDOps callback. Guest IOTLB invalidations
are cascaded downto the host through another IOMMU MR UNMAP
notifier.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com>
2021-08-04 11:28:27 +08:00