From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659548040; cv=none; d=zohomail.com; s=zohoarc; b=JqkkxdAzqQCSmrXvbjUlevUYH7iP0/KjJSdy3nCQ/ColPk31zMXqwHqRlqAXuCJN8jRkvNoiFmOR0B3iRy0vnImAYU0CIMqEjakfc1FIJbnC7eTtVyLB72Zrdk0PpiXqEFP+5XM2FDyGWaPiaDtGlxW1Uf9QBuCj60ahVfjUw1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659548040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wz8dDRc1Kik8jS6DvNP9SENgWTXOgyoxMLKTfC+D3M0=; b=eD2ZxqpnzKsZJVvNqhIjgVe8mI34Mf++cSlH7J06xxOurII1mBIpujThdzihFmvWTM+hFwDvL0QesktEDo2tGndjiZMUNRbRAieN5WHkF3hSF2zk05xobbm/+yrQvhcEIbWCOQEFEkmygxH9g7twJNzpzJkLDZKmJnTan7u7ZyM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659548040347682.863679649262; Wed, 3 Aug 2022 10:34:00 -0700 (PDT) Received: from localhost ([::1]:50856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJIFq-0006h3-3Q for importer@patchew.org; Wed, 03 Aug 2022 13:33:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1u-0004og-4X for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1r-00048K-5S for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:33 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-23UBlwo_NGeLkkNZoVomyQ-1; Wed, 03 Aug 2022 13:19:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A8CFC82DFFF; Wed, 3 Aug 2022 17:18:29 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id C10CA1121314; Wed, 3 Aug 2022 17:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wz8dDRc1Kik8jS6DvNP9SENgWTXOgyoxMLKTfC+D3M0=; b=WEGYtT60qV8OacSvw4vj9g1eioElEk93/4IBPVMmxgLV9A7bFuEvh1lWtELBNT9tPUMXSd FwzBGIvi3BgvJe3/gwOhoX6m/EPfvEQy3q4M4esPmMfAMExMsghUC1ouJC22ftRFLO6L9r UcZEPKZaeEg19Aim6OSd4x/XBMizOQc= X-MC-Unique: 23UBlwo_NGeLkkNZoVomyQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 1/7] linux-headers: Update kernel headers Date: Wed, 3 Aug 2022 19:18:15 +0200 Message-Id: <20220803171821.481336-2-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659548042356100001 Main reason is for new vhost_vdpa address space ioctls to be available. Update kernel headers until 9de1f9c8ca51 ("Merge tag 'irq-core-2022-08-01' of git://git.kernel.org/pub/= scm/linux/kernel/git/tip/tip"). Signed-off-by: Eugenio P=C3=A9rez --- include/standard-headers/asm-x86/bootparam.h | 7 +- include/standard-headers/drm/drm_fourcc.h | 69 ++++++++++++++++++++ include/standard-headers/linux/ethtool.h | 1 + include/standard-headers/linux/input.h | 12 ++-- include/standard-headers/linux/pci_regs.h | 1 + include/standard-headers/linux/vhost_types.h | 11 +++- include/standard-headers/linux/virtio_ids.h | 14 ++-- linux-headers/asm-arm64/kvm.h | 27 ++++++++ linux-headers/asm-generic/unistd.h | 4 +- linux-headers/asm-riscv/kvm.h | 20 ++++++ linux-headers/asm-riscv/unistd.h | 3 +- linux-headers/asm-x86/kvm.h | 11 ++-- linux-headers/asm-x86/mman.h | 14 ---- linux-headers/linux/kvm.h | 56 +++++++++++++++- linux-headers/linux/userfaultfd.h | 10 ++- linux-headers/linux/vfio.h | 4 +- linux-headers/linux/vhost.h | 26 ++++++-- 17 files changed, 240 insertions(+), 50 deletions(-) diff --git a/include/standard-headers/asm-x86/bootparam.h b/include/standar= d-headers/asm-x86/bootparam.h index b2aaad10e5..0b06d2bff1 100644 --- a/include/standard-headers/asm-x86/bootparam.h +++ b/include/standard-headers/asm-x86/bootparam.h @@ -10,12 +10,13 @@ #define SETUP_EFI 4 #define SETUP_APPLE_PROPERTIES 5 #define SETUP_JAILHOUSE 6 +#define SETUP_CC_BLOB 7 +#define SETUP_IMA 8 #define SETUP_RNG_SEED 9 +#define SETUP_ENUM_MAX SETUP_RNG_SEED =20 #define SETUP_INDIRECT (1<<31) - -/* SETUP_INDIRECT | max(SETUP_*) */ -#define SETUP_TYPE_MAX (SETUP_INDIRECT | SETUP_JAILHOUSE) +#define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT) =20 /* ram_size flags */ #define RAMDISK_IMAGE_START_MASK 0x07FF diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index 4888f85f69..0b051545d3 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -571,6 +571,53 @@ extern "C" { */ #define I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC fourcc_mod_code(INTEL, 8) =20 +/* + * Intel Tile 4 layout + * + * This is a tiled layout using 4KB tiles in a row-major layout. It has th= e same + * shape as Tile Y at two granularities: 4KB (128B x 32) and 64B (16B x 4)= . It + * only differs from Tile Y at the 256B granularity in between. At this + * granularity, Tile Y has a shape of 16B x 32 rows, but this tiling has a= shape + * of 64B x 8 rows. + */ +#define I915_FORMAT_MOD_4_TILED fourcc_mod_code(INTEL, 9) + +/* + * Intel color control surfaces (CCS) for DG2 render compression. + * + * The main surface is Tile 4 and at plane index 0. The CCS data is stored + * outside of the GEM object in a reserved memory area dedicated for the + * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. T= he + * main surface pitch is required to be a multiple of four Tile 4 widths. + */ +#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS fourcc_mod_code(INTEL, 10) + +/* + * Intel color control surfaces (CCS) for DG2 media compression. + * + * The main surface is Tile 4 and at plane index 0. For semi-planar formats + * like NV12, the Y and UV planes are Tile 4 and are located at plane indi= ces + * 0 and 1, respectively. The CCS for all planes are stored outside of the + * GEM object in a reserved memory area dedicated for the storage of the + * CCS data for all RC/RC_CC/MC compressible GEM objects. The main surface + * pitch is required to be a multiple of four Tile 4 widths. + */ +#define I915_FORMAT_MOD_4_TILED_DG2_MC_CCS fourcc_mod_code(INTEL, 11) + +/* + * Intel Color Control Surface with Clear Color (CCS) for DG2 render compr= ession. + * + * The main surface is Tile 4 and at plane index 0. The CCS data is stored + * outside of the GEM object in a reserved memory area dedicated for the + * storage of the CCS data for all RC/RC_CC/MC compressible GEM objects. T= he + * main surface pitch is required to be a multiple of four Tile 4 widths. = The + * clear color is stored at plane index 1 and the pitch should be ignored.= The + * format of the 256 bits of clear color data matches the one used for the + * I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC modifier, see its description + * for details. + */ +#define I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC fourcc_mod_code(INTEL, 12) + /* * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks * @@ -608,6 +655,28 @@ extern "C" { */ #define DRM_FORMAT_MOD_QCOM_COMPRESSED fourcc_mod_code(QCOM, 1) =20 +/* + * Qualcomm Tiled Format + * + * Similar to DRM_FORMAT_MOD_QCOM_COMPRESSED but not compressed. + * Implementation may be platform and base-format specific. + * + * Each macrotile consists of m x n (mostly 4 x 4) tiles. + * Pixel data pitch/stride is aligned with macrotile width. + * Pixel data height is aligned with macrotile height. + * Entire pixel data buffer is aligned with 4k(bytes). + */ +#define DRM_FORMAT_MOD_QCOM_TILED3 fourcc_mod_code(QCOM, 3) + +/* + * Qualcomm Alternate Tiled Format + * + * Alternate tiled format typically only used within GMEM. + * Implementation may be platform and base-format specific. + */ +#define DRM_FORMAT_MOD_QCOM_TILED2 fourcc_mod_code(QCOM, 2) + + /* Vivante framebuffer modifiers */ =20 /* diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index 38d5a4cd6e..5a99f13471 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -1691,6 +1691,7 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT =3D 89, ETHTOOL_LINK_MODE_100baseFX_Half_BIT =3D 90, ETHTOOL_LINK_MODE_100baseFX_Full_BIT =3D 91, + ETHTOOL_LINK_MODE_10baseT1L_Full_BIT =3D 92, /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS }; diff --git a/include/standard-headers/linux/input.h b/include/standard-head= ers/linux/input.h index 7822c24178..942ea6aaa9 100644 --- a/include/standard-headers/linux/input.h +++ b/include/standard-headers/linux/input.h @@ -75,10 +75,13 @@ struct input_id { * Note that input core does not clamp reported values to the * [minimum, maximum] limits, such task is left to userspace. * - * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z) - * is reported in units per millimeter (units/mm), resolution - * for rotational axes (ABS_RX, ABS_RY, ABS_RZ) is reported - * in units per radian. + * The default resolution for main axes (ABS_X, ABS_Y, ABS_Z, + * ABS_MT_POSITION_X, ABS_MT_POSITION_Y) is reported in units + * per millimeter (units/mm), resolution for rotational axes + * (ABS_RX, ABS_RY, ABS_RZ) is reported in units per radian. + * The resolution for the size axes (ABS_MT_TOUCH_MAJOR, + * ABS_MT_TOUCH_MINOR, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR) + * is reported in units per millimeter (units/mm). * When INPUT_PROP_ACCELEROMETER is set the resolution changes. * The main axes (ABS_X, ABS_Y, ABS_Z) are then reported in * units per g (units/g) and in units per degree per second @@ -268,6 +271,7 @@ struct input_mask { #define BUS_RMI 0x1D #define BUS_CEC 0x1E #define BUS_INTEL_ISHTP 0x1F +#define BUS_AMD_SFH 0x20 =20 /* * MT_TOOL types diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index bee1a9ed6e..108f8523fa 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -616,6 +616,7 @@ #define PCI_EXP_SLTCTL_PWR_OFF 0x0400 /* Power Off */ #define PCI_EXP_SLTCTL_EIC 0x0800 /* Electromechanical Interlock Control = */ #define PCI_EXP_SLTCTL_DLLSCE 0x1000 /* Data Link Layer State Changed Ena= ble */ +#define PCI_EXP_SLTCTL_ASPL_DISABLE 0x2000 /* Auto Slot Power Limit Disab= le */ #define PCI_EXP_SLTCTL_IBPD_DISABLE 0x4000 /* In-band PD disable */ #define PCI_EXP_SLTSTA 0x1a /* Slot Status */ #define PCI_EXP_SLTSTA_ABP 0x0001 /* Attention Button Pressed */ diff --git a/include/standard-headers/linux/vhost_types.h b/include/standar= d-headers/linux/vhost_types.h index 0bd2684a2a..ce78551b0f 100644 --- a/include/standard-headers/linux/vhost_types.h +++ b/include/standard-headers/linux/vhost_types.h @@ -87,7 +87,7 @@ struct vhost_msg { =20 struct vhost_msg_v2 { uint32_t type; - uint32_t reserved; + uint32_t asid; union { struct vhost_iotlb_msg iotlb; uint8_t padding[64]; @@ -153,4 +153,13 @@ struct vhost_vdpa_iova_range { /* vhost-net should add virtio_net_hdr for RX, and strip for TX packets. */ #define VHOST_NET_F_VIRTIO_NET_HDR 27 =20 +/* Use message type V2 */ +#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 +/* IOTLB can accept batching hints */ +#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 +/* IOTLB can accept address space identifier through V2 type of IOTLB + * message + */ +#define VHOST_BACKEND_F_IOTLB_ASID 0x3 + #endif diff --git a/include/standard-headers/linux/virtio_ids.h b/include/standard= -headers/linux/virtio_ids.h index 80d76b75bc..7aa2eb7662 100644 --- a/include/standard-headers/linux/virtio_ids.h +++ b/include/standard-headers/linux/virtio_ids.h @@ -73,12 +73,12 @@ * Virtio Transitional IDs */ =20 -#define VIRTIO_TRANS_ID_NET 1000 /* transitional virtio net */ -#define VIRTIO_TRANS_ID_BLOCK 1001 /* transitional virtio block */ -#define VIRTIO_TRANS_ID_BALLOON 1002 /* transitional virtio balloon */ -#define VIRTIO_TRANS_ID_CONSOLE 1003 /* transitional virtio console */ -#define VIRTIO_TRANS_ID_SCSI 1004 /* transitional virtio SCSI */ -#define VIRTIO_TRANS_ID_RNG 1005 /* transitional virtio rng */ -#define VIRTIO_TRANS_ID_9P 1009 /* transitional virtio 9p console */ +#define VIRTIO_TRANS_ID_NET 0x1000 /* transitional virtio net */ +#define VIRTIO_TRANS_ID_BLOCK 0x1001 /* transitional virtio block */ +#define VIRTIO_TRANS_ID_BALLOON 0x1002 /* transitional virtio balloon */ +#define VIRTIO_TRANS_ID_CONSOLE 0x1003 /* transitional virtio console */ +#define VIRTIO_TRANS_ID_SCSI 0x1004 /* transitional virtio SCSI */ +#define VIRTIO_TRANS_ID_RNG 0x1005 /* transitional virtio rng */ +#define VIRTIO_TRANS_ID_9P 0x1009 /* transitional virtio 9p console */ =20 #endif /* _LINUX_VIRTIO_IDS_H */ diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 5c28a9737a..286668285f 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -139,8 +139,10 @@ struct kvm_guest_debug_arch { __u64 dbg_wvr[KVM_ARM_MAX_DBG_REGS]; }; =20 +#define KVM_DEBUG_ARCH_HSR_HIGH_VALID (1 << 0) struct kvm_debug_exit_arch { __u32 hsr; + __u32 hsr_high; /* ESR_EL2[61:32] */ __u64 far; /* used for watchpoints */ }; =20 @@ -332,6 +334,31 @@ struct kvm_arm_copy_mte_tags { #define KVM_ARM64_SVE_VLS_WORDS \ ((KVM_ARM64_SVE_VQ_MAX - KVM_ARM64_SVE_VQ_MIN) / 64 + 1) =20 +/* Bitmap feature firmware registers */ +#define KVM_REG_ARM_FW_FEAT_BMAP (0x0016 << KVM_REG_ARM_COPROC_SHIFT) +#define KVM_REG_ARM_FW_FEAT_BMAP_REG(r) (KVM_REG_ARM64 | KVM_REG_SIZE_U64= | \ + KVM_REG_ARM_FW_FEAT_BMAP | \ + ((r) & 0xffff)) + +#define KVM_REG_ARM_STD_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(0) + +enum { + KVM_REG_ARM_STD_BIT_TRNG_V1_0 =3D 0, +}; + +#define KVM_REG_ARM_STD_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(1) + +enum { + KVM_REG_ARM_STD_HYP_BIT_PV_TIME =3D 0, +}; + +#define KVM_REG_ARM_VENDOR_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(2) + +enum { + KVM_REG_ARM_VENDOR_HYP_BIT_FUNC_FEAT =3D 0, + KVM_REG_ARM_VENDOR_HYP_BIT_PTP =3D 1, +}; + /* Device Control API: ARM VGIC */ #define KVM_DEV_ARM_VGIC_GRP_ADDR 0 #define KVM_DEV_ARM_VGIC_GRP_DIST_REGS 1 diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic= /unistd.h index 1c48b0ae3b..45fa180cc5 100644 --- a/linux-headers/asm-generic/unistd.h +++ b/linux-headers/asm-generic/unistd.h @@ -383,7 +383,7 @@ __SYSCALL(__NR_syslog, sys_syslog) =20 /* kernel/ptrace.c */ #define __NR_ptrace 117 -__SYSCALL(__NR_ptrace, sys_ptrace) +__SC_COMP(__NR_ptrace, sys_ptrace, compat_sys_ptrace) =20 /* kernel/sched/core.c */ #define __NR_sched_setparam 118 @@ -779,7 +779,7 @@ __SYSCALL(__NR_rseq, sys_rseq) #define __NR_kexec_file_load 294 __SYSCALL(__NR_kexec_file_load, sys_kexec_file_load) /* 295 through 402 are unassigned to sync up with generic numbers, don't u= se */ -#if __BITS_PER_LONG =3D=3D 32 +#if defined(__SYSCALL_COMPAT) || __BITS_PER_LONG =3D=3D 32 #define __NR_clock_gettime64 403 __SYSCALL(__NR_clock_gettime64, sys_clock_gettime) #define __NR_clock_settime64 404 diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h index f808ad1ce5..6119368ba6 100644 --- a/linux-headers/asm-riscv/kvm.h +++ b/linux-headers/asm-riscv/kvm.h @@ -82,6 +82,23 @@ struct kvm_riscv_timer { __u64 state; }; =20 +/* + * ISA extension IDs specific to KVM. This is not the same as the host ISA + * extension IDs as that is internal to the host and should not be exposed + * to the guest. This should always be contiguous to keep the mapping simp= le + * in KVM implementation. + */ +enum KVM_RISCV_ISA_EXT_ID { + KVM_RISCV_ISA_EXT_A =3D 0, + KVM_RISCV_ISA_EXT_C, + KVM_RISCV_ISA_EXT_D, + KVM_RISCV_ISA_EXT_F, + KVM_RISCV_ISA_EXT_H, + KVM_RISCV_ISA_EXT_I, + KVM_RISCV_ISA_EXT_M, + KVM_RISCV_ISA_EXT_MAX, +}; + /* Possible states for kvm_riscv_timer */ #define KVM_RISCV_TIMER_STATE_OFF 0 #define KVM_RISCV_TIMER_STATE_ON 1 @@ -123,6 +140,9 @@ struct kvm_riscv_timer { #define KVM_REG_RISCV_FP_D_REG(name) \ (offsetof(struct __riscv_d_ext_state, name) / sizeof(__u64)) =20 +/* ISA Extension registers are mapped as type 7 */ +#define KVM_REG_RISCV_ISA_EXT (0x07 << KVM_REG_RISCV_TYPE_SHIFT) + #endif =20 #endif /* __LINUX_KVM_RISCV_H */ diff --git a/linux-headers/asm-riscv/unistd.h b/linux-headers/asm-riscv/uni= std.h index 8062996c2d..73d7cdd2ec 100644 --- a/linux-headers/asm-riscv/unistd.h +++ b/linux-headers/asm-riscv/unistd.h @@ -15,12 +15,13 @@ * along with this program. If not, see . */ =20 -#ifdef __LP64__ +#if defined(__LP64__) && !defined(__SYSCALL_COMPAT) #define __ARCH_WANT_NEW_STAT #define __ARCH_WANT_SET_GET_RLIMIT #endif /* __LP64__ */ =20 #define __ARCH_WANT_SYS_CLONE3 +#define __ARCH_WANT_MEMFD_SECRET =20 #include =20 diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index bf6e96011d..21614807a2 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -428,11 +428,12 @@ struct kvm_sync_regs { struct kvm_vcpu_events events; }; =20 -#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0) -#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) -#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) -#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) -#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) +#define KVM_X86_QUIRK_LINT0_REENABLED (1 << 0) +#define KVM_X86_QUIRK_CD_NW_CLEARED (1 << 1) +#define KVM_X86_QUIRK_LAPIC_MMIO_HOLE (1 << 2) +#define KVM_X86_QUIRK_OUT_7E_INC_RIP (1 << 3) +#define KVM_X86_QUIRK_MISC_ENABLE_NO_MWAIT (1 << 4) +#define KVM_X86_QUIRK_FIX_HYPERCALL_INSN (1 << 5) =20 #define KVM_STATE_NESTED_FORMAT_VMX 0 #define KVM_STATE_NESTED_FORMAT_SVM 1 diff --git a/linux-headers/asm-x86/mman.h b/linux-headers/asm-x86/mman.h index d4a8d0424b..775dbd3aff 100644 --- a/linux-headers/asm-x86/mman.h +++ b/linux-headers/asm-x86/mman.h @@ -5,20 +5,6 @@ #define MAP_32BIT 0x40 /* only give out 32bit addresses */ =20 #ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS -/* - * Take the 4 protection key bits out of the vma->vm_flags - * value and turn them in to the bits that we can put in - * to a pte. - * - * Only override these if Protection Keys are available - * (which is only on 64-bit). - */ -#define arch_vm_get_page_prot(vm_flags) __pgprot( \ - ((vm_flags) & VM_PKEY_BIT0 ? _PAGE_PKEY_BIT0 : 0) | \ - ((vm_flags) & VM_PKEY_BIT1 ? _PAGE_PKEY_BIT1 : 0) | \ - ((vm_flags) & VM_PKEY_BIT2 ? _PAGE_PKEY_BIT2 : 0) | \ - ((vm_flags) & VM_PKEY_BIT3 ? _PAGE_PKEY_BIT3 : 0)) - #define arch_calc_vm_prot_bits(prot, key) ( \ ((key) & 0x1 ? VM_PKEY_BIT0 : 0) | \ ((key) & 0x2 ? VM_PKEY_BIT1 : 0) | \ diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index f089349149..a0dff15c2b 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -444,6 +444,9 @@ struct kvm_run { #define KVM_SYSTEM_EVENT_SHUTDOWN 1 #define KVM_SYSTEM_EVENT_RESET 2 #define KVM_SYSTEM_EVENT_CRASH 3 +#define KVM_SYSTEM_EVENT_WAKEUP 4 +#define KVM_SYSTEM_EVENT_SUSPEND 5 +#define KVM_SYSTEM_EVENT_SEV_TERM 6 __u32 type; __u32 ndata; union { @@ -644,6 +647,7 @@ struct kvm_vapic_addr { #define KVM_MP_STATE_OPERATING 7 #define KVM_MP_STATE_LOAD 8 #define KVM_MP_STATE_AP_RESET_HOLD 9 +#define KVM_MP_STATE_SUSPENDED 10 =20 struct kvm_mp_state { __u32 mp_state; @@ -1148,8 +1152,9 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_S390_MEM_OP_EXTENSION 211 #define KVM_CAP_PMU_CAPABILITY 212 #define KVM_CAP_DISABLE_QUIRKS2 213 -/* #define KVM_CAP_VM_TSC_CONTROL 214 */ +#define KVM_CAP_VM_TSC_CONTROL 214 #define KVM_CAP_SYSTEM_EVENT_DATA 215 +#define KVM_CAP_ARM_SYSTEM_SUSPEND 216 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1238,6 +1243,7 @@ struct kvm_x86_mce { #define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2) #define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3) #define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4) +#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5) =20 struct kvm_xen_hvm_config { __u32 flags; @@ -1476,7 +1482,8 @@ struct kvm_s390_ucas_mapping { #define KVM_SET_PIT2 _IOW(KVMIO, 0xa0, struct kvm_pit_state2) /* Available with KVM_CAP_PPC_GET_PVINFO */ #define KVM_PPC_GET_PVINFO _IOW(KVMIO, 0xa1, struct kvm_ppc_pvinfo) -/* Available with KVM_CAP_TSC_CONTROL */ +/* Available with KVM_CAP_TSC_CONTROL for a vCPU, or with +* KVM_CAP_VM_TSC_CONTROL to set defaults for a VM */ #define KVM_SET_TSC_KHZ _IO(KVMIO, 0xa2) #define KVM_GET_TSC_KHZ _IO(KVMIO, 0xa3) /* Available with KVM_CAP_PCI_2_3 */ @@ -1692,6 +1699,32 @@ struct kvm_xen_hvm_attr { struct { __u64 gfn; } shared_info; + struct { + __u32 send_port; + __u32 type; /* EVTCHNSTAT_ipi / EVTCHNSTAT_interdomain */ + __u32 flags; +#define KVM_XEN_EVTCHN_DEASSIGN (1 << 0) +#define KVM_XEN_EVTCHN_UPDATE (1 << 1) +#define KVM_XEN_EVTCHN_RESET (1 << 2) + /* + * Events sent by the guest are either looped back to + * the guest itself (potentially on a different port#) + * or signalled via an eventfd. + */ + union { + struct { + __u32 port; + __u32 vcpu; + __u32 priority; + } port; + struct { + __u32 port; /* Zero for eventfd */ + __s32 fd; + } eventfd; + __u32 padding[4]; + } deliver; + } evtchn; + __u32 xen_version; __u64 pad[8]; } u; }; @@ -1700,11 +1733,17 @@ struct kvm_xen_hvm_attr { #define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0 #define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1 #define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ +#define KVM_XEN_ATTR_TYPE_EVTCHN 0x3 +#define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4 =20 /* Per-vCPU Xen attributes */ #define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr) #define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr) =20 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ +#define KVM_XEN_HVM_EVTCHN_SEND _IOW(KVMIO, 0xd0, struct kvm_irq_routing_= xen_evtchn) + #define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2) #define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2) =20 @@ -1722,6 +1761,13 @@ struct kvm_xen_vcpu_attr { __u64 time_blocked; __u64 time_offline; } runstate; + __u32 vcpu_id; + struct { + __u32 port; + __u32 priority; + __u64 expires_ns; + } timer; + __u8 vector; } u; }; =20 @@ -1732,6 +1778,10 @@ struct kvm_xen_vcpu_attr { #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4 #define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5 +/* Available with KVM_CAP_XEN_HVM / KVM_XEN_HVM_CONFIG_EVTCHN_SEND */ +#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6 +#define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7 +#define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8 =20 /* Secure Encrypted Virtualization command */ enum sev_cmd_id { @@ -2032,7 +2082,7 @@ struct kvm_stats_header { #define KVM_STATS_UNIT_SECONDS (0x2 << KVM_STATS_UNIT_SHIFT) #define KVM_STATS_UNIT_CYCLES (0x3 << KVM_STATS_UNIT_SHIFT) #define KVM_STATS_UNIT_BOOLEAN (0x4 << KVM_STATS_UNIT_SHIFT) -#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_CYCLES +#define KVM_STATS_UNIT_MAX KVM_STATS_UNIT_BOOLEAN =20 #define KVM_STATS_BASE_SHIFT 8 #define KVM_STATS_BASE_MASK (0xF << KVM_STATS_BASE_SHIFT) diff --git a/linux-headers/linux/userfaultfd.h b/linux-headers/linux/userfa= ultfd.h index 769b8379e4..a3a377cd44 100644 --- a/linux-headers/linux/userfaultfd.h +++ b/linux-headers/linux/userfaultfd.h @@ -33,7 +33,8 @@ UFFD_FEATURE_THREAD_ID | \ UFFD_FEATURE_MINOR_HUGETLBFS | \ UFFD_FEATURE_MINOR_SHMEM | \ - UFFD_FEATURE_EXACT_ADDRESS) + UFFD_FEATURE_EXACT_ADDRESS | \ + UFFD_FEATURE_WP_HUGETLBFS_SHMEM) #define UFFD_API_IOCTLS \ ((__u64)1 << _UFFDIO_REGISTER | \ (__u64)1 << _UFFDIO_UNREGISTER | \ @@ -47,7 +48,8 @@ #define UFFD_API_RANGE_IOCTLS_BASIC \ ((__u64)1 << _UFFDIO_WAKE | \ (__u64)1 << _UFFDIO_COPY | \ - (__u64)1 << _UFFDIO_CONTINUE) + (__u64)1 << _UFFDIO_CONTINUE | \ + (__u64)1 << _UFFDIO_WRITEPROTECT) =20 /* * Valid ioctl command number range with this API is from 0x00 to @@ -194,6 +196,9 @@ struct uffdio_api { * UFFD_FEATURE_EXACT_ADDRESS indicates that the exact address of page * faults would be provided and the offset within the page would not be * masked. + * + * UFFD_FEATURE_WP_HUGETLBFS_SHMEM indicates that userfaultfd + * write-protection mode is supported on both shmem and hugetlbfs. */ #define UFFD_FEATURE_PAGEFAULT_FLAG_WP (1<<0) #define UFFD_FEATURE_EVENT_FORK (1<<1) @@ -207,6 +212,7 @@ struct uffdio_api { #define UFFD_FEATURE_MINOR_HUGETLBFS (1<<9) #define UFFD_FEATURE_MINOR_SHMEM (1<<10) #define UFFD_FEATURE_EXACT_ADDRESS (1<<11) +#define UFFD_FEATURE_WP_HUGETLBFS_SHMEM (1<<12) __u64 features; =20 __u64 ioctls; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index e9f7795c39..ede44b5572 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -643,7 +643,7 @@ enum { }; =20 /** - * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12, + * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 12, * struct vfio_pci_hot_reset_info) * * Return: 0 on success, -errno on failure: @@ -770,7 +770,7 @@ struct vfio_device_ioeventfd { #define VFIO_DEVICE_IOEVENTFD _IO(VFIO_TYPE, VFIO_BASE + 16) =20 /** - * VFIO_DEVICE_FEATURE - _IORW(VFIO_TYPE, VFIO_BASE + 17, + * VFIO_DEVICE_FEATURE - _IOWR(VFIO_TYPE, VFIO_BASE + 17, * struct vfio_device_feature) * * Get, set, or probe feature data of the device. The feature is selected diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index 5d99e7c242..cab645d4a6 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -89,11 +89,6 @@ =20 /* Set or get vhost backend capability */ =20 -/* Use message type V2 */ -#define VHOST_BACKEND_F_IOTLB_MSG_V2 0x1 -/* IOTLB can accept batching hints */ -#define VHOST_BACKEND_F_IOTLB_BATCH 0x2 - #define VHOST_SET_BACKEND_FEATURES _IOW(VHOST_VIRTIO, 0x25, __u64) #define VHOST_GET_BACKEND_FEATURES _IOR(VHOST_VIRTIO, 0x26, __u64) =20 @@ -150,11 +145,30 @@ /* Get the valid iova range */ #define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, \ struct vhost_vdpa_iova_range) - /* Get the config size */ #define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32) =20 /* Get the count of all virtqueues */ #define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32) =20 +/* Get the number of virtqueue groups. */ +#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32) + +/* Get the number of address spaces. */ +#define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int) + +/* Get the group for a virtqueue: read index, write group in num, + * The virtqueue index is stored in the index field of + * vhost_vring_state. The group for this specific virtqueue is + * returned via num field of vhost_vring_state. + */ +#define VHOST_VDPA_GET_VRING_GROUP _IOWR(VHOST_VIRTIO, 0x7B, \ + struct vhost_vring_state) +/* Set the ASID for a virtqueue group. The group index is stored in + * the index field of vhost_vring_state, the ASID associated with this + * group is stored at num field of vhost_vring_state. + */ +#define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, \ + struct vhost_vring_state) + #endif --=20 2.31.1 From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659547852; cv=none; d=zohomail.com; s=zohoarc; b=KtJJMpTj4nZFhm32IXQRdPTRSsBzHwJ/1AAEi2/7RV3T+0dU+LXVGvdsVaIq2WopZKy8c4TnbjHIq17d0TZ7BQlB7qbAynmxOzLs7Bz8ppqSHHn6IeHuBHDKSJ40Eh1Q66+4R+ZYzCCCUKvpmDbP8FdzVgcdlcdVI5iJ/IYRT1g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659547852; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XeG5DeXDR8n2qm8KVXnMTak0Ka3Vwc9brstON/jdkvk=; b=eHMRBw05wuJZm+R0VG4hbinVxc+TMnKS4VG7PIkyjC29ccgmH8Nv6FwX/qIRX18cYlz9yf/kIeXcXtEkvXi6t4Ob+pdbwaq04f4kgsgmPO1OVaizMiAk87d9hC73tDqp52vVhdAS7S1o/UYBewMi/4uSvbMVUFroSsFY7KGd2vg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165954785270023.52611181670261; Wed, 3 Aug 2022 10:30:52 -0700 (PDT) Received: from localhost ([::1]:48126 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJICp-0004d3-KI for importer@patchew.org; Wed, 03 Aug 2022 13:30:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJIAC-0002T5-6w for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:28:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:39246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJIA9-0007IC-8y for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:28:06 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-79-4Xl8AagqNeirfUD4tvkLPQ-1; Wed, 03 Aug 2022 13:19:04 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D1BA3804507; Wed, 3 Aug 2022 17:18:32 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC62B1121314; Wed, 3 Aug 2022 17:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XeG5DeXDR8n2qm8KVXnMTak0Ka3Vwc9brstON/jdkvk=; b=MlyoRweMnCjJ/J7EQkGRsAam467NWQujESsmr5aZ/5oFzVKYOEozHdmq4GOajugjWW4ddA f6IUe2FQ23JrOmigWaKCo2wc9J/k1xLKg5pGxmOCeH/8QP/MEIr7VvPcTvrXahwj64QVkX FONEUt9DUqhKtHoRr2T4ijTX6pbZZJI= X-MC-Unique: 4Xl8AagqNeirfUD4tvkLPQ-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 2/7] vdpa: Use v->shadow_vqs_enabled in vhost_vdpa_svqs_start & stop Date: Wed, 3 Aug 2022 19:18:16 +0200 Message-Id: <20220803171821.481336-3-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659547853379100001 This function used to trust in v->shadow_vqs !=3D NULL to know if it must start svq or not. This is not going to be valid anymore, as qemu is going to allocate svq unconditionally (but it will only start them conditionally). Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-vdpa.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 8882077955..2b8d807860 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -1025,7 +1025,7 @@ static bool vhost_vdpa_svqs_start(struct vhost_dev *d= ev) Error *err =3D NULL; unsigned i; =20 - if (!v->shadow_vqs) { + if (!v->shadow_vqs_enabled) { return true; } =20 @@ -1078,7 +1078,7 @@ static bool vhost_vdpa_svqs_stop(struct vhost_dev *de= v) { struct vhost_vdpa *v =3D dev->opaque; =20 - if (!v->shadow_vqs) { + if (!v->shadow_vqs_enabled) { return true; } =20 --=20 2.31.1 From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659547734; cv=none; d=zohomail.com; s=zohoarc; b=FAm55nYVootBq7JuxWV3vscs+aM0zMqbJX1cQnVrCbSa25X1wF1dOnGV/KpYB0uP9dD0qOTDzdk5o3Ls9xktJ6sMVaJo9ORYvSUCwcFeZynndUiaVEQpO9qZIrJqxf7fBN4bqChcj/CJknWPPUqTeNCF7BXEWJTO5wSqIpJXMtA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659547734; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=21el2oUj9JF0VNxYEg+sbKoPeC1EJHv6rHdzDcy3Mn8=; b=a4KT0kTVU5cx2CyY/9XzaOltQnyVn4gwLHSUaGT2aS5fwmT2ZZJAZg+KVlUxhDQ56mQxQqNRGoVs1A/7YuPNNlSZiKXLMJ8TuZL1grCewZ35I/4vi0RBDVbXYaiS2NgYxguKqNjpf7uBTnOR8zF1o7qBxKrYGcGC6UKzOm6rsGM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659547734466980.281514839289; Wed, 3 Aug 2022 10:28:54 -0700 (PDT) Received: from localhost ([::1]:44484 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJIAv-0002AP-Cu for importer@patchew.org; Wed, 03 Aug 2022 13:28:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1g-0004ji-SG for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:54632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1Y-00045A-Fz for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:19 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-156-kqAWVpcPNVGk6dQYsB7D4w-1; Wed, 03 Aug 2022 13:18:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 907FB891F55; Wed, 3 Aug 2022 17:18:35 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id E08DC1121314; Wed, 3 Aug 2022 17:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=21el2oUj9JF0VNxYEg+sbKoPeC1EJHv6rHdzDcy3Mn8=; b=WqRKfRHL//m08p1UEARtsNzr0ECotWWW7CwVssNx6RHrMh2NzE3tMJBH3h8u3FOE1Xg/iM nSPViIMUpi/wGI4socxiIHTX6dx5a36kluxNJCFyy0fwE7xMjj1loACbJZ1Ug2Vb+kp/uC u4s+7PCs0r7puYKZ9X538O1xMs/pipM= X-MC-Unique: kqAWVpcPNVGk6dQYsB7D4w-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 3/7] vdpa: Allocate SVQ unconditionally Date: Wed, 3 Aug 2022 19:18:17 +0200 Message-Id: <20220803171821.481336-4-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659547734691100001 SVQ may run or not in a device depending on runtime conditions (for example, if the device can move CVQ to its own group or not). Allocate the resources unconditionally, and decide later if to use them or not. Signed-off-by: Eugenio P=C3=A9rez --- hw/virtio/vhost-vdpa.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 2b8d807860..2fefcc66ad 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -406,6 +406,21 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev,= struct vhost_vdpa *v, int r; bool ok; =20 + shadow_vqs =3D g_ptr_array_new_full(hdev->nvqs, vhost_svq_free); + for (unsigned n =3D 0; n < hdev->nvqs; ++n) { + g_autoptr(VhostShadowVirtqueue) svq; + + svq =3D vhost_svq_new(v->iova_tree, v->shadow_vq_ops, + v->shadow_vq_ops_opaque); + if (unlikely(!svq)) { + error_setg(errp, "Cannot create svq %u", n); + return -1; + } + g_ptr_array_add(shadow_vqs, g_steal_pointer(&svq)); + } + + v->shadow_vqs =3D g_steal_pointer(&shadow_vqs); + if (!v->shadow_vqs_enabled) { return 0; } @@ -422,20 +437,6 @@ static int vhost_vdpa_init_svq(struct vhost_dev *hdev,= struct vhost_vdpa *v, return -1; } =20 - shadow_vqs =3D g_ptr_array_new_full(hdev->nvqs, vhost_svq_free); - for (unsigned n =3D 0; n < hdev->nvqs; ++n) { - g_autoptr(VhostShadowVirtqueue) svq; - - svq =3D vhost_svq_new(v->iova_tree, v->shadow_vq_ops, - v->shadow_vq_ops_opaque); - if (unlikely(!svq)) { - error_setg(errp, "Cannot create svq %u", n); - return -1; - } - g_ptr_array_add(shadow_vqs, g_steal_pointer(&svq)); - } - - v->shadow_vqs =3D g_steal_pointer(&shadow_vqs); return 0; } =20 @@ -576,10 +577,6 @@ static void vhost_vdpa_svq_cleanup(struct vhost_dev *d= ev) struct vhost_vdpa *v =3D dev->opaque; size_t idx; =20 - if (!v->shadow_vqs) { - return; - } - for (idx =3D 0; idx < v->shadow_vqs->len; ++idx) { vhost_svq_stop(g_ptr_array_index(v->shadow_vqs, idx)); } --=20 2.31.1 From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659548223; cv=none; d=zohomail.com; s=zohoarc; b=Bh+4CfGALPWEOB1NcqwzFHsAR9CtTzHuKq0rR89Fy6s/N1RSH4gcxzMIaZWOuD8zW4YnClUGZMpct0oaVOAt13w7I1Yuou5BqHHmrJJincY/N6ddXQNsIafJnCHB5JFD1y5agA9kuvBXMuuJ2+PtaJCgX2YG2FsOO3XCHoO24e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659548223; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KbOko6gMfQIb6cyqomfdDvdqvI6gs4RI2G1Qx446eXs=; b=G2AFC9svEcDmtspNScNjG2uHCIFcNLBE/91KFw4SSre4lyOFq4OcJTFSFx+VLxHrphVDGKXFCXfI0Naq8abbVXHAqSvLeD67HkXvGH/X/NxoppYMdJHL8/NX55N/sGyMatgEcPwksmwh6t0+/1USGxpOJGAL/IhaTLXGpT9wyjU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659548223547963.5847151888427; Wed, 3 Aug 2022 10:37:03 -0700 (PDT) Received: from localhost ([::1]:57232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJIIo-0002m8-HR for importer@patchew.org; Wed, 03 Aug 2022 13:37:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI3r-0007d8-Nr for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:21:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI3p-0005Qk-5z for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:21:35 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-449-A4aoL7ErO6OG_WBtX16NsA-1; Wed, 03 Aug 2022 13:18:55 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 843263C10150; Wed, 3 Aug 2022 17:18:38 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id D22091121314; Wed, 3 Aug 2022 17:18:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KbOko6gMfQIb6cyqomfdDvdqvI6gs4RI2G1Qx446eXs=; b=C+ZHEC7+Yytk9I7UlD7P4KGNpaHnl0L4Y36T02y9g50b9DthJjaI6N7VPppUSH8jzw+qak 9lueJ+39wKhkUZMSmU9ONsRXnPXArZglB345dTSCkKW2cTWpvNI96gdnWHWYIiDyVg/hSY Pr02qwwnSQEcP5gzSjjA2LetgZ3cxRQ= X-MC-Unique: A4aoL7ErO6OG_WBtX16NsA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 4/7] vdpa: Add asid parameter to vhost_vdpa_dma_map/unmap Date: Wed, 3 Aug 2022 19:18:18 +0200 Message-Id: <20220803171821.481336-5-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659548225473100001 So the caller can choose which ASID is destined. No need to update the batch functions as they will always be called from memory listener updates at the moment. Memory listener updates will always update ASID 0, as it's the passthrough ASID. All vhost devices's ASID are 0 at this moment. Signed-off-by: Eugenio P=C3=A9rez --- v3: Deleted unneeded space --- include/hw/virtio/vhost-vdpa.h | 8 +++++--- hw/virtio/vhost-vdpa.c | 25 +++++++++++++++---------- net/vhost-vdpa.c | 6 +++--- hw/virtio/trace-events | 4 ++-- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/include/hw/virtio/vhost-vdpa.h b/include/hw/virtio/vhost-vdpa.h index 1111d85643..6560bb9d78 100644 --- a/include/hw/virtio/vhost-vdpa.h +++ b/include/hw/virtio/vhost-vdpa.h @@ -29,6 +29,7 @@ typedef struct vhost_vdpa { int index; uint32_t msg_type; bool iotlb_batch_begin_sent; + uint32_t address_space_id; MemoryListener listener; struct vhost_vdpa_iova_range iova_range; uint64_t acked_features; @@ -42,8 +43,9 @@ typedef struct vhost_vdpa { VhostVDPAHostNotifier notifier[VIRTIO_QUEUE_MAX]; } VhostVDPA; =20 -int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size, - void *vaddr, bool readonly); -int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size); +int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, + hwaddr size, void *vaddr, bool readonly); +int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, + hwaddr size); =20 #endif diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 2fefcc66ad..131100841c 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -72,22 +72,24 @@ static bool vhost_vdpa_listener_skipped_section(MemoryR= egionSection *section, return false; } =20 -int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr iova, hwaddr size, - void *vaddr, bool readonly) +int vhost_vdpa_dma_map(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, + hwaddr size, void *vaddr, bool readonly) { struct vhost_msg_v2 msg =3D {}; int fd =3D v->device_fd; int ret =3D 0; =20 msg.type =3D v->msg_type; + msg.asid =3D asid; msg.iotlb.iova =3D iova; msg.iotlb.size =3D size; msg.iotlb.uaddr =3D (uint64_t)(uintptr_t)vaddr; msg.iotlb.perm =3D readonly ? VHOST_ACCESS_RO : VHOST_ACCESS_RW; msg.iotlb.type =3D VHOST_IOTLB_UPDATE; =20 - trace_vhost_vdpa_dma_map(v, fd, msg.type, msg.iotlb.iova, msg.iotlb.siz= e, - msg.iotlb.uaddr, msg.iotlb.perm, msg.iotlb.typ= e); + trace_vhost_vdpa_dma_map(v, fd, msg.type, msg.asid, msg.iotlb.iova, + msg.iotlb.size, msg.iotlb.uaddr, msg.iotlb.pe= rm, + msg.iotlb.type); =20 if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { error_report("failed to write, fd=3D%d, errno=3D%d (%s)", @@ -98,18 +100,20 @@ int vhost_vdpa_dma_map(struct vhost_vdpa *v, hwaddr io= va, hwaddr size, return ret; } =20 -int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, hwaddr iova, hwaddr size) +int vhost_vdpa_dma_unmap(struct vhost_vdpa *v, uint32_t asid, hwaddr iova, + hwaddr size) { struct vhost_msg_v2 msg =3D {}; int fd =3D v->device_fd; int ret =3D 0; =20 msg.type =3D v->msg_type; + msg.asid =3D asid; msg.iotlb.iova =3D iova; msg.iotlb.size =3D size; msg.iotlb.type =3D VHOST_IOTLB_INVALIDATE; =20 - trace_vhost_vdpa_dma_unmap(v, fd, msg.type, msg.iotlb.iova, + trace_vhost_vdpa_dma_unmap(v, fd, msg.type, msg.asid, msg.iotlb.iova, msg.iotlb.size, msg.iotlb.type); =20 if (write(fd, &msg, sizeof(msg)) !=3D sizeof(msg)) { @@ -229,7 +233,7 @@ static void vhost_vdpa_listener_region_add(MemoryListen= er *listener, } =20 vhost_vdpa_iotlb_batch_begin_once(v); - ret =3D vhost_vdpa_dma_map(v, iova, int128_get64(llsize), + ret =3D vhost_vdpa_dma_map(v, 0, iova, int128_get64(llsize), vaddr, section->readonly); if (ret) { error_report("vhost vdpa map fail!"); @@ -299,7 +303,7 @@ static void vhost_vdpa_listener_region_del(MemoryListen= er *listener, vhost_iova_tree_remove(v->iova_tree, result); } vhost_vdpa_iotlb_batch_begin_once(v); - ret =3D vhost_vdpa_dma_unmap(v, iova, int128_get64(llsize)); + ret =3D vhost_vdpa_dma_unmap(v, 0, iova, int128_get64(llsize)); if (ret) { error_report("vhost_vdpa dma unmap error!"); } @@ -890,7 +894,7 @@ static bool vhost_vdpa_svq_unmap_ring(struct vhost_vdpa= *v, } =20 size =3D ROUND_UP(result->size, qemu_real_host_page_size()); - r =3D vhost_vdpa_dma_unmap(v, result->iova, size); + r =3D vhost_vdpa_dma_unmap(v, v->address_space_id, result->iova, size); return r =3D=3D 0; } =20 @@ -932,7 +936,8 @@ static bool vhost_vdpa_svq_map_ring(struct vhost_vdpa *= v, DMAMap *needle, return false; } =20 - r =3D vhost_vdpa_dma_map(v, needle->iova, needle->size + 1, + r =3D vhost_vdpa_dma_map(v, v->address_space_id, needle->iova, + needle->size + 1, (void *)(uintptr_t)needle->translated_addr, needle->perm =3D=3D IOMMU_RO); if (unlikely(r !=3D 0)) { diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index f933ba53a3..f96c3cb1da 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -239,7 +239,7 @@ static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa = *v, void *addr) return; } =20 - r =3D vhost_vdpa_dma_unmap(v, map->iova, map->size + 1); + r =3D vhost_vdpa_dma_unmap(v, v->address_space_id, map->iova, map->siz= e + 1); if (unlikely(r !=3D 0)) { error_report("Device cannot unmap: %s(%d)", g_strerror(r), r); } @@ -288,8 +288,8 @@ static bool vhost_vdpa_cvq_map_buf(struct vhost_vdpa *v, return false; } =20 - r =3D vhost_vdpa_dma_map(v, map.iova, vhost_vdpa_net_cvq_cmd_page_len(= ), buf, - !write); + r =3D vhost_vdpa_dma_map(v, v->address_space_id, map.iova, + vhost_vdpa_net_cvq_cmd_page_len(), buf, !write); if (unlikely(r < 0)) { goto dma_map_err; } diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 20af2e7ebd..36e5ae75f6 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -26,8 +26,8 @@ vhost_user_write(uint32_t req, uint32_t flags) "req:%d fl= ags:0x%"PRIx32"" vhost_user_create_notifier(int idx, void *n) "idx:%d n:%p" =20 # vhost-vdpa.c -vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint64_t iova, u= int64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "vdpa:%p fd: %d m= sg_type: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" uaddr: 0x%"PRIx64" p= erm: 0x%"PRIx8" type: %"PRIu8 -vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint64_t iova,= uint64_t size, uint8_t type) "vdpa:%p fd: %d msg_type: %"PRIu32" iova: 0x%= "PRIx64" size: 0x%"PRIx64" type: %"PRIu8 +vhost_vdpa_dma_map(void *vdpa, int fd, uint32_t msg_type, uint32_t asid, u= int64_t iova, uint64_t size, uint64_t uaddr, uint8_t perm, uint8_t type) "v= dpa:%p fd: %d msg_type: %"PRIu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0= x%"PRIx64" uaddr: 0x%"PRIx64" perm: 0x%"PRIx8" type: %"PRIu8 +vhost_vdpa_dma_unmap(void *vdpa, int fd, uint32_t msg_type, uint32_t asid,= uint64_t iova, uint64_t size, uint8_t type) "vdpa:%p fd: %d msg_type: %"PR= Iu32" asid: %"PRIu32" iova: 0x%"PRIx64" size: 0x%"PRIx64" type: %"PRIu8 vhost_vdpa_listener_begin_batch(void *v, int fd, uint32_t msg_type, uint8_= t type) "vdpa:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 vhost_vdpa_listener_commit(void *v, int fd, uint32_t msg_type, uint8_t typ= e) "vdpa:%p fd: %d msg_type: %"PRIu32" type: %"PRIu8 vhost_vdpa_listener_region_add(void *vdpa, uint64_t iova, uint64_t llend, = void *vaddr, bool readonly) "vdpa: %p iova 0x%"PRIx64" llend 0x%"PRIx64" va= ddr: %p read-only: %d" --=20 2.31.1 From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659547591; cv=none; d=zohomail.com; s=zohoarc; b=G8hJCNzNAuMbq4MVv8yvSmYLAUzbozubvPYDE03fT2YdPgw94o6MKBvRkgUDsLOJHnd9H0tysbVLuVOOWhQikos6R7qbYMd9mlr3oDBpklMZy13N95sfxKPXgogtjx09j4VTo+TBcXRbNKI42tD9Fvht/oxNacQPCw+4EdwLEdc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659547591; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gkrFAJTZsaDe0mfYkYOAto1t21JBj/2fWn1m0fbCcqE=; b=jDRjFOG/bV+z0W8+7FftpihA10EwqwO6WT2sP3x1YWypDsd72CiiCJFDXZOxpqApGPhD7X9PnRy/k6h4492InFLIqwb11sjz8ZVPoOfod318INbrg1Yggv2JngADzHEy83LFzJ9du9ZG6fpGN0RYkGObUnIGaQMFYPYwPEqu4o0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659547591062602.5053761462298; Wed, 3 Aug 2022 10:26:31 -0700 (PDT) Received: from localhost ([::1]:38900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJI8b-0006ia-UT for importer@patchew.org; Wed, 03 Aug 2022 13:26:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI3r-0007d7-3A for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:21:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:49494) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI3p-0005Qp-6D for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:21:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-16-aU_LvNn-M8iGcGdgTzdAhA-1; Wed, 03 Aug 2022 13:19:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77A4118E527A; Wed, 3 Aug 2022 17:18:41 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5B011121314; Wed, 3 Aug 2022 17:18:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gkrFAJTZsaDe0mfYkYOAto1t21JBj/2fWn1m0fbCcqE=; b=B88GeoGxqIC/vCzWMb8gulWgMFlUU33EGlTuoVZtxfZELO7SDhszsTjbhM4su1/TVmBx75 Y+CAzvJxFjxaEfSyjpMwwH4l+LppnwjFjLYlwFmbf0bcbVLD/k2/9tA4DXXSrnMg3HPD6Y m6/SwzQy/N3AbKvLyinhUnwcR3I2XmE= X-MC-Unique: aU_LvNn-M8iGcGdgTzdAhA-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 5/7] vdpa: Store x-svq parameter in VhostVDPAState Date: Wed, 3 Aug 2022 19:18:19 +0200 Message-Id: <20220803171821.481336-6-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659547591839100001 CVQ can be shadowed two ways: - Device has x-svq=3Don parameter (current way) - The device can isolate CVQ in its own vq group QEMU needs to check for the second condition dynamically, because CVQ index is not known at initialization time. Since this is dynamic, the CVQ isolation could vary with different conditions, making it possible to go from "not isolated group" to "isolated". Saving the cmdline parameter in an extra field so we never disable CVQ SVQ in case the device was started with cmdline. Signed-off-by: Eugenio P=C3=A9rez --- net/vhost-vdpa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index f96c3cb1da..e3b65ed546 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -36,6 +36,9 @@ typedef struct VhostVDPAState { =20 /* Control commands shadow buffers */ void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer; + + /* The device always have SVQ enabled */ + bool always_svq; bool started; } VhostVDPAState; =20 @@ -564,6 +567,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, =20 s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; + s->always_svq =3D svq; s->vhost_vdpa.shadow_vqs_enabled =3D svq; s->vhost_vdpa.iova_tree =3D iova_tree; if (!is_datapath) { --=20 2.31.1 From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659547352; cv=none; d=zohomail.com; s=zohoarc; b=Pjojnl/o7GFlAkqcwOxdib9zhgRZRIC2vKeeHTZrSZUlOshHGn218UTR2sWYuOSna/AH9GQRwH845i4XS/P0n6VgOCNb2d++hA49J49Z2f+JbzUoufRYlz9cHVYlO5g4vrINLWLuunV9irFaBYXDk7lN2XGOOqDW9OYjiSzmIeA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659547352; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=teEvkmaXnJDu+MYlIAEDQQW7Rkz2f8TRd1LEgOhTJIY=; b=Teezv3462DrVERX73OMaelPPjcUqw7vaV1MczWa6wBOBOfao3jMDzYypVU/G0ALWtpe0px0l4JX0ZbZNFqjsXkH9FvNFJCqDtixEA7CpLyzAYc/BbOggAv/BQodmW8Z5PN6nYZ2uUZ7fiB/rDayRfFXFRIVC+R/XtLBdElgVGOE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659547352171726.3972618595159; Wed, 3 Aug 2022 10:22:32 -0700 (PDT) Received: from localhost ([::1]:56614 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJI4l-0007Yr-1s for importer@patchew.org; Wed, 03 Aug 2022 13:22:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1j-0004kt-Px for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1Y-00046H-GH for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-ufOuDDrjNF-e8XedZcot8g-1; Wed, 03 Aug 2022 13:18:59 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8AAFD3C10248; Wed, 3 Aug 2022 17:18:44 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id B91261121314; Wed, 3 Aug 2022 17:18:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547147; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=teEvkmaXnJDu+MYlIAEDQQW7Rkz2f8TRd1LEgOhTJIY=; b=iBeE5/87KuICb3EovclmSSi5T4pGZ/8yMPb1eizIYfaIKG6CD1e588ffHQpRxQEFNnnPm1 AxA78/AnLp8xjio5s+689XWmq9gTIM0KIC5LJdktet6lAdNSorJONWiaYX7d5OYbqP3iQs Vgtn3fQFELnQNuMDRKqIL7CJMqvZVog= X-MC-Unique: ufOuDDrjNF-e8XedZcot8g-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 6/7] vhost_net: Add NetClientInfo prepare callback Date: Wed, 3 Aug 2022 19:18:20 +0200 Message-Id: <20220803171821.481336-7-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659547354206100001 This is used by the backend to perform actions before the device is started. In particular, vdpa will use it to isolate CVQ in its own ASID if possible, and start SVQ unconditionally only in CVQ. Signed-off-by: Eugenio P=C3=A9rez --- include/net/net.h | 2 ++ hw/net/vhost_net.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index a8d47309cd..efa6448886 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -44,6 +44,7 @@ typedef struct NICConf { =20 typedef void (NetPoll)(NetClientState *, bool enable); typedef bool (NetCanReceive)(NetClientState *); +typedef void (NetPrepare)(NetClientState *); typedef int (NetLoad)(NetClientState *); typedef ssize_t (NetReceive)(NetClientState *, const uint8_t *, size_t); typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, in= t); @@ -72,6 +73,7 @@ typedef struct NetClientInfo { NetReceive *receive_raw; NetReceiveIOV *receive_iov; NetCanReceive *can_receive; + NetPrepare *prepare; NetLoad *load; NetCleanup *cleanup; LinkStatusChanged *link_status_changed; diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index a9bf72dcda..bbbb6d759b 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -244,6 +244,10 @@ static int vhost_net_start_one(struct vhost_net *net, struct vhost_vring_file file =3D { }; int r; =20 + if (net->nc->info->prepare) { + net->nc->info->prepare(net->nc); + } + r =3D vhost_dev_enable_notifiers(&net->dev, dev); if (r < 0) { goto fail_notifiers; --=20 2.31.1 From nobody Wed Apr 24 21:35:23 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1659547390; cv=none; d=zohomail.com; s=zohoarc; b=eLfldxZS6SAcUJJ7JfJMMzM/nhkg5V3TePVpmGDtA09pWzfuszoevzkS0io6K+eOsjnmKpViA9WTd+zJgkZ5m4uLHY+v9ugv5WWpqzAdRhuhOh0az+Z3MIIzAWy4rNZcAoRL+6Z5F69Ai8KD+mkrlbGooDp6eEzmwikr8CSF/qE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659547390; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FS8WOWx2Mlz/EPB9nn2iUK0MkKtiWEii0lW9lgeSWZc=; b=mFGSGxqRJkQEmdCQ7vFMc2PP6XODJ63M+d0QRo8rEoOx8BKF6Pr1By7GO01pk1ZxdEan3+8Vf6Z3AEEVRTCFoo6kW5i8G5MvMIvhCPkdTE4D8HjaPthyH2+h9rAANn6vcMzuO0nMB2CwHCbl97V9A8vlAobE6ReQ8ik7n8DXnTg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1659547390778183.69651974507804; Wed, 3 Aug 2022 10:23:10 -0700 (PDT) Received: from localhost ([::1]:58962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJI5N-000139-NK for importer@patchew.org; Wed, 03 Aug 2022 13:23:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1k-0004lL-AK for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:55491) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJI1i-00047J-Bn for qemu-devel@nongnu.org; Wed, 03 Aug 2022 13:19:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-184-_Mgt6Ij6ORGrFasUXz0O6w-1; Wed, 03 Aug 2022 13:19:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B5EA1C04B64; Wed, 3 Aug 2022 17:18:47 +0000 (UTC) Received: from eperezma.remote.csb (unknown [10.39.192.202]) by smtp.corp.redhat.com (Postfix) with ESMTP id D103C1121314; Wed, 3 Aug 2022 17:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659547157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FS8WOWx2Mlz/EPB9nn2iUK0MkKtiWEii0lW9lgeSWZc=; b=hgQPa9NYTj/rVcaXi1ZOn59aJmR/+Ccp4tEJ1OW2PHvQ3+tQ5ckfHiCX/DN4tNBlEBBoXq KPDt3iuYb9HH4tnQiqkYaGm2rWg8vAD/fR2J4Wqr5CqD7FvR3Jlc+VSWVKB1ZX85WIp6nL 4yoOoZLJHhNcZTFXVegQ7sMZxqd8GNY= X-MC-Unique: _Mgt6Ij6ORGrFasUXz0O6w-1 From: =?UTF-8?q?Eugenio=20P=C3=A9rez?= To: qemu-devel@nongnu.org Cc: Jason Wang , Stefan Hajnoczi , Gautam Dawar , Cornelia Huck , Eli Cohen , Stefano Garzarella , Harpreet Singh Anand , Zhu Lingshan , Laurent Vivier , "Michael S. Tsirkin" , kvm@vger.kernel.org, Paolo Bonzini , Liuxiangdong , Parav Pandit , Cindy Lu , "Gonglei (Arei)" Subject: [PATCH v3 7/7] vdpa: Always start CVQ in SVQ mode Date: Wed, 3 Aug 2022 19:18:21 +0200 Message-Id: <20220803171821.481336-8-eperezma@redhat.com> In-Reply-To: <20220803171821.481336-1-eperezma@redhat.com> References: <20220803171821.481336-1-eperezma@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eperezma@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1659547392393100001 Isolate control virtqueue in its own group, allowing to intercept control commands but letting dataplane run totally passthrough to the guest. Signed-off-by: Eugenio P=C3=A9rez --- v3: * Make asid related queries print a warning instead of returning an error and stop the start of qemu. --- hw/virtio/vhost-vdpa.c | 3 +- net/vhost-vdpa.c | 144 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 142 insertions(+), 5 deletions(-) diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c index 131100841c..a4cb68862b 100644 --- a/hw/virtio/vhost-vdpa.c +++ b/hw/virtio/vhost-vdpa.c @@ -674,7 +674,8 @@ static int vhost_vdpa_set_backend_cap(struct vhost_dev = *dev) { uint64_t features; uint64_t f =3D 0x1ULL << VHOST_BACKEND_F_IOTLB_MSG_V2 | - 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH; + 0x1ULL << VHOST_BACKEND_F_IOTLB_BATCH | + 0x1ULL << VHOST_BACKEND_F_IOTLB_ASID; int r; =20 if (vhost_vdpa_call(dev, VHOST_GET_BACKEND_FEATURES, &features)) { diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index e3b65ed546..5f39f0edb5 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -37,6 +37,9 @@ typedef struct VhostVDPAState { /* Control commands shadow buffers */ void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer; =20 + /* Number of address spaces supported by the device */ + unsigned address_space_num; + /* The device always have SVQ enabled */ bool always_svq; bool started; @@ -100,6 +103,8 @@ static const uint64_t vdpa_svq_device_features =3D BIT_ULL(VIRTIO_NET_F_RSC_EXT) | BIT_ULL(VIRTIO_NET_F_STANDBY); =20 +#define VHOST_VDPA_NET_CVQ_ASID 1 + VHostNetState *vhost_vdpa_get_vhost_net(NetClientState *nc) { VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); @@ -224,6 +229,101 @@ static NetClientInfo net_vhost_vdpa_info =3D { .check_peer_type =3D vhost_vdpa_check_peer_type, }; =20 +static void vhost_vdpa_get_vring_group(int device_fd, + struct vhost_vring_state *state) +{ + int r =3D ioctl(device_fd, VHOST_VDPA_GET_VRING_GROUP, state); + if (unlikely(r < 0)) { + /* + * Assume all groups are 0, the consequences are the same and we w= ill + * not abort device creation + */ + state->num =3D 0; + } +} + +/** + * Check if all the virtqueues of the virtio device are in a different vq = than + * the last vq. VQ group of last group passed in cvq_group. + */ +static bool vhost_vdpa_cvq_group_is_independent(struct vhost_vdpa *v, + struct vhost_vring_state cvq_g= roup) +{ + struct vhost_dev *dev =3D v->dev; + + for (int i =3D 0; i < (dev->vq_index_end - 1); ++i) { + struct vhost_vring_state vq_group =3D { + .index =3D i, + }; + + vhost_vdpa_get_vring_group(v->device_fd, &vq_group); + if (unlikely(vq_group.num =3D=3D cvq_group.num)) { + warn_report("CVQ %u group is the same as VQ %u one (%u)", + cvq_group.index, vq_group.index, cvq_group.num); + return false; + } + } + + return true; +} + +static int vhost_vdpa_set_address_space_id(struct vhost_vdpa *v, + unsigned vq_group, + unsigned asid_num) +{ + struct vhost_vring_state asid =3D { + .index =3D vq_group, + .num =3D asid_num, + }; + int ret; + + ret =3D ioctl(v->device_fd, VHOST_VDPA_SET_GROUP_ASID, &asid); + if (unlikely(ret < 0)) { + warn_report("Can't set vq group %u asid %u, errno=3D%d (%s)", + asid.index, asid.num, errno, g_strerror(errno)); + } + return ret; +} + +static void vhost_vdpa_net_prepare(NetClientState *nc) +{ + VhostVDPAState *s =3D DO_UPCAST(VhostVDPAState, nc, nc); + struct vhost_vdpa *v =3D &s->vhost_vdpa; + struct vhost_dev *dev =3D v->dev; + struct vhost_vring_state cvq_group =3D { + .index =3D v->dev->vq_index_end - 1, + }; + int r; + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); + + if (dev->nvqs !=3D 1 || dev->vq_index + dev->nvqs !=3D dev->vq_index_e= nd) { + /* Only interested in CVQ */ + return; + } + + if (s->always_svq) { + /* SVQ is already enabled */ + return; + } + + if (s->address_space_num < 2) { + v->shadow_vqs_enabled =3D false; + return; + } + + vhost_vdpa_get_vring_group(v->device_fd, &cvq_group); + if (!vhost_vdpa_cvq_group_is_independent(v, cvq_group)) { + v->shadow_vqs_enabled =3D false; + return; + } + + r =3D vhost_vdpa_set_address_space_id(v, cvq_group.num, + VHOST_VDPA_NET_CVQ_ASID); + v->shadow_vqs_enabled =3D r =3D=3D 0; + s->vhost_vdpa.address_space_id =3D r =3D=3D 0 ? 1 : 0; +} + static void vhost_vdpa_cvq_unmap_buf(struct vhost_vdpa *v, void *addr) { VhostIOVATree *tree =3D v->iova_tree; @@ -431,6 +531,7 @@ static NetClientInfo net_vhost_vdpa_cvq_info =3D { .type =3D NET_CLIENT_DRIVER_VHOST_VDPA, .size =3D sizeof(VhostVDPAState), .receive =3D vhost_vdpa_receive, + .prepare =3D vhost_vdpa_net_prepare, .load =3D vhost_vdpa_net_load, .cleanup =3D vhost_vdpa_cleanup, .has_vnet_hdr =3D vhost_vdpa_has_vnet_hdr, @@ -541,12 +642,38 @@ static const VhostShadowVirtqueueOps vhost_vdpa_net_s= vq_ops =3D { .avail_handler =3D vhost_vdpa_net_handle_ctrl_avail, }; =20 +static uint32_t vhost_vdpa_get_as_num(int vdpa_device_fd) +{ + uint64_t features; + unsigned num_as; + int r; + + r =3D ioctl(vdpa_device_fd, VHOST_GET_BACKEND_FEATURES, &features); + if (unlikely(r < 0)) { + warn_report("Cannot get backend features"); + return 1; + } + + if (!(features & BIT_ULL(VHOST_BACKEND_F_IOTLB_ASID))) { + return 1; + } + + r =3D ioctl(vdpa_device_fd, VHOST_VDPA_GET_AS_NUM, &num_as); + if (unlikely(r < 0)) { + warn_report("Cannot retrieve number of supported ASs"); + return 1; + } + + return num_as; +} + static NetClientState *net_vhost_vdpa_init(NetClientState *peer, const char *device, const char *name, int vdpa_device_fd, int queue_pair_index, int nvqs, + unsigned nas, bool is_datapath, bool svq, VhostIOVATree *iova_tree) @@ -565,6 +692,7 @@ static NetClientState *net_vhost_vdpa_init(NetClientSta= te *peer, snprintf(nc->info_str, sizeof(nc->info_str), TYPE_VHOST_VDPA); s =3D DO_UPCAST(VhostVDPAState, nc, nc); =20 + s->address_space_num =3D nas; s->vhost_vdpa.device_fd =3D vdpa_device_fd; s->vhost_vdpa.index =3D queue_pair_index; s->always_svq =3D svq; @@ -650,6 +778,8 @@ int net_init_vhost_vdpa(const Netdev *netdev, const cha= r *name, g_autoptr(VhostIOVATree) iova_tree =3D NULL; NetClientState *nc; int queue_pairs, r, i =3D 0, has_cvq =3D 0; + unsigned num_as =3D 1; + bool svq_cvq; =20 assert(netdev->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); opts =3D &netdev->u.vhost_vdpa; @@ -674,7 +804,13 @@ int net_init_vhost_vdpa(const Netdev *netdev, const ch= ar *name, goto err; } =20 - if (opts->x_svq) { + svq_cvq =3D opts->x_svq; + if (has_cvq && !opts->x_svq) { + num_as =3D vhost_vdpa_get_as_num(vdpa_device_fd); + svq_cvq =3D num_as > 1; + } + + if (opts->x_svq || svq_cvq) { struct vhost_vdpa_iova_range iova_range; =20 uint64_t invalid_dev_features =3D @@ -697,15 +833,15 @@ int net_init_vhost_vdpa(const Netdev *netdev, const c= har *name, =20 for (i =3D 0; i < queue_pairs; i++) { ncs[i] =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, - vdpa_device_fd, i, 2, true, opts->x_s= vq, - iova_tree); + vdpa_device_fd, i, 2, num_as, true, + opts->x_svq, iova_tree); if (!ncs[i]) goto err; } =20 if (has_cvq) { nc =3D net_vhost_vdpa_init(peer, TYPE_VHOST_VDPA, name, - vdpa_device_fd, i, 1, false, + vdpa_device_fd, i, 1, num_as, false, opts->x_svq, iova_tree); if (!nc) goto err; --=20 2.31.1