[PATCH v2] vfio/pci: Verify each MSI vector to avoid invalid MSI vectors

2022-11-22 Thread chenxiang via
From: Xiang Chen Currently the number of MSI vectors comes from register PCI_MSI_FLAGS which should be power-of-2 in qemu, in some scenaries it is not the same as the number that driver requires in guest, for example, a PCI driver wants to allocate 6 MSI vecotrs in guest, but as the limitation, i

[PATCH] vfio/pci: Add system call KVM_VERIFY_MSI to verify every MSI vector

2022-11-07 Thread chenxiang via
From: Xiang Chen Currently the numbers of MSI vectors come from register PCI_MSI_FLAGS which should be power-of-2, but in some scenaries it is not the same as the number that driver requires in guest, for example, a PCI driver wants to allocate 6 MSI vecotrs in guest, but as the limitation, it wi

[PATCH] KVM: Add system call KVM_VERIFY_MSI to verify MSI vector

2022-11-07 Thread chenxiang via
From: Xiang Chen Currently the numbers of MSI vectors come from register PCI_MSI_FLAGS which should be power-of-2, but in some scenaries it is not the same as the number that driver requires in guest, for example, a PCI driver wants to allocate 6 MSI vecotrs in guest, but as the limitation, it wi

[PATCH v2] hw/vfio/common: Fix a small boundary issue of a trace

2022-04-16 Thread chenxiang via
From: Xiang Chen It uses [offset, offset + size - 1] to indicate that the length of range is size in most places in vfio trace code (such as trace_vfio_region_region_mmap()) execpt trace_vfio_region_sparse_mmap_entry(). So change it for trace_vfio_region_sparse_mmap_entry(), but if size is zero,

[PATCH] softmmu/memory: Skip translation size instead of fixed granularity if translate() successfully

2022-04-16 Thread chenxiang via
From: Xiang Chen Currently memory_region_iommu_replay() does full page table walk with fixed granularity (page size) no matter translate() succeeds or not. Actually if translate() successfully, we can skip translation size (iotlb.addr_mask + 1) instead of fixed granularity. Signed-off-by: Xiang

[PATCH v2] hw/arm/smmuv3: Pass the actual perm to returned IOMMUTLBEntry in smmuv3_translate()

2022-04-16 Thread chenxiang via
From: Xiang Chen It always calls the IOMMU MR translate() callback with flag=IOMMU_NONE in memory_region_iommu_replay(). Currently, smmuv3_translate() return an IOMMUTLBEntry with perm set to IOMMU_NONE even if the translation success, whereas it is expected to return the actual permission set in

[PATCH] hw/arm/smmuv3: Pass the real perm to returned IOMMUTLBEntry in smmuv3_translate()

2022-04-07 Thread chenxiang via
From: Xiang Chen In function memory_region_iommu_replay(), it decides to notify() or not according to the perm of returned IOMMUTLBEntry. But for smmuv3, the returned perm is always IOMMU_NONE even if the translation success. Pass the real perm to returned IOMMUTLBEntry to avoid the issue. Signe

[PATCH] hw/vfio/common: Fix a small boundary issue of a trace

2022-04-06 Thread chenxiang via
From: Xiang Chen Right now the trace of vfio_region_sparse_mmap_entry is as follows: vfio_region_sparse_mmap_entry sparse entry 0 [0x1000 - 0x9000] Actually the range it wants to show is [0x1000 - 0x8fff]???so fix it. Signed-off-by: Xiang Chen --- hw/vfio/common.c | 2 +- 1 file changed, 1 ins

[PATCH] hw/arm/virt: Enable HMAT on arm virt machine

2022-01-25 Thread chenxiang via
From: Xiang Chen Since the patchset ("Build ACPI Heterogeneous Memory Attribute Table (HMAT)"), HMAT is supported, but only x86 is enabled. Enable HMAT on arm virt machine. Signed-off-by: Xiang Chen --- hw/arm/Kconfig | 1 + hw/arm/virt-acpi-build.c | 7 +++ 2 files changed, 8 in