vfio: Add DMABUF support for PCI BAR regions
cover vfio: Add DMABUF support for PCI BAR regions
Hi,
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. This adds support for vfio devices to create a dmabuf for each mapped BAR region.
Requires linux-headers update to 6.19-rc1(patch #1). That update introduces a virtio-net build issue, which is addressed by patch #2.
The dmabuf support was sanity tested on an NVIDIA grace paltform.
Please take a look and let me know.
Thanks,
Shameer
Nicolin Chen (1):
hw/vfio/region: Create dmabuf for PCI BAR per region
Shameer Kolothum (2):
linux-headers: Update to Linux v6.19-rc1 hw/net/virtio-net: Adapt hash handling to updated UAPI
hw/net/virtio-net.c | 11 +- hw/vfio/region.c | 57 ++- hw/vfio/trace-events | 1 + include/standard-headers/drm/drm_fourcc.h | 25 +- include/standard-headers/linux/ethtool.h | 5 + .../linux/input-event-codes.h | 14 +- include/standard-headers/linux/pci_regs.h | 89 ++++ include/standard-headers/linux/virtio_net.h | 3 +- include/standard-headers/linux/virtio_pci.h | 2 +- linux-headers/asm-arm64/kvm.h | 2 +- linux-headers/asm-arm64/unistd_64.h | 1 + linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-loongarch/kvm.h | 1 + linux-headers/asm-loongarch/unistd.h | 6 + linux-headers/asm-loongarch/unistd_64.h | 1 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 3 + linux-headers/asm-riscv/unistd_32.h | 1 + linux-headers/asm-riscv/unistd_64.h | 1 + linux-headers/asm-s390/bitsperlong.h | 4 - linux-headers/asm-s390/unistd.h | 4 - linux-headers/asm-s390/unistd_32.h | 446 ------------------ linux-headers/asm-s390/unistd_64.h | 9 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/iommufd.h | 10 + linux-headers/linux/kvm.h | 11 + linux-headers/linux/mshv.h | 116 ++++- linux-headers/linux/psp-sev.h | 66 ++- linux-headers/linux/vfio.h | 28 ++ 36 files changed, 427 insertions(+), 503 deletions(-) delete mode 100644 linux-headers/asm-s390/unistd_32.h
Signature · 1 line
2.43.0
PATCH 1/3 linux-headers: Update to Linux v6.19-rc1
Mainly for adding support for VFIO DMABUF. While at it, update all headers.
---
I was getting this error from update-linux-headers script:
cp: cannot stat '/tmp/tmp.OfzanvZP6L/headers/include/asm/unistd_32.h':
No such file or directory
I used the hunk below to fix it. This likely requires another patch, though. If this is the right fix, I will include that in v2.
scripts/update-linux-headers.sh +0 -1
@@ -154,7 +154,6 @@ EOF mkdir -p "$output/include/standard-headers/asm-$arch" if [ $arch = s390 ]; then cp_portable "$hdrdir/include/asm/virtio-ccw.h" "$output/include/standard-headers/asm-s390/" - cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-s390/" cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-s390/" fi if [ $arch = arm64 ]; then
--- include/standard-headers/drm/drm_fourcc.h | 25 +- include/standard-headers/linux/ethtool.h | 5 + .../linux/input-event-codes.h | 14 +- include/standard-headers/linux/pci_regs.h | 89 ++++ include/standard-headers/linux/virtio_net.h | 3 +- include/standard-headers/linux/virtio_pci.h | 2 +- linux-headers/asm-arm64/kvm.h | 2 +- linux-headers/asm-arm64/unistd_64.h | 1 + linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-loongarch/kvm.h | 1 + linux-headers/asm-loongarch/unistd.h | 6 + linux-headers/asm-loongarch/unistd_64.h | 1 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 3 + linux-headers/asm-riscv/unistd_32.h | 1 + linux-headers/asm-riscv/unistd_64.h | 1 + linux-headers/asm-s390/bitsperlong.h | 4 - linux-headers/asm-s390/unistd.h | 4 - linux-headers/asm-s390/unistd_32.h | 446 ------------------ linux-headers/asm-s390/unistd_64.h | 9 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/iommufd.h | 10 + linux-headers/linux/kvm.h | 11 + linux-headers/linux/mshv.h | 116 ++++- linux-headers/linux/psp-sev.h | 66 ++- linux-headers/linux/vfio.h | 28 ++ 33 files changed, 363 insertions(+), 498 deletions(-) delete mode 100644 linux-headers/asm-s390/unistd_32.h
include/standard-headers/drm/drm_fourcc.h +16 -9
@@ -978,14 +978,20 @@ extern "C" {* 2 = Gob Height 8, Turing+ Page Kind mapping * 3 = Reserved for future use. * -* 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further -* bit remapping step that occurs at an even lower level than the -* page kind and block linear swizzles. This causes the layout of -* surfaces mapped in those SOC's GPUs to be incompatible with the -* equivalent mapping on other GPUs in the same system. -* -* 0 = Tegra K1 - Tegra Parker/TX2 Layout. -* 1 = Desktop GPU and Tegra Xavier+ Layout +* 22:22 s Sector layout. There is a further bit remapping step that occurs +* 26:27 at an even lower level than the page kind and block linear +* swizzles. This causes the bit arrangement of surfaces in memory +* to differ subtly, and prevents direct sharing of surfaces between +* GPUs with different layouts. +* +* 0 = Tegra K1 - Tegra Parker/TX2 Layout +* 1 = Pre-GB20x, GB20x 32+ bpp, GB10, Tegra Xavier-Orin Layout +* 2 = GB20x(Blackwell 2)+ 8 bpp surface layout +* 3 = GB20x(Blackwell 2)+ 16 bpp surface layout +* 4 = Reserved for future use. +* 5 = Reserved for future use. +* 6 = Reserved for future use. +* 7 = Reserved for future use. * * 25:23 c Lossless Framebuffer Compression type. *
@@ -1000,7 +1006,7 @@ extern "C" {* 6 = Reserved for future use * 7 = Reserved for future use * -* 55:25 - Reserved for future use. Must be zero. +* 55:28 - Reserved for future use. Must be zero. */ #define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D (c, s, g, k, h) \ fourcc_mod_code(NVIDIA, (0x10 | \
@@ -1008,6 +1014,7 @@ extern "C" { (((k) &0xff ) <<12 ) | \ (((g) &0x3 ) <<20 ) | \ (((s) &0x1 ) <<22 ) | \ + (((s) &0x6 ) <<25 ) | \ (((c) & 0x7) << 23)))/* To grandfather in prior block linear format modifiers to the above layout,
include/standard-headers/linux/ethtool.h +5 -0
@@ -2077,6 +2077,10 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_800000baseDR4_2_Full_BIT =118 , ETHTOOL_LINK_MODE_800000baseSR4_Full_BIT =119 , ETHTOOL_LINK_MODE_800000baseVR4_Full_BIT =120 , + ETHTOOL_LINK_MODE_1600000baseCR8_Full_BIT =121 , + ETHTOOL_LINK_MODE_1600000baseKR8_Full_BIT =122 , + ETHTOOL_LINK_MODE_1600000baseDR8_Full_BIT =123 , + ETHTOOL_LINK_MODE_1600000baseDR8_2_Full_BIT =124 ,/* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS
@@ -2190,6 +2194,7 @@ enum ethtool_link_mode_bit_indices {#define SPEED_200000 200000#define SPEED_400000 400000#define SPEED_800000 800000 +#define SPEED_1600000 1600000#define SPEED_UNKNOWN -1
include/standard-headers/linux/input-event-codes.h +13 -1
@@ -27,7 +27,7 @@#define INPUT_PROP_TOPBUTTONPAD 0x04/* softbuttons at top of pad */ #define INPUT_PROP_POINTING_STICK 0x05/* is a pointing stick */ #define INPUT_PROP_ACCELEROMETER 0x06/* has accelerometer */ -#define INPUT_PROP_HAPTIC_TOUCHPAD 0x07/* is a haptic touchpad */ +#define INPUT_PROP_PRESSUREPAD 0x07/* pressure triggers clicks */ #define INPUT_PROP_MAX 0x1f#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)
@@ -631,6 +631,18 @@#define KEY_BRIGHTNESS_MIN 0x250/* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251/* Set Brightness to Maximum */ +/* +* Keycodes for hotkeys toggling the electronic privacy screen found on some +* laptops on/off. Note when the embedded-controller turns on/off the eprivacy +* screen itself then the state should be reported through drm connecter props: +* https://www.kernel.org/doc/html/latest/gpu/drm-kms.html#standard-connector-properties +* Except when implementing the drm connecter properties API is not possible +* because e.g. the firmware does not allow querying the presence and/or status +* of the eprivacy screen at boot. +*/ +#define KEY_EPRIVACY_SCREEN_ON 0x252 +#define KEY_EPRIVACY_SCREEN_OFF 0x253 +#define KEY_KBDINPUTASSIST_PREV 0x260#define KEY_KBDINPUTASSIST_NEXT 0x261#define KEY_KBDINPUTASSIST_PREVGROUP 0x262
include/standard-headers/linux/pci_regs.h +89 -0
110 lines not on this page · raw message
include/standard-headers/linux/virtio_net.h +2 -1
@@ -193,7 +193,8 @@ struct virtio_net_hdr_v1 {struct virtio_net_hdr_v1_hash {struct virtio_net_hdr_v1 hdr; -uint32_t hash_value; +uint16_t hash_value_lo; +uint16_t hash_value_hi;#define VIRTIO_NET_HASH_REPORT_NONE 0#define VIRTIO_NET_HASH_REPORT_IPv4 1#define VIRTIO_NET_HASH_REPORT_TCPv4 2
include/standard-headers/linux/virtio_pci.h +1 -1
@@ -40,7 +40,7 @@#define _LINUX_VIRTIO_PCI_H#include "standard-headers/linux/types.h" -#include "standard-headers/linux/kernel.h" +#include "standard-headers/linux/const.h" #ifndef VIRTIO_PCI_NO_LEGACY
linux-headers/asm-arm64/kvm.h +1 -1
@@ -31,7 +31,7 @@#define KVM_SPSR_FIQ 4#define KVM_NR_SPSR 5 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <linux/psci.h> #include <linux/types.h> #include <asm/ptrace.h>
linux-headers/asm-arm64/unistd_64.h +1 -0
@@ -326,6 +326,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-generic/unistd.h +3 -1
@@ -857,9 +857,11 @@ __SYSCALL(__NR_open_tree_attr, sys_open_tree_attr) __SYSCALL(__NR_file_getattr, sys_file_getattr)#define __NR_file_setattr 469 __SYSCALL(__NR_file_setattr, sys_file_setattr) +#define __NR_listns 470 +__SYSCALL(__NR_listns, sys_listns)#undef __NR_syscalls -#define __NR_syscalls 470 +#define __NR_syscalls 471/* * 32 bit systems traditionally used different
linux-headers/asm-loongarch/kvm.h +1 -0
@@ -104,6 +104,7 @@ struct kvm_fpu {#define KVM_LOONGARCH_VM_FEAT_PV_IPI 6#define KVM_LOONGARCH_VM_FEAT_PV_STEALTIME 7#define KVM_LOONGARCH_VM_FEAT_PTW 8 +#define KVM_LOONGARCH_VM_FEAT_MSGINT 9/* Device Control API on vcpu fd */ #define KVM_LOONGARCH_VCPU_CPUCFG 0
linux-headers/asm-loongarch/unistd.h +6 -0
@@ -1,3 +1,9 @@/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include <asm/bitsperlong.h> + +#if __BITS_PER_LONG ==32 +#include <asm/unistd_32.h> +#else #include <asm/unistd_64.h> +#endif
linux-headers/asm-loongarch/unistd_64.h +1 -0
@@ -322,6 +322,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-mips/unistd_n32.h +1 -0
@@ -398,5 +398,6 @@#define __NR_open_tree_attr (__NR_Linux + 467)#define __NR_file_getattr (__NR_Linux + 468)#define __NR_file_setattr (__NR_Linux + 469) +#define __NR_listns (__NR_Linux + 470)#endif /* _ASM_UNISTD_N32_H */
linux-headers/asm-mips/unistd_n64.h +1 -0
@@ -374,5 +374,6 @@#define __NR_open_tree_attr (__NR_Linux + 467)#define __NR_file_getattr (__NR_Linux + 468)#define __NR_file_setattr (__NR_Linux + 469) +#define __NR_listns (__NR_Linux + 470)#endif /* _ASM_UNISTD_N64_H */
linux-headers/asm-mips/unistd_o32.h +1 -0
@@ -444,5 +444,6 @@#define __NR_open_tree_attr (__NR_Linux + 467)#define __NR_file_getattr (__NR_Linux + 468)#define __NR_file_setattr (__NR_Linux + 469) +#define __NR_listns (__NR_Linux + 470)#endif /* _ASM_UNISTD_O32_H */
linux-headers/asm-powerpc/unistd_32.h +1 -0
@@ -451,6 +451,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_32_H */
linux-headers/asm-powerpc/unistd_64.h +1 -0
@@ -423,6 +423,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-riscv/kvm.h +3 -0
@@ -23,6 +23,8 @@#define KVM_INTERRUPT_SET -1U#define KVM_INTERRUPT_UNSET -2U +#define KVM_EXIT_FAIL_ENTRY_NO_VSFILE (1ULL << 0) +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs { };
@@ -211,6 +213,7 @@ enum KVM_RISCV_SBI_EXT_ID {KVM_RISCV_SBI_EXT_STA ,KVM_RISCV_SBI_EXT_SUSP ,KVM_RISCV_SBI_EXT_FWFT , +KVM_RISCV_SBI_EXT_MPXY , KVM_RISCV_SBI_EXT_MAX, };
linux-headers/asm-riscv/unistd_32.h +1 -0
@@ -317,6 +317,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_32_H */
linux-headers/asm-riscv/unistd_64.h +1 -0
@@ -327,6 +327,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-s390/bitsperlong.h +0 -4
@@ -2,11 +2,7 @@#ifndef __ASM_S390_BITSPERLONG_H#define __ASM_S390_BITSPERLONG_H -#ifndef __s390x__ -#define __BITS_PER_LONG 32 -#else #define __BITS_PER_LONG 64 -#endif #include <asm-generic/bitsperlong.h>
linux-headers/asm-s390/unistd.h +0 -4
@@ -8,10 +8,6 @@#ifndef _ASM_S390_UNISTD_H_#define _ASM_S390_UNISTD_H_ -#ifdef __s390x__#include <asm/unistd_64.h> -#else -#include <asm/unistd_32.h> -#endif #endif /* _ASM_S390_UNISTD_H_ */
linux-headers/asm-s390/unistd_32.h deleted +0 -446
446 lines not on this page · raw message
linux-headers/asm-s390/unistd_64.h +5 -4
@@ -1,6 +1,5 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _ASM_S390_UNISTD_64_H -#define _ASM_S390_UNISTD_64_H +#ifndef _ASM_UNISTD_64_H +#define _ASM_UNISTD_64_H#define __NR_exit 1#define __NR_fork 2
@@ -390,5 +389,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470 -#endif /* _ASM_S390_UNISTD_64_H */ + +#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-x86/kvm.h +1 -0
@@ -500,6 +500,7 @@ struct kvm_sync_regs {/* vendor-specific groups and attributes for system fd */ #define KVM_X86_GRP_SEV 1# define KVM_X86_SEV_VMSA_FEATURES 0 +# define KVM_X86_SNP_POLICY_BITS 1struct kvm_vmx_nested_state_data {__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE ];
linux-headers/asm-x86/unistd_32.h +1 -0
@@ -460,6 +460,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_32_H */
linux-headers/asm-x86/unistd_64.h +1 -0
@@ -384,6 +384,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */
linux-headers/asm-x86/unistd_x32.h +1 -0
@@ -337,6 +337,7 @@#define __NR_open_tree_attr (__X32_SYSCALL_BIT + 467)#define __NR_file_getattr (__X32_SYSCALL_BIT + 468)#define __NR_file_setattr (__X32_SYSCALL_BIT + 469) +#define __NR_listns (__X32_SYSCALL_BIT + 470)#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
linux-headers/linux/iommufd.h +10 -0
@@ -450,6 +450,16 @@ struct iommu_hwpt_vtd_s1 {* nested domain will translate the same as the nesting parent. The S1 will * install a Context Descriptor Table pointing at userspace memory translated * by the nesting parent. +* +* It's suggested to allocate a vDEVICE object carrying vSID and then re-attach +* the nested domain, as soon as the vSID is available in the VMM level: +* +* - when Cfg=translate, a vDEVICE must be allocated prior to attaching to the +* allocated nested domain, as CD/ATS invalidations and vevents need a vSID. +* - when Cfg=bypass/abort, a vDEVICE is not enforced during the nested domain +* attachment, to support a GBPA case where VM sets CR0.SMMUEN=0. However, if +* VM sets CR0.SMMUEN=1 while missing a vDEVICE object, kernel would fail to +* report events to the VM. E.g. F_TRANSLATION when guest STE.Cfg=abort. */ struct iommu_hwpt_arm_smmuv3 {__aligned_le64 ste[2 ];
linux-headers/linux/kvm.h +11 -0
@@ -179,6 +179,7 @@ struct kvm_xen_exit {#define KVM_EXIT_LOONGARCH_IOCSR 38#define KVM_EXIT_MEMORY_FAULT 39#define KVM_EXIT_TDX 40 +#define KVM_EXIT_ARM_SEA 41/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */
@@ -465,6 +466,14 @@ struct kvm_run { } setup_event_notify; }; } tdx; +/* KVM_EXIT_ARM_SEA */ +struct { +#define KVM_EXIT_ARM_SEA_FLAG_GPA_VALID (1ULL << 0) +__u64 flags; +__u64 esr; +__u64 gva; +__u64 gpa; + } arm_sea;/* Fix the size of the union. */ char padding[256 ]; };
@@ -955,6 +964,8 @@ struct kvm_enable_cap {#define KVM_CAP_RISCV_MP_STATE_RESET 242#define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243#define KVM_CAP_GUEST_MEMFD_FLAGS 244 +#define KVM_CAP_ARM_SEA_TO_USER 245 +#define KVM_CAP_S390_USER_OPEREXEC 246struct kvm_irq_routing_irqchip {__u32 irqchip;
linux-headers/linux/mshv.h +115 -1
144 lines not on this page · raw message
linux-headers/linux/psp-sev.h +41 -25
79 lines not on this page · raw message
linux-headers/linux/vfio.h +28 -0
@@ -14,6 +14,7 @@#include <linux/types.h> #include <linux/ioctl.h> +#include <linux/stddef.h> #define VFIO_API_VERSION 0
@@ -1478,6 +1479,33 @@ struct vfio_device_feature_bus_master { };#define VFIO_DEVICE_FEATURE_BUS_MASTER 10 +/** +* Upon VFIO_DEVICE_FEATURE_GET create a dma_buf fd for the +* regions selected. +* +* open_flags are the typical flags passed to open(2), eg O_RDWR, O_CLOEXEC, +* etc. offset/length specify a slice of the region to create the dmabuf from. +* nr_ranges is the total number of (P2P DMA) ranges that comprise the dmabuf. +* +* flags should be 0. +* +* Return: The fd number on success, -1 and errno is set on failure. +*/ +#define VFIO_DEVICE_FEATURE_DMA_BUF 11 + +struct vfio_region_dma_range { +__u64 offset; +__u64 length; +}; + +struct vfio_device_feature_dma_buf { +__u32 region_index; +__u32 open_flags; +__u32 flags; +__u32 nr_ranges; + struct vfio_region_dma_range dma_ranges[] __counted_by(nr_ranges); +}; +/* -------- API for Type1 VFIO IOMMU -------- */ /**
Signature · 1 line
2.43.0
Re: [PATCH 1/3] linux-headers: Update to Linux v6.19-rc1
Hello,
+Magnus, +Paolo
Quoted 25 lines · Shameer Kolothum
Mainly for adding support for VFIO DMABUF. While at it, update all headers.
Signed-off-by Shameer Kolothum <[email protected]>---
I was getting this error from update-linux-headers script:cp: cannot stat '
/tmp/tmp.OfzanvZP6L/headers/include/asm/unistd_32.h':
No such file or directoryI used the hunk below to fix it. This likely requires another patch, though. If this is the right fix, I will include that in v2.
scripts/update-linux-headers.sh +0
-1@@ -154,7 +154,6 @@ EOF mkdir -p "$output/include/standard-headers/asm-$arch" if [ $arch = s390 ]; then cp_portable "$hdrdir/include/asm/virtio-ccw.h" "$output/include/standard-headers/asm-s390/" - cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-s390/" cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-s390/" fi if [ $arch = arm64 ]; then
[ ... ]
Quoted 75 lines
linux-headers/linux/mshv.h +38
-1@@ -26,6 +26,7 @@ enum {MSHV_PT_BIT_LAPIC ,MSHV_PT_BIT_X2APIC ,MSHV_PT_BIT_GPA_SUPER_PAGES , +MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES , MSHV_PT_BIT_COUNT, };@@ -41,6 +42,8 @@ enum {* @pt_flags: Bitmask of 1 << MSHV_PT_BIT_* * @pt_isolation: MSHV_PT_ISOLATION_* * +* This is the initial/v1 version for backward compatibility. +* * Returns a file descriptor to act as a handle to a guest partition. * At this point the partition is not yet initialized in the hypervisor. * Some operations must be done with the partition in this state, e.g. setting @@ -52,6 +55,37 @@ struct mshv_create_partition {__u64 pt_isolation; }; +#define MSHV_NUM_CPU_FEATURES_BANKS 2 + +/** +* struct mshv_create_partition_v2 +* +* This is extended version of the above initial MSHV_CREATE_PARTITION +* ioctl and allows for following additional parameters: +* +* @pt_num_cpu_fbanks: Must be set to MSHV_NUM_CPU_FEATURES_BANKS. +* @pt_cpu_fbanks: Disabled processor feature banks array. +* @pt_disabled_xsave: Disabled xsave feature bits. +* +* pt_cpu_fbanks and pt_disabled_xsave are passed through as-is to the create +* partition hypercall. +* +* Returns : same as above original mshv_create_partition +*/ +struct mshv_create_partition_v2 { +__u64 pt_flags; +__u64 pt_isolation; +__u16 pt_num_cpu_fbanks; +__u8 pt_rsvd[6 ];/* MBZ */ +__u64 pt_cpu_fbanks[MSHV_NUM_CPU_FEATURES_BANKS ]; +__u64 pt_rsvd1[2 ];/* MBZ */ +#if defined(__x86_64__) +__u64 pt_disabled_xsave; +#else +__u64 pt_rsvd2;/* MBZ */ +#endif +} __attribute__((packed)); +/* /dev/mshv */ #define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition)@@ -89,7 +123,7 @@ enum {* @rsvd: MBZ * * Map or unmap a region of userspace memory to Guest Physical Addresses (GPA). -* Mappings can't overlap in GPA space or userspace. +* Mappings can't overlap in GPA space. * To unmap, these fields must match an existing mapping. */ struct mshv_user_mem_region {@@ -288,4 +322,84 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ + +#define MSHV_CAP_CORE_API_STABLE 0x0
linux-headers/linux/mshv.h struct mshv_get_set_vp_state { · line 337
Quoted 10 lines
linux-headers/linux/mshv.h +10
-0+#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +struct mshv_vp_registers { +__u32 count;/* supports only 1 register at a time */ +__u32 reserved;/* Reserved for alignment or future use */ +__u64 regs_ptr;/* pointer to struct hv_register_assoc */ +};
I am seeing errors due to the redefinition of 'struct mshv_vp_registers', already available in file : include/hw/hyperv/hvgdk_mini.h.
Does include/hw/hyperv/hvgdk_mini.h need some clean up first ?
Thanks,
C.
Re: [PATCH 1/3] linux-headers: Update to Linux v6.19-rc1
In reply to Shameer Kolothum+ Thomas,
Quoted 18 lines · Shameer Kolothum
Mainly for adding support for VFIO DMABUF. While at it, update all headers.
Signed-off-by Shameer Kolothum <[email protected]>---
I was getting this error from update-linux-headers script:cp: cannot stat '
/tmp/tmp.OfzanvZP6L/headers/include/asm/unistd_32.h':
No such file or directoryI used the hunk below to fix it. This likely requires another patch, though. If this is the right fix, I will include that in v2.
scripts/update-linux-headers.sh +0
-0
scripts/update-linux-headers.sh EOF · line 159
Quoted 7 lines
scripts/update-linux-headers.sh +0
-1@@ -154,7 +154,6 @@ EOF mkdir -p "$output/include/standard-headers/asm-$arch" if [ $arch = s390 ]; then cp_portable "$hdrdir/include/asm/virtio-ccw.h" "$output/include/standard-headers/asm-s390/" - cp "$hdrdir/include/asm/unistd_32.h" "$output/linux-headers/asm-s390/" cp "$hdrdir/include/asm/unistd_64.h" "$output/linux-headers/asm-s390/" fi if [ $arch = arm64 ]; then
The asm/unistd_32.h file was generated for the 31-bit compatibility mode on the s390 architecture and support was removed in v6.19-rc1, commit 4ac286c4a8d9 ("s390/syscalls: Switch to generic system call table generation")
So unistd_32.h is no longer generated when running make header_install.
I think this change deserves to have its own patch. You can use the paragraph above for it.
Thanks,
C.
Quoted 1,362 lines
--- include/standard-headers/drm/drm_fourcc.h | 25 +- include/standard-headers/linux/ethtool.h | 5 + .../linux/input-event-codes.h | 14 +- include/standard-headers/linux/pci_regs.h | 89 ++++ include/standard-headers/linux/virtio_net.h | 3 +- include/standard-headers/linux/virtio_pci.h | 2 +- linux-headers/asm-arm64/kvm.h | 2 +- linux-headers/asm-arm64/unistd_64.h | 1 + linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-loongarch/kvm.h | 1 + linux-headers/asm-loongarch/unistd.h | 6 + linux-headers/asm-loongarch/unistd_64.h | 1 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 3 + linux-headers/asm-riscv/unistd_32.h | 1 + linux-headers/asm-riscv/unistd_64.h | 1 + linux-headers/asm-s390/bitsperlong.h | 4 - linux-headers/asm-s390/unistd.h | 4 - linux-headers/asm-s390/unistd_32.h | 446 ------------------ linux-headers/asm-s390/unistd_64.h | 9 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/iommufd.h | 10 + linux-headers/linux/kvm.h | 11 + linux-headers/linux/mshv.h | 116 ++++- linux-headers/linux/psp-sev.h | 66 ++- linux-headers/linux/vfio.h | 28 ++ 33 files changed, 363 insertions(+), 498 deletions(-)delete mode 100644
linux-headers/asm-s390/unistd_32.hinclude/standard-headers/drm/drm_fourcc.h +16
-9@@ -978,14 +978,20 @@ extern "C" {* 2 = Gob Height 8, Turing+ Page Kind mapping * 3 = Reserved for future use. * -* 22:22 s Sector layout. On Tegra GPUs prior to Xavier, there is a further -* bit remapping step that occurs at an even lower level than the -* page kind and block linear swizzles. This causes the layout of -* surfaces mapped in those SOC's GPUs to be incompatible with the -* equivalent mapping on other GPUs in the same system. -* -* 0 = Tegra K1 - Tegra Parker/TX2 Layout. -* 1 = Desktop GPU and Tegra Xavier+ Layout +* 22:22 s Sector layout. There is a further bit remapping step that occurs +* 26:27 at an even lower level than the page kind and block linear +* swizzles. This causes the bit arrangement of surfaces in memory +* to differ subtly, and prevents direct sharing of surfaces between +* GPUs with different layouts. +* +* 0 = Tegra K1 - Tegra Parker/TX2 Layout +* 1 = Pre-GB20x, GB20x 32+ bpp, GB10, Tegra Xavier-Orin Layout +* 2 = GB20x(Blackwell 2)+ 8 bpp surface layout +* 3 = GB20x(Blackwell 2)+ 16 bpp surface layout +* 4 = Reserved for future use. +* 5 = Reserved for future use. +* 6 = Reserved for future use. +* 7 = Reserved for future use. * * 25:23 c Lossless Framebuffer Compression type. * @@ -1000,7 +1006,7 @@ extern "C" {* 6 = Reserved for future use * 7 = Reserved for future use * -* 55:25 - Reserved for future use. Must be zero. +* 55:28 - Reserved for future use. Must be zero. */ #define DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D (c, s, g, k, h) \ fourcc_mod_code(NVIDIA, (0x10 | \@@ -1008,6 +1014,7 @@ extern "C" { (((k) &0xff ) <<12 ) | \ (((g) &0x3 ) <<20 ) | \ (((s) &0x1 ) <<22 ) | \ + (((s) &0x6 ) <<25 ) | \ (((c) & 0x7) << 23)))/* To grandfather in prior block linear format modifiers to the above layout, include/standard-headers/linux/ethtool.h +5
-0@@ -2077,6 +2077,10 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_800000baseDR4_2_Full_BIT =118 , ETHTOOL_LINK_MODE_800000baseSR4_Full_BIT =119 , ETHTOOL_LINK_MODE_800000baseVR4_Full_BIT =120 , + ETHTOOL_LINK_MODE_1600000baseCR8_Full_BIT =121 , + ETHTOOL_LINK_MODE_1600000baseKR8_Full_BIT =122 , + ETHTOOL_LINK_MODE_1600000baseDR8_Full_BIT =123 , + ETHTOOL_LINK_MODE_1600000baseDR8_2_Full_BIT =124 ,/* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS@@ -2190,6 +2194,7 @@ enum ethtool_link_mode_bit_indices {#define SPEED_200000 200000#define SPEED_400000 400000#define SPEED_800000 800000 +#define SPEED_1600000 1600000#define SPEED_UNKNOWN -1include/standard-headers/linux/input-event-codes.h +13
-1@@ -27,7 +27,7 @@#define INPUT_PROP_TOPBUTTONPAD 0x04/* softbuttons at top of pad */ #define INPUT_PROP_POINTING_STICK 0x05/* is a pointing stick */ #define INPUT_PROP_ACCELEROMETER 0x06/* has accelerometer */ -#define INPUT_PROP_HAPTIC_TOUCHPAD 0x07/* is a haptic touchpad */ +#define INPUT_PROP_PRESSUREPAD 0x07/* pressure triggers clicks */ #define INPUT_PROP_MAX 0x1f#define INPUT_PROP_CNT (INPUT_PROP_MAX + 1)@@ -631,6 +631,18 @@#define KEY_BRIGHTNESS_MIN 0x250/* Set Brightness to Minimum */ #define KEY_BRIGHTNESS_MAX 0x251/* Set Brightness to Maximum */ +/* +* Keycodes for hotkeys toggling the electronic privacy screen found on some +* laptops on/off. Note when the embedded-controller turns on/off the eprivacy +* screen itself then the state should be reported through drm connecter props: +* https://www.kernel.org/doc/html/latest/gpu/drm-kms.html#standard-connector-properties +* Except when implementing the drm connecter properties API is not possible +* because e.g. the firmware does not allow querying the presence and/or status +* of the eprivacy screen at boot. +*/ +#define KEY_EPRIVACY_SCREEN_ON 0x252 +#define KEY_EPRIVACY_SCREEN_OFF 0x253 +#define KEY_KBDINPUTASSIST_PREV 0x260#define KEY_KBDINPUTASSIST_NEXT 0x261#define KEY_KBDINPUTASSIST_PREVGROUP 0x262include/standard-headers/linux/pci_regs.h +89
-0@@ -503,6 +503,7 @@#define PCI_EXP_DEVCAP_PWR_VAL 0x03fc0000/* Slot Power Limit Value */ #define PCI_EXP_DEVCAP_PWR_SCL 0x0c000000/* Slot Power Limit Scale */ #define PCI_EXP_DEVCAP_FLR 0x10000000/* Function Level Reset */ +#define PCI_EXP_DEVCAP_TEE 0x40000000/* TEE I/O (TDISP) Support */ #define PCI_EXP_DEVCTL 0x08/* Device Control */ #define PCI_EXP_DEVCTL_CERE 0x0001/* Correctable Error Reporting En. */ #define PCI_EXP_DEVCTL_NFERE 0x0002/* Non-Fatal Error Reporting Enable */ @@ -754,6 +755,8 @@#define PCI_EXT_CAP_ID_NPEM 0x29/* Native PCIe Enclosure Management */ #define PCI_EXT_CAP_ID_PL_32GT 0x2A/* Physical Layer 32.0 GT/s */ #define PCI_EXT_CAP_ID_DOE 0x2E/* Data Object Exchange */ +#define PCI_EXT_CAP_ID_DEV3 0x2F/* Device 3 Capability/Control/Status */ +#define PCI_EXT_CAP_ID_IDE 0x30/* Integrity and Data Encryption */ #define PCI_EXT_CAP_ID_PL_64GT 0x31/* Physical Layer 64.0 GT/s */ #define PCI_EXT_CAP_ID_MAX PCI_EXT_CAP_ID_PL_64GT@@ -1244,9 +1247,95 @@/* Deprecated old name, replaced with PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE */ #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE +/* Device 3 Extended Capability */ +#define PCI_DEV3_CAP 0x04/* Device 3 Capabilities Register */ +#define PCI_DEV3_CTL 0x08/* Device 3 Control Register */ +#define PCI_DEV3_STA 0x0c/* Device 3 Status Register */ +#define PCI_DEV3_STA_SEGMENT 0x8/* Segment Captured (end-to-end flit-mode detected) */ +/* Compute Express Link (CXL r3.1, sec 8.1.5) */ #define PCI_DVSEC_CXL_PORT 3#define PCI_DVSEC_CXL_PORT_CTL 0x0c#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001 +/* Integrity and Data Encryption Extended Capability */ +#define PCI_IDE_CAP 0x04 +#define PCI_IDE_CAP_LINK 0x1/* Link IDE Stream Supported */ +#define PCI_IDE_CAP_SELECTIVE 0x2/* Selective IDE Streams Supported */ +#define PCI_IDE_CAP_FLOWTHROUGH 0x4/* Flow-Through IDE Stream Supported */ +#define PCI_IDE_CAP_PARTIAL_HEADER_ENC 0x8/* Partial Header Encryption Supported */ +#define PCI_IDE_CAP_AGGREGATION 0x10/* Aggregation Supported */ +#define PCI_IDE_CAP_PCRC 0x20/* PCRC Supported */ +#define PCI_IDE_CAP_IDE_KM 0x40/* IDE_KM Protocol Supported */ +#define PCI_IDE_CAP_SEL_CFG 0x80/* Selective IDE for Config Request Support */ +#define PCI_IDE_CAP_ALG __GENMASK(12, 8)/* Supported Algorithms */ +#define PCI_IDE_CAP_ALG_AES_GCM_256 0/* AES-GCM 256 key size, 96b MAC */ +#define PCI_IDE_CAP_LINK_TC_NUM __GENMASK(15, 13)/* Link IDE TCs */ +#define PCI_IDE_CAP_SEL_NUM __GENMASK(23, 16)/* Supported Selective IDE Streams */ +#define PCI_IDE_CAP_TEE_LIMITED 0x1000000/* TEE-Limited Stream Supported */ +#define PCI_IDE_CTL 0x08 +#define PCI_IDE_CTL_FLOWTHROUGH_IDE 0x4/* Flow-Through IDE Stream Enabled */ + +#define PCI_IDE_LINK_STREAM_0 0xc/* First Link Stream Register Block */ +#define PCI_IDE_LINK_BLOCK_SIZE 8 +/* Link IDE Stream block, up to PCI_IDE_CAP_LINK_TC_NUM */ +#define PCI_IDE_LINK_CTL_0 0x00/* First Link Control Register Offset in block */ +#define PCI_IDE_LINK_CTL_EN 0x1/* Link IDE Stream Enable */ +#define PCI_IDE_LINK_CTL_TX_AGGR_NPR __GENMASK(3, 2)/* Tx Aggregation Mode NPR */ +#define PCI_IDE_LINK_CTL_TX_AGGR_PR __GENMASK(5, 4)/* Tx Aggregation Mode PR */ +#define PCI_IDE_LINK_CTL_TX_AGGR_CPL __GENMASK(7, 6)/* Tx Aggregation Mode CPL */ +#define PCI_IDE_LINK_CTL_PCRC_EN 0x100/* PCRC Enable */ +#define PCI_IDE_LINK_CTL_PART_ENC __GENMASK(13, 10)/* Partial Header Encryption Mode */ +#define PCI_IDE_LINK_CTL_ALG __GENMASK(18, 14)/* Selection from PCI_IDE_CAP_ALG */ +#define PCI_IDE_LINK_CTL_TC __GENMASK(21, 19)/* Traffic Class */ +#define PCI_IDE_LINK_CTL_ID __GENMASK(31, 24)/* Stream ID */ +#define PCI_IDE_LINK_STS_0 0x4/* First Link Status Register Offset in block */ +#define PCI_IDE_LINK_STS_STATE __GENMASK(3, 0)/* Link IDE Stream State */ +#define PCI_IDE_LINK_STS_IDE_FAIL 0x80000000/* IDE fail message received */ + +/* Selective IDE Stream block, up to PCI_IDE_CAP_SELECTIVE_STREAMS_NUM */ +/* Selective IDE Stream Capability Register */ +#define PCI_IDE_SEL_CAP 0x00 +#define PCI_IDE_SEL_CAP_ASSOC_NUM __GENMASK(3, 0) +/* Selective IDE Stream Control Register */ +#define PCI_IDE_SEL_CTL 0x04 +#define PCI_IDE_SEL_CTL_EN 0x1/* Selective IDE Stream Enable */ +#define PCI_IDE_SEL_CTL_TX_AGGR_NPR __GENMASK(3, 2)/* Tx Aggregation Mode NPR */ +#define PCI_IDE_SEL_CTL_TX_AGGR_PR __GENMASK(5, 4)/* Tx Aggregation Mode PR */ +#define PCI_IDE_SEL_CTL_TX_AGGR_CPL __GENMASK(7, 6)/* Tx Aggregation Mode CPL */ +#define PCI_IDE_SEL_CTL_PCRC_EN 0x100/* PCRC Enable */ +#define PCI_IDE_SEL_CTL_CFG_EN 0x200/* Selective IDE for Configuration Requests */ +#define PCI_IDE_SEL_CTL_PART_ENC __GENMASK(13, 10)/* Partial Header Encryption Mode */ +#define PCI_IDE_SEL_CTL_ALG __GENMASK(18, 14)/* Selection from PCI_IDE_CAP_ALG */ +#define PCI_IDE_SEL_CTL_TC __GENMASK(21, 19)/* Traffic Class */ +#define PCI_IDE_SEL_CTL_DEFAULT 0x400000/* Default Stream */ +#define PCI_IDE_SEL_CTL_TEE_LIMITED 0x800000/* TEE-Limited Stream */ +#define PCI_IDE_SEL_CTL_ID __GENMASK(31, 24)/* Stream ID */ +#define PCI_IDE_SEL_CTL_ID_MAX 255 +/* Selective IDE Stream Status Register */ +#define PCI_IDE_SEL_STS 0x08 +#define PCI_IDE_SEL_STS_STATE __GENMASK(3, 0)/* Selective IDE Stream State */ +#define PCI_IDE_SEL_STS_STATE_INSECURE 0 +#define PCI_IDE_SEL_STS_STATE_SECURE 2 +#define PCI_IDE_SEL_STS_IDE_FAIL 0x80000000/* IDE fail message received */ +/* IDE RID Association Register 1 */ +#define PCI_IDE_SEL_RID_1 0x0c +#define PCI_IDE_SEL_RID_1_LIMIT __GENMASK(23, 8) +/* IDE RID Association Register 2 */ +#define PCI_IDE_SEL_RID_2 0x10 +#define PCI_IDE_SEL_RID_2_VALID 0x1 +#define PCI_IDE_SEL_RID_2_BASE __GENMASK(23, 8) +#define PCI_IDE_SEL_RID_2_SEG __GENMASK(31, 24) +/* Selective IDE Address Association Register Block, up to PCI_IDE_SEL_CAP_ASSOC_NUM */ +#define PCI_IDE_SEL_ADDR_BLOCK_SIZE 12 +#define PCI_IDE_SEL_ADDR_1 (x) (20 + (x) * PCI_IDE_SEL_ADDR_BLOCK_SIZE) +#define PCI_IDE_SEL_ADDR_1_VALID 0x1 +#define PCI_IDE_SEL_ADDR_1_BASE_LOW __GENMASK(19, 8) +#define PCI_IDE_SEL_ADDR_1_LIMIT_LOW __GENMASK(31, 20) +/* IDE Address Association Register 2 is "Memory Limit Upper" */ +#define PCI_IDE_SEL_ADDR_2 (x) (24 + (x) * PCI_IDE_SEL_ADDR_BLOCK_SIZE) +/* IDE Address Association Register 3 is "Memory Base Upper" */ +#define PCI_IDE_SEL_ADDR_3 (x) (28 + (x) * PCI_IDE_SEL_ADDR_BLOCK_SIZE) +#define PCI_IDE_SEL_BLOCK_SIZE (nr_assoc) (20 + PCI_IDE_SEL_ADDR_BLOCK_SIZE * (nr_assoc)) +#endif /* LINUX_PCI_REGS_H */ include/standard-headers/linux/virtio_net.h +2
-1@@ -193,7 +193,8 @@ struct virtio_net_hdr_v1 {struct virtio_net_hdr_v1_hash {struct virtio_net_hdr_v1 hdr; -uint32_t hash_value; +uint16_t hash_value_lo; +uint16_t hash_value_hi;#define VIRTIO_NET_HASH_REPORT_NONE 0#define VIRTIO_NET_HASH_REPORT_IPv4 1#define VIRTIO_NET_HASH_REPORT_TCPv4 2include/standard-headers/linux/virtio_pci.h +1
-1@@ -40,7 +40,7 @@#define _LINUX_VIRTIO_PCI_H#include "standard-headers/linux/types.h" -#include "standard-headers/linux/kernel.h" +#include "standard-headers/linux/const.h" #ifndef VIRTIO_PCI_NO_LEGACY linux-headers/asm-arm64/kvm.h +1
-1@@ -31,7 +31,7 @@#define KVM_SPSR_FIQ 4#define KVM_NR_SPSR 5 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__#include <linux/psci.h> #include <linux/types.h> #include <asm/ptrace.h> linux-headers/asm-arm64/unistd_64.h +1
-0@@ -326,6 +326,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */ linux-headers/asm-generic/unistd.h +3
-1@@ -857,9 +857,11 @@ __SYSCALL(__NR_open_tree_attr, sys_open_tree_attr) __SYSCALL(__NR_file_getattr, sys_file_getattr)#define __NR_file_setattr 469 __SYSCALL(__NR_file_setattr, sys_file_setattr) +#define __NR_listns 470 +__SYSCALL(__NR_listns, sys_listns)#undef __NR_syscalls -#define __NR_syscalls 470 +#define __NR_syscalls 471/* * 32 bit systems traditionally used different linux-headers/asm-loongarch/kvm.h +1
-0@@ -104,6 +104,7 @@ struct kvm_fpu {#define KVM_LOONGARCH_VM_FEAT_PV_IPI 6#define KVM_LOONGARCH_VM_FEAT_PV_STEALTIME 7#define KVM_LOONGARCH_VM_FEAT_PTW 8 +#define KVM_LOONGARCH_VM_FEAT_MSGINT 9/* Device Control API on vcpu fd */ #define KVM_LOONGARCH_VCPU_CPUCFG 0linux-headers/asm-loongarch/unistd.h +6
-0@@ -1,3 +1,9 @@/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#include <asm/bitsperlong.h> + +#if __BITS_PER_LONG ==32 +#include <asm/unistd_32.h> +#else #include <asm/unistd_64.h> +#endif linux-headers/asm-loongarch/unistd_64.h +1
-0@@ -322,6 +322,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */ linux-headers/asm-mips/unistd_n32.h +1
-0@@ -398,5 +398,6 @@#define __NR_open_tree_attr (__NR_Linux + 467)#define __NR_file_getattr (__NR_Linux + 468)#define __NR_file_setattr (__NR_Linux + 469) +#define __NR_listns (__NR_Linux + 470)#endif /* _ASM_UNISTD_N32_H */ linux-headers/asm-mips/unistd_n64.h +1
-0@@ -374,5 +374,6 @@#define __NR_open_tree_attr (__NR_Linux + 467)#define __NR_file_getattr (__NR_Linux + 468)#define __NR_file_setattr (__NR_Linux + 469) +#define __NR_listns (__NR_Linux + 470)#endif /* _ASM_UNISTD_N64_H */ linux-headers/asm-mips/unistd_o32.h +1
-0@@ -444,5 +444,6 @@#define __NR_open_tree_attr (__NR_Linux + 467)#define __NR_file_getattr (__NR_Linux + 468)#define __NR_file_setattr (__NR_Linux + 469) +#define __NR_listns (__NR_Linux + 470)#endif /* _ASM_UNISTD_O32_H */ linux-headers/asm-powerpc/unistd_32.h +1
-0@@ -451,6 +451,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_32_H */ linux-headers/asm-powerpc/unistd_64.h +1
-0@@ -423,6 +423,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */ linux-headers/asm-riscv/kvm.h +3
-0@@ -23,6 +23,8 @@#define KVM_INTERRUPT_SET -1U#define KVM_INTERRUPT_UNSET -2U +#define KVM_EXIT_FAIL_ENTRY_NO_VSFILE (1ULL << 0) +/* for KVM_GET_REGS and KVM_SET_REGS */ struct kvm_regs { };@@ -211,6 +213,7 @@ enum KVM_RISCV_SBI_EXT_ID {KVM_RISCV_SBI_EXT_STA ,KVM_RISCV_SBI_EXT_SUSP ,KVM_RISCV_SBI_EXT_FWFT , +KVM_RISCV_SBI_EXT_MPXY , KVM_RISCV_SBI_EXT_MAX, };linux-headers/asm-riscv/unistd_32.h +1
-0@@ -317,6 +317,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_32_H */ linux-headers/asm-riscv/unistd_64.h +1
-0@@ -327,6 +327,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */ linux-headers/asm-s390/bitsperlong.h +0
-4@@ -2,11 +2,7 @@#ifndef __ASM_S390_BITSPERLONG_H#define __ASM_S390_BITSPERLONG_H -#ifndef __s390x__ -#define __BITS_PER_LONG 32 -#else #define __BITS_PER_LONG 64 -#endif #include <asm-generic/bitsperlong.h> linux-headers/asm-s390/unistd.h +0
-4@@ -8,10 +8,6 @@#ifndef _ASM_S390_UNISTD_H_#define _ASM_S390_UNISTD_H_ -#ifdef __s390x__#include <asm/unistd_64.h> -#else -#include <asm/unistd_32.h> -#endif #endif /* _ASM_S390_UNISTD_H_ */ linux-headers/asm-s390/unistd_32.h deleted +0
-446@@ -1,446 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _ASM_S390_UNISTD_32_H -#define _ASM_S390_UNISTD_32_H - -#define __NR_exit 1 -#define __NR_fork 2 -#define __NR_read 3 -#define __NR_write 4 -#define __NR_open 5 -#define __NR_close 6 -#define __NR_restart_syscall 7 -#define __NR_creat 8 -#define __NR_link 9 -#define __NR_unlink 10 -#define __NR_execve 11 -#define __NR_chdir 12 -#define __NR_time 13 -#define __NR_mknod 14 -#define __NR_chmod 15 -#define __NR_lchown 16 -#define __NR_lseek 19 -#define __NR_getpid 20 -#define __NR_mount 21 -#define __NR_umount 22 -#define __NR_setuid 23 -#define __NR_getuid 24 -#define __NR_stime 25 -#define __NR_ptrace 26 -#define __NR_alarm 27 -#define __NR_pause 29 -#define __NR_utime 30 -#define __NR_access 33 -#define __NR_nice 34 -#define __NR_sync 36 -#define __NR_kill 37 -#define __NR_rename 38 -#define __NR_mkdir 39 -#define __NR_rmdir 40 -#define __NR_dup 41 -#define __NR_pipe 42 -#define __NR_times 43 -#define __NR_brk 45 -#define __NR_setgid 46 -#define __NR_getgid 47 -#define __NR_signal 48 -#define __NR_geteuid 49 -#define __NR_getegid 50 -#define __NR_acct 51 -#define __NR_umount2 52 -#define __NR_ioctl 54 -#define __NR_fcntl 55 -#define __NR_setpgid 57 -#define __NR_umask 60 -#define __NR_chroot 61 -#define __NR_ustat 62 -#define __NR_dup2 63 -#define __NR_getppid 64 -#define __NR_getpgrp 65 -#define __NR_setsid 66 -#define __NR_sigaction 67 -#define __NR_setreuid 70 -#define __NR_setregid 71 -#define __NR_sigsuspend 72 -#define __NR_sigpending 73 -#define __NR_sethostname 74 -#define __NR_setrlimit 75 -#define __NR_getrlimit 76 -#define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 -#define __NR_getgroups 80 -#define __NR_setgroups 81 -#define __NR_symlink 83 -#define __NR_readlink 85 -#define __NR_uselib 86 -#define __NR_swapon 87 -#define __NR_reboot 88 -#define __NR_readdir 89 -#define __NR_mmap 90 -#define __NR_munmap 91 -#define __NR_truncate 92 -#define __NR_ftruncate 93 -#define __NR_fchmod 94 -#define __NR_fchown 95 -#define __NR_getpriority 96 -#define __NR_setpriority 97 -#define __NR_statfs 99 -#define __NR_fstatfs 100 -#define __NR_ioperm 101 -#define __NR_socketcall 102 -#define __NR_syslog 103 -#define __NR_setitimer 104 -#define __NR_getitimer 105 -#define __NR_stat 106 -#define __NR_lstat 107 -#define __NR_fstat 108 -#define __NR_lookup_dcookie 110 -#define __NR_vhangup 111 -#define __NR_idle 112 -#define __NR_wait4 114 -#define __NR_swapoff 115 -#define __NR_sysinfo 116 -#define __NR_ipc 117 -#define __NR_fsync 118 -#define __NR_sigreturn 119 -#define __NR_clone 120 -#define __NR_setdomainname 121 -#define __NR_uname 122 -#define __NR_adjtimex 124 -#define __NR_mprotect 125 -#define __NR_sigprocmask 126 -#define __NR_create_module 127 -#define __NR_init_module 128 -#define __NR_delete_module 129 -#define __NR_get_kernel_syms 130 -#define __NR_quotactl 131 -#define __NR_getpgid 132 -#define __NR_fchdir 133 -#define __NR_bdflush 134 -#define __NR_sysfs 135 -#define __NR_personality 136 -#define __NR_afs_syscall 137 -#define __NR_setfsuid 138 -#define __NR_setfsgid 139 -#define __NR__llseek 140 -#define __NR_getdents 141 -#define __NR__newselect 142 -#define __NR_flock 143 -#define __NR_msync 144 -#define __NR_readv 145 -#define __NR_writev 146 -#define __NR_getsid 147 -#define __NR_fdatasync 148 -#define __NR__sysctl 149 -#define __NR_mlock 150 -#define __NR_munlock 151 -#define __NR_mlockall 152 -#define __NR_munlockall 153 -#define __NR_sched_setparam 154 -#define __NR_sched_getparam 155 -#define __NR_sched_setscheduler 156 -#define __NR_sched_getscheduler 157 -#define __NR_sched_yield 158 -#define __NR_sched_get_priority_max 159 -#define __NR_sched_get_priority_min 160 -#define __NR_sched_rr_get_interval 161 -#define __NR_nanosleep 162 -#define __NR_mremap 163 -#define __NR_setresuid 164 -#define __NR_getresuid 165 -#define __NR_query_module 167 -#define __NR_poll 168 -#define __NR_nfsservctl 169 -#define __NR_setresgid 170 -#define __NR_getresgid 171 -#define __NR_prctl 172 -#define __NR_rt_sigreturn 173 -#define __NR_rt_sigaction 174 -#define __NR_rt_sigprocmask 175 -#define __NR_rt_sigpending 176 -#define __NR_rt_sigtimedwait 177 -#define __NR_rt_sigqueueinfo 178 -#define __NR_rt_sigsuspend 179 -#define __NR_pread64 180 -#define __NR_pwrite64 181 -#define __NR_chown 182 -#define __NR_getcwd 183 -#define __NR_capget 184 -#define __NR_capset 185 -#define __NR_sigaltstack 186 -#define __NR_sendfile 187 -#define __NR_getpmsg 188 -#define __NR_putpmsg 189 -#define __NR_vfork 190 -#define __NR_ugetrlimit 191 -#define __NR_mmap2 192 -#define __NR_truncate64 193 -#define __NR_ftruncate64 194 -#define __NR_stat64 195 -#define __NR_lstat64 196 -#define __NR_fstat64 197 -#define __NR_lchown32 198 -#define __NR_getuid32 199 -#define __NR_getgid32 200 -#define __NR_geteuid32 201 -#define __NR_getegid32 202 -#define __NR_setreuid32 203 -#define __NR_setregid32 204 -#define __NR_getgroups32 205 -#define __NR_setgroups32 206 -#define __NR_fchown32 207 -#define __NR_setresuid32 208 -#define __NR_getresuid32 209 -#define __NR_setresgid32 210 -#define __NR_getresgid32 211 -#define __NR_chown32 212 -#define __NR_setuid32 213 -#define __NR_setgid32 214 -#define __NR_setfsuid32 215 -#define __NR_setfsgid32 216 -#define __NR_pivot_root 217 -#define __NR_mincore 218 -#define __NR_madvise 219 -#define __NR_getdents64 220 -#define __NR_fcntl64 221 -#define __NR_readahead 222 -#define __NR_sendfile64 223 -#define __NR_setxattr 224 -#define __NR_lsetxattr 225 -#define __NR_fsetxattr 226 -#define __NR_getxattr 227 -#define __NR_lgetxattr 228 -#define __NR_fgetxattr 229 -#define __NR_listxattr 230 -#define __NR_llistxattr 231 -#define __NR_flistxattr 232 -#define __NR_removexattr 233 -#define __NR_lremovexattr 234 -#define __NR_fremovexattr 235 -#define __NR_gettid 236 -#define __NR_tkill 237 -#define __NR_futex 238 -#define __NR_sched_setaffinity 239 -#define __NR_sched_getaffinity 240 -#define __NR_tgkill 241 -#define __NR_io_setup 243 -#define __NR_io_destroy 244 -#define __NR_io_getevents 245 -#define __NR_io_submit 246 -#define __NR_io_cancel 247 -#define __NR_exit_group 248 -#define __NR_epoll_create 249 -#define __NR_epoll_ctl 250 -#define __NR_epoll_wait 251 -#define __NR_set_tid_address 252 -#define __NR_fadvise64 253 -#define __NR_timer_create 254 -#define __NR_timer_settime 255 -#define __NR_timer_gettime 256 -#define __NR_timer_getoverrun 257 -#define __NR_timer_delete 258 -#define __NR_clock_settime 259 -#define __NR_clock_gettime 260 -#define __NR_clock_getres 261 -#define __NR_clock_nanosleep 262 -#define __NR_fadvise64_64 264 -#define __NR_statfs64 265 -#define __NR_fstatfs64 266 -#define __NR_remap_file_pages 267 -#define __NR_mbind 268 -#define __NR_get_mempolicy 269 -#define __NR_set_mempolicy 270 -#define __NR_mq_open 271 -#define __NR_mq_unlink 272 -#define __NR_mq_timedsend 273 -#define __NR_mq_timedreceive 274 -#define __NR_mq_notify 275 -#define __NR_mq_getsetattr 276 -#define __NR_kexec_load 277 -#define __NR_add_key 278 -#define __NR_request_key 279 -#define __NR_keyctl 280 -#define __NR_waitid 281 -#define __NR_ioprio_set 282 -#define __NR_ioprio_get 283 -#define __NR_inotify_init 284 -#define __NR_inotify_add_watch 285 -#define __NR_inotify_rm_watch 286 -#define __NR_migrate_pages 287 -#define __NR_openat 288 -#define __NR_mkdirat 289 -#define __NR_mknodat 290 -#define __NR_fchownat 291 -#define __NR_futimesat 292 -#define __NR_fstatat64 293 -#define __NR_unlinkat 294 -#define __NR_renameat 295 -#define __NR_linkat 296 -#define __NR_symlinkat 297 -#define __NR_readlinkat 298 -#define __NR_fchmodat 299 -#define __NR_faccessat 300 -#define __NR_pselect6 301 -#define __NR_ppoll 302 -#define __NR_unshare 303 -#define __NR_set_robust_list 304 -#define __NR_get_robust_list 305 -#define __NR_splice 306 -#define __NR_sync_file_range 307 -#define __NR_tee 308 -#define __NR_vmsplice 309 -#define __NR_move_pages 310 -#define __NR_getcpu 311 -#define __NR_epoll_pwait 312 -#define __NR_utimes 313 -#define __NR_fallocate 314 -#define __NR_utimensat 315 -#define __NR_signalfd 316 -#define __NR_timerfd 317 -#define __NR_eventfd 318 -#define __NR_timerfd_create 319 -#define __NR_timerfd_settime 320 -#define __NR_timerfd_gettime 321 -#define __NR_signalfd4 322 -#define __NR_eventfd2 323 -#define __NR_inotify_init1 324 -#define __NR_pipe2 325 -#define __NR_dup3 326 -#define __NR_epoll_create1 327 -#define __NR_preadv 328 -#define __NR_pwritev 329 -#define __NR_rt_tgsigqueueinfo 330 -#define __NR_perf_event_open 331 -#define __NR_fanotify_init 332 -#define __NR_fanotify_mark 333 -#define __NR_prlimit64 334 -#define __NR_name_to_handle_at 335 -#define __NR_open_by_handle_at 336 -#define __NR_clock_adjtime 337 -#define __NR_syncfs 338 -#define __NR_setns 339 -#define __NR_process_vm_readv 340 -#define __NR_process_vm_writev 341 -#define __NR_s390_runtime_instr 342 -#define __NR_kcmp 343 -#define __NR_finit_module 344 -#define __NR_sched_setattr 345 -#define __NR_sched_getattr 346 -#define __NR_renameat2 347 -#define __NR_seccomp 348 -#define __NR_getrandom 349 -#define __NR_memfd_create 350 -#define __NR_bpf 351 -#define __NR_s390_pci_mmio_write 352 -#define __NR_s390_pci_mmio_read 353 -#define __NR_execveat 354 -#define __NR_userfaultfd 355 -#define __NR_membarrier 356 -#define __NR_recvmmsg 357 -#define __NR_sendmmsg 358 -#define __NR_socket 359 -#define __NR_socketpair 360 -#define __NR_bind 361 -#define __NR_connect 362 -#define __NR_listen 363 -#define __NR_accept4 364 -#define __NR_getsockopt 365 -#define __NR_setsockopt 366 -#define __NR_getsockname 367 -#define __NR_getpeername 368 -#define __NR_sendto 369 -#define __NR_sendmsg 370 -#define __NR_recvfrom 371 -#define __NR_recvmsg 372 -#define __NR_shutdown 373 -#define __NR_mlock2 374 -#define __NR_copy_file_range 375 -#define __NR_preadv2 376 -#define __NR_pwritev2 377 -#define __NR_s390_guarded_storage 378 -#define __NR_statx 379 -#define __NR_s390_sthyi 380 -#define __NR_kexec_file_load 381 -#define __NR_io_pgetevents 382 -#define __NR_rseq 383 -#define __NR_pkey_mprotect 384 -#define __NR_pkey_alloc 385 -#define __NR_pkey_free 386 -#define __NR_semget 393 -#define __NR_semctl 394 -#define __NR_shmget 395 -#define __NR_shmctl 396 -#define __NR_shmat 397 -#define __NR_shmdt 398 -#define __NR_msgget 399 -#define __NR_msgsnd 400 -#define __NR_msgrcv 401 -#define __NR_msgctl 402 -#define __NR_clock_gettime64 403 -#define __NR_clock_settime64 404 -#define __NR_clock_adjtime64 405 -#define __NR_clock_getres_time64 406 -#define __NR_clock_nanosleep_time64 407 -#define __NR_timer_gettime64 408 -#define __NR_timer_settime64 409 -#define __NR_timerfd_gettime64 410 -#define __NR_timerfd_settime64 411 -#define __NR_utimensat_time64 412 -#define __NR_pselect6_time64 413 -#define __NR_ppoll_time64 414 -#define __NR_io_pgetevents_time64 416 -#define __NR_recvmmsg_time64 417 -#define __NR_mq_timedsend_time64 418 -#define __NR_mq_timedreceive_time64 419 -#define __NR_semtimedop_time64 420 -#define __NR_rt_sigtimedwait_time64 421 -#define __NR_futex_time64 422 -#define __NR_sched_rr_get_interval_time64 423 -#define __NR_pidfd_send_signal 424 -#define __NR_io_uring_setup 425 -#define __NR_io_uring_enter 426 -#define __NR_io_uring_register 427 -#define __NR_open_tree 428 -#define __NR_move_mount 429 -#define __NR_fsopen 430 -#define __NR_fsconfig 431 -#define __NR_fsmount 432 -#define __NR_fspick 433 -#define __NR_pidfd_open 434 -#define __NR_clone3 435 -#define __NR_close_range 436 -#define __NR_openat2 437 -#define __NR_pidfd_getfd 438 -#define __NR_faccessat2 439 -#define __NR_process_madvise 440 -#define __NR_epoll_pwait2 441 -#define __NR_mount_setattr 442 -#define __NR_quotactl_fd 443 -#define __NR_landlock_create_ruleset 444 -#define __NR_landlock_add_rule 445 -#define __NR_landlock_restrict_self 446 -#define __NR_memfd_secret 447 -#define __NR_process_mrelease 448 -#define __NR_futex_waitv 449 -#define __NR_set_mempolicy_home_node 450 -#define __NR_cachestat 451 -#define __NR_fchmodat2 452 -#define __NR_map_shadow_stack 453 -#define __NR_futex_wake 454 -#define __NR_futex_wait 455 -#define __NR_futex_requeue 456 -#define __NR_statmount 457 -#define __NR_listmount 458 -#define __NR_lsm_get_self_attr 459 -#define __NR_lsm_set_self_attr 460 -#define __NR_lsm_list_modules 461 -#define __NR_mseal 462 -#define __NR_setxattrat 463 -#define __NR_getxattrat 464 -#define __NR_listxattrat 465 -#define __NR_removexattrat 466 -#define __NR_open_tree_attr 467 -#define __NR_file_getattr 468 -#define __NR_file_setattr 469 - -#endif /* _ASM_S390_UNISTD_32_H */ linux-headers/asm-s390/unistd_64.h +5
-4@@ -1,6 +1,5 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _ASM_S390_UNISTD_64_H -#define _ASM_S390_UNISTD_64_H +#ifndef _ASM_UNISTD_64_H +#define _ASM_UNISTD_64_H#define __NR_exit 1#define __NR_fork 2@@ -390,5 +389,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470 -#endif /* _ASM_S390_UNISTD_64_H */ + +#endif /* _ASM_UNISTD_64_H */ linux-headers/asm-x86/kvm.h +1
-0@@ -500,6 +500,7 @@ struct kvm_sync_regs {/* vendor-specific groups and attributes for system fd */ #define KVM_X86_GRP_SEV 1# define KVM_X86_SEV_VMSA_FEATURES 0 +# define KVM_X86_SNP_POLICY_BITS 1struct kvm_vmx_nested_state_data {__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE ];linux-headers/asm-x86/unistd_32.h +1
-0@@ -460,6 +460,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_32_H */ linux-headers/asm-x86/unistd_64.h +1
-0@@ -384,6 +384,7 @@#define __NR_open_tree_attr 467#define __NR_file_getattr 468#define __NR_file_setattr 469 +#define __NR_listns 470#endif /* _ASM_UNISTD_64_H */ linux-headers/asm-x86/unistd_x32.h +1
-0@@ -337,6 +337,7 @@#define __NR_open_tree_attr (__X32_SYSCALL_BIT + 467)#define __NR_file_getattr (__X32_SYSCALL_BIT + 468)#define __NR_file_setattr (__X32_SYSCALL_BIT + 469) +#define __NR_listns (__X32_SYSCALL_BIT + 470)#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)#define __NR_ioctl (__X32_SYSCALL_BIT + 514)linux-headers/linux/iommufd.h +10
-0@@ -450,6 +450,16 @@ struct iommu_hwpt_vtd_s1 {* nested domain will translate the same as the nesting parent. The S1 will * install a Context Descriptor Table pointing at userspace memory translated * by the nesting parent. +* +* It's suggested to allocate a vDEVICE object carrying vSID and then re-attach +* the nested domain, as soon as the vSID is available in the VMM level: +* +* - when Cfg=translate, a vDEVICE must be allocated prior to attaching to the +* allocated nested domain, as CD/ATS invalidations and vevents need a vSID. +* - when Cfg=bypass/abort, a vDEVICE is not enforced during the nested domain +* attachment, to support a GBPA case where VM sets CR0.SMMUEN=0. However, if +* VM sets CR0.SMMUEN=1 while missing a vDEVICE object, kernel would fail to +* report events to the VM. E.g. F_TRANSLATION when guest STE.Cfg=abort. */ struct iommu_hwpt_arm_smmuv3 {__aligned_le64 ste[2 ];linux-headers/linux/kvm.h +11
-0@@ -179,6 +179,7 @@ struct kvm_xen_exit {#define KVM_EXIT_LOONGARCH_IOCSR 38#define KVM_EXIT_MEMORY_FAULT 39#define KVM_EXIT_TDX 40 +#define KVM_EXIT_ARM_SEA 41/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ @@ -465,6 +466,14 @@ struct kvm_run { } setup_event_notify; }; } tdx; +/* KVM_EXIT_ARM_SEA */ +struct { +#define KVM_EXIT_ARM_SEA_FLAG_GPA_VALID (1ULL << 0) +__u64 flags; +__u64 esr; +__u64 gva; +__u64 gpa; + } arm_sea;/* Fix the size of the union. */ char padding[256 ]; };@@ -955,6 +964,8 @@ struct kvm_enable_cap {#define KVM_CAP_RISCV_MP_STATE_RESET 242#define KVM_CAP_ARM_CACHEABLE_PFNMAP_SUPPORTED 243#define KVM_CAP_GUEST_MEMFD_FLAGS 244 +#define KVM_CAP_ARM_SEA_TO_USER 245 +#define KVM_CAP_S390_USER_OPEREXEC 246struct kvm_irq_routing_irqchip {__u32 irqchip;linux-headers/linux/mshv.h +115
-1@@ -26,6 +26,7 @@ enum {MSHV_PT_BIT_LAPIC ,MSHV_PT_BIT_X2APIC ,MSHV_PT_BIT_GPA_SUPER_PAGES , +MSHV_PT_BIT_CPU_AND_XSAVE_FEATURES , MSHV_PT_BIT_COUNT, };@@ -41,6 +42,8 @@ enum {* @pt_flags: Bitmask of 1 << MSHV_PT_BIT_* * @pt_isolation: MSHV_PT_ISOLATION_* * +* This is the initial/v1 version for backward compatibility. +* * Returns a file descriptor to act as a handle to a guest partition. * At this point the partition is not yet initialized in the hypervisor. * Some operations must be done with the partition in this state, e.g. setting @@ -52,6 +55,37 @@ struct mshv_create_partition {__u64 pt_isolation; }; +#define MSHV_NUM_CPU_FEATURES_BANKS 2 + +/** +* struct mshv_create_partition_v2 +* +* This is extended version of the above initial MSHV_CREATE_PARTITION +* ioctl and allows for following additional parameters: +* +* @pt_num_cpu_fbanks: Must be set to MSHV_NUM_CPU_FEATURES_BANKS. +* @pt_cpu_fbanks: Disabled processor feature banks array. +* @pt_disabled_xsave: Disabled xsave feature bits. +* +* pt_cpu_fbanks and pt_disabled_xsave are passed through as-is to the create +* partition hypercall. +* +* Returns : same as above original mshv_create_partition +*/ +struct mshv_create_partition_v2 { +__u64 pt_flags; +__u64 pt_isolation; +__u16 pt_num_cpu_fbanks; +__u8 pt_rsvd[6 ];/* MBZ */ +__u64 pt_cpu_fbanks[MSHV_NUM_CPU_FEATURES_BANKS ]; +__u64 pt_rsvd1[2 ];/* MBZ */ +#if defined(__x86_64__) +__u64 pt_disabled_xsave; +#else +__u64 pt_rsvd2;/* MBZ */ +#endif +} __attribute__((packed)); +/* /dev/mshv */ #define MSHV_CREATE_PARTITION _IOW(MSHV_IOCTL, 0x00, struct mshv_create_partition)@@ -89,7 +123,7 @@ enum {* @rsvd: MBZ * * Map or unmap a region of userspace memory to Guest Physical Addresses (GPA). -* Mappings can't overlap in GPA space or userspace. +* Mappings can't overlap in GPA space. * To unmap, these fields must match an existing mapping. */ struct mshv_user_mem_region {@@ -288,4 +322,84 @@ struct mshv_get_set_vp_state {* #define MSHV_ROOT_HVCALL _IOWR(MSHV_IOCTL, 0x07, struct mshv_root_hvcall) */ +/* Structure definitions, macros and IOCTLs for mshv_vtl */ + +#define MSHV_CAP_CORE_API_STABLE 0x0 +#define MSHV_CAP_REGISTER_PAGE 0x1 +#define MSHV_CAP_VTL_RETURN_ACTION 0x2 +#define MSHV_CAP_DR6_SHARED 0x3 +#define MSHV_MAX_RUN_MSG_SIZE 256 + +struct mshv_vp_registers { +__u32 count;/* supports only 1 register at a time */ +__u32 reserved;/* Reserved for alignment or future use */ +__u64 regs_ptr;/* pointer to struct hv_register_assoc */ +}; + +struct mshv_vtl_set_eventfd { +__s32 fd; +__u32 flag; +}; + +struct mshv_vtl_signal_event { +__u32 connection_id; +__u32 flag; +}; + +struct mshv_vtl_sint_post_msg { +__u64 message_type; +__u32 connection_id; +__u32 payload_size;/* Must not exceed HV_MESSAGE_PAYLOAD_BYTE_COUNT */ +__u64 payload_ptr;/* pointer to message payload (bytes) */ +}; + +struct mshv_vtl_ram_disposition { +__u64 start_pfn; +__u64 last_pfn; +}; + +struct mshv_vtl_set_poll_file { +__u32 cpu; +__u32 fd; +}; + +struct mshv_vtl_hvcall_setup { +__u64 bitmap_array_size;/* stores number of bytes */ +__u64 allow_bitmap_ptr; +}; + +struct mshv_vtl_hvcall { +__u64 control;/* Hypercall control code */ +__u64 input_size;/* Size of the input data */ +__u64 input_ptr;/* Pointer to the input struct */ +__u64 status;/* Status of the hypercall (output) */ +__u64 output_size;/* Size of the output data */ +__u64 output_ptr;/* Pointer to the output struct */ +}; + +struct mshv_sint_mask { +__u8 mask; +__u8 reserved[7 ]; +}; + +/* /dev/mshv device IOCTL */ +#define MSHV_CHECK_EXTENSION _IOW(MSHV_IOCTL, 0x00, __u32) + +/* vtl device */ +#define MSHV_CREATE_VTL _IOR(MSHV_IOCTL, 0x1D, char) +#define MSHV_ADD_VTL0_MEMORY _IOW(MSHV_IOCTL, 0x21, struct mshv_vtl_ram_disposition) +#define MSHV_SET_POLL_FILE _IOW(MSHV_IOCTL, 0x25, struct mshv_vtl_set_poll_file) +#define MSHV_RETURN_TO_LOWER_VTL _IO(MSHV_IOCTL, 0x27) +#define MSHV_GET_VP_REGISTERS _IOWR(MSHV_IOCTL, 0x05, struct mshv_vp_registers) +#define MSHV_SET_VP_REGISTERS _IOW(MSHV_IOCTL, 0x06, struct mshv_vp_registers) + +/* VMBus device IOCTLs */ +#define MSHV_SINT_SIGNAL_EVENT _IOW(MSHV_IOCTL, 0x22, struct mshv_vtl_signal_event) +#define MSHV_SINT_POST_MESSAGE _IOW(MSHV_IOCTL, 0x23, struct mshv_vtl_sint_post_msg) +#define MSHV_SINT_SET_EVENTFD _IOW(MSHV_IOCTL, 0x24, struct mshv_vtl_set_eventfd) +#define MSHV_SINT_PAUSE_MESSAGE_STREAM _IOW(MSHV_IOCTL, 0x25, struct mshv_sint_mask) + +/* hv_hvcall device */ +#define MSHV_HVCALL_SETUP _IOW(MSHV_IOCTL, 0x1E, struct mshv_vtl_hvcall_setup) +#define MSHV_HVCALL _IOWR(MSHV_IOCTL, 0x1F, struct mshv_vtl_hvcall)#endif linux-headers/linux/psp-sev.h +41
-25@@ -47,32 +47,32 @@ typedef enum {* with possible values from the specification. */ SEV_RET_NO_FW_CALL =-1 , -SEV_RET_SUCCESS =0 , -SEV_RET_INVALID_PLATFORM_STATE , -SEV_RET_INVALID_GUEST_STATE , -SEV_RET_INAVLID_CONFIG , +SEV_RET_SUCCESS =0 , +SEV_RET_INVALID_PLATFORM_STATE =0x0001 , +SEV_RET_INVALID_GUEST_STATE =0x0002 , +SEV_RET_INAVLID_CONFIG =0x0003 ,SEV_RET_INVALID_CONFIG =SEV_RET_INAVLID_CONFIG , -SEV_RET_INVALID_LEN , -SEV_RET_ALREADY_OWNED , -SEV_RET_INVALID_CERTIFICATE , -SEV_RET_POLICY_FAILURE , -SEV_RET_INACTIVE , -SEV_RET_INVALID_ADDRESS , -SEV_RET_BAD_SIGNATURE , -SEV_RET_BAD_MEASUREMENT , -SEV_RET_ASID_OWNED , -SEV_RET_INVALID_ASID , -SEV_RET_WBINVD_REQUIRED , -SEV_RET_DFFLUSH_REQUIRED , -SEV_RET_INVALID_GUEST , -SEV_RET_INVALID_COMMAND , -SEV_RET_ACTIVE , -SEV_RET_HWSEV_RET_PLATFORM , -SEV_RET_HWSEV_RET_UNSAFE , -SEV_RET_UNSUPPORTED , -SEV_RET_INVALID_PARAM , -SEV_RET_RESOURCE_LIMIT , -SEV_RET_SECURE_DATA_INVALID , +SEV_RET_INVALID_LEN =0x0004 , +SEV_RET_ALREADY_OWNED =0x0005 , +SEV_RET_INVALID_CERTIFICATE =0x0006 , +SEV_RET_POLICY_FAILURE =0x0007 , +SEV_RET_INACTIVE =0x0008 , +SEV_RET_INVALID_ADDRESS =0x0009 , +SEV_RET_BAD_SIGNATURE =0x000A , +SEV_RET_BAD_MEASUREMENT =0x000B , +SEV_RET_ASID_OWNED =0x000C , +SEV_RET_INVALID_ASID =0x000D , +SEV_RET_WBINVD_REQUIRED =0x000E , +SEV_RET_DFFLUSH_REQUIRED =0x000F , +SEV_RET_INVALID_GUEST =0x0010 , +SEV_RET_INVALID_COMMAND =0x0011 , +SEV_RET_ACTIVE =0x0012 , +SEV_RET_HWSEV_RET_PLATFORM =0x0013 , +SEV_RET_HWSEV_RET_UNSAFE =0x0014 , +SEV_RET_UNSUPPORTED =0x0015 , +SEV_RET_INVALID_PARAM =0x0016 , +SEV_RET_RESOURCE_LIMIT =0x0017 , +SEV_RET_SECURE_DATA_INVALID =0x0018 ,SEV_RET_INVALID_PAGE_SIZE =0x0019 ,SEV_RET_INVALID_PAGE_STATE =0x001A , SEV_RET_INVALID_MDATA_ENTRY = 0x001B,@@ -87,6 +87,22 @@ typedef enum {SEV_RET_RESTORE_REQUIRED =0x0025 ,SEV_RET_RMP_INITIALIZATION_FAILED =0x0026 ,SEV_RET_INVALID_KEY =0x0027 , +SEV_RET_SHUTDOWN_INCOMPLETE =0x0028 , +SEV_RET_INCORRECT_BUFFER_LENGTH =0x0030 , +SEV_RET_EXPAND_BUFFER_LENGTH_REQUEST =0x0031 , +SEV_RET_SPDM_REQUEST =0x0032 , +SEV_RET_SPDM_ERROR =0x0033 , +SEV_RET_SEV_STATUS_ERR_IN_DEV_CONN =0x0035 , +SEV_RET_SEV_STATUS_INVALID_DEV_CTX =0x0036 , +SEV_RET_SEV_STATUS_INVALID_TDI_CTX =0x0037 , +SEV_RET_SEV_STATUS_INVALID_TDI =0x0038 , +SEV_RET_SEV_STATUS_RECLAIM_REQUIRED =0x0039 , +SEV_RET_IN_USE =0x003A , +SEV_RET_SEV_STATUS_INVALID_DEV_STATE =0x003B , +SEV_RET_SEV_STATUS_INVALID_TDI_STATE =0x003C , +SEV_RET_SEV_STATUS_DEV_CERT_CHANGED =0x003D , +SEV_RET_SEV_STATUS_RESYNC_REQ =0x003E , +SEV_RET_SEV_STATUS_RESPONSE_TOO_LARGE =0x003F ,SEV_RET_MAX , } sev_ret_code;linux-headers/linux/vfio.h +28
-0@@ -14,6 +14,7 @@#include <linux/types.h> #include <linux/ioctl.h> +#include <linux/stddef.h> #define VFIO_API_VERSION 0@@ -1478,6 +1479,33 @@ struct vfio_device_feature_bus_master { };#define VFIO_DEVICE_FEATURE_BUS_MASTER 10 +/** +* Upon VFIO_DEVICE_FEATURE_GET create a dma_buf fd for the +* regions selected. +* +* open_flags are the typical flags passed to open(2), eg O_RDWR, O_CLOEXEC, +* etc. offset/length specify a slice of the region to create the dmabuf from. +* nr_ranges is the total number of (P2P DMA) ranges that comprise the dmabuf. +* +* flags should be 0. +* +* Return: The fd number on success, -1 and errno is set on failure. +*/ +#define VFIO_DEVICE_FEATURE_DMA_BUF 11 + +struct vfio_region_dma_range { +__u64 offset; +__u64 length; +}; + +struct vfio_device_feature_dma_buf { +__u32 region_index; +__u32 open_flags; +__u32 flags; +__u32 nr_ranges; + struct vfio_region_dma_range dma_ranges[] __counted_by(nr_ranges); +}; +/* -------- API for Type1 VFIO IOMMU -------- */ /**
PATCH 2/3 hw/net/virtio-net: Adapt hash handling to updated UAPI
In reply to Shameer KolothumThe virtio_net_hdr_v1_hash layout changed in the Linux UAPI, replacing the 32-bit hash_value field with two 16-bit fields, hash_value_lo and hash_value_hi.
Update hash handling to populate the new fields correctly and adjust offset and size calculations accordingly.
--- hw/net/virtio-net.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
hw/net/virtio-net.c +7 -4
@@ -1879,7 +1879,8 @@ static int virtio_net_process_rss(NetClientState *nc, const uint8_t *buf, n->rss_data.runtime_hash_types);if (net_hash_type > NetPktRssIpV6UdpEx) {if (n->rss_data.populate_hash) { - hdr->hash_value =VIRTIO_NET_HASH_REPORT_NONE ; + hdr->hash_value_lo =VIRTIO_NET_HASH_REPORT_NONE ; + hdr->hash_value_hi =VIRTIO_NET_HASH_REPORT_NONE ; hdr->hash_report =0 ; }return n->rss_data.redirect ? n->rss_data.default_queue :-1 ;
@@ -1888,7 +1889,8 @@ static int virtio_net_process_rss(NetClientState *nc, const uint8_t *buf, hash =net_rx_pkt_calc_rss_hash (pkt, net_hash_type, n->rss_data.key);if (n->rss_data.populate_hash) { - hdr->hash_value = hash; + hdr->hash_value_lo =cpu_to_le16 (hash &0xffff ); + hdr->hash_value_hi =cpu_to_le16 ((hash >>16 ) &0xffff ); hdr->hash_report = reports[net_hash_type]; }
@@ -1990,10 +1992,11 @@ static ssize_t virtio_net_receive_rcu(NetClientState *nc, const uint8_t *buf,receive_header (n, sg, elem->in_num, buf, size);if (n->rss_data.populate_hash) { - offset = offsetof(typeof (extra_hdr ), hash_value); + offset = offsetof(typeof (extra_hdr ), hash_value_lo);iov_from_buf (sg, elem->in_num, offset, (char *)&extra_hdr + offset, -sizeof (extra_hdr.hash_value) + +sizeof (extra_hdr.hash_value_lo) + +sizeof (extra_hdr.hash_value_hi) +sizeof (extra_hdr.hash_report)); } offset = n->host_hdr_len;
Signature · 1 line
2.43.0
PATCH 3/3 hw/vfio/region: Create dmabuf for PCI BAR per region
In reply to Shameer KolothumFrom: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU page table.
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
--- hw/vfio/region.c | 57 +++++++++++++++++++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)
hw/vfio/region.c +56 -1
@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /*
@@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion *region, int index) region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) +{ + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size; +int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags =VFIO_DEVICE_FEATURE_GET |VFIO_DEVICE_FEATURE_DMA_BUF , + }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature); +for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd; -if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {return 0 ; }
@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno)); + } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem; +RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:
hw/vfio/trace-events +1 -0
@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64 vfio_region_setup(const char *dev, int index, const char *name, unsigned long flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx" +vfio_region_dmabuf(const char *dev, int fd, int index, const char *name, unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx" vfio_region_mmap_fault(const char *name, int index, unsigned long offset, unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault: %d" vfio_region_mmap(const char *name, unsigned long offset, unsigned long end) "Region %s [0x%lx - 0x%lx]" vfio_region_exit(const char *name, int index) "Device %s, region %d"
Signature · 1 line
2.43.0
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Hi Shameer, Cedric,
Quoted 38 lines
Subject: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P
use cases. Create a dmabuf for each mapped BAR region after the mmap is set
up, and store the returned fd in the region's RAMBlock. This allows QEMU to
pass the fd todma_map_file(), enabling iommufd to import the dmabuf and map
the BAR correctly in the host IOMMU page table.If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57 +++++++++++++++++++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /*
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion · line 243
Quoted 5 lines
hw/vfio/region.c +1
-0@@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion *region, int index) region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region)
Would it make sense to consolidate this implementation with the one from my
series: https://lore.kernel.org/qemu-devel/[email protected]/
so that it is a bit more generic and can also be invoked from outside of VFIO?
Or, is it ok to have two dmabuf implementations: one that is internal to VFIO and takes a VFIORegion as input like this one and another one that takes a VFIODevice and iovec as input and can be invoked externally?
Thanks,
Vivek
Quoted 96 lines
hw/vfio/region.c +39
-1+{ + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size; +int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags =VFIO_DEVICE_FEATURE_GET |VFIO_DEVICE_FEATURE_DMA_BUF , + }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature); +for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd; -if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {return 0 ;}hw/vfio/region.c +15
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno)); + } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem; +RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events +0
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_tdata, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
vfio_region_read(char *name, int index,uint64_taddr, unsigned size,uint64_tdata) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64
vfio_region_setup(const char *dev, int index, const char *name, unsigned
long flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx" +vfio_region_dmabuf(const char *dev, int fd, int index, const char *name, unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx"
vfio_region_mmap_fault(const char *name, int index, unsigned long offset,
unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault:
%d"
vfio_region_mmap(const char *name, unsigned long offset, unsigned long
end) "Region %s [0x%lx - 0x%lx]"
vfio_region_exit(const char *name, int index)"Device %s, region %d"
--
2.43.0
Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Hello Vivek,
Quoted 44 lines · Vivek
Hi Shameer, Cedric,
Quoted 42 lines
Subject: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P
use cases. Create a dmabuf for each mapped BAR region after the mmap is set
up, and store the returned fd in the region's RAMBlock. This allows QEMU to
pass the fd todma_map_file(), enabling iommufd to import the dmabuf and map
the BAR correctly in the host IOMMU page table.If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57 +++++++++++++++++++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion *region, int index) region->mmaps[index].mmap =NULL ; }
Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 242
Quoted 1 line
hw/vfio/region.c +1
-0+static int vfio_region_create_dma_buf (VFIORegion *region)Would it make sense to consolidate this implementation with the one from my
series: https://lore.kernel.org/qemu-devel/[email protected]/
so that it is a bit more generic and can also be invoked from outside of VFIO?
I would prefer to start by the generic dmabuf support in VFIO, as it covers multiple use cases. Then, we can look at virtio-gpu.
Quoted 3 lines
Or, is it ok to have two dmabuf implementations: one that is internal to VFIO and takes a VFIORegion as input like this one and another one that takes a VFIODevice and iovec as input and can be invoked externally?
May be this approach can be revisited a bit ? I haven't looked yet.
Thanks,
C.
Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
In reply to Shameer KolothumQuoted 55 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU page table.If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57 +++++++++++++++++++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c +22
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion *region, int index) region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) +{ + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size; +int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags =VFIO_DEVICE_FEATURE_GET |VFIO_DEVICE_FEATURE_DMA_BUF , + }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr,
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 10 lines
hw/vfio/region.c +10
-0+ .open_flags = O_RDWR, + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_feature may be NULL for other backend like vfio-user.
Quoted 6 lines
hw/vfio/region.c +6
-0+for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret;
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 10 lines
hw/vfio/region.c +3
-1+} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd; -if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {
Just curious, when will above check return true?
Quoted 7 lines
hw/vfio/region.c +0
-0return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); }
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 357
Quoted 10 lines
hw/vfio/region.c +10
-0+ ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno)); + } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;
Do we need to support region->mmaps[1]?
Thanks
Zhenzhong
Quoted 20 lines
hw/vfio/region.c +5
-0+RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events +1
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64 vfio_region_setup(const char *dev, int index, const char *name, unsigned long flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx" +vfio_region_dmabuf(const char *dev, int fd, int index, const char *name, unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx" vfio_region_mmap_fault(const char *name, int index, unsigned long offset, unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault: %d" vfio_region_mmap(const char *name, unsigned long offset, unsigned long end) "Region %s [0x%lx - 0x%lx]" vfio_region_exit(const char *name, int index) "Device %s, region %d"
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 81 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 7 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 8 lines
hw/vfio/region.c +5
-0region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size;hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 10 lines
hw/vfio/region.c +10
-0+int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 10 lines
hw/vfio/region.c +10
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) {
Quoted 8 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 5 lines
hw/vfio/region.c +5
-0+ dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend like vfio- user.
Ah..Ok. I will add a check.
Quoted 15 lines
Quoted 15 lines
hw/vfio/region.c +8
-0+for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;
Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think !region->mem covers cases where no MemoryRegion was created (e.g. zero sized regions). And nr_mmaps checks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/ _CAP_SPARSE_MMAP).
Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c +0
-0return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); }
Quoted 12 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 357
Quoted 10 lines
hw/vfio/region.c +10
-0+ ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno)); + } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Thanks,
Shameer
Quoted 34 lines
Thanks
Zhenzhong
Quoted 13 lines
hw/vfio/region.c +5
-0+RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events index renamed from hw/vfio/trace-events +0
-0
1e895448cd..592a0349d4100644hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 117
Quoted 1 line
hw/vfio/trace-events +0
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_tdata, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 118
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_read(char *name, int index, uint64_t addr, unsigned size,
uint64_tdata) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 119
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_setup(const char *dev, int index, const char *name, unsignedlong flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 120
Quoted 1 line
hw/vfio/trace-events +1
-0+vfio_region_dmabuf(const char *dev, int fd, int index, const char *name,unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 121
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap_fault(const char *name, int index, unsigned long offset,unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault:
%d"hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 122
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap(const char *name, unsigned long offset, unsigned longend) "Region %s [0x%lx - 0x%lx]"
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_exit(const char *name, int index) "Device %s, region %d"
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 120 lines
-----Original Message-----
From: Shameer Kolothum <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionQuoted 7 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin ChenQuoted 5 lines
Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionQuoted 7 lines
External email: Use caution opening links or attachments
Quoted 3 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory
for
Quoted 34 lines
Quoted 4 lines
P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 3 lines
hw/vfio/region.c +0
-0region->mmaps[index].mmap =NULL ; }Quoted 11 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 11 lines
hw/vfio/region.c +11
-0+static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size; +int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + + sizeof(struct vfio_region_dma_range) *
region->nr_mmaps;Quoted 14 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 4 lines
hw/vfio/region.c +4
-0+ feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 9 lines
hw/vfio/region.c +9
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; +Quoted 8 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 6 lines
hw/vfio/region.c +6
-0+for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend likevfio-
Quoted 1 line
user.
Ah..Ok. I will add a check.
Quoted 3 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion · line 273
Quoted 3 lines
hw/vfio/region.c +2
-0+for (i =0 ; i < region->nr_mmaps; i++) { + trace_vfio_region_dmabuf(region->vbasedev->name, ret,
region->nr,Quoted 1 line
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion · line 274
Quoted 1 line
hw/vfio/region.c +1
-0+ region->mem->name,region->mmaps[i].offset,
Quoted 11 lines
Quoted 11 lines
hw/vfio/region.c +5
-0+ region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;
Quoted 7 lines
Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think
!region->memcovers cases where no MemoryRegion was created (e.g. zero sized regions). Andnr_mmapschecks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/_CAP_SPARSE_MMAP).
Understood, thanks.
Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
hw/vfio/region.c +0
-0return 0 ; }Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 351
Quoted 8 lines
hw/vfio/region.c +4
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { + warn_report_once("VFIO dmabuf not supported inkernel");
Quoted 3 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 3 lines
hw/vfio/region.c +3
-0+ }else { + error_report("%s: failed to create dmabuf: %s", + memory_region_name(region->mem),strerror(errno));
Quoted 4 lines
Quoted 3 lines
hw/vfio/region.c +3
-0+ } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;
Quoted 5 lines
Quoted 1 line
Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Not get, can RAMBlock have holes?
Quoted 42 lines
Thanks,
ShameerQuoted 20 lines
Thanks
Zhenzhong
Quoted 13 lines
hw/vfio/region.c +5
-0+RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events index renamed from hw/vfio/trace-events +0
-0
1e895448cd..592a0349d4100644hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 117
Quoted 1 line
hw/vfio/trace-events +0
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_tdata, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
Quoted 3 lines
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 118
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_read(char *name, int index, uint64_t addr, unsigned size,
uint64_tdata) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_setup(const char *dev, int index, const char *name,unsigned
Quoted 3 lines
long flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx"
Quoted 1 line
hw/vfio/trace-events +1
-0+vfio_region_dmabuf(const char *dev, int fd, int index, const char*name,
Quoted 1 line
unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d
region %d
Quoted 2 lines
\"%s\", offset: 0x%lx, size: 0x%lx"
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap_fault(const char *name, int index, unsigned longoffset,
Quoted 3 lines
unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault:
%d"Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap(const char *name, unsigned long offset, unsignedlong
Quoted 2 lines
end) "Region %s [0x%lx - 0x%lx]"
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_exit(const char *name, int index) "Device %s, region %d"
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 170 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 09 January 2026 10:13
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 11 lines
-----Original Message-----
From: Shameer Kolothum <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionQuoted 4 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu-Quoted 5 lines
Quoted 3 lines
[email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin ChenQuoted 1 line
Nathan Chen <[email protected]>; Matt Ochs <[email protected]>;
Jason
Quoted 103 lines
Quoted 11 lines
Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 3 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory
for
Quoted 35 lines
Quoted 5 lines
P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 3 lines
hw/vfio/region.c +0
-0region->mmaps[index].mmap =NULL ; }Quoted 11 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 11 lines
hw/vfio/region.c +11
-0+static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size; +int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + + sizeof(struct vfio_region_dma_range) *
region->nr_mmaps;Quoted 14 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 4 lines
hw/vfio/region.c +4
-0+ feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 9 lines
hw/vfio/region.c +9
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; +Quoted 8 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 6 lines
hw/vfio/region.c +6
-0+for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend likevfio-
Quoted 1 line
user.
Ah..Ok. I will add a check.
Quoted 3 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion · line 273
Quoted 3 lines
hw/vfio/region.c +2
-0+for (i =0 ; i < region->nr_mmaps; i++) { + trace_vfio_region_dmabuf(region->vbasedev->name, ret,
region->nr,Quoted 1 line
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion · line 274
Quoted 1 line
hw/vfio/region.c +1
-0+ region->mem->name,region->mmaps[i].offset,
Quoted 11 lines
Quoted 11 lines
hw/vfio/region.c +5
-0+ region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;Quoted 7 lines
Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think
!region->memcovers cases where no MemoryRegion was created (e.g. zero sized regions). Andnr_mmapschecks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/_CAP_SPARSE_MMAP).Understood, thanks.
Quoted 22 lines
Quoted 5 lines
Quoted 5 lines
hw/vfio/region.c +0
-0return 0 ; }Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 351
Quoted 8 lines
hw/vfio/region.c +4
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { + warn_report_once("VFIO dmabuf not supported inkernel");
Quoted 3 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 3 lines
hw/vfio/region.c +3
-0+ }else { + error_report("%s: failed to create dmabuf: %s", + memory_region_name(region->mem),strerror(errno));
Quoted 4 lines
Quoted 3 lines
hw/vfio/region.c +3
-0+ } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Not get, can RAMBlock have holes?
Yes, a RAMBlock can effectively have holes, but in this context that is not what is happening.
IIUC, for a VFIO PCI BAR region, all region->mmaps[] entries correspond to subranges of the same BAR and are backed by the same MemoryRegion and therefore the same RAMBlock. The sparse mmap layout (nr_mmaps > 1) exists to describe which parts of the BAR are mappable, not to represent distinct backing memory objects.
So while sparse regions may look like "holes" at the mmap level, there are no holes in the RAMBlock abstraction itself. All region->mmaps[] entries share the same RAMBlock, which is why attaching the returned dmabuf fd to region->mmaps[0].mem.ram_block is sufficient, I think.
However, possible I may be missing the case you are concerned about here. Please let me know.
Thanks,
Shameer
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 34 lines
Quoted 17 lines
Quoted 17 lines
Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 351
Quoted 8 lines
hw/vfio/region.c +4
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { + warn_report_once("VFIO dmabuf not supported inkernel");
Quoted 3 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 3 lines
hw/vfio/region.c +3
-0+ }else { + error_report("%s: failed to create dmabuf: %s", + memory_region_name(region->mem),strerror(errno));
Quoted 4 lines
Quoted 3 lines
hw/vfio/region.c +3
-0+ } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Not get, can RAMBlock have holes?
Yes, a RAMBlock can effectively have holes, but in this context that is not what is happening.
IIUC, for a VFIO PCI BAR region, all region->mmaps[] entries correspond to subranges of the same BAR and are backed by the same MemoryRegion and therefore the same RAMBlock. The sparse mmap layout (
nr_mmaps> 1) exists to describe which parts of the BAR are mappable, not to represent distinct backing memory objects.
Quoted 7 lines
So while sparse regions may look like "holes" at the mmap level, there are no holes in the RAMBlock abstraction itself. All region->mmaps[] entries share the same RAMBlock, which is why attaching the returned dmabuf fd to region->mmaps[0].mem.ram_block is sufficient, I think.
However, possible I may be missing the case you are concerned about here. Please let me know.
I see memory_region_init_ram_device_ptr() is called for each region->mmaps[x].mem, and RAMBlock is allocated in each call.
IIUC, we should set fd and fd_offset in each RAMBlock.
Thanks
Zhenzhong
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 56 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 12 January 2026 02:33
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 39 lines
Quoted 17 lines
Quoted 17 lines
Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 351
Quoted 8 lines
hw/vfio/region.c +4
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { + warn_report_once("VFIO dmabuf not supported inkernel");
Quoted 3 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 3 lines
hw/vfio/region.c +3
-0+ }else { + error_report("%s: failed to create dmabuf: %s", + memory_region_name(region->mem),strerror(errno));
Quoted 4 lines
Quoted 3 lines
hw/vfio/region.c +3
-0+ } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Not get, can RAMBlock have holes?
Yes, a RAMBlock can effectively have holes, but in this context that is not what is happening.
IIUC, for a VFIO PCI BAR region, all region->mmaps[] entries correspond to subranges of the same BAR and are backed by the same MemoryRegion and therefore the same RAMBlock. The sparse mmap layout (
nr_mmaps> 1) exists to describe which parts of the BAR are mappable, not to represent distinct backing memory objects.So while sparse regions may look like "holes" at the mmap level, there are no holes in the RAMBlock abstraction itself. All region->mmaps[] entries share the same RAMBlock, which is why attaching the returned dmabuf fd to region->mmaps[0].mem.ram_block is sufficient, I think.
Quoted 6 lines
Quoted 2 lines
However, possible I may be missing the case you are concerned about here. Please let me know.
I see
memory_region_init_ram_device_ptr()is called for each region-Quoted 1 line
mmaps[x].mem,
and RAMBlock is allocated in each call.
Ah.. I see. It does allocate RAMBlock per mmaps[i].
Quoted 1 line
IIUC, we should set fd and
fd_offsetin each RAMBlock.
Ok. Will update in v2.
Thanks,
Shameer
Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 60 lines · Shameer Kolothum
Quoted 60 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 12 January 2026 02:33
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 34 lines
Quoted 17 lines
Quoted 17 lines
Quoted 8 lines
Review int vfio_region_mmap(VFIORegion *region) · line 351
Quoted 8 lines
(quoted diff) +4
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret = vfio_region_create_dma_buf(region); + if (ret < 0) { + if (ret == -ENOTTY) { + warn_report_once("VFIO dmabuf not supported inkernel");
Quoted 3 lines
Review int vfio_region_mmap(VFIORegion *region) · line 354
Quoted 3 lines
(quoted diff) +3
-0+ } else { + error_report("%s: failed to create dmabuf: %s", + memory_region_name(region->mem),strerror(errno));
Quoted 4 lines
Quoted 3 lines
(quoted diff) +3
-0+ } + } else { + MemoryRegion *mr = ®ion->mmaps[0].mem;Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Not get, can RAMBlock have holes?
Yes, a RAMBlock can effectively have holes, but in this context that is not what is happening.
IIUC, for a VFIO PCI BAR region, all region->mmaps[] entries correspond to subranges of the same BAR and are backed by the same MemoryRegion and therefore the same RAMBlock. The sparse mmap layout (
nr_mmaps> 1) exists to describe which parts of the BAR are mappable, not to represent distinct backing memory objects.Quoted 7 lines
So while sparse regions may look like "holes" at the mmap level, there are no holes in the RAMBlock abstraction itself. All region->mmaps[] entries share the same RAMBlock, which is why attaching the returned dmabuf fd to region->mmaps[0].mem.ram_block is sufficient, I think.
However, possible I may be missing the case you are concerned about here. Please let me know.
I see
memory_region_init_ram_device_ptr()is called for each region-
Quoted 8 lines
Quoted 2 lines
Quoted 1 line
mmaps[x].mem,
and RAMBlock is allocated in each call.
Ah.. I see. It does allocate RAMBlock per mmaps[i].
Quoted 1 line
IIUC, we should set fd and
fd_offsetin each RAMBlock.Ok. Will update in v2.
I'd like to send a vfio PR soon and this v2 looks a like good candidate for it.
Thanks,
C.
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 85 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 12 January 2026 15:16
To: Shameer Kolothum <[email protected]>; Duan, Zhenzhong <[email protected]>; [email protected]; qemu- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 6 lines · Shameer Kolothum
Quoted 6 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 12 January 2026 02:33
To: Shameer Kolothum <[email protected]>; qemu-Quoted 35 lines
Quoted 35 lines
[email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 23 lines
Quoted 23 lines
Quoted 22 lines
Quoted 8 lines
Review int vfio_region_mmap(VFIORegion *region) · line 351
Quoted 8 lines
(quoted diff) +4
-0@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret = vfio_region_create_dma_buf(region); + if (ret < 0) { + if (ret == -ENOTTY) { + warn_report_once("VFIO dmabuf not supported inkernel");
Quoted 3 lines
Review int vfio_region_mmap(VFIORegion *region) · line 354
Quoted 3 lines
(quoted diff) +3
-0+ } else { + error_report("%s: failed to create dmabuf: %s", + memory_region_name(region->mem),strerror(errno));
Quoted 5 lines
Review int vfio_region_mmap(VFIORegion *region) · line 357
Quoted 3 lines
(quoted diff) +3
-0+ } + } else { + MemoryRegion *mr = ®ion->mmaps[0].mem;Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Not get, can RAMBlock have holes?
Yes, a RAMBlock can effectively have holes, but in this context that is not what is happening.
IIUC, for a VFIO PCI BAR region, all region->mmaps[] entries correspond to subranges of the same BAR and are backed by the same MemoryRegion and therefore the same RAMBlock. The sparse mmap
layout
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
(
nr_mmaps> 1) exists to describe which parts of the BAR are mappable, not to represent distinct backing memory objects.So while sparse regions may look like "holes" at the mmap level, there are no holes in the RAMBlock abstraction itself. All region->mmaps[] entries share the same RAMBlock, which is why attaching the returned dmabuf fd to region->mmaps[0].mem.ram_block is
sufficient, I think.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
However, possible I may be missing the case you are concerned about
here.
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
Please let me know.
I see
memory_region_init_ram_device_ptr()is called for each region-Quoted 1 line
mmaps[x].mem,
Quoted 8 lines
Quoted 7 lines
Quoted 1 line
and RAMBlock is allocated in each call.
Ah.. I see. It does allocate RAMBlock per mmaps[i].
Quoted 1 line
IIUC, we should set fd and
fd_offsetin each RAMBlock.Ok. Will update in v2.
I'd like to send a vfio PR soon and this v2 looks a like good candidate for it.
Sure. Will send out the v2 soon and thanks for sending those update-linux-headers and the hyperv patches.
Thanks,
Shameer
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
In reply to Shameer KolothumQuoted 13 lines
-----Original Message-----
From: Shameer Kolothum <[email protected]>
Sent: 12 January 2026 08:45
To: Duan, Zhenzhong <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
[...]
Quoted 5 lines
Ah.. I see. It does allocate RAMBlock per mmaps[i].
Quoted 1 line
IIUC, we should set fd and
fd_offsetin each RAMBlock.Ok. Will update in v2.
I have sent out a v2 and missed to CC few. Sorry. Please find here:
https://lore.kernel.org/qemu-devel/[email protected]/
Thanks,
Shameer
Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
In reply to Shameer KolothumQuoted 90 lines · Shameer Kolothum
Quoted 81 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 7 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 8 lines
hw/vfio/region.c +5
-0region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size;hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 10 lines
hw/vfio/region.c +10
-0+int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 10 lines
hw/vfio/region.c +10
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) {Quoted 8 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 5 lines
hw/vfio/region.c +5
-0+ dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend like vfio- user.
Quoted 1 line
Ah..Ok. I will add a check.
Could you please add a global routine :
int vfio_device_get_feature(VFIODevice *vbasedev, struct vfio_device_feature *feature)
Quoted 32 lines
Quoted 16 lines
Quoted 16 lines
hw/vfio/region.c +8
-0+for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think
!region->memcovers cases where no MemoryRegion was created (e.g. zero sized regions). Andnr_mmapschecks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/_CAP_SPARSE_MMAP).Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c +0
-0return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); }
Quoted 7 lines
Quoted 7 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 354
Quoted 7 lines
hw/vfio/region.c +7
-0+ ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno));
Shouldn't we return 'ret' in this case ?
Thanks,
C.
Quoted 46 lines
Quoted 5 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region) · line 357
Quoted 3 lines
hw/vfio/region.c +3
-0+ } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem;Do we need to support region->mmaps[1]?
My understanding is all region->mmaps[] entries for a VFIO region share the same RAMBlock. And the kernel returns a single dmabuf fd per region, not per subrange.
Thanks,
ShameerQuoted 34 lines
Thanks
Zhenzhong
Quoted 13 lines
hw/vfio/region.c +5
-0+RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events index renamed from hw/vfio/trace-events +0
-0
1e895448cd..592a0349d4100644hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 117
Quoted 1 line
hw/vfio/trace-events +0
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_tdata, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 118
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_read(char *name, int index, uint64_t addr, unsigned size,
uint64_tdata) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 119
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_setup(const char *dev, int index, const char *name, unsignedlong flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 120
Quoted 1 line
hw/vfio/trace-events +1
-0+vfio_region_dmabuf(const char *dev, int fd, int index, const char *name,unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 121
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap_fault(const char *name, int index, unsigned long offset,unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault:
%d"hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 122
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap(const char *name, unsigned long offset, unsigned longend) "Region %s [0x%lx - 0x%lx]"
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_exit(const char *name, int index) "Device %s, region %d"
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Hi Cédric,
Quoted 111 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 09 January 2026 17:05
To: Shameer Kolothum <[email protected]>; Duan, Zhenzhong <[email protected]>; [email protected]; qemu- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 6 lines · Shameer Kolothum
Quoted 6 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu-Quoted 87 lines
Quoted 86 lines
[email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 8 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 8 lines
hw/vfio/region.c +5
-0region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size;hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 10 lines
hw/vfio/region.c +10
-0+int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 5 lines
hw/vfio/region.c +5
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr,hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 10 lines
hw/vfio/region.c +10
-0+ .open_flags = O_RDWR, + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend like vbasedev->vfio-
user.
Quoted 6 lines
Quoted 1 line
Ah..Ok. I will add a check.
Could you please add a global routine :
int vfio_device_get_feature(VFIODevice *vbasedev, struct
vfio_device_feature*feature)
Ok.
Quoted 34 lines
Quoted 34 lines
Quoted 18 lines
Quoted 18 lines
hw/vfio/region.c +8
-0+for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think
!region->memcovers cases where no MemoryRegion was created (e.g. zero sized regions). Andnr_mmapschecks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/_CAP_SPARSE_MMAP).Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c +0
-0return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); }
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 8 lines
hw/vfio/region.c +8
-0+ ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem), +strerror (errno));Shouldn't we return 'ret' in this case ?
That would result in:
Failed to mmap 0018:06:00.0 BAR 0. Performance may be slow
Not sure that error msg is correct in this context. If we don't return 'ret' here vfio_container_dma_map() will eventually report the warning:
qemu-system-aarch64: warning: vfio_container_dma_map(0xaaaaff67ad40, 0x58000000000, 0xb90000, 0xffff64000000) = -14 (Bad address) 0018:06:00.0: PCI peer-to-peer transactions on BARs are not supported.
qemu-system-aarch64: warning: IOMMU_IOAS_MAP failed: Bad address, PCI BAR?
I think the above is good enough for this. Please let me know.
Thanks,
Shameer
Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 167 lines · Shameer Kolothum
Hi Cédric,
Quoted 111 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 09 January 2026 17:05
To: Shameer Kolothum <[email protected]>; Duan, Zhenzhong <[email protected]>; [email protected]; qemu- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 6 lines · Shameer Kolothum
Quoted 6 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu-Quoted 87 lines
Quoted 86 lines
[email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 8 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 8 lines
hw/vfio/region.c +5
-0region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size;hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 10 lines
hw/vfio/region.c +10
-0+int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 5 lines
hw/vfio/region.c +5
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr,hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 10 lines
hw/vfio/region.c +10
-0+ .open_flags = O_RDWR, + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend like vbasedev->vfio-
user.Quoted 6 lines
Quoted 1 line
Ah..Ok. I will add a check.
Could you please add a global routine :
int vfio_device_get_feature(VFIODevice *vbasedev, struct
vfio_device_feature*feature)Ok.
Quoted 34 lines
Quoted 34 lines
Quoted 18 lines
Quoted 18 lines
hw/vfio/region.c +8
-0+for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think
!region->memcovers cases where no MemoryRegion was created (e.g. zero sized regions). Andnr_mmapschecks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/_CAP_SPARSE_MMAP).Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c +0
-0return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); }Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 8 lines
hw/vfio/region.c +8
-0+ ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem), +strerror (errno));Shouldn't we return 'ret' in this case ?
Quoted 5 lines
That would result in:
Failed to mmap 0018:06:00.0 BAR 0. Performance may be slow
Not sure that error msg is correct in this context.
Agree. It would be a step backwards from the current situation.
Quoted 6 lines
If we don't return 'ret' here
vfio_container_dma_map()will eventually report the warning:qemu-system-aarch64: warning:
vfio_container_dma_map(0xaaaaff67ad40, 0x58000000000, 0xb90000, 0xffff64000000)= -14 (Bad address) 0018:06:00.0: PCI peer-to-peer transactions on BARs are not supported.
qemu-system-aarch64: warning:IOMMU_IOAS_MAPfailed: Bad address, PCI BAR?
Yes that's what we have today.
Quoted 1 line
I think the above is good enough for this. Please let me know.
Given that, with this change, QEMU will now always request a DMABUF fd, the question is to what extent a failure should be considered critical.
Would there be reasons to fail to realize the vfio-pci device and stop the machine ?
Thanks,
C.
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Quoted 210 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 12 January 2026 18:32
To: Shameer Kolothum <[email protected]>; Duan, Zhenzhong <[email protected]>; [email protected]; qemu- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 11 lines · Shameer Kolothum
Hi Cédric,
Quoted 9 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Sent: 09 January 2026 17:05
To: Shameer Kolothum <[email protected]>; Duan, Zhenzhong <[email protected]>; [email protected]; qemu- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; JasonGunthorpe
Quoted 60 lines
Quoted 60 lines
<[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 6 lines · Shameer Kolothum
Quoted 6 lines
-----Original Message-----
From: Duan, Zhenzhong <[email protected]>
Sent: 08 January 2026 09:41
To: Shameer Kolothum <[email protected]>; qemu-Quoted 45 lines
Quoted 45 lines
[email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Quoted 8 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU pagetable.
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
Quoted 14 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c index renamed from hw/vfio/region.c +0
-0
b165ab0b93..6949f6779c100644hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
hw/vfio/region.c static void
Quoted 2 lines
hw/vfio/region.c +0
-0/* @@ -238,13 +239,52 @@ static voidvfio_subregion_unmap(VFIORegion
Quoted 53 lines
Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
*region, int index)
Quoted 8 lines
hw/vfio/region.c +5
-0region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) { + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size;hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 10 lines
hw/vfio/region.c +10
-0+int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 5 lines
hw/vfio/region.c +5
-0+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr,hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 272
Quoted 10 lines
hw/vfio/region.c +10
-0+ .open_flags = O_RDWR, + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature);
vbasedev->io_ops->device_featuremay be NULL for other backend like vbasedev->vfio-
user.Quoted 6 lines
Quoted 1 line
Ah..Ok. I will add a check.
Could you please add a global routine :
int vfio_device_get_feature(VFIODevice *vbasedev, struct
vfio_device_feature*feature)Ok.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 22 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
hw/vfio/region.c static void · line 273
Quoted 2 lines
hw/vfio/region.c +2
-0+for (i =0 ; i < region->nr_mmaps; i++) { + trace_vfio_region_dmabuf(region->vbasedev->name, ret, region-nr,
Quoted 19 lines
Quoted 19 lines
Quoted 12 lines
Quoted 12 lines
hw/vfio/region.c +6
-0+ region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd;Quoted 4 lines
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index) · line 287
Quoted 2 lines
hw/vfio/region.c +1
-1-if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {Just curious, when will above check return true?
I think
!region->memcovers cases where no MemoryRegion was created (e.g. zero sized regions). Andnr_mmapschecks regions with mmap support exists (VFIO_REGION_INFO_FLAG_MMAP/
_CAP_SPARSE_MMAP).Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
hw/vfio/region.c +0
-0return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); }Quoted 10 lines
Quoted 8 lines
Quoted 8 lines
hw/vfio/region.c int vfio_region_mmap(VFIORegion *region)
Quoted 8 lines
hw/vfio/region.c +8
-0+ ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem), +strerror (errno));Shouldn't we return 'ret' in this case ?
Quoted 5 lines
That would result in:
Failed to mmap 0018:06:00.0 BAR 0. Performance may be slow
Not sure that error msg is correct in this context.
Agree. It would be a step backwards from the current situation.
Quoted 4 lines
If we don't return 'ret' here
vfio_container_dma_map()will eventually report the warning:qemu-system-aarch64: warning:
vfio_container_dma_map(0xaaaaff67ad40, 0x58000000000, 0xb90000, 0xffff64000000)= -14 (Bad address)Quoted 2 lines
0018:06:00.0: PCI peer-to-peer transactions on BARs are not supported.
qemu-system-aarch64: warning:IOMMU_IOAS_MAPfailed: Bad address,PCI BAR?
Yes that's what we have today.
Quoted 8 lines
Quoted 1 line
I think the above is good enough for this. Please let me know.
Given that, with this change, QEMU will now always request a DMABUF fd, the question is to what extent a failure should be considered critical.
Would there be reasons to fail to realize the vfio-pci device and stop the machine ?
Hmm...I don’t think so. This mainly matters for devices that make use of P2P DMA or expose device memory, such as Grace GPUs. Also, QEMU currently does not treat vfio_container_dma_map() failures as fatal either.
For v2, I will keep the existing behaviour. We can consider tightening this later if there is a concrete requirement to fail device realization in such cases.
Hope, that is reasonable for now.
Thanks,
Shameer
Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
In reply to Shameer KolothumHi Shameer,
Quoted 7 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. Create a dmabuf for each mapped BAR region after the mmap is set up, and store the returned fd in the region’s RAMBlock. This allows QEMU to pass the fd to
dma_map_file(), enabling iommufd to import the dmabuf and map the BAR correctly in the host IOMMU page table.
I tested the series with upstream kernel and your master-smmuv3-accel-v6-veventq-v2-vcmdq-rfcv1-dmabuf-v1 branch
It works fine with Grace Hopper GPU passthrough, without cmdqv. However with cmdqv, I get
qemu-system-aarch64: warning: IOMMU_IOAS_MAP failed: Bad address, PCI BAR?
qemu-system-aarch64: warning: vfio_container_dma_map(0xaaaea68471b0, 0xc090000, 0x10000, 0xffffb5c90000) = -14 (Bad address)
qemu-system-aarch64: warning: IOMMU_IOAS_MAP failed: Bad address, PCI BAR?
Maybe this is unrelated to this series and rather relates to the cmdqv one.
Wonder if you get the same warning, and in the positive, if the root cause is understood and maybe fixed elsewhere.
Thank you in advance
Eric
Quoted 111 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57 +++++++++++++++++++++++++++++++++++++++++++- hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c +56
-1@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion *region, int index) region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) +{ + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size; +int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags =VFIO_DEVICE_FEATURE_GET |VFIO_DEVICE_FEATURE_DMA_BUF , + }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature); +for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd; -if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno)); + } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem; +RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events +1
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data, unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)" vfio_region_read(char *name, int index, uint64_t addr, unsigned size, uint64_t data) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64 vfio_region_setup(const char *dev, int index, const char *name, unsigned long flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx" +vfio_region_dmabuf(const char *dev, int fd, int index, const char *name, unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx" vfio_region_mmap_fault(const char *name, int index, unsigned long offset, unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault: %d" vfio_region_mmap(const char *name, unsigned long offset, unsigned long end) "Region %s [0x%lx - 0x%lx]" vfio_region_exit(const char *name, int index) "Device %s, region %d"
RE: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per region
Hi Eric,
Quoted 43 lines
-----Original Message-----
From: Eric Auger <[email protected]>
Sent: 12 January 2026 09:16
To: Shameer Kolothum <[email protected]>; qemu- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Nicolin Chen <[email protected]>; Nathan Chen <[email protected]>; Matt Ochs <[email protected]>; Jason Gunthorpe <[email protected]>; Krishnakant Jaju <[email protected]>
Subject: Re: [PATCH 3/3] hw/vfio/region: Create dmabuf for PCI BAR per regionExternal email: Use caution opening links or attachments
Hi Shameer,
Quoted 3 lines · Shameer Kolothum
From: Nicolin Chen <[email protected]>
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for
P2P
Quoted 1 line
use cases. Create a dmabuf for each mapped BAR region after the mmap is
set
Quoted 1 line
up, and store the returned fd in the region’s RAMBlock. This allows QEMU
to
Quoted 1 line
pass the fd to
dma_map_file(), enabling iommufd to import the dmabufand map
Quoted 1 line
the BAR correctly in the host IOMMU page table.
I tested the series with upstream kernel and your master-smmuv3-accel-v6-veventq-v2-vcmdq-rfcv1-dmabuf-v1 branch
It works fine with Grace Hopper GPU passthrough, without cmdqv. However with cmdqv, I get
qemu-system-aarch64: warning:
IOMMU_IOAS_MAPfailed: Bad address, PCI BAR?
qemu-system-aarch64: warning:vfio_container_dma_map(0xaaaea68471b0, 0xc090000, 0x10000, 0xffffb5c90000)= -14 (Bad address)
qemu-system-aarch64: warning:IOMMU_IOAS_MAPfailed: Bad address, PCI BAR?
Quoted 4 lines
Maybe this is unrelated to this series and rather relates to the cmdqv one.
Wonder if you get the same warning, and in the positive, if the root cause is understood and maybe fixed elsewhere.
Yes. I can reproduce this with cmdqv enabled. This is triggered during tegra241_cmdqv_init_vcmdq_page0(), when QEMU sets up the VINTF / vCMDQ page0 mappings.
IIUC, this is not guest RAM and there is also no dmabuf support for this memory in the kernel, which leads to the IOMMU_IOAS_MAP failure. AFAICS, this memory region does not participate in device DMA and does not require any IOMMU mappings. Hence, we can ignore this warning for now.
I will look into this in more detail during the next vCMDQ respin to see whether we can avoid triggering this warning.
Thanks,
Shameer
Quoted 129 lines
Thank you in advance
Eric
Quoted 8 lines
If the kernel lacks support or dmabuf setup fails, QEMU skips the setup and continues with normal mmap handling.
Signed-off-by Nicolin Chen <[email protected]>Signed-off-by Shameer Kolothum <[email protected]>--- hw/vfio/region.c | 57+++++++++++++++++++++++++++++++++++++++++++-
hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion
Quoted 16 lines
hw/vfio/trace-events | 1 + 2 files changed, 57 insertions(+), 1 deletion(-)hw/vfio/region.c +1
-0@@ -29,6 +29,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "monitor/monitor.h" +#include "system/ramblock.h" #include "vfio-helpers.h" /* @@ -238,13 +239,52 @@ static void vfio_subregion_unmap(VFIORegion*region, int index)
Quoted 9 lines
hw/vfio/region.c +6
-0region->mmaps[index].mmap =NULL ; } +static int vfio_region_create_dma_buf (VFIORegion *region) +{ + g_autofree struct vfio_device_feature *feature = NULL; +VFIODevice *vbasedev = region->vbasedev; +struct vfio_device_feature_dma_buf *dma_buf; +size_t total_size;hw/vfio/region.c static void vfio_subregion_unmap(VFIORegion *region, int index)
Quoted 10 lines
hw/vfio/region.c +10
-0+int i, ret; + +g_assert (region->nr_mmaps); + + total_size =sizeof (*feature) +sizeof (*dma_buf) + +sizeof (struct vfio_region_dma_range ) * region->nr_mmaps; + feature =g_malloc0 (total_size); + *feature = (struct vfio_device_feature ) { + .argsz = total_size, + .flags = VFIO_DEVICE_FEATURE_GET |
VFIO_DEVICE_FEATURE_DMA_BUF,Quoted 61 lines
hw/vfio/region.c +39
-1+ }; + + dma_buf = (void *)feature->data; + *dma_buf = (struct vfio_device_feature_dma_buf ) { + .region_index = region->nr, + .open_flags =O_RDWR , + .nr_ranges = region->nr_mmaps, + }; + +for (i =0 ; i < region->nr_mmaps; i++) { + dma_buf->dma_ranges[i].offset = region->mmaps[i].offset; + dma_buf->dma_ranges[i].length = region->mmaps[i].size; + } + + ret = vbasedev->io_ops->device_feature (vbasedev, feature); +for (i =0 ; i < region->nr_mmaps; i++) { +trace_vfio_region_dmabuf (region->vbasedev->name, ret, region->nr, + region->mem->name, region->mmaps[i].offset, + region->mmaps[i].size); + } +return ret; +} +int vfio_region_mmap (VFIORegion *region) {int i, ret, prot =0 ;char *name;int fd; -if (!region->mem) { +if (!region->mem || !region->nr_mmaps) {return 0 ; }@@ -305,6 +345,21 @@ int vfio_region_mmap(VFIORegion *region) region->mmaps[i].size - 1); } + ret =vfio_region_create_dma_buf (region); +if (ret <0 ) { +if (ret == -ENOTTY ) { +warn_report_once ("VFIO dmabuf not supported in kernel" ); + }else { +error_report ("%s: failed to create dmabuf: %s" , +memory_region_name (region->mem),strerror (errno)); + } + }else { +MemoryRegion *mr = ®ion->mmaps[0 ].mem; +RAMBlock *ram_block = mr->ram_block; + + ram_block->fd = ret; + } +return 0 ; no_mmap:hw/vfio/trace-events +0
-0hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 117
Quoted 1 line
hw/vfio/trace-events +0
-0@@ -117,6 +117,7 @@ vfio_device_put(int fd) "close vdev->fd=%d" vfio_region_write(const char *name, int index, uint64_t addr, uint64_t data,unsigned size) " (%s:region%d+0x%"PRIx64", 0x%"PRIx64 ", %d)"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 118
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_read(char *name, int index, uint64_t addr, unsigned size,
uint64_tdata) " (%s:region%d+0x%"PRIx64", %d) = 0x%"PRIx64hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 119
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_setup(const char *dev, int index, const char *name, unsignedlong flags, unsigned long offset, unsigned long size) "Device %s, region %d \"%s\", flags: 0x%lx, offset: 0x%lx, size: 0x%lx"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 120
Quoted 1 line
hw/vfio/trace-events +1
-0+vfio_region_dmabuf(const char *dev, int fd, int index, const char *name,unsigned long offset, unsigned long size) "Device %s, dmabuf fd %d region %d \"%s\", offset: 0x%lx, size: 0x%lx"
hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 121
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap_fault(const char *name, int index, unsigned long offset,unsigned long size, int fault) "Region %s mmaps[%d], [0x%lx - 0x%lx], fault:
%d"hw/vfio/trace-events vfio_device_put(int fd) "close vdev->fd=%d" · line 122
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_mmap(const char *name, unsigned long offset, unsigned longend) "Region %s [0x%lx - 0x%lx]"
Quoted 1 line
hw/vfio/trace-events +0
-0vfio_region_exit(const char *name, int index) "Device %s, region %d"
Quoted 10 lines · Shameer Kolothum
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. This adds support for vfio devices to create a dmabuf for each mapped BAR region.
Requires linux-headers update to 6.19-rc1(patch #1). That update introduces a virtio-net build issue, which is addressed by patch #2.
The dmabuf support was sanity tested on an NVIDIA grace paltform.
Please take a look and let me know.
Hi Shameer,
Quoted 6 lines · Shameer Kolothum
Hi,
Linux now provides a VFIO dmabuf exporter to expose PCI BAR memory for P2P use cases. This adds support for vfio devices to create a dmabuf for each mapped BAR region.
Quoted 6 lines
Requires linux-headers update to 6.19-rc1(patch #1). That update introduces a virtio-net build issue, which is addressed by patch #2.
The dmabuf support was sanity tested on an NVIDIA grace paltform.
Please take a look and let me know.
I gave it a try with a pair of GPUs on x86_64. LGTM.
It should be ready to merge after the linux-headers update is fixed.
Thanks,
C.
Quoted 50 lines
Thanks,
ShameerNicolin Chen (1):
hw/vfio/region: Create dmabuf for PCI BAR per regionShameer Kolothum (2):
linux-headers: Update to Linux v6.19-rc1 hw/net/virtio-net: Adapt hash handling to updated UAPIhw/net/virtio-net.c | 11 +- hw/vfio/region.c | 57 ++- hw/vfio/trace-events | 1 + include/standard-headers/drm/drm_fourcc.h | 25 +- include/standard-headers/linux/ethtool.h | 5 + .../linux/input-event-codes.h | 14 +- include/standard-headers/linux/pci_regs.h | 89 ++++ include/standard-headers/linux/virtio_net.h | 3 +- include/standard-headers/linux/virtio_pci.h | 2 +- linux-headers/asm-arm64/kvm.h | 2 +- linux-headers/asm-arm64/unistd_64.h | 1 + linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-loongarch/kvm.h | 1 + linux-headers/asm-loongarch/unistd.h | 6 + linux-headers/asm-loongarch/unistd_64.h | 1 + linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-riscv/kvm.h | 3 + linux-headers/asm-riscv/unistd_32.h | 1 + linux-headers/asm-riscv/unistd_64.h | 1 + linux-headers/asm-s390/bitsperlong.h | 4 - linux-headers/asm-s390/unistd.h | 4 - linux-headers/asm-s390/unistd_32.h | 446 ------------------ linux-headers/asm-s390/unistd_64.h | 9 +- linux-headers/asm-x86/kvm.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/iommufd.h | 10 + linux-headers/linux/kvm.h | 11 + linux-headers/linux/mshv.h | 116 ++++- linux-headers/linux/psp-sev.h | 66 ++- linux-headers/linux/vfio.h | 28 ++ 36 files changed, 427 insertions(+), 503 deletions(-)delete mode 100644
linux-headers/asm-s390/unistd_32.h