From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827370; cv=none; d=zohomail.com; s=zohoarc; b=T6fH0dlPiJ/I503CULxD3rWjCnTIklxtL7zOE40IGTU8FDZPEt5+pTDTLcVAMswDR+srwbaySqa8cYlw23Vge94Z++00EnwKyNp9xAIJmB5MyB+TU7IGF6OJukhF/WFAxHZErJ9q/7l9a8EfBoC+KJg/3W8VlS6VWvZFLjqSnTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827370; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9KYDcMn4w6cWFuz5VGJ233wy6uIZk1M/SdcSIJB+lCc=; b=NVkmyaeeHINYBFTruVKQBL7H3rDPSzT6cJLUMUFx+l7Kk3pCu/sf3qkJt+5MNpJ28v5J1+MyP/4vfQFB7VCD4swc/cMd/2wWoIXjkkyJ1m0q0YMKp8gLuJoWpqYc9/snSVdn/pkRwapbAmCDdZRDF9L/PxCkzmGCoFgHe1hCw3w= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827370837531.6002282840049; Wed, 21 May 2025 04:36:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhjJ-0003Yg-6T; Wed, 21 May 2025 07:35:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjG-0003YQ-TC for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjB-0000uq-Ko for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:22 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-215-2nakLIUVPnCPjnYcmjTdTw-1; Wed, 21 May 2025 07:35:03 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DF9C61955DB3; Wed, 21 May 2025 11:35:01 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 623E919560B7; Wed, 21 May 2025 11:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827308; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9KYDcMn4w6cWFuz5VGJ233wy6uIZk1M/SdcSIJB+lCc=; b=IyntL/t5+JB+UesW7MEzai0mgRGQx+qeCrFtJ1Y5VQdJMEEHuSGHDuXjF9UrMIA/coAwlC h+Cwuz0audLdGW+f6rRddRH00t8EU44YUxsfLbtYdo5sCXKyN8rKzNLBMNwKumT2ZxiCMq GvnJ04ijvUQFITYQiDn5News4hKUZ64= X-MC-Unique: 2nakLIUVPnCPjnYcmjTdTw-1 X-Mimecast-MFC-AGG-ID: 2nakLIUVPnCPjnYcmjTdTw_1747827302 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 01/16] linux-headers: Update to Linux v6.15-rc net-next Date: Wed, 21 May 2025 13:33:55 +0200 Message-ID: <84aabcb1d09fdfb24470b018d3f00d7e692008a5.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827373251116600 Content-Type: text/plain; charset="utf-8" Update headers to include the virtio GSO over UDP tunnel features Signed-off-by: Paolo Abeni --- The relevant bits are not yet merged upstream, will update this patch after merge. --- include/standard-headers/asm-x86/setup_data.h | 4 +- include/standard-headers/drm/drm_fourcc.h | 41 +++++ include/standard-headers/linux/const.h | 2 +- include/standard-headers/linux/ethtool.h | 156 ++++++++++-------- include/standard-headers/linux/fuse.h | 12 +- include/standard-headers/linux/pci_regs.h | 13 +- include/standard-headers/linux/virtio_net.h | 46 ++++++ include/standard-headers/linux/virtio_pci.h | 1 + include/standard-headers/linux/virtio_snd.h | 2 +- linux-headers/asm-arm64/kvm.h | 11 ++ linux-headers/asm-arm64/unistd_64.h | 1 + linux-headers/asm-generic/mman-common.h | 1 + linux-headers/asm-generic/unistd.h | 4 +- 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 | 2 + linux-headers/asm-riscv/unistd_32.h | 1 + linux-headers/asm-riscv/unistd_64.h | 1 + linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/kvm.h | 3 + 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/bits.h | 8 +- linux-headers/linux/const.h | 2 +- linux-headers/linux/iommufd.h | 129 ++++++++++++++- linux-headers/linux/kvm.h | 1 + linux-headers/linux/psp-sev.h | 21 ++- linux-headers/linux/stddef.h | 2 + linux-headers/linux/vfio.h | 30 ++-- linux-headers/linux/vhost.h | 12 +- 36 files changed, 414 insertions(+), 103 deletions(-) diff --git a/include/standard-headers/asm-x86/setup_data.h b/include/standa= rd-headers/asm-x86/setup_data.h index 09355f54c5..a483d72f42 100644 --- a/include/standard-headers/asm-x86/setup_data.h +++ b/include/standard-headers/asm-x86/setup_data.h @@ -18,7 +18,7 @@ #define SETUP_INDIRECT (1<<31) #define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT) =20 -#ifndef __ASSEMBLY__ +#ifndef __ASSEMBLER__ =20 #include "standard-headers/linux/types.h" =20 @@ -78,6 +78,6 @@ struct ima_setup_data { uint64_t size; } QEMU_PACKED; =20 -#endif /* __ASSEMBLY__ */ +#endif /* __ASSEMBLER__ */ =20 #endif /* _ASM_X86_SETUP_DATA_H */ diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index 708647776f..a8b759dcbc 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -420,6 +420,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 #define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a +#define DRM_FORMAT_MOD_VENDOR_MTK 0x0b =20 /* add more to the end as needed */ =20 @@ -1452,6 +1453,46 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t m= odifier) */ #define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) =20 +/* MediaTek modifiers + * Bits Parameter Notes + * ----- ------------------------ ----------------------------------------= ----- + * 7: 0 TILE LAYOUT Values are MTK_FMT_MOD_TILE_* + * 15: 8 COMPRESSION Values are MTK_FMT_MOD_COMPRESS_* + * 23:16 10 BIT LAYOUT Values are MTK_FMT_MOD_10BIT_LAYOUT_* + * + */ + +#define DRM_FORMAT_MOD_MTK(__flags) fourcc_mod_code(MTK, __flags) + +/* + * MediaTek Tiled Modifier + * The lowest 8 bits of the modifier is used to specify the tiling + * layout. Only the 16L_32S tiling is used for now, but we define an + * "untiled" version and leave room for future expansion. + */ +#define MTK_FMT_MOD_TILE_MASK 0xf +#define MTK_FMT_MOD_TILE_NONE 0x0 +#define MTK_FMT_MOD_TILE_16L32S 0x1 + +/* + * Bits 8-15 specify compression options + */ +#define MTK_FMT_MOD_COMPRESS_MASK (0xf << 8) +#define MTK_FMT_MOD_COMPRESS_NONE (0x0 << 8) +#define MTK_FMT_MOD_COMPRESS_V1 (0x1 << 8) + +/* + * Bits 16-23 specify how the bits of 10 bit formats are + * stored out in memory + */ +#define MTK_FMT_MOD_10BIT_LAYOUT_MASK (0xf << 16) +#define MTK_FMT_MOD_10BIT_LAYOUT_PACKED (0x0 << 16) +#define MTK_FMT_MOD_10BIT_LAYOUT_LSBTILED (0x1 << 16) +#define MTK_FMT_MOD_10BIT_LAYOUT_LSBRASTER (0x2 << 16) + +/* alias for the most common tiling format */ +#define DRM_FORMAT_MOD_MTK_16L_32S_TILE DRM_FORMAT_MOD_MTK(MTK_FMT_MOD_TI= LE_16L32S) + /* * AMD modifiers * diff --git a/include/standard-headers/linux/const.h b/include/standard-head= ers/linux/const.h index 2122610de7..95ede23342 100644 --- a/include/standard-headers/linux/const.h +++ b/include/standard-headers/linux/const.h @@ -33,7 +33,7 @@ * Missing __asm__ support * * __BIT128() would not work in the __asm__ code, as it shifts an - * 'unsigned __init128' data type as direct representation of + * 'unsigned __int128' data type as direct representation of * 128 bit constants is not supported in the gcc compiler, as * they get silently truncated. * diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index e83382531c..cef0d207a6 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -2059,6 +2059,24 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_10baseT1S_Half_BIT =3D 100, ETHTOOL_LINK_MODE_10baseT1S_P2MP_Half_BIT =3D 101, ETHTOOL_LINK_MODE_10baseT1BRR_Full_BIT =3D 102, + ETHTOOL_LINK_MODE_200000baseCR_Full_BIT =3D 103, + ETHTOOL_LINK_MODE_200000baseKR_Full_BIT =3D 104, + ETHTOOL_LINK_MODE_200000baseDR_Full_BIT =3D 105, + ETHTOOL_LINK_MODE_200000baseDR_2_Full_BIT =3D 106, + ETHTOOL_LINK_MODE_200000baseSR_Full_BIT =3D 107, + ETHTOOL_LINK_MODE_200000baseVR_Full_BIT =3D 108, + ETHTOOL_LINK_MODE_400000baseCR2_Full_BIT =3D 109, + ETHTOOL_LINK_MODE_400000baseKR2_Full_BIT =3D 110, + ETHTOOL_LINK_MODE_400000baseDR2_Full_BIT =3D 111, + ETHTOOL_LINK_MODE_400000baseDR2_2_Full_BIT =3D 112, + ETHTOOL_LINK_MODE_400000baseSR2_Full_BIT =3D 113, + ETHTOOL_LINK_MODE_400000baseVR2_Full_BIT =3D 114, + ETHTOOL_LINK_MODE_800000baseCR4_Full_BIT =3D 115, + ETHTOOL_LINK_MODE_800000baseKR4_Full_BIT =3D 116, + ETHTOOL_LINK_MODE_800000baseDR4_Full_BIT =3D 117, + ETHTOOL_LINK_MODE_800000baseDR4_2_Full_BIT =3D 118, + ETHTOOL_LINK_MODE_800000baseSR4_Full_BIT =3D 119, + ETHTOOL_LINK_MODE_800000baseVR4_Full_BIT =3D 120, =20 /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS @@ -2271,73 +2289,81 @@ static inline int ethtool_validate_duplex(uint8_t d= uplex) * be exploited to reduce the RSS queue spread. */ #define RXH_XFRM_SYM_XOR (1 << 0) +/* Similar to SYM_XOR, except that one copy of the XOR'ed fields is replac= ed by + * an OR of the same fields + */ +#define RXH_XFRM_SYM_OR_XOR (1 << 1) #define RXH_XFRM_NO_CHANGE 0xff =20 -/* L2-L4 network traffic flow types */ -#define TCP_V4_FLOW 0x01 /* hash or spec (tcp_ip4_spec) */ -#define UDP_V4_FLOW 0x02 /* hash or spec (udp_ip4_spec) */ -#define SCTP_V4_FLOW 0x03 /* hash or spec (sctp_ip4_spec) */ -#define AH_ESP_V4_FLOW 0x04 /* hash only */ -#define TCP_V6_FLOW 0x05 /* hash or spec (tcp_ip6_spec; nfc only) */ -#define UDP_V6_FLOW 0x06 /* hash or spec (udp_ip6_spec; nfc only) */ -#define SCTP_V6_FLOW 0x07 /* hash or spec (sctp_ip6_spec; nfc only) */ -#define AH_ESP_V6_FLOW 0x08 /* hash only */ -#define AH_V4_FLOW 0x09 /* hash or spec (ah_ip4_spec) */ -#define ESP_V4_FLOW 0x0a /* hash or spec (esp_ip4_spec) */ -#define AH_V6_FLOW 0x0b /* hash or spec (ah_ip6_spec; nfc only) */ -#define ESP_V6_FLOW 0x0c /* hash or spec (esp_ip6_spec; nfc only) */ -#define IPV4_USER_FLOW 0x0d /* spec only (usr_ip4_spec) */ -#define IP_USER_FLOW IPV4_USER_FLOW -#define IPV6_USER_FLOW 0x0e /* spec only (usr_ip6_spec; nfc only) */ -#define IPV4_FLOW 0x10 /* hash only */ -#define IPV6_FLOW 0x11 /* hash only */ -#define ETHER_FLOW 0x12 /* spec only (ether_spec) */ - -/* Used for GTP-U IPv4 and IPv6. - * The format of GTP packets only includes - * elements such as TEID and GTP version. - * It is primarily intended for data communication of the UE. - */ -#define GTPU_V4_FLOW 0x13 /* hash only */ -#define GTPU_V6_FLOW 0x14 /* hash only */ - -/* Use for GTP-C IPv4 and v6. - * The format of these GTP packets does not include TEID. - * Primarily expected to be used for communication - * to create sessions for UE data communication, - * commonly referred to as CSR (Create Session Request). - */ -#define GTPC_V4_FLOW 0x15 /* hash only */ -#define GTPC_V6_FLOW 0x16 /* hash only */ - -/* Use for GTP-C IPv4 and v6. - * Unlike GTPC_V4_FLOW, the format of these GTP packets includes TEID. - * After session creation, it becomes this packet. - * This is mainly used for requests to realize UE handover. - */ -#define GTPC_TEID_V4_FLOW 0x17 /* hash only */ -#define GTPC_TEID_V6_FLOW 0x18 /* hash only */ - -/* Use for GTP-U and extended headers for the PSC (PDU Session Container). - * The format of these GTP packets includes TEID and QFI. - * In 5G communication using UPF (User Plane Function), - * data communication with this extended header is performed. - */ -#define GTPU_EH_V4_FLOW 0x19 /* hash only */ -#define GTPU_EH_V6_FLOW 0x1a /* hash only */ - -/* Use for GTP-U IPv4 and v6 PSC (PDU Session Container) extended headers. - * This differs from GTPU_EH_V(4|6)_FLOW in that it is distinguished by - * UL/DL included in the PSC. - * There are differences in the data included based on Downlink/Uplink, - * and can be used to distinguish packets. - * The functions described so far are useful when you want to - * handle communication from the mobile network in UPF, PGW, etc. - */ -#define GTPU_UL_V4_FLOW 0x1b /* hash only */ -#define GTPU_UL_V6_FLOW 0x1c /* hash only */ -#define GTPU_DL_V4_FLOW 0x1d /* hash only */ -#define GTPU_DL_V6_FLOW 0x1e /* hash only */ +enum { + /* L2-L4 network traffic flow types */ + TCP_V4_FLOW =3D 0x01, /* hash or spec (tcp_ip4_spec) */ + UDP_V4_FLOW =3D 0x02, /* hash or spec (udp_ip4_spec) */ + SCTP_V4_FLOW =3D 0x03, /* hash or spec (sctp_ip4_spec) */ + AH_ESP_V4_FLOW =3D 0x04, /* hash only */ + TCP_V6_FLOW =3D 0x05, /* hash or spec (tcp_ip6_spec; nfc only) */ + UDP_V6_FLOW =3D 0x06, /* hash or spec (udp_ip6_spec; nfc only) */ + SCTP_V6_FLOW =3D 0x07, /* hash or spec (sctp_ip6_spec; nfc only) */ + AH_ESP_V6_FLOW =3D 0x08, /* hash only */ + AH_V4_FLOW =3D 0x09, /* hash or spec (ah_ip4_spec) */ + ESP_V4_FLOW =3D 0x0a, /* hash or spec (esp_ip4_spec) */ + AH_V6_FLOW =3D 0x0b, /* hash or spec (ah_ip6_spec; nfc only) */ + ESP_V6_FLOW =3D 0x0c, /* hash or spec (esp_ip6_spec; nfc only) */ + IPV4_USER_FLOW =3D 0x0d, /* spec only (usr_ip4_spec) */ + IP_USER_FLOW =3D IPV4_USER_FLOW, + IPV6_USER_FLOW =3D 0x0e, /* spec only (usr_ip6_spec; nfc only) */ + IPV4_FLOW =3D 0x10, /* hash only */ + IPV6_FLOW =3D 0x11, /* hash only */ + ETHER_FLOW =3D 0x12, /* spec only (ether_spec) */ + + /* Used for GTP-U IPv4 and IPv6. + * The format of GTP packets only includes + * elements such as TEID and GTP version. + * It is primarily intended for data communication of the UE. + */ + GTPU_V4_FLOW =3D 0x13, /* hash only */ + GTPU_V6_FLOW =3D 0x14, /* hash only */ + + /* Use for GTP-C IPv4 and v6. + * The format of these GTP packets does not include TEID. + * Primarily expected to be used for communication + * to create sessions for UE data communication, + * commonly referred to as CSR (Create Session Request). + */ + GTPC_V4_FLOW =3D 0x15, /* hash only */ + GTPC_V6_FLOW =3D 0x16, /* hash only */ + + /* Use for GTP-C IPv4 and v6. + * Unlike GTPC_V4_FLOW, the format of these GTP packets includes TEID. + * After session creation, it becomes this packet. + * This is mainly used for requests to realize UE handover. + */ + GTPC_TEID_V4_FLOW =3D 0x17, /* hash only */ + GTPC_TEID_V6_FLOW =3D 0x18, /* hash only */ + + /* Use for GTP-U and extended headers for the PSC (PDU Session Container). + * The format of these GTP packets includes TEID and QFI. + * In 5G communication using UPF (User Plane Function), + * data communication with this extended header is performed. + */ + GTPU_EH_V4_FLOW =3D 0x19, /* hash only */ + GTPU_EH_V6_FLOW =3D 0x1a, /* hash only */ + + /* Use for GTP-U IPv4 and v6 PSC (PDU Session Container) extended headers. + * This differs from GTPU_EH_V(4|6)_FLOW in that it is distinguished by + * UL/DL included in the PSC. + * There are differences in the data included based on Downlink/Uplink, + * and can be used to distinguish packets. + * The functions described so far are useful when you want to + * handle communication from the mobile network in UPF, PGW, etc. + */ + GTPU_UL_V4_FLOW =3D 0x1b, /* hash only */ + GTPU_UL_V6_FLOW =3D 0x1c, /* hash only */ + GTPU_DL_V4_FLOW =3D 0x1d, /* hash only */ + GTPU_DL_V6_FLOW =3D 0x1e, /* hash only */ + + __FLOW_TYPE_COUNT, +}; =20 /* Flag to enable additional fields in struct ethtool_rx_flow_spec */ #define FLOW_EXT 0x80000000 diff --git a/include/standard-headers/linux/fuse.h b/include/standard-heade= rs/linux/fuse.h index d303effb2a..a2b5815d89 100644 --- a/include/standard-headers/linux/fuse.h +++ b/include/standard-headers/linux/fuse.h @@ -229,6 +229,9 @@ * - FUSE_URING_IN_OUT_HEADER_SZ * - FUSE_URING_OP_IN_OUT_SZ * - enum fuse_uring_cmd + * + * 7.43 + * - add FUSE_REQUEST_TIMEOUT */ =20 #ifndef _LINUX_FUSE_H @@ -260,7 +263,7 @@ #define FUSE_KERNEL_VERSION 7 =20 /** Minor version number of this interface */ -#define FUSE_KERNEL_MINOR_VERSION 42 +#define FUSE_KERNEL_MINOR_VERSION 43 =20 /** The node ID of the root inode */ #define FUSE_ROOT_ID 1 @@ -431,6 +434,8 @@ struct fuse_file_lock { * of the request ID indicates resend requests * FUSE_ALLOW_IDMAP: allow creation of idmapped mounts * FUSE_OVER_IO_URING: Indicate that client supports io-uring + * FUSE_REQUEST_TIMEOUT: kernel supports timing out requests. + * init_out.request_timeout contains the timeout (in secs) */ #define FUSE_ASYNC_READ (1 << 0) #define FUSE_POSIX_LOCKS (1 << 1) @@ -473,11 +478,11 @@ struct fuse_file_lock { #define FUSE_PASSTHROUGH (1ULL << 37) #define FUSE_NO_EXPORT_SUPPORT (1ULL << 38) #define FUSE_HAS_RESEND (1ULL << 39) - /* Obsolete alias for FUSE_DIRECT_IO_ALLOW_MMAP */ #define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP #define FUSE_ALLOW_IDMAP (1ULL << 40) #define FUSE_OVER_IO_URING (1ULL << 41) +#define FUSE_REQUEST_TIMEOUT (1ULL << 42) =20 /** * CUSE INIT request/reply flags @@ -905,7 +910,8 @@ struct fuse_init_out { uint16_t map_alignment; uint32_t flags2; uint32_t max_stack_depth; - uint32_t unused[6]; + uint16_t request_timeout; + uint16_t unused[11]; }; =20 #define CUSE_INIT_INFO_MAX 4096 diff --git a/include/standard-headers/linux/pci_regs.h b/include/standard-h= eaders/linux/pci_regs.h index 3445c4970e..ba326710f9 100644 --- a/include/standard-headers/linux/pci_regs.h +++ b/include/standard-headers/linux/pci_regs.h @@ -486,6 +486,7 @@ #define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */ #define PCI_EXP_FLAGS_SLOT 0x0100 /* Slot implemented */ #define PCI_EXP_FLAGS_IRQ 0x3e00 /* Interrupt message number */ +#define PCI_EXP_FLAGS_FLIT 0x8000 /* Flit Mode Supported */ #define PCI_EXP_DEVCAP 0x04 /* Device capabilities */ #define PCI_EXP_DEVCAP_PAYLOAD 0x00000007 /* Max_Payload_Size */ #define PCI_EXP_DEVCAP_PHANTOM 0x00000018 /* Phantom functions */ @@ -795,6 +796,8 @@ #define PCI_ERR_CAP_ECRC_CHKC 0x00000080 /* ECRC Check Capable */ #define PCI_ERR_CAP_ECRC_CHKE 0x00000100 /* ECRC Check Enable */ #define PCI_ERR_CAP_PREFIX_LOG_PRESENT 0x00000800 /* TLP Prefix Log Prese= nt */ +#define PCI_ERR_CAP_TLP_LOG_FLIT 0x00040000 /* TLP was logged in Flit Mod= e */ +#define PCI_ERR_CAP_TLP_LOG_SIZE 0x00f80000 /* Logged TLP Size (only in F= lit mode) */ #define PCI_ERR_HEADER_LOG 0x1c /* Header Log Register (16 bytes) */ #define PCI_ERR_ROOT_COMMAND 0x2c /* Root Error Command */ #define PCI_ERR_ROOT_CMD_COR_EN 0x00000001 /* Correctable Err Reporting E= nable */ @@ -1013,7 +1016,7 @@ =20 /* Resizable BARs */ #define PCI_REBAR_CAP 4 /* capability register */ -#define PCI_REBAR_CAP_SIZES 0x00FFFFF0 /* supported BAR sizes */ +#define PCI_REBAR_CAP_SIZES 0xFFFFFFF0 /* supported BAR sizes */ #define PCI_REBAR_CTRL 8 /* control register */ #define PCI_REBAR_CTRL_BAR_IDX 0x00000007 /* BAR index */ #define PCI_REBAR_CTRL_NBAR_MASK 0x000000E0 /* # of resizable BARs */ @@ -1061,8 +1064,9 @@ #define PCI_EXP_DPC_CAP_RP_EXT 0x0020 /* Root Port Extensions */ #define PCI_EXP_DPC_CAP_POISONED_TLP 0x0040 /* Poisoned TLP Egress Blocki= ng Supported */ #define PCI_EXP_DPC_CAP_SW_TRIGGER 0x0080 /* Software Triggering Supporte= d */ -#define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0x0F00 /* RP PIO Log Size */ +#define PCI_EXP_DPC_RP_PIO_LOG_SIZE 0x0F00 /* RP PIO Log Size [3:0] */ #define PCI_EXP_DPC_CAP_DL_ACTIVE 0x1000 /* ERR_COR signal on DL_Active s= upported */ +#define PCI_EXP_DPC_RP_PIO_LOG_SIZE4 0x2000 /* RP PIO Log Size [4] */ =20 #define PCI_EXP_DPC_CTL 0x06 /* DPC control */ #define PCI_EXP_DPC_CTL_EN_FATAL 0x0001 /* Enable trigger on ERR_FATAL me= ssage */ @@ -1205,9 +1209,12 @@ #define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff #define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER 0x0000ff00 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff -#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000 +#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_TYPE 0x00ff0000 #define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000 =20 +/* 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 + /* Compute Express Link (CXL r3.1, sec 8.1.5) */ #define PCI_DVSEC_CXL_PORT 3 #define PCI_DVSEC_CXL_PORT_CTL 0x0c diff --git a/include/standard-headers/linux/virtio_net.h b/include/standard= -headers/linux/virtio_net.h index fc594fe5fc..4ddefe25d6 100644 --- a/include/standard-headers/linux/virtio_net.h +++ b/include/standard-headers/linux/virtio_net.h @@ -70,6 +70,28 @@ * with the same MAC. */ #define VIRTIO_NET_F_SPEED_DUPLEX 63 /* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO 65 /* Driver can receive + * GSO-over-UDP-tunnel packets + */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM 66 /* Driver handles + * GSO-over-UDP-tunnel + * packets with partial csum + * for the outer header + */ +#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO 67 /* Device can receive + * GSO-over-UDP-tunnel packets + */ +#define VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM 68 /* Device handles + * GSO-over-UDP-tunnel + * packets with partial csum + * for the outer header + */ + +/* Offloads bits corresponding to VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO{,_CSUM} + * features + */ +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_MAPPED 46 +#define VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM_MAPPED 47 =20 #ifndef VIRTIO_NET_NO_LEGACY #define VIRTIO_NET_F_GSO 6 /* Host handles pkts w/ any GSO type */ @@ -131,12 +153,17 @@ struct virtio_net_hdr_v1 { #define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 /* Use csum_start, csum_offset */ #define VIRTIO_NET_HDR_F_DATA_VALID 2 /* Csum is valid */ #define VIRTIO_NET_HDR_F_RSC_INFO 4 /* rsc info in csum_ fields */ +#define VIRTIO_NET_HDR_F_UDP_TUNNEL_CSUM 8 /* UDP tunnel requires csum off= load */ uint8_t flags; #define VIRTIO_NET_HDR_GSO_NONE 0 /* Not a GSO frame */ #define VIRTIO_NET_HDR_GSO_TCPV4 1 /* GSO frame, IPv4 TCP (TSO) */ #define VIRTIO_NET_HDR_GSO_UDP 3 /* GSO frame, IPv4 UDP (UFO) */ #define VIRTIO_NET_HDR_GSO_TCPV6 4 /* GSO frame, IPv6 TCP */ #define VIRTIO_NET_HDR_GSO_UDP_L4 5 /* GSO frame, IPv4& IPv6 UDP (USO) */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 0x20 /* UDP over IPv4 tunnel pr= esent */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 0x40 /* UDP over IPv6 tunnel pr= esent */ +#define VIRTIO_NET_HDR_GSO_UDP_TUNNEL (VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 = | \ + VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6) #define VIRTIO_NET_HDR_GSO_ECN 0x80 /* TCP has ECN set */ uint8_t gso_type; __virtio16 hdr_len; /* Ethernet + IP + tcp/udp hdrs */ @@ -181,6 +208,12 @@ struct virtio_net_hdr_v1_hash { uint16_t padding; }; =20 +/* This header after hashing information */ +struct virtio_net_hdr_tunnel { + __virtio16 outer_th_offset; + __virtio16 inner_nh_offset; +}; + #ifndef VIRTIO_NET_NO_LEGACY /* This header comes first in the scatter-gather list. * For legacy virtio, if VIRTIO_F_ANY_LAYOUT is not negotiated, it must @@ -327,6 +360,19 @@ struct virtio_net_rss_config { uint8_t hash_key_data[/* hash_key_length */]; }; =20 +struct virtio_net_rss_config_hdr { + uint32_t hash_types; + uint16_t indirection_table_mask; + uint16_t unclassified_queue; + uint16_t indirection_table[/* 1 + indirection_table_mask */]; +}; + +struct virtio_net_rss_config_trailer { + uint16_t max_tx_vq; + uint8_t hash_key_length; + uint8_t hash_key_data[/* hash_key_length */]; +}; + #define VIRTIO_NET_CTRL_MQ_RSS_CONFIG 1 =20 /* diff --git a/include/standard-headers/linux/virtio_pci.h b/include/standard= -headers/linux/virtio_pci.h index 91fec6f502..09e964e6ee 100644 --- a/include/standard-headers/linux/virtio_pci.h +++ b/include/standard-headers/linux/virtio_pci.h @@ -246,6 +246,7 @@ struct virtio_pci_cfg_cap { #define VIRTIO_ADMIN_CMD_LIST_USE 0x1 =20 /* Admin command group type. */ +#define VIRTIO_ADMIN_GROUP_TYPE_SELF 0x0 #define VIRTIO_ADMIN_GROUP_TYPE_SRIOV 0x1 =20 /* Transitional device admin command. */ diff --git a/include/standard-headers/linux/virtio_snd.h b/include/standard= -headers/linux/virtio_snd.h index 860f12e0a4..160d57899f 100644 --- a/include/standard-headers/linux/virtio_snd.h +++ b/include/standard-headers/linux/virtio_snd.h @@ -25,7 +25,7 @@ struct virtio_snd_config { uint32_t streams; /* # of available channel maps */ uint32_t chmaps; - /* # of available control elements */ + /* # of available control elements (if VIRTIO_SND_F_CTLS) */ uint32_t controls; }; =20 diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index ec1e82bdc8..4e6aff08df 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -105,6 +105,7 @@ struct kvm_regs { #define KVM_ARM_VCPU_PTRAUTH_ADDRESS 5 /* VCPU uses address authentication= */ #define KVM_ARM_VCPU_PTRAUTH_GENERIC 6 /* VCPU uses generic authentication= */ #define KVM_ARM_VCPU_HAS_EL2 7 /* Support nested virtualization */ +#define KVM_ARM_VCPU_HAS_EL2_E2H0 8 /* Limit NV support to E2H RES0 */ =20 struct kvm_vcpu_init { __u32 target; @@ -365,6 +366,7 @@ enum { KVM_REG_ARM_STD_HYP_BIT_PV_TIME =3D 0, }; =20 +/* Vendor hyper call function numbers 0-63 */ #define KVM_REG_ARM_VENDOR_HYP_BMAP KVM_REG_ARM_FW_FEAT_BMAP_REG(2) =20 enum { @@ -372,6 +374,14 @@ enum { KVM_REG_ARM_VENDOR_HYP_BIT_PTP =3D 1, }; =20 +/* Vendor hyper call function numbers 64-127 */ +#define KVM_REG_ARM_VENDOR_HYP_BMAP_2 KVM_REG_ARM_FW_FEAT_BMAP_REG(3) + +enum { + KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_VER =3D 0, + KVM_REG_ARM_VENDOR_HYP_BIT_DISCOVER_IMPL_CPUS =3D 1, +}; + /* Device Control API on vm fd */ #define KVM_ARM_VM_SMCCC_CTRL 0 #define KVM_ARM_VM_SMCCC_FILTER 0 @@ -394,6 +404,7 @@ enum { #define KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS 6 #define KVM_DEV_ARM_VGIC_GRP_LEVEL_INFO 7 #define KVM_DEV_ARM_VGIC_GRP_ITS_REGS 8 +#define KVM_DEV_ARM_VGIC_GRP_MAINT_IRQ 9 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT 10 #define KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_MASK \ (0x3fffffULL << KVM_DEV_ARM_VGIC_LINE_LEVEL_INFO_SHIFT) diff --git a/linux-headers/asm-arm64/unistd_64.h b/linux-headers/asm-arm64/= unistd_64.h index d4e90fff76..ee9aaebdf3 100644 --- a/linux-headers/asm-arm64/unistd_64.h +++ b/linux-headers/asm-arm64/unistd_64.h @@ -323,6 +323,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-generic/mman-common.h b/linux-headers/asm-ge= neric/mman-common.h index 1ea2c4c33b..ef1c27fa3c 100644 --- a/linux-headers/asm-generic/mman-common.h +++ b/linux-headers/asm-generic/mman-common.h @@ -85,6 +85,7 @@ /* compatibility flags */ #define MAP_FILE 0 =20 +#define PKEY_UNRESTRICTED 0x0 #define PKEY_DISABLE_ACCESS 0x1 #define PKEY_DISABLE_WRITE 0x2 #define PKEY_ACCESS_MASK (PKEY_DISABLE_ACCESS |\ diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic= /unistd.h index 88dc393c2b..2892a45023 100644 --- a/linux-headers/asm-generic/unistd.h +++ b/linux-headers/asm-generic/unistd.h @@ -849,9 +849,11 @@ __SYSCALL(__NR_getxattrat, sys_getxattrat) __SYSCALL(__NR_listxattrat, sys_listxattrat) #define __NR_removexattrat 466 __SYSCALL(__NR_removexattrat, sys_removexattrat) +#define __NR_open_tree_attr 467 +__SYSCALL(__NR_open_tree_attr, sys_open_tree_attr) =20 #undef __NR_syscalls -#define __NR_syscalls 467 +#define __NR_syscalls 468 =20 /* * 32 bit systems traditionally used different diff --git a/linux-headers/asm-loongarch/unistd_64.h b/linux-headers/asm-lo= ongarch/unistd_64.h index 23fb96a8a7..50d22df8f7 100644 --- a/linux-headers/asm-loongarch/unistd_64.h +++ b/linux-headers/asm-loongarch/unistd_64.h @@ -319,6 +319,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-mips/unistd_n32.h b/linux-headers/asm-mips/u= nistd_n32.h index 9a75719644..bdcc2f460b 100644 --- a/linux-headers/asm-mips/unistd_n32.h +++ b/linux-headers/asm-mips/unistd_n32.h @@ -395,5 +395,6 @@ #define __NR_getxattrat (__NR_Linux + 464) #define __NR_listxattrat (__NR_Linux + 465) #define __NR_removexattrat (__NR_Linux + 466) +#define __NR_open_tree_attr (__NR_Linux + 467) =20 #endif /* _ASM_UNISTD_N32_H */ diff --git a/linux-headers/asm-mips/unistd_n64.h b/linux-headers/asm-mips/u= nistd_n64.h index 7086783b0c..3b6b0193b6 100644 --- a/linux-headers/asm-mips/unistd_n64.h +++ b/linux-headers/asm-mips/unistd_n64.h @@ -371,5 +371,6 @@ #define __NR_getxattrat (__NR_Linux + 464) #define __NR_listxattrat (__NR_Linux + 465) #define __NR_removexattrat (__NR_Linux + 466) +#define __NR_open_tree_attr (__NR_Linux + 467) =20 #endif /* _ASM_UNISTD_N64_H */ diff --git a/linux-headers/asm-mips/unistd_o32.h b/linux-headers/asm-mips/u= nistd_o32.h index b3825823e4..4609a4b4d3 100644 --- a/linux-headers/asm-mips/unistd_o32.h +++ b/linux-headers/asm-mips/unistd_o32.h @@ -441,5 +441,6 @@ #define __NR_getxattrat (__NR_Linux + 464) #define __NR_listxattrat (__NR_Linux + 465) #define __NR_removexattrat (__NR_Linux + 466) +#define __NR_open_tree_attr (__NR_Linux + 467) =20 #endif /* _ASM_UNISTD_O32_H */ diff --git a/linux-headers/asm-powerpc/unistd_32.h b/linux-headers/asm-powe= rpc/unistd_32.h index 38ee4dc35d..5d38a427e0 100644 --- a/linux-headers/asm-powerpc/unistd_32.h +++ b/linux-headers/asm-powerpc/unistd_32.h @@ -448,6 +448,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-powerpc/unistd_64.h b/linux-headers/asm-powe= rpc/unistd_64.h index 5e5f156834..860a488e4d 100644 --- a/linux-headers/asm-powerpc/unistd_64.h +++ b/linux-headers/asm-powerpc/unistd_64.h @@ -420,6 +420,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-riscv/kvm.h b/linux-headers/asm-riscv/kvm.h index f06bc5efcd..5f59fd226c 100644 --- a/linux-headers/asm-riscv/kvm.h +++ b/linux-headers/asm-riscv/kvm.h @@ -182,6 +182,8 @@ enum KVM_RISCV_ISA_EXT_ID { KVM_RISCV_ISA_EXT_SVVPTC, KVM_RISCV_ISA_EXT_ZABHA, KVM_RISCV_ISA_EXT_ZICCRSE, + KVM_RISCV_ISA_EXT_ZAAMO, + KVM_RISCV_ISA_EXT_ZALRSC, KVM_RISCV_ISA_EXT_MAX, }; =20 diff --git a/linux-headers/asm-riscv/unistd_32.h b/linux-headers/asm-riscv/= unistd_32.h index 74f6127aed..a5e769f1d9 100644 --- a/linux-headers/asm-riscv/unistd_32.h +++ b/linux-headers/asm-riscv/unistd_32.h @@ -314,6 +314,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-riscv/unistd_64.h b/linux-headers/asm-riscv/= unistd_64.h index bb6a15a2ec..8df4d64841 100644 --- a/linux-headers/asm-riscv/unistd_64.h +++ b/linux-headers/asm-riscv/unistd_64.h @@ -324,6 +324,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/un= istd_32.h index 620201cb36..85eedbd18e 100644 --- a/linux-headers/asm-s390/unistd_32.h +++ b/linux-headers/asm-s390/unistd_32.h @@ -439,5 +439,6 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 #endif /* _ASM_S390_UNISTD_32_H */ diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/un= istd_64.h index e7e4a10aaf..c03b1b9701 100644 --- a/linux-headers/asm-s390/unistd_64.h +++ b/linux-headers/asm-s390/unistd_64.h @@ -387,5 +387,6 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 #endif /* _ASM_S390_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 86f2c34e7a..dc591fb17e 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -557,6 +557,9 @@ struct kvm_x86_mce { #define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7) #define KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA (1 << 8) =20 +#define KVM_XEN_MSR_MIN_INDEX 0x40000000u +#define KVM_XEN_MSR_MAX_INDEX 0x4fffffffu + struct kvm_xen_hvm_config { __u32 flags; __u32 msr; diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unis= td_32.h index a2eb492a75..491d6b4eb6 100644 --- a/linux-headers/asm-x86/unistd_32.h +++ b/linux-headers/asm-x86/unistd_32.h @@ -457,6 +457,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_32_H */ diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unis= td_64.h index 2f5fc400f5..7cf88bf9bd 100644 --- a/linux-headers/asm-x86/unistd_64.h +++ b/linux-headers/asm-x86/unistd_64.h @@ -380,6 +380,7 @@ #define __NR_getxattrat 464 #define __NR_listxattrat 465 #define __NR_removexattrat 466 +#define __NR_open_tree_attr 467 =20 =20 #endif /* _ASM_UNISTD_64_H */ diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/uni= std_x32.h index fecd832e7f..82959111e6 100644 --- a/linux-headers/asm-x86/unistd_x32.h +++ b/linux-headers/asm-x86/unistd_x32.h @@ -333,6 +333,7 @@ #define __NR_getxattrat (__X32_SYSCALL_BIT + 464) #define __NR_listxattrat (__X32_SYSCALL_BIT + 465) #define __NR_removexattrat (__X32_SYSCALL_BIT + 466) +#define __NR_open_tree_attr (__X32_SYSCALL_BIT + 467) #define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512) #define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513) #define __NR_ioctl (__X32_SYSCALL_BIT + 514) diff --git a/linux-headers/linux/bits.h b/linux-headers/linux/bits.h index c0d00c0a98..58596d18f4 100644 --- a/linux-headers/linux/bits.h +++ b/linux-headers/linux/bits.h @@ -4,13 +4,9 @@ #ifndef _LINUX_BITS_H #define _LINUX_BITS_H =20 -#define __GENMASK(h, l) \ - (((~_UL(0)) - (_UL(1) << (l)) + 1) & \ - (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) +#define __GENMASK(h, l) (((~_UL(0)) << (l)) & (~_UL(0) >> (BITS_PER_LONG -= 1 - (h)))) =20 -#define __GENMASK_ULL(h, l) \ - (((~_ULL(0)) - (_ULL(1) << (l)) + 1) & \ - (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) +#define __GENMASK_ULL(h, l) (((~_ULL(0)) << (l)) & (~_ULL(0) >> (BITS_PER_= LONG_LONG - 1 - (h)))) =20 #define __GENMASK_U128(h, l) \ ((_BIT128((h)) << 1) - (_BIT128(l))) diff --git a/linux-headers/linux/const.h b/linux-headers/linux/const.h index 2122610de7..95ede23342 100644 --- a/linux-headers/linux/const.h +++ b/linux-headers/linux/const.h @@ -33,7 +33,7 @@ * Missing __asm__ support * * __BIT128() would not work in the __asm__ code, as it shifts an - * 'unsigned __init128' data type as direct representation of + * 'unsigned __int128' data type as direct representation of * 128 bit constants is not supported in the gcc compiler, as * they get silently truncated. * diff --git a/linux-headers/linux/iommufd.h b/linux-headers/linux/iommufd.h index ccbdca5e11..cb0f7d6b4d 100644 --- a/linux-headers/linux/iommufd.h +++ b/linux-headers/linux/iommufd.h @@ -55,6 +55,7 @@ enum { IOMMUFD_CMD_VIOMMU_ALLOC =3D 0x90, IOMMUFD_CMD_VDEVICE_ALLOC =3D 0x91, IOMMUFD_CMD_IOAS_CHANGE_PROCESS =3D 0x92, + IOMMUFD_CMD_VEVENTQ_ALLOC =3D 0x93, }; =20 /** @@ -392,6 +393,9 @@ struct iommu_vfio_ioas { * Any domain attached to the non-PASID part of t= he * device must also be flagged, otherwise attachi= ng a * PASID will blocked. + * For the user that wants to attach PASID, ioas = is + * not recommended for both the non-PASID part + * and PASID part of the device. * If IOMMU does not support PASID it will return * error (-EOPNOTSUPP). */ @@ -608,9 +612,17 @@ enum iommu_hw_info_type { * IOMMU_HWPT_GET_DIRTY_BITMAP * IOMMU_HWPT_SET_DIRTY_TRACKING * + * @IOMMU_HW_CAP_PCI_PASID_EXEC: Execute Permission Supported, user ignore= s it + * when the struct + * iommu_hw_info::out_max_pasid_log2 is zero. + * @IOMMU_HW_CAP_PCI_PASID_PRIV: Privileged Mode Supported, user ignores it + * when the struct + * iommu_hw_info::out_max_pasid_log2 is zero. */ enum iommufd_hw_capabilities { IOMMU_HW_CAP_DIRTY_TRACKING =3D 1 << 0, + IOMMU_HW_CAP_PCI_PASID_EXEC =3D 1 << 1, + IOMMU_HW_CAP_PCI_PASID_PRIV =3D 1 << 2, }; =20 /** @@ -626,6 +638,9 @@ enum iommufd_hw_capabilities { * iommu_hw_info_type. * @out_capabilities: Output the generic iommu capability info type as def= ined * in the enum iommu_hw_capabilities. + * @out_max_pasid_log2: Output the width of PASIDs. 0 means no PASID suppo= rt. + * PCI devices turn to out_capabilities to check if t= he + * specific capabilities is supported or not. * @__reserved: Must be 0 * * Query an iommu type specific hardware information data from an iommu be= hind @@ -649,7 +664,8 @@ struct iommu_hw_info { __u32 data_len; __aligned_u64 data_uptr; __u32 out_data_type; - __u32 __reserved; + __u8 out_max_pasid_log2; + __u8 __reserved[3]; __aligned_u64 out_capabilities; }; #define IOMMU_GET_HW_INFO _IO(IOMMUFD_TYPE, IOMMUFD_CMD_GET_HW_INFO) @@ -1014,4 +1030,115 @@ struct iommu_ioas_change_process { #define IOMMU_IOAS_CHANGE_PROCESS \ _IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_CHANGE_PROCESS) =20 +/** + * enum iommu_veventq_flag - flag for struct iommufd_vevent_header + * @IOMMU_VEVENTQ_FLAG_LOST_EVENTS: vEVENTQ has lost vEVENTs + */ +enum iommu_veventq_flag { + IOMMU_VEVENTQ_FLAG_LOST_EVENTS =3D (1U << 0), +}; + +/** + * struct iommufd_vevent_header - Virtual Event Header for a vEVENTQ Status + * @flags: Combination of enum iommu_veventq_flag + * @sequence: The sequence index of a vEVENT in the vEVENTQ, with a range = of + * [0, INT_MAX] where the following index of INT_MAX is 0 + * + * Each iommufd_vevent_header reports a sequence index of the following vE= VENT: + * + * +----------------------+-------+----------------------+-------+---+----= ---+ + * | header0 {sequence=3D0} | data0 | header1 {sequence=3D1} | data1 |...|= dataN | + * +----------------------+-------+----------------------+-------+---+----= ---+ + * + * And this sequence index is expected to be monotonic to the sequence ind= ex of + * the previous vEVENT. If two adjacent sequence indexes has a delta large= r than + * 1, it means that delta - 1 number of vEVENTs has lost, e.g. two lost vE= VENTs: + * + * +-----+----------------------+-------+----------------------+-------+--= ---+ + * | ... | header3 {sequence=3D3} | data3 | header6 {sequence=3D6} | data6= | ... | + * +-----+----------------------+-------+----------------------+-------+--= ---+ + * + * If a vEVENT lost at the tail of the vEVENTQ and there is no following v= EVENT + * providing the next sequence index, an IOMMU_VEVENTQ_FLAG_LOST_EVENTS he= ader + * would be added to the tail, and no data would follow this header: + * + * +--+----------------------+-------+------------------------------------= -----+ + * |..| header3 {sequence=3D3} | data3 | header4 {flags=3DLOST_EVENTS, seq= uence=3D4} | + * +--+----------------------+-------+------------------------------------= -----+ + */ +struct iommufd_vevent_header { + __u32 flags; + __u32 sequence; +}; + +/** + * enum iommu_veventq_type - Virtual Event Queue Type + * @IOMMU_VEVENTQ_TYPE_DEFAULT: Reserved for future use + * @IOMMU_VEVENTQ_TYPE_ARM_SMMUV3: ARM SMMUv3 Virtual Event Queue + */ +enum iommu_veventq_type { + IOMMU_VEVENTQ_TYPE_DEFAULT =3D 0, + IOMMU_VEVENTQ_TYPE_ARM_SMMUV3 =3D 1, +}; + +/** + * struct iommu_vevent_arm_smmuv3 - ARM SMMUv3 Virtual Event + * (IOMMU_VEVENTQ_TYPE_ARM_SMMUV3) + * @evt: 256-bit ARM SMMUv3 Event record, little-endian. + * Reported event records: (Refer to "7.3 Event records" in SMMUv3 H= W Spec) + * - 0x04 C_BAD_STE + * - 0x06 F_STREAM_DISABLED + * - 0x08 C_BAD_SUBSTREAMID + * - 0x0a C_BAD_CD + * - 0x10 F_TRANSLATION + * - 0x11 F_ADDR_SIZE + * - 0x12 F_ACCESS + * - 0x13 F_PERMISSION + * + * StreamID field reports a virtual device ID. To receive a virtual event = for a + * device, a vDEVICE must be allocated via IOMMU_VDEVICE_ALLOC. + */ +struct iommu_vevent_arm_smmuv3 { + __aligned_le64 evt[4]; +}; + +/** + * struct iommu_veventq_alloc - ioctl(IOMMU_VEVENTQ_ALLOC) + * @size: sizeof(struct iommu_veventq_alloc) + * @flags: Must be 0 + * @viommu_id: virtual IOMMU ID to associate the vEVENTQ with + * @type: Type of the vEVENTQ. Must be defined in enum iommu_veventq_type + * @veventq_depth: Maximum number of events in the vEVENTQ + * @out_veventq_id: The ID of the new vEVENTQ + * @out_veventq_fd: The fd of the new vEVENTQ. User space must close the + * successfully returned fd after using it + * @__reserved: Must be 0 + * + * Explicitly allocate a virtual event queue interface for a vIOMMU. A vIO= MMU + * can have multiple FDs for different types, but is confined to one per @= type. + * User space should open the @out_veventq_fd to read vEVENTs out of a vEV= ENTQ, + * if there are vEVENTs available. A vEVENTQ will lose events due to overf= low, + * if the number of the vEVENTs hits @veventq_depth. + * + * Each vEVENT in a vEVENTQ encloses a struct iommufd_vevent_header follow= ed by + * a type-specific data structure, in a normal case: + * + * +-+---------+-------+---------+-------+-----+---------+-------+-+ + * | | header0 | data0 | header1 | data1 | ... | headerN | dataN | | + * +-+---------+-------+---------+-------+-----+---------+-------+-+ + * + * unless a tailing IOMMU_VEVENTQ_FLAG_LOST_EVENTS header is logged (refer= to + * struct iommufd_vevent_header). + */ +struct iommu_veventq_alloc { + __u32 size; + __u32 flags; + __u32 viommu_id; + __u32 type; + __u32 veventq_depth; + __u32 out_veventq_id; + __u32 out_veventq_fd; + __u32 __reserved; +}; +#define IOMMU_VEVENTQ_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VEVENTQ_ALLOC) #endif diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 27181b3dd8..e5f3e8b5a0 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -921,6 +921,7 @@ struct kvm_enable_cap { #define KVM_CAP_PRE_FAULT_MEMORY 236 #define KVM_CAP_X86_APIC_BUS_CYCLES_NS 237 #define KVM_CAP_X86_GUEST_MODE 238 +#define KVM_CAP_ARM_WRITABLE_IMP_ID_REGS 239 =20 struct kvm_irq_routing_irqchip { __u32 irqchip; diff --git a/linux-headers/linux/psp-sev.h b/linux-headers/linux/psp-sev.h index 17bf191573..113c4ceb78 100644 --- a/linux-headers/linux/psp-sev.h +++ b/linux-headers/linux/psp-sev.h @@ -73,13 +73,20 @@ typedef enum { SEV_RET_INVALID_PARAM, SEV_RET_RESOURCE_LIMIT, SEV_RET_SECURE_DATA_INVALID, - SEV_RET_INVALID_KEY =3D 0x27, - SEV_RET_INVALID_PAGE_SIZE, - SEV_RET_INVALID_PAGE_STATE, - SEV_RET_INVALID_MDATA_ENTRY, - SEV_RET_INVALID_PAGE_OWNER, - SEV_RET_INVALID_PAGE_AEAD_OFLOW, - SEV_RET_RMP_INIT_REQUIRED, + SEV_RET_INVALID_PAGE_SIZE =3D 0x0019, + SEV_RET_INVALID_PAGE_STATE =3D 0x001A, + SEV_RET_INVALID_MDATA_ENTRY =3D 0x001B, + SEV_RET_INVALID_PAGE_OWNER =3D 0x001C, + SEV_RET_AEAD_OFLOW =3D 0x001D, + SEV_RET_EXIT_RING_BUFFER =3D 0x001F, + SEV_RET_RMP_INIT_REQUIRED =3D 0x0020, + SEV_RET_BAD_SVN =3D 0x0021, + SEV_RET_BAD_VERSION =3D 0x0022, + SEV_RET_SHUTDOWN_REQUIRED =3D 0x0023, + SEV_RET_UPDATE_FAILED =3D 0x0024, + SEV_RET_RESTORE_REQUIRED =3D 0x0025, + SEV_RET_RMP_INITIALIZATION_FAILED =3D 0x0026, + SEV_RET_INVALID_KEY =3D 0x0027, SEV_RET_MAX, } sev_ret_code; =20 diff --git a/linux-headers/linux/stddef.h b/linux-headers/linux/stddef.h index e1416f7937..e1fcfcf3b3 100644 --- a/linux-headers/linux/stddef.h +++ b/linux-headers/linux/stddef.h @@ -70,4 +70,6 @@ #define __counted_by_be(m) #endif =20 +#define __kernel_nonstring + #endif /* _LINUX_STDDEF_H */ diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index 1b5e254d6a..79bf8c0cc5 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -671,6 +671,7 @@ enum { */ enum { VFIO_AP_REQ_IRQ_INDEX, + VFIO_AP_CFG_CHG_IRQ_INDEX, VFIO_AP_NUM_IRQS }; =20 @@ -931,29 +932,34 @@ struct vfio_device_bind_iommufd { * VFIO_DEVICE_ATTACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 19, * struct vfio_device_attach_iommufd_pt) * @argsz: User filled size of this data. - * @flags: Must be 0. + * @flags: Flags for attach. * @pt_id: Input the target id which can represent an ioas or a hwpt * allocated via iommufd subsystem. * Output the input ioas id or the attached hwpt id which could * be the specified hwpt itself or a hwpt automatically created * for the specified ioas by kernel during the attachment. + * @pasid: The pasid to be attached, only meaningful when + * VFIO_DEVICE_ATTACH_PASID is set in @flags * * Associate the device with an address space within the bound iommufd. * Undo by VFIO_DEVICE_DETACH_IOMMUFD_PT or device fd close. This is only * allowed on cdev fds. * - * If a vfio device is currently attached to a valid hw_pagetable, without= doing - * a VFIO_DEVICE_DETACH_IOMMUFD_PT, a second VFIO_DEVICE_ATTACH_IOMMUFD_PT= ioctl - * passing in another hw_pagetable (hwpt) id is allowed. This action, also= known - * as a hw_pagetable replacement, will replace the device's currently atta= ched - * hw_pagetable with a new hw_pagetable corresponding to the given pt_id. + * If a vfio device or a pasid of this device is currently attached to a v= alid + * hw_pagetable (hwpt), without doing a VFIO_DEVICE_DETACH_IOMMUFD_PT, a s= econd + * VFIO_DEVICE_ATTACH_IOMMUFD_PT ioctl passing in another hwpt id is allow= ed. + * This action, also known as a hw_pagetable replacement, will replace the + * currently attached hwpt of the device or the pasid of this device with = a new + * hwpt corresponding to the given pt_id. * * Return: 0 on success, -errno on failure. */ struct vfio_device_attach_iommufd_pt { __u32 argsz; __u32 flags; +#define VFIO_DEVICE_ATTACH_PASID (1 << 0) __u32 pt_id; + __u32 pasid; }; =20 #define VFIO_DEVICE_ATTACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 19) @@ -962,17 +968,21 @@ struct vfio_device_attach_iommufd_pt { * VFIO_DEVICE_DETACH_IOMMUFD_PT - _IOW(VFIO_TYPE, VFIO_BASE + 20, * struct vfio_device_detach_iommufd_pt) * @argsz: User filled size of this data. - * @flags: Must be 0. + * @flags: Flags for detach. + * @pasid: The pasid to be detached, only meaningful when + * VFIO_DEVICE_DETACH_PASID is set in @flags * - * Remove the association of the device and its current associated address - * space. After it, the device should be in a blocking DMA state. This i= s only - * allowed on cdev fds. + * Remove the association of the device or a pasid of the device and its c= urrent + * associated address space. After it, the device or the pasid should be = in a + * blocking DMA state. This is only allowed on cdev fds. * * Return: 0 on success, -errno on failure. */ struct vfio_device_detach_iommufd_pt { __u32 argsz; __u32 flags; +#define VFIO_DEVICE_DETACH_PASID (1 << 0) + __u32 pasid; }; =20 #define VFIO_DEVICE_DETACH_IOMMUFD_PT _IO(VFIO_TYPE, VFIO_BASE + 20) diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h index b95dd84eef..328e81badf 100644 --- a/linux-headers/linux/vhost.h +++ b/linux-headers/linux/vhost.h @@ -28,10 +28,10 @@ =20 /* Set current process as the (exclusive) owner of this file descriptor. = This * must be called before any other vhost command. Further calls to - * VHOST_OWNER_SET fail until VHOST_OWNER_RESET is called. */ + * VHOST_SET_OWNER fail until VHOST_RESET_OWNER is called. */ #define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01) /* Give up ownership, and reset the device to default values. - * Allows subsequent call to VHOST_OWNER_SET to succeed. */ + * Allows subsequent call to VHOST_SET_OWNER to succeed. */ #define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02) =20 /* Set up/modify memory layout */ @@ -235,4 +235,12 @@ */ #define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, \ struct vhost_vring_state) + +/* Extended features manipulation + */ +#ifdef __SIZEOF_INT128__ +#define VHOST_GET_FEATURES_EX _IOR(VHOST_VIRTIO, 0x83, __u128) +#define VHOST_SET_FEATURES_EX _IOW(VHOST_VIRTIO, 0x83, __u128) +#endif + #endif --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827370; cv=none; d=zohomail.com; s=zohoarc; b=PbZPShwj+/FZHdlGHUKPE4wukD/kFyR/c88mktldLiHoXgbJkuXcfKlT/vLdEa96+d4/5ppsz3VOgeG99WSM2Jc28hBP0hbQJ0hAfWZXIvMMGGWFAH1CmsAZUxewpV3QodNNg/lJeHcY8XMvmgVLv6rbEh8+j3hT8FZ9OEgK4R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827370; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=dfYPO1yivZj59r4kdmpa9effDikIteX3GGVpxfn4DKg=; b=ZC+GPSlSCKSwDT0XAXZrF30gby1Ic9sXDQpzS0TW06grb2Uc1XkAFsMeZC9hi3+1pHOtMNghGdzWzWOOmDD4ls5dK9mKEVrrzXPTorRg8u9daU3qtXE8CMr/8uIxQZFvxfc2U9AUopr1heNZwUaY7yQUGkJL/Zu0D3Kj243sSmk= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174782737038188.9036361291702; Wed, 21 May 2025 04:36:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhjR-0003aP-OC; Wed, 21 May 2025 07:35:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjK-0003ZS-CZ for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:26 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjF-00011Q-Vl for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:25 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-dLQ_FupqP-CVCB8jxXCjpw-1; Wed, 21 May 2025 07:35:17 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2A16D1850D04; Wed, 21 May 2025 11:35:08 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A438A19560B7; Wed, 21 May 2025 11:35:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827320; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dfYPO1yivZj59r4kdmpa9effDikIteX3GGVpxfn4DKg=; b=eBLwUYIz1BGiilh0MmwAYUECqXLru4mn9iHus+DO7OlEKIxioWYpNfaQXzp0pidKUyfTTw n5GuERjQaJwwIiD3/114PrsO8fNk939L26QJOgnyipAHIBqgkQY0sSuzxx9eMO3DdQy/kf b9VfMuDWg+5xaITPx64A6W5BeMZVGGw= X-MC-Unique: dLQ_FupqP-CVCB8jxXCjpw-1 X-Mimecast-MFC-AGG-ID: dLQ_FupqP-CVCB8jxXCjpw_1747827315 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 02/16] migration: introduce support for 128 bit int state. Date: Wed, 21 May 2025 13:33:56 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827372828116600 Content-Type: text/plain; charset="utf-8" The virtio specifications allows for up to 128 bits for the device features. Soon we are going to use some of the 'extended' bits features (above 64) for the virtio net driver. For platform natively supporting 128 bits, introduce a 128 bit integer state. Signed-off-by: Paolo Abeni --- include/migration/qemu-file-types.h | 15 +++++++++++++++ include/migration/vmstate.h | 11 +++++++++++ migration/qemu-file.c | 16 ++++++++++++++++ migration/vmstate-types.c | 25 +++++++++++++++++++++++++ 4 files changed, 67 insertions(+) diff --git a/include/migration/qemu-file-types.h b/include/migration/qemu-f= ile-types.h index adec5abc07..094ace5bb2 100644 --- a/include/migration/qemu-file-types.h +++ b/include/migration/qemu-file-types.h @@ -92,6 +92,21 @@ static inline void qemu_get_8s(QEMUFile *f, uint8_t *pv) *pv =3D qemu_get_byte(f); } =20 +#ifdef CONFIG_INT128 +void qemu_put_be128(QEMUFile *f, __uint128_t v); +__uint128_t qemu_get_be128(QEMUFile *f); + +static inline void qemu_put_be128s(QEMUFile *f, const __uint128_t *pv) +{ + qemu_put_be128(f, *pv); +} + +static inline void qemu_get_be128s(QEMUFile *f, __uint128_t *pv) +{ + *pv =3D qemu_get_be128(f); +} +#endif + /* Signed versions for type safety */ static inline void qemu_put_sbe16(QEMUFile *f, int v) { diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index a1dfab4460..9695d4ba06 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -903,6 +903,17 @@ extern const VMStateInfo vmstate_info_qlist; #define VMSTATE_UINT64_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint64, uint64_t) =20 +#ifdef CONFIG_INT128 +#define VMSTATE_UINT128_V(_f, _s, _v) \ + VMSTATE_SINGLE(_f, _s, _v, vmstate_info_uint128, __uint128_t) +#define VMSTATE_UINT128(_f, _s) \ + VMSTATE_UINT128_V(_f, _s, 0) +#define VMSTATE_UINT128_TEST(_f, _s, _t) \ + VMSTATE_SINGLE_TEST(_f, _s, _t, 0, vmstate_info_int128, __int128_t) + +extern const VMStateInfo vmstate_info_uint128; +#endif + #define VMSTATE_FD_V(_f, _s, _v) \ VMSTATE_SINGLE(_f, _s, _v, vmstate_info_fd, int32_t) =20 diff --git a/migration/qemu-file.c b/migration/qemu-file.c index b6ac190034..3dc7645d3e 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -825,6 +825,22 @@ void qemu_put_be64(QEMUFile *f, uint64_t v) qemu_put_be32(f, v); } =20 +#ifdef CONFIG_INT128 +void qemu_put_be128(QEMUFile *f, __uint128_t v) +{ + qemu_put_be64(f, v >> 64); + qemu_put_be64(f, v); +} + +__uint128_t qemu_get_be128(QEMUFile *f) +{ + __uint128_t v; + v =3D (__uint128_t)qemu_get_be64(f) << 64; + v |=3D qemu_get_be64(f); + return v; +} +#endif + unsigned int qemu_get_be16(QEMUFile *f) { unsigned int v; diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 741a588b7e..120ea1f9cd 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -315,6 +315,31 @@ const VMStateInfo vmstate_info_uint64 =3D { .put =3D put_uint64, }; =20 +/* 128 bit unsigned int */ +#ifdef CONFIG_INT128 +static int get_uint128(QEMUFile *f, void *pv, size_t size, + const VMStateField *field) +{ + __uint128_t *v =3D pv; + qemu_get_be128s(f, v); + return 0; +} + +static int put_uint128(QEMUFile *f, void *pv, size_t size, + const VMStateField *field, JSONWriter *vmdesc) +{ + __uint128_t *v =3D pv; + qemu_put_be128s(f, v); + return 0; +} + +const VMStateInfo vmstate_info_uint128 =3D { + .name =3D "uint128", + .get =3D get_uint128, + .put =3D put_uint128, +}; +#endif + /* File descriptor communicated via SCM_RIGHTS */ =20 static int get_fd(QEMUFile *f, void *pv, size_t size, --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827372; cv=none; d=zohomail.com; s=zohoarc; b=inFb6EEIM3R/OdxWyBvjXNLTf/B2NlJ7Zi76+L1aN4Dna1ZFEGIJ5REX0D7dZmtgbR6w/XTIjjoKD1NVyDfJJuzxIcVmGTOrntSITodGEIqqKDimI611+ep2bObP9qrl1S0qAuUmCaeGkHyQEFAyU6nfdfF1ZWIlc0RPZPyTg8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827372; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=rgN0+d7s/t88dhPMNH/Un4MUlEI3ZGm8MBQFbfKWW64=; b=NF+OziG541HkROUZ2E0bp9IGrRkxvQ/jlhHSbJ3bnYifjy3lQBDnAOZhBDXSSntaoSMWfemlIyfwKIFlRY3JCSXpi/sQCplDQO2E+KTuXmzHBHgbQG529xE1Ob5k5ACnAg1et08JopOcV6ZrikqwAYlhccR5H05IWKNp/diqGI0= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827372039455.87191812626213; Wed, 21 May 2025 04:36:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhjL-0003Zf-I6; Wed, 21 May 2025 07:35:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjJ-0003Yx-BQ for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjE-00010y-6e for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:24 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-383-QVFlCDbJNdWzhgfjWEALeA-1; Wed, 21 May 2025 07:35:16 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8365F195608A; Wed, 21 May 2025 11:35:14 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C066419560B7; Wed, 21 May 2025 11:35:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827318; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rgN0+d7s/t88dhPMNH/Un4MUlEI3ZGm8MBQFbfKWW64=; b=V9nzN7FR6vPyZBbsYMU0E6tUtTUlqDTBN5ziYnYqeymqQfl39SJRRRpPIvHaWQHmx6tOoo s88AMkczO0pqZFkIUTGJMPn8lCD2ozP6VPFGJ0gG9gV4g3X3A5uqoMPbY0qTvyewOwqCs5 73f5rqJ6v2FXNzMe6XkYRtt5nIcqJYA= X-MC-Unique: QVFlCDbJNdWzhgfjWEALeA-1 X-Mimecast-MFC-AGG-ID: QVFlCDbJNdWzhgfjWEALeA_1747827314 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 03/16] virtio: introduce extended features type Date: Wed, 21 May 2025 13:33:57 +0200 Message-ID: <968b3e3d162d161c1aaaa477979c4a11c46c68ea.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827375060116600 Content-Type: text/plain; charset="utf-8" The virtio specifications allows for up to 128 bits for the device features. Soon we are going to use some of the 'extended' bits features (above 64) for the virtio net driver. Introduce a specific type to represent the virtio features bitmask. On platform where 128 bits integer are available use such wide int for the features bitmask, otherwise maintain the current u64. Most drivers will keep using only 64 bits features space; use union to allow them access the lower part of the extended space without any per driver change, but let the features field initializers set the extended space. Signed-off-by: Paolo Abeni --- hw/net/virtio-net.c | 2 +- hw/virtio/virtio-bus.c | 4 +- hw/virtio/virtio.c | 4 +- include/hw/virtio/virtio-features.h | 90 +++++++++++++++++++++++++++++ include/hw/virtio/virtio.h | 9 +-- 5 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 include/hw/virtio/virtio-features.h diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 2de037c273..9f500c64e7 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -799,7 +799,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, virtio_clear_feature(&features, VIRTIO_NET_F_RSS); } features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); - vdev->backend_features =3D features; + vdev->backend_features_ex =3D features; =20 if (n->mtu_bypass_backend && (n->host_features & 1ULL << VIRTIO_NET_F_MTU)) { diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 11adfbf3ab..9b84ead831 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -63,8 +63,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error = **errp) =20 /* Get the features of the plugged device. */ assert(vdc->get_features !=3D NULL); - vdev->host_features =3D vdc->get_features(vdev, vdev->host_features, - &local_err); + vdev->host_features_ex =3D vdc->get_features(vdev, vdev->host_features, + &local_err); if (local_err) { error_propagate(errp, local_err); return; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 480c2e5036..701f59884d 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2346,7 +2346,7 @@ void virtio_reset(void *opaque) vdev->start_on_kick =3D false; vdev->started =3D false; vdev->broken =3D false; - vdev->guest_features =3D 0; + vdev->guest_features_ex =3D 0; vdev->queue_sel =3D 0; vdev->status =3D 0; vdev->disabled =3D false; @@ -3239,7 +3239,7 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int vers= ion_id) * Note: devices should always test host features in future - don't cr= eate * new dependencies like this. */ - vdev->guest_features =3D features; + vdev->guest_features_ex =3D features; =20 config_len =3D qemu_get_be32(f); =20 diff --git a/include/hw/virtio/virtio-features.h b/include/hw/virtio/virtio= -features.h new file mode 100644 index 0000000000..a0a115cd66 --- /dev/null +++ b/include/hw/virtio/virtio-features.h @@ -0,0 +1,90 @@ +/* + * Virtio features helpers + * + * Copyright 2025 Red Hat, Inc. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef _QEMU_VIRTIO_FEATURES_H +#define _QEMU_VIRTIO_FEATURES_H + +#define VIRTIO_FEATURES_FMT "%016"PRIx64"%016"PRIx64 + +#ifdef CONFIG_INT128 +#define VIRTIO_BIT(b) ((__int128_t)1 << b) +#define VIRTIO_FEATURES_WORDS 4 +#define VIRTIO_FEATURES_HI(f) ((uint64_t)((f) >> 64)) +#define VIRTIO_FEATURES_LOW(f) ((uint64_t)(f)) + +typedef __uint128_t virtio_features_t; + +#if HOST_BIG_ENDIAN +#define DECLARE_FEATURES(name) \ + union { \ + struct { \ + uint64_t name##_hi; \ + uint64_t name; \ + }; \ + __uint128_t name##_ex; \ + } +#else +#define DECLARE_FEATURES(name) \ + union { \ + struct { \ + uint64_t name; \ + uint64_t name##_hi; \ + }; \ + __uint128_t name##_ex; \ + } +#endif + +static inline void virtio_add_feature_ex(__uint128_t *features, + unsigned int fbit) +{ + assert(fbit < 128); + *features |=3D VIRTIO_BIT(fbit); +} + +static inline void virtio_clear_feature_ex(__uint128_t *features, + unsigned int fbit) +{ + assert(fbit < 128); + *features &=3D ~VIRTIO_BIT(fbit); +} + +static inline bool virtio_has_feature_ex(__uint128_t features, + unsigned int fbit) +{ + assert(fbit < 128); + return !!(features & VIRTIO_BIT(fbit)); +} + +#else /* !CONFIG_INT128 */ + +#define VIRTIO_BIT(b) (1ULL << b) +#define VIRTIO_FEATURES_WORDS 2 +#define VIRTIO_FEATURES_HI(f) 0 +#define VIRTIO_FEATURES_LOW(f) f + +typedef uint64_t virtio_features_t; + +/* + * Without 128 bits support, 'features_ex' is just an alias for the 64 bits + * variable. This help avoiding conditionals in the core virtio code + * manipulation the features + */ +#define DECLARE_FEATURES(name) \ + union { \ + uint64_t name; \ + uint64_t name##_ex; \ + } + +#define virtio_clear_feature_ex virtio_clear_feature +#define virtio_add_feature_ex virtio_add_feature +#define virtio_has_feature_ex virtio_has_feature + +#endif + +#endif + diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 7e0c471ea4..82ff6c1630 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -16,6 +16,7 @@ =20 #include "system/memory.h" #include "hw/qdev-core.h" +#include "hw/virtio/virtio-features.h" #include "net/net.h" #include "migration/vmstate.h" #include "qemu/event_notifier.h" @@ -121,9 +122,9 @@ struct VirtIODevice * backend (e.g. vhost) and could potentially be a subset of the * total feature set offered by QEMU. */ - uint64_t host_features; - uint64_t guest_features; - uint64_t backend_features; + DECLARE_FEATURES(host_features); + DECLARE_FEATURES(guest_features); + DECLARE_FEATURES(backend_features); =20 size_t config_len; void *config; @@ -195,7 +196,7 @@ struct VirtioDeviceClass { * that are only exposed on the legacy interface but not * the modern one. */ - uint64_t legacy_features; + virtio_features_t legacy_features; /* Test and clear event pending status. * Should be called after unmask to avoid losing events. * If backend does not support masking, --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827437; cv=none; d=zohomail.com; s=zohoarc; b=REdvrM2WmLzTRNY92UpbuSLlpCpUQ5eBLlEH4VczKf/jdFixCiBDPExAbBubAigiZ1SDQA5e48RdL26o1heRPby8vDgIr8Sn3H9lUyhc223ZphoFFgIGgngSpThqVPAI6KkG7G6CR5n5XK60Y/pKQ+WZgt2Lo/7Sxn+OqUKG8UA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827437; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+5RrZ8gaODIz2f20pZnxWw3ECS5vPxsdWXWwTpC9Sgo=; b=Sl1sckkk/Gnk5FbNHSHdC7ebgaArBMx7dxR/BhKoLLpALf3RyFjrsKubFOCcvQGiqlOHjeY7evSFZ1gCssFDTOMnEKG3UR9lWT+GBPfMrKp7m9GeOXSfmScRpH5whm7s8y0h5VJyJZhfzvFek7bK2sMydu3n2QgdhWSYG9Zi9Jc= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174782743709428.385667208169593; Wed, 21 May 2025 04:37:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhjz-0003dd-8L; Wed, 21 May 2025 07:36:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjV-0003bS-Ni for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjP-00012r-OY for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:37 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-384-XsHL_GJgP4KFnk6LM6jHdw-1; Wed, 21 May 2025 07:35:23 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ED15C1801A33; Wed, 21 May 2025 11:35:20 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0F32F19560B7; Wed, 21 May 2025 11:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+5RrZ8gaODIz2f20pZnxWw3ECS5vPxsdWXWwTpC9Sgo=; b=gezD3u/WKK7grMpb0CjXEMm7AxNgWFZ7fK48lepiu7aIQJ7zLrKqL30J2fZZ2fIGXQB92I 5LA3mdwbCO9dJ7ADIocyYhTR5vGowLWWYMBn9Kjd38hn1aV0jtAeXDABjDsQ1B49//C6fl feS9VsEbR93498SlGtE3WHFMbXhBJfg= X-MC-Unique: XsHL_GJgP4KFnk6LM6jHdw-1 X-Mimecast-MFC-AGG-ID: XsHL_GJgP4KFnk6LM6jHdw_1747827321 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 04/16] virtio: serialize extended features state Date: Wed, 21 May 2025 13:33:58 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827439668116600 Content-Type: text/plain; charset="utf-8" If the host supports 128 bit-wide features, and the driver use any of them, serialize the full features range leveraging newly introduced 128bits integer helpers. Signed-off-by: Paolo Abeni --- hw/virtio/virtio.c | 76 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 701f59884d..ef15a1835e 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2982,6 +2982,26 @@ static const VMStateDescription vmstate_virtio_disab= led =3D { } }; =20 +#ifdef CONFIG_INT128 +static bool virtio_128bit_features_needed(void *opaque) +{ + VirtIODevice *vdev =3D opaque; + + return (vdev->host_features_ex >> 64) !=3D 0; +} + +static const VMStateDescription vmstate_virtio_128bit_features =3D { + .name =3D "virtio/128bit_features", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D &virtio_128bit_features_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT128(guest_features_ex, VirtIODevice), + VMSTATE_END_OF_LIST() + } +}; +#endif + static const VMStateDescription vmstate_virtio =3D { .name =3D "virtio", .version_id =3D 1, @@ -2991,6 +3011,9 @@ static const VMStateDescription vmstate_virtio =3D { }, .subsections =3D (const VMStateDescription * const []) { &vmstate_virtio_device_endian, +#ifdef CONFIG_INT128 + &vmstate_virtio_128bit_features, +#endif &vmstate_virtio_64bit_features, &vmstate_virtio_virtqueues, &vmstate_virtio_ringsize, @@ -3087,7 +3110,8 @@ const VMStateInfo virtio_vmstate_info =3D { .put =3D virtio_device_put, }; =20 -static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val) +static int virtio_set_features_nocheck(VirtIODevice *vdev, + virtio_features_t val) { VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); bool bad =3D (val & ~(vdev->host_features)) !=3D 0; @@ -3133,6 +3157,42 @@ virtio_set_features_nocheck_maybe_co(VirtIODevice *v= dev, uint64_t val) } } =20 +#ifdef CONFIG_INT128 +typedef struct VirtioSetFeaturesExNocheckData { + Coroutine *co; + VirtIODevice *vdev; + __uint128_t val; + int ret; +} VirtioSetFeaturesExNocheckData; + +static void virtio_set_features_ex_nocheck_bh(void *opaque) +{ + VirtioSetFeaturesExNocheckData *data =3D opaque; + + data->ret =3D virtio_set_features_nocheck(data->vdev, data->val); + aio_co_wake(data->co); +} + +static int coroutine_mixed_fn +virtio_set_features_ex_nocheck_maybe_co(VirtIODevice *vdev, __uint128_t va= l) +{ + if (qemu_in_coroutine()) { + VirtioSetFeaturesExNocheckData data =3D { + .co =3D qemu_coroutine_self(), + .vdev =3D vdev, + .val =3D val, + }; + aio_bh_schedule_oneshot(qemu_get_current_aio_context(), + virtio_set_features_ex_nocheck_bh, &data); + qemu_coroutine_yield(); + return data.ret; + } else { + return virtio_set_features_nocheck(vdev, val); + } +} + +#endif + int virtio_set_features(VirtIODevice *vdev, uint64_t val) { int ret; @@ -3318,6 +3378,20 @@ virtio_load(VirtIODevice *vdev, QEMUFile *f, int ver= sion_id) vdev->device_endian =3D virtio_default_endian(); } =20 +#ifdef CONFIG_INT128 + if (virtio_128bit_features_needed(vdev)) { + __int128_t features128 =3D vdev->guest_features_ex; + if (virtio_set_features_ex_nocheck_maybe_co(vdev, features128) < 0= ) { + error_report("Features 0x" VIRTIO_FEATURES_FMT " unsupported. " + "Allowed features: 0x" VIRTIO_FEATURES_FMT, + VIRTIO_FEATURES_HI(features128), + VIRTIO_FEATURES_LOW(features128), + VIRTIO_FEATURES_HI(vdev->host_features_ex), + VIRTIO_FEATURES_LOW(vdev->host_features_ex)); + return -1; + } + } else +#endif if (virtio_64bit_features_needed(vdev)) { /* * Subsection load filled vdev->guest_features. Run them --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827651; cv=none; d=zohomail.com; s=zohoarc; b=VhbdxMEKVBTS8PnY/7UFLMUPDI7K/HOW0SxEZUu4o3Be3wz6QbbaXQRBEf6HJ2er9M00eXMtAEq1ZonZjwYSamAUk5sjmV1TCstxTR+DH52CEg+fi4XLZbUKrfQMCpNZXAXmmaItQjNdaKjgyccCA+khozncYsPDWAV8mUslJCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827651; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vtpd/F9Kg9OS+alvH0U2zFB3IMxT0Cnkw+gwojoXVYY=; b=fzZOYeXi6N9xCNI2E8xyVyXR4k2/kToRJEwtGYJjZfOZPUTVf1p7dnCJi1wqUJv+lz6my6n8kL79clB8HflD4l6Pi0Xb24HzVxkCuL4EIDioxLtkp4M7+xmoNHgiEWzQnaF5DPvzSSm56vkCDIbf3CMHkJSBOD9pyQjAKdjd4u4= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827651108193.606441876212; Wed, 21 May 2025 04:40:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhk8-0003nr-BZ; Wed, 21 May 2025 07:36:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjY-0003bh-KU for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjT-00013g-T5 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:39 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-HhyDetnbO-Wu0VxO9kAv1A-1; Wed, 21 May 2025 07:35:29 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 19561180035C; Wed, 21 May 2025 11:35:27 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8228C19560B7; Wed, 21 May 2025 11:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827332; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vtpd/F9Kg9OS+alvH0U2zFB3IMxT0Cnkw+gwojoXVYY=; b=gV0Sl3lPQw3olaSyLdiTMW5L6YLDNsH16bXu8lJdiKYfDn6a6m0c81ZTKYsADbrlFReAZz vgum1+qeKy/Z8+mHyCRaRlIubIrz1KlAt4/NgGxIJ74TFSe2PIGo85ux+S0C3z6ERdllf5 HHDqGDdfEieILqqQvphz2v4rLU69fE4= X-MC-Unique: HhyDetnbO-Wu0VxO9kAv1A-1 X-Mimecast-MFC-AGG-ID: HhyDetnbO-Wu0VxO9kAv1A_1747827327 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 05/16] qmp: update virtio features map to support extended features Date: Wed, 21 May 2025 13:33:59 +0200 Message-ID: <666ad0179dd74bc263b13ef4050c72cbc23b4a81.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827652318116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Paolo Abeni --- hw/virtio/virtio-hmp-cmds.c | 3 ++- hw/virtio/virtio-qmp.c | 28 ++++++++++++++++++++++------ hw/virtio/virtio-qmp.h | 3 ++- qapi/virtio.json | 8 ++++++-- 4 files changed, 32 insertions(+), 10 deletions(-) diff --git a/hw/virtio/virtio-hmp-cmds.c b/hw/virtio/virtio-hmp-cmds.c index 7d8677bcf0..04c7fae1c8 100644 --- a/hw/virtio/virtio-hmp-cmds.c +++ b/hw/virtio/virtio-hmp-cmds.c @@ -74,7 +74,8 @@ static void hmp_virtio_dump_features(Monitor *mon, } =20 if (features->has_unknown_dev_features) { - monitor_printf(mon, " unknown-features(0x%016"PRIx64")\n", + monitor_printf(mon, " unknown-features(0x%016"PRIx64"%016"PRIx64"= )\n", + features->unknown_dev_features_hi, features->unknown_dev_features); } } diff --git a/hw/virtio/virtio-qmp.c b/hw/virtio/virtio-qmp.c index 3b6377cf0d..d172a6e9f9 100644 --- a/hw/virtio/virtio-qmp.c +++ b/hw/virtio/virtio-qmp.c @@ -325,6 +325,20 @@ static const qmp_virtio_feature_map_t virtio_net_featu= re_map[] =3D { FEATURE_ENTRY(VHOST_USER_F_PROTOCOL_FEATURES, \ "VHOST_USER_F_PROTOCOL_FEATURES: Vhost-user protocol features " "negotiation supported"), + FEATURE_ENTRY(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO, \ + "VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO: Driver can receive GSO ove= r " + "UDP tunnel packets"), + FEATURE_ENTRY(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM, \ + "VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO: Driver can receive GSO ove= r " + "UDP tunnel packets requiring checksum offload for the outer " + "header"), + FEATURE_ENTRY(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO, \ + "VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO: Device can receive GSO ove= r " + "UDP tunnel packets"), + FEATURE_ENTRY(VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM, \ + "VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO: Device can receive GSO ove= r " + "UDP tunnel packets requiring checksum offload for the outer " + "header"), { -1, "" } }; #endif @@ -496,7 +510,7 @@ static const qmp_virtio_feature_map_t virtio_gpio_featu= re_map[] =3D { bit =3D map[i].virtio_bit; \ } \ else { \ - bit =3D 1ULL << map[i].virtio_bit; \ + bit =3D VIRTIO_BIT(map[i].virtio_bit); \ } \ if ((bitmap & bit) =3D=3D 0) { \ continue; \ @@ -545,10 +559,11 @@ VhostDeviceProtocols *qmp_decode_protocols(uint64_t b= itmap) return vhu_protocols; } =20 -VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bit= map) +VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + virtio_features_t bitmap) { VirtioDeviceFeatures *features; - uint64_t bit; + virtio_features_t bit; int i; =20 features =3D g_new0(VirtioDeviceFeatures, 1); @@ -683,6 +698,7 @@ VirtioDeviceFeatures *qmp_decode_features(uint16_t devi= ce_id, uint64_t bitmap) features->has_unknown_dev_features =3D bitmap !=3D 0; if (features->has_unknown_dev_features) { features->unknown_dev_features =3D bitmap; + features->unknown_dev_features_hi =3D bitmap >> 64; } =20 return features; @@ -743,11 +759,11 @@ VirtioStatus *qmp_x_query_virtio_status(const char *p= ath, Error **errp) status->device_id =3D vdev->device_id; status->vhost_started =3D vdev->vhost_started; status->guest_features =3D qmp_decode_features(vdev->device_id, - vdev->guest_features); + vdev->guest_features_ex); status->host_features =3D qmp_decode_features(vdev->device_id, - vdev->host_features); + vdev->host_features_ex); status->backend_features =3D qmp_decode_features(vdev->device_id, - vdev->backend_features); + vdev->backend_features_= ex); =20 switch (vdev->device_endian) { case VIRTIO_DEVICE_ENDIAN_LITTLE: diff --git a/hw/virtio/virtio-qmp.h b/hw/virtio/virtio-qmp.h index 245a446a56..b64899f04a 100644 --- a/hw/virtio/virtio-qmp.h +++ b/hw/virtio/virtio-qmp.h @@ -18,6 +18,7 @@ VirtIODevice *qmp_find_virtio_device(const char *path); VirtioDeviceStatus *qmp_decode_status(uint8_t bitmap); VhostDeviceProtocols *qmp_decode_protocols(uint64_t bitmap); -VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, uint64_t bit= map); +VirtioDeviceFeatures *qmp_decode_features(uint16_t device_id, + virtio_features_t bitmap); =20 #endif diff --git a/qapi/virtio.json b/qapi/virtio.json index d351d2166e..2fde8ed753 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -488,14 +488,18 @@ # unique features) # # @unknown-dev-features: Virtio device features bitmap that have not -# been decoded +# been decoded (lower 64 bit) +# +# @unknown-dev-features-hi: Virtio device features bitmap that have not +# been decoded (high 64 bit) # # Since: 7.2 ## { 'struct': 'VirtioDeviceFeatures', 'data': { 'transports': [ 'str' ], '*dev-features': [ 'str' ], - '*unknown-dev-features': 'uint64' } } + '*unknown-dev-features': 'uint64', + '*unknown-dev-features-hi': 'uint64' } } =20 ## # @VirtQueueStatus: --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827484; cv=none; d=zohomail.com; s=zohoarc; b=ctR8cDsP3/RlcfC0UjZY1fKO3NEv6Sp/crjEtvqm1ZtSpZ5pFSY/R/gsb8Nhty7SDC8kSqeUAj36TKUv5rOyJlaDshcD3bgwg5N6MMfy9/CGX/4Ao55EaUDVmTM6KUVjeGK6w94rLUgtMw94nx4ftwssKODU83RmLJTNvDQUI2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827484; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kHYTDzDbqLXiCzMSclhXqCm2qiuVW6gwIJGPukVe9dI=; b=mECvO/OhkI+C/NjQry5uV980bJs1EMiC+XeE/b8tpv2HTjvUK4wBXtxNTFJsxG5ZWmjJnFgh+jqzTr+Koe10oQP/iJJq5UrZSGdReBtumJ6RWBjA3CPH79aq4iCOMOX1yTlDuY5Ng+xhOD9va7WFdzrHN4pRLii+8eiQveg3LgY= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827484151754.1238868705503; Wed, 21 May 2025 04:38:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhjz-0003dl-9R; Wed, 21 May 2025 07:36:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhja-0003cS-KI for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjY-00014a-Ii for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:42 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-541-0_GP6oTzOXycXwyVgNjgBQ-1; Wed, 21 May 2025 07:35:35 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EFC5F195608B; Wed, 21 May 2025 11:35:33 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD0C619560B7; Wed, 21 May 2025 11:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827339; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kHYTDzDbqLXiCzMSclhXqCm2qiuVW6gwIJGPukVe9dI=; b=WB93NNGSNOOtEqpMqj3DNY3Ub5nUDX+i2aEvI8XuP26rlyCDbCSeHTj+DrrJ2t1NC/BCbt YO9zk2gCcQhp7IKGNby2FqG1wOBZZk5Lw8FKqYeTFaYatStucDlj14pJhiUjOJJc842YgP QNvwv40EBkmrNASyiNRFg7oNxZoEwwA= X-MC-Unique: 0_GP6oTzOXycXwyVgNjgBQ-1 X-Mimecast-MFC-AGG-ID: 0_GP6oTzOXycXwyVgNjgBQ_1747827334 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 06/16] virtio: add support for negotiating extended features. Date: Wed, 21 May 2025 13:34:00 +0200 Message-ID: <7e11b2708f54fb30fea1801eff979d6a3230acf5.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827486282116600 Content-Type: text/plain; charset="utf-8" The virtio specifications allows for up to 128 bits for the device features. Soon we are going to use some of the 'extended' bits features (above 64) for the virtio net driver. Add support to allow extended features negotiation on a per devices basis. Devices willing to negotiated extended features need to implemented a new pair of features getter/setter, the core will conditionally use them instead of the basic one. Note that 'bad_features' don't need to be extended, as they are bound to the 64 bits limit. No functional changes intended for host without 128 bit support. Signed-off-by: Paolo Abeni --- hw/virtio/virtio-bus.c | 15 ++++++++++++--- hw/virtio/virtio.c | 23 +++++++++++++++++------ include/hw/virtio/virtio.h | 8 +++++++- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index 9b84ead831..40948fca39 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -62,9 +62,18 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error= **errp) } =20 /* Get the features of the plugged device. */ - assert(vdc->get_features !=3D NULL); - vdev->host_features_ex =3D vdc->get_features(vdev, vdev->host_features, - &local_err); +#ifdef CONFIG_INT128 + if (vdc->get_features_ex) + vdev->host_features_ex =3D vdc->get_features_ex(vdev, + vdev->host_features_= ex, + &local_err); + else +#endif + { + assert(vdc->get_features !=3D NULL); + vdev->host_features_ex =3D vdc->get_features(vdev, vdev->host_feat= ures, + &local_err); + } if (local_err) { error_propagate(errp, local_err); return; diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index ef15a1835e..90822e54f8 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -3114,13 +3114,24 @@ static int virtio_set_features_nocheck(VirtIODevice= *vdev, virtio_features_t val) { VirtioDeviceClass *k =3D VIRTIO_DEVICE_GET_CLASS(vdev); - bool bad =3D (val & ~(vdev->host_features)) !=3D 0; + bool bad =3D (val & ~(vdev->host_features_ex)) !=3D 0; =20 - val &=3D vdev->host_features; - if (k->set_features) { - k->set_features(vdev, val); + val &=3D vdev->host_features_ex; +#ifdef CONFIG_INT128 + if (!k->set_features_ex) { + val =3D (uint64_t)val; + } + + if (k->set_features_ex) { + k->set_features_ex(vdev, val); + } else +#endif + { + if (k->set_features) { + k->set_features(vdev, val); + } } - vdev->guest_features =3D val; + vdev->guest_features_ex =3D val; return bad ? -1 : 0; } =20 @@ -3193,7 +3204,7 @@ virtio_set_features_ex_nocheck_maybe_co(VirtIODevice = *vdev, __uint128_t val) =20 #endif =20 -int virtio_set_features(VirtIODevice *vdev, uint64_t val) +int virtio_set_features(VirtIODevice *vdev, virtio_features_t val) { int ret; /* diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 82ff6c1630..e98fd76e7f 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -178,6 +178,12 @@ struct VirtioDeviceClass { /* This is what a VirtioDevice must implement */ DeviceRealize realize; DeviceUnrealize unrealize; +#ifdef CONFIG_INT128 + virtio_features_t (*get_features_ex)(VirtIODevice *vdev, + virtio_features_t requested_featu= res, + Error **errp); + void (*set_features_ex)(VirtIODevice *vdev, virtio_features_t val); +#endif uint64_t (*get_features)(VirtIODevice *vdev, uint64_t requested_features, Error **errp); @@ -366,7 +372,7 @@ void virtio_reset(void *opaque); void virtio_queue_reset(VirtIODevice *vdev, uint32_t queue_index); void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index); void virtio_update_irq(VirtIODevice *vdev); -int virtio_set_features(VirtIODevice *vdev, uint64_t val); +int virtio_set_features(VirtIODevice *vdev, virtio_features_t val); =20 /* Base devices. */ typedef struct VirtIOBlkConf VirtIOBlkConf; --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827442; cv=none; d=zohomail.com; s=zohoarc; b=Qly9WtbbNRgfoIbtW41Ml+jvdJpqoF7ZA0EvzeY2TjiF8LX2H3DH+3ZD5Cb273PF7X2QvJ+5RPJF7tAl+qyXc3zGRw3q6UVsTy2bTCtEzT/+HmukkmvzM8//DwJlAdlqyv+Xd8nhrtQiyBBjj/xLReLGZYMUzD7SWQmYrV+Pi3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827442; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gxKz+6bpWitxKHfviy6aTNvEKI4WqbqkaK+pWRWEn0s=; b=MF7Wt1DELeoS6B8fau2W+ulAELNEX5OccQpmRg3C+EEjXFtKcyYNJQOXoZyEZqMVbj1fxrJULzi71Ys2l5yjEasjiz67JXdwb50TG38dciZg8Rm/rzapQBzb5THP6hg5gWuLRA1WvVseuiSTYA4xv0KRCgIcLYWL7dDeH98L/j8= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827442856526.276204186252; Wed, 21 May 2025 04:37:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkB-0003qb-85; Wed, 21 May 2025 07:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhji-0003d5-Ry for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjd-00015E-PV for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:50 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-1-BjXBGQKLMsqjf5xASl9-mA-1; Wed, 21 May 2025 07:35:41 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 343001956089; Wed, 21 May 2025 11:35:40 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8544619560B7; Wed, 21 May 2025 11:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gxKz+6bpWitxKHfviy6aTNvEKI4WqbqkaK+pWRWEn0s=; b=YDOn73gdoq9m2+Oq8j08TL8J8j0Xi5dx46M+ysNEritKOlvHcxdxAPwJl5VbFvN8f7DX8K d79cMuO4LNevwf7NFU8YvSL/7h2kSdcE3w7vIdr/ntna9YAAqdoUZngqgIgIW89mNeyDjk TSlOZgdwmwyafkVC7muE7eg4W8rjGOk= X-MC-Unique: BjXBGQKLMsqjf5xASl9-mA-1 X-Mimecast-MFC-AGG-ID: BjXBGQKLMsqjf5xASl9-mA_1747827340 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 07/16] virtio-pci: implement support for extended features. Date: Wed, 21 May 2025 13:34:01 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827443643116600 Content-Type: text/plain; charset="utf-8" Allow the common read/write operation to access all the available features space. Signed-off-by: Paolo Abeni --- hw/virtio/virtio-pci.c | 19 +++++++++++++------ include/hw/virtio/virtio-pci.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 0fa8fe4955..7815ef2d9b 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -123,7 +123,8 @@ static const VMStateDescription vmstate_virtio_pci_mode= rn_state_sub =3D { .fields =3D (const VMStateField[]) { VMSTATE_UINT32(dfselect, VirtIOPCIProxy), VMSTATE_UINT32(gfselect, VirtIOPCIProxy), - VMSTATE_UINT32_ARRAY(guest_features, VirtIOPCIProxy, 2), + VMSTATE_UINT32_ARRAY(guest_features, VirtIOPCIProxy, + VIRTIO_FEATURES_WORDS), VMSTATE_STRUCT_ARRAY(vqs, VirtIOPCIProxy, VIRTIO_QUEUE_MAX, 0, vmstate_virtio_pci_modern_queue_state, VirtIOPCIQueue), @@ -1490,10 +1491,10 @@ static uint64_t virtio_pci_common_read(void *opaque= , hwaddr addr, val =3D proxy->dfselect; break; case VIRTIO_PCI_COMMON_DF: - if (proxy->dfselect <=3D 1) { + if (proxy->dfselect < VIRTIO_FEATURES_WORDS) { VirtioDeviceClass *vdc =3D VIRTIO_DEVICE_GET_CLASS(vdev); =20 - val =3D (vdev->host_features & ~vdc->legacy_features) >> + val =3D (vdev->host_features_ex & ~vdc->legacy_features) >> (32 * proxy->dfselect); } break; @@ -1585,10 +1586,16 @@ static void virtio_pci_common_write(void *opaque, h= waddr addr, break; case VIRTIO_PCI_COMMON_GF: if (proxy->gfselect < ARRAY_SIZE(proxy->guest_features)) { + virtio_features_t features =3D 0; + int i; + proxy->guest_features[proxy->gfselect] =3D val; - virtio_set_features(vdev, - (((uint64_t)proxy->guest_features[1]) << 3= 2) | - proxy->guest_features[0]); + for (i =3D 0; i < VIRTIO_FEATURES_WORDS; ++i) { + virtio_features_t cur =3D proxy->guest_features[i]; + + features |=3D cur << (i * 32); + } + virtio_set_features(vdev, features); } break; case VIRTIO_PCI_COMMON_MSIX: diff --git a/include/hw/virtio/virtio-pci.h b/include/hw/virtio/virtio-pci.h index 31ec144509..c20b289e64 100644 --- a/include/hw/virtio/virtio-pci.h +++ b/include/hw/virtio/virtio-pci.h @@ -165,7 +165,7 @@ struct VirtIOPCIProxy { uint32_t nvectors; uint32_t dfselect; uint32_t gfselect; - uint32_t guest_features[2]; + uint32_t guest_features[VIRTIO_FEATURES_WORDS]; VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX]; =20 VirtIOIRQFD *vector_irqfd; --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827412; cv=none; d=zohomail.com; s=zohoarc; b=LGPhiCezJwB86PQybEJOmdDpHU+cUp6iMo2+ZnmPmzOjp2L9B/4WYmqP2TI7tGFDZMfgl41vYDZa++aeG3n73UXSwNt04wkEn11jouQPY9AY1wERF7goFqFb6bz3nkUopxbQ3/usuWPihbacW2us3COMZjqg5/d7HTfv1f8T5Wo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827412; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c3p/a0Mco18zN0Bh70yv0+94scFUHDvA4mUep1qxnV8=; b=EpK+SVlTIpidYigtHEJQGqZQookkMHusdVXHC8Db58LKAWNL9B0xOdK78m65R/0MjLJlu+TtQ1DdPNfOYWFST8G0ojENiiIrfe0quJHNAXIqWDY61ktS7xZo2EjFTLtvdjFEeJ34V8ilRwvtgQpZfw15MzLjgvDn0I63dwGeiZ8= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827412891723.2829627808635; Wed, 21 May 2025 04:36:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhk9-0003q8-PC; Wed, 21 May 2025 07:36:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjm-0003dO-SD for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjk-000166-C6 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:35:54 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-113-O4I3zrhiMA-RbXf0OLtYNA-1; Wed, 21 May 2025 07:35:47 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 86365180034E; Wed, 21 May 2025 11:35:46 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B710519560B7; Wed, 21 May 2025 11:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c3p/a0Mco18zN0Bh70yv0+94scFUHDvA4mUep1qxnV8=; b=G2Z1dsQZg/hHtToYFdoLXlbn6BvRfW8QfL/ceAafVqER06q5toXkWsnK4ScKo+8W/BJKSD v8krPt3/aya3WxWrPOcJgzVNFD1JADc1qkDUKTlqIrZEc4Zw7jIGOsZyyQTh/+htSLejiU eJ32n53Op5EL8Qh+xVVAoXM80UcRufU= X-MC-Unique: O4I3zrhiMA-RbXf0OLtYNA-1 X-Mimecast-MFC-AGG-ID: O4I3zrhiMA-RbXf0OLtYNA_1747827346 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 08/16] vhost: add support for negotiating extended features. Date: Wed, 21 May 2025 13:34:02 +0200 Message-ID: <556d26160601ca8e2075ec3619aef4fe39725d11.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827415457116600 Content-Type: text/plain; charset="utf-8" Similar to virtio infra, vhost core maintain the features status in the widest format available and allow the devices to implement extended version of the getter/setter. Some care is needed for features bit manipulation: when clearing a bit with 'and not' bitwise operations, the bit mask must be extended to the feature format, or the all highest bits will be unintentionally cleared. Note that 'protocol_features' are not extended: they are only used by vhost-user, and the latter device is not going to implement extended features soon. Signed-off-by: Paolo Abeni --- hw/virtio/vhost.c | 58 ++++++++++++++++++++++++------- include/hw/virtio/vhost-backend.h | 10 ++++++ include/hw/virtio/vhost.h | 13 +++---- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 4cae7c1664..20592473f3 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -985,20 +985,34 @@ static int vhost_virtqueue_set_addr(struct vhost_dev = *dev, static int vhost_dev_set_features(struct vhost_dev *dev, bool enable_log) { - uint64_t features =3D dev->acked_features; + virtio_features_t features =3D dev->acked_features; int r; if (enable_log) { - features |=3D 0x1ULL << VHOST_F_LOG_ALL; + features |=3D VIRTIO_BIT(VHOST_F_LOG_ALL); } if (!vhost_dev_has_iommu(dev)) { - features &=3D ~(0x1ULL << VIRTIO_F_IOMMU_PLATFORM); + features &=3D ~VIRTIO_BIT(VIRTIO_F_IOMMU_PLATFORM); } if (dev->vhost_ops->vhost_force_iommu) { if (dev->vhost_ops->vhost_force_iommu(dev) =3D=3D true) { - features |=3D 0x1ULL << VIRTIO_F_IOMMU_PLATFORM; + features |=3D VIRTIO_BIT(VIRTIO_F_IOMMU_PLATFORM); } } - r =3D dev->vhost_ops->vhost_set_features(dev, features); + +#ifdef CONFIG_INT128 + if ((features >> 64) && !dev->vhost_ops->vhost_set_features_ex) { + VHOST_OPS_DEBUG(r, "extended features without device support"); + r =3D -EINVAL; + goto out; + } + + if (dev->vhost_ops->vhost_set_features_ex) { + r =3D dev->vhost_ops->vhost_set_features_ex(dev, features); + } else +#endif + { + r =3D dev->vhost_ops->vhost_set_features(dev, features); + } if (r < 0) { VHOST_OPS_DEBUG(r, "vhost_set_features failed"); goto out; @@ -1505,12 +1519,29 @@ static void vhost_virtqueue_cleanup(struct vhost_vi= rtqueue *vq) } } =20 +static int vhost_dev_get_features(struct vhost_dev *hdev, + virtio_features_t *features) +{ + uint64_t features64; + int r; + +#ifdef CONFIG_INT128 + if (hdev->vhost_ops->vhost_get_features_ex) + return hdev->vhost_ops->vhost_get_features_ex(hdev, features); + else +#endif + + r =3D hdev->vhost_ops->vhost_get_features(hdev, &features64); + *features =3D features64; + return r; +} + int vhost_dev_init(struct vhost_dev *hdev, void *opaque, VhostBackendType backend_type, uint32_t busyloop_timeou= t, Error **errp) { unsigned int used, reserved, limit; - uint64_t features; + virtio_features_t features; int i, r, n_initialized_vqs =3D 0; =20 hdev->vdev =3D NULL; @@ -1530,7 +1561,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, goto fail; } =20 - r =3D hdev->vhost_ops->vhost_get_features(hdev, &features); + r =3D vhost_dev_get_features(hdev, &features); if (r < 0) { error_setg_errno(errp, -r, "vhost_get_features failed"); goto fail; @@ -1591,7 +1622,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaq= ue, }; =20 if (hdev->migration_blocker =3D=3D NULL) { - if (!(hdev->features & (0x1ULL << VHOST_F_LOG_ALL))) { + if (!(hdev->features & VIRTIO_BIT(VHOST_F_LOG_ALL))) { error_setg(&hdev->migration_blocker, "Migration disabled: vhost lacks VHOST_F_LOG_ALL fe= ature."); } else if (vhost_dev_log_is_shared(hdev) && !qemu_memfd_alloc_chec= k()) { @@ -1860,12 +1891,13 @@ static void vhost_start_config_intr(struct vhost_de= v *dev) } } =20 -uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bit= s, - uint64_t features) +virtio_features_t vhost_get_features(struct vhost_dev *hdev, + const int *feature_bits, + virtio_features_t features) { const int *bit =3D feature_bits; while (*bit !=3D VHOST_INVALID_FEATURE_BIT) { - uint64_t bit_mask =3D (1ULL << *bit); + virtio_features_t bit_mask =3D VIRTIO_BIT(*bit); if (!(hdev->features & bit_mask)) { features &=3D ~bit_mask; } @@ -1875,11 +1907,11 @@ uint64_t vhost_get_features(struct vhost_dev *hdev,= const int *feature_bits, } =20 void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, - uint64_t features) + virtio_features_t features) { const int *bit =3D feature_bits; while (*bit !=3D VHOST_INVALID_FEATURE_BIT) { - uint64_t bit_mask =3D (1ULL << *bit); + virtio_features_t bit_mask =3D VIRTIO_BIT(*bit); if (features & bit_mask) { hdev->acked_features |=3D bit_mask; } diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-ba= ckend.h index d6df209a2f..de9bcaf95f 100644 --- a/include/hw/virtio/vhost-backend.h +++ b/include/hw/virtio/vhost-backend.h @@ -95,6 +95,12 @@ typedef int (*vhost_new_worker_op)(struct vhost_dev *dev, struct vhost_worker_state *worker); typedef int (*vhost_free_worker_op)(struct vhost_dev *dev, struct vhost_worker_state *worker); +#ifdef CONFIG_INT128 +typedef int (*vhost_set_features_ex_op)(struct vhost_dev *dev, + __uint128_t features); +typedef int (*vhost_get_features_ex_op)(struct vhost_dev *dev, + __uint128_t *features); +#endif typedef int (*vhost_set_features_op)(struct vhost_dev *dev, uint64_t features); typedef int (*vhost_get_features_op)(struct vhost_dev *dev, @@ -186,6 +192,10 @@ typedef struct VhostOps { vhost_free_worker_op vhost_free_worker; vhost_get_vring_worker_op vhost_get_vring_worker; vhost_attach_vring_worker_op vhost_attach_vring_worker; +#ifdef CONFIG_INT128 + vhost_set_features_ex_op vhost_set_features_ex; + vhost_get_features_ex_op vhost_get_features_ex; +#endif vhost_set_features_op vhost_set_features; vhost_get_features_op vhost_get_features; vhost_set_backend_cap_op vhost_set_backend_cap; diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index bb4b58e115..ea5ad117c5 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -106,9 +106,9 @@ struct vhost_dev { * future use should be discouraged and the variable retired as * its easy to confuse with the VirtIO backend_features. */ - uint64_t features; - uint64_t acked_features; - uint64_t backend_features; + virtio_features_t features; + virtio_features_t acked_features; + virtio_features_t backend_features; =20 /** * @protocol_features: is the vhost-user only feature set by @@ -308,8 +308,9 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtI= ODevice *vdev, int n, * is supported by the vhost backend (hdev->features), the supported * feature_bits and the requested feature set. */ -uint64_t vhost_get_features(struct vhost_dev *hdev, const int *feature_bit= s, - uint64_t features); +virtio_features_t vhost_get_features(struct vhost_dev *hdev, + const int *feature_bits, + virtio_features_t features); =20 /** * vhost_ack_features() - set vhost acked_features @@ -321,7 +322,7 @@ uint64_t vhost_get_features(struct vhost_dev *hdev, con= st int *feature_bits, * the backends advertised features and the supported feature_bits. */ void vhost_ack_features(struct vhost_dev *hdev, const int *feature_bits, - uint64_t features); + virtio_features_t features); unsigned int vhost_get_max_memslots(void); unsigned int vhost_get_free_memslots(void); =20 --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827445; cv=none; d=zohomail.com; s=zohoarc; b=N67fHZtlplilXplRNKfWKKckUL9qb1eT/ZV3y6IYzad8VvF868IweG7DihQbzTljz6CNWnZf0SfXjfCQRcyKlYHpdnp8ffxOgNaa8u7nNDv4hKKyWhbxY01XM0bZJqlzV01sySA8TvIAgwkUd/rXahYSeDQHRfobyFABb0GZ3I8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827445; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=enaBYQCINliwTGyHAbl3e/ASgYxjRCYgvrL673vfrl4=; b=WR+xCGkvxNaiAjHX22LVQnnONGCKqrG/AHiX30nexi+PsmJaPk81wYCaHkhbOe6P3Z0q0G8aEIr0REq0CR0E+qRvBK3JLw5j1nbfvVMyo07YOMrLg05aiv7iOMsFFgCODSYehgvB3OVGRTXfxI7bzpVxcfDnz5asLcOb+wrj8cI= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827444923346.5345425106201; Wed, 21 May 2025 04:37:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhk9-0003q6-OO; Wed, 21 May 2025 07:36:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjx-0003eQ-On for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjo-00016c-Na for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:05 -0400 Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-QwiUcKQgMIecFlxLmqYVdg-1; Wed, 21 May 2025 07:35:54 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E266A1954236; Wed, 21 May 2025 11:35:52 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3B85E19560B7; Wed, 21 May 2025 11:35:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827355; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=enaBYQCINliwTGyHAbl3e/ASgYxjRCYgvrL673vfrl4=; b=dfERX2pT9hB+smp7PJFTWT6wom/nBTsip2Sk2t65wB6UkRYusJsVpdnL1xbxmlYly8XH+L d21Vm3GvTIG40pw2c0fhZxHZqRscuevf6+AB0BNn7gPvm7P8lzQfrjTljM548lHVZ3xRX4 7WiINpio3IIihHgYxaXH3nbdpI//cQ0= X-MC-Unique: QwiUcKQgMIecFlxLmqYVdg-1 X-Mimecast-MFC-AGG-ID: QwiUcKQgMIecFlxLmqYVdg_1747827353 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 09/16] vhost-backend: implement extended features support. Date: Wed, 21 May 2025 13:34:03 +0200 Message-ID: <5f1afbf8865c9d51f01aa5ba3b09fb4449c458a0.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827445663116600 Content-Type: text/plain; charset="utf-8" Leverage the kernel extended features manipulation ioctls(), if available, and fallback to old ops otherwise. Error out when setting extended features but kernel support is not available. Note that extended support for get/set backend features is not needed, as the only feature that can be changed belongs to the 64 bit range. Signed-off-by: Paolo Abeni --- hw/virtio/vhost-backend.c | 59 +++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c index 833804dd40..a5e28e15ee 100644 --- a/hw/virtio/vhost-backend.c +++ b/hw/virtio/vhost-backend.c @@ -182,12 +182,6 @@ static int vhost_kernel_get_vring_worker(struct vhost_= dev *dev, return vhost_kernel_call(dev, VHOST_GET_VRING_WORKER, worker); } =20 -static int vhost_kernel_set_features(struct vhost_dev *dev, - uint64_t features) -{ - return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features); -} - static int vhost_kernel_set_backend_cap(struct vhost_dev *dev) { uint64_t features; @@ -210,11 +204,59 @@ static int vhost_kernel_set_backend_cap(struct vhost_= dev *dev) return 0; } =20 +#ifdef CONFIG_INT128 +static int vhost_kernel_set_features_ex(struct vhost_dev *dev, + virtio_features_t features) +{ + uint64_t features64; + int r; + + /* + * Can't check for ENOTTY, as the kernel for unknown ioctls interprets + * the argument as a virtio queue id and most likely errors out valida= ting + * such id, instead of reporting an unknown operation. + */ + r =3D vhost_kernel_call(dev, VHOST_SET_FEATURES_EX, &features); + if (!r) { + return 0; + } + + if (!!(features >> 64)) { + error_report("Trying to set extended features without kernel suppo= rt"); + return -EINVAL; + } + features64 =3D (uint64_t)features; + return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features64); +} + +static int vhost_kernel_get_features_ex(struct vhost_dev *dev, + virtio_features_t *features) +{ + uint64_t features64; + int r; + + r =3D vhost_kernel_call(dev, VHOST_GET_FEATURES_EX, features); + if (!r) { + return 0; + } + + r =3D vhost_kernel_call(dev, VHOST_GET_FEATURES, &features64); + *features =3D features64; + return r; +} +#else +static int vhost_kernel_set_features(struct vhost_dev *dev, + uint64_t features) +{ + return vhost_kernel_call(dev, VHOST_SET_FEATURES, &features); +} + static int vhost_kernel_get_features(struct vhost_dev *dev, uint64_t *features) { return vhost_kernel_call(dev, VHOST_GET_FEATURES, features); } +#endif =20 static int vhost_kernel_set_owner(struct vhost_dev *dev) { @@ -341,8 +383,13 @@ const VhostOps kernel_ops =3D { .vhost_attach_vring_worker =3D vhost_kernel_attach_vring_worker, .vhost_new_worker =3D vhost_kernel_new_worker, .vhost_free_worker =3D vhost_kernel_free_worker, +#ifdef CONFIG_INT128 + .vhost_set_features_ex =3D vhost_kernel_set_features_ex, + .vhost_get_features_ex =3D vhost_kernel_get_features_ex, +#else .vhost_set_features =3D vhost_kernel_set_features, .vhost_get_features =3D vhost_kernel_get_features, +#endif .vhost_set_backend_cap =3D vhost_kernel_set_backend_cap, .vhost_set_owner =3D vhost_kernel_set_owner, .vhost_get_vq_index =3D vhost_kernel_get_vq_index, --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827649; cv=none; d=zohomail.com; s=zohoarc; b=GcpLb8d8Uc9i2SRs64Jw+4x2ejORVs1vP+7/RwnejHFclrdEkcfItq+FAPVxTEqgS9nef7Y+3NYUPajewVrrF2IvTGaKWKsbPU3/4IeIQa7DCLTeGmhto3vjdnK/9jqNhzgrFdghIdpqtQnqM9/+YxDHEZ0bIQYSKXsk/S/p4Qs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827649; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/VNFzrq/Ooi4pork00bC5nqjr61W6Qox9V85Ynz5t7U=; b=i88+z/R0/2OQLUmJ7APC1hdsQy+wNFr7NETSw9QGSWRAPNA9nXePt8Zv9RQEgIzSII0Pmu4navWiv1PmJQhAh+PzHeZk2GAxLD4lhkX82X/LJUNkSBPG1pagwxzAB8CHTkTz3fho4zoMaaN2AmIHO9w3tsYc2U3d0rF+sKkWBKA= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827649406475.981322287642; Wed, 21 May 2025 04:40:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkD-0003rP-LY; Wed, 21 May 2025 07:36:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhk0-0003f7-T7 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhjx-00017c-PA for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:07 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-619-r1Rv4ylxPbKJjYg9vDuZTg-1; Wed, 21 May 2025 07:36:00 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E7814180034A; Wed, 21 May 2025 11:35:58 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 71FA419560B7; Wed, 21 May 2025 11:35:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/VNFzrq/Ooi4pork00bC5nqjr61W6Qox9V85Ynz5t7U=; b=QmjUdFsDTQmhbIgD9N2hIXfjduol7E10N4iaWLz3jsYQ32G133pPipkHCv3gmDI8LIMQz6 RcAJVpUrpkyccukos85wRY7TqnMGCCTR6lPoLUw44U+HGu5BzbeQNe31VBR4uk6rvX04en 9kQDxPl8qluQ6o/0S43vij0HWzJ9gn4= X-MC-Unique: r1Rv4ylxPbKJjYg9vDuZTg-1 X-Mimecast-MFC-AGG-ID: r1Rv4ylxPbKJjYg9vDuZTg_1747827359 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 10/16] vhost-net: implement extended features support. Date: Wed, 21 May 2025 13:34:04 +0200 Message-ID: <625a5d2173d582e58f90c96897e2ca569c73e4c3.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827652661116600 Content-Type: text/plain; charset="utf-8" Update the features manipulation helpers to cope with the extended features, adjust the relevant format strings accordingly and always use the virtio features type for bitmask manipulation. Signed-off-by: Paolo Abeni --- hw/net/vhost_net-stub.c | 7 ++++--- hw/net/vhost_net.c | 31 ++++++++++++++++++------------- include/net/vhost_net.h | 8 +++++--- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/hw/net/vhost_net-stub.c b/hw/net/vhost_net-stub.c index 72df6d757e..3997b3b814 100644 --- a/hw/net/vhost_net-stub.c +++ b/hw/net/vhost_net-stub.c @@ -47,7 +47,8 @@ void vhost_net_cleanup(struct vhost_net *net) { } =20 -uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) +virtio_features_t vhost_net_get_features(struct vhost_net *net, + virtio_features_t features) { return features; } @@ -63,11 +64,11 @@ int vhost_net_set_config(struct vhost_net *net, const u= int8_t *data, return 0; } =20 -void vhost_net_ack_features(struct vhost_net *net, uint64_t features) +void vhost_net_ack_features(struct vhost_net *net, virtio_features_t featu= res) { } =20 -uint64_t vhost_net_get_acked_features(VHostNetState *net) +virtio_features_t vhost_net_get_acked_features(VHostNetState *net) { return 0; } diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 891f235a0a..58d7619fc8 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -121,7 +121,8 @@ static const int *vhost_net_get_feature_bits(struct vho= st_net *net) return feature_bits; } =20 -uint64_t vhost_net_get_features(struct vhost_net *net, uint64_t features) +virtio_features_t vhost_net_get_features(struct vhost_net *net, + virtio_features_t features) { return vhost_get_features(&net->dev, vhost_net_get_feature_bits(net), features); @@ -137,7 +138,7 @@ int vhost_net_set_config(struct vhost_net *net, const u= int8_t *data, return vhost_dev_set_config(&net->dev, data, offset, size, flags); } =20 -void vhost_net_ack_features(struct vhost_net *net, uint64_t features) +void vhost_net_ack_features(struct vhost_net *net, virtio_features_t featu= res) { net->dev.acked_features =3D net->dev.backend_features; vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), feature= s); @@ -148,7 +149,7 @@ uint64_t vhost_net_get_max_queues(VHostNetState *net) return net->dev.max_queues; } =20 -uint64_t vhost_net_get_acked_features(VHostNetState *net) +virtio_features_t vhost_net_get_acked_features(VHostNetState *net) { return net->dev.acked_features; } @@ -317,10 +318,11 @@ static int vhost_net_get_fd(NetClientState *backend) =20 struct vhost_net *vhost_net_init(VhostNetOptions *options) { + virtio_features_t missing_features; int r; bool backend_kernel =3D options->backend_type =3D=3D VHOST_BACKEND_TYP= E_KERNEL; struct vhost_net *net =3D g_new0(struct vhost_net, 1); - uint64_t features =3D 0; + virtio_features_t features =3D 0; Error *local_err =3D NULL; =20 if (!options->net_backend) { @@ -361,12 +363,14 @@ struct vhost_net *vhost_net_init(VhostNetOptions *opt= ions) if (backend_kernel) { if (!qemu_has_vnet_hdr_len(options->net_backend, sizeof(struct virtio_net_hdr_mrg_rxbuf))) { - net->dev.features &=3D ~(1ULL << VIRTIO_NET_F_MRG_RXBUF); + net->dev.features &=3D ~VIRTIO_BIT(VIRTIO_NET_F_MRG_RXBUF); } - if (~net->dev.features & net->dev.backend_features) { - fprintf(stderr, "vhost lacks feature mask 0x%" PRIx64 - " for backend\n", - (uint64_t)(~net->dev.features & net->dev.backend_featur= es)); + + missing_features =3D ~net->dev.features & net->dev.backend_feature= s; + if (missing_features) { + fprintf(stderr, "vhost lacks feature mask 0x" VIRTIO_FEATURES_= FMT + " for backend\n", VIRTIO_FEATURES_HI(missing_features), + VIRTIO_FEATURES_LOW(missing_features)); goto fail; } } @@ -375,10 +379,11 @@ struct vhost_net *vhost_net_init(VhostNetOptions *opt= ions) #ifdef CONFIG_VHOST_NET_USER if (net->nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_USER) { features =3D vhost_user_get_acked_features(net->nc); - if (~net->dev.features & features) { - fprintf(stderr, "vhost lacks feature mask 0x%" PRIx64 - " for backend\n", - (uint64_t)(~net->dev.features & features)); + missing_features =3D ~net->dev.features & features; + if (missing_features) { + fprintf(stderr, "vhost lacks feature mask 0x" VIRTIO_FEATURES_= FMT + " for backend\n", VIRTIO_FEATURES_HI(missing_features), + VIRTIO_FEATURES_LOW(missing_features)); goto fail; } } diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h index c6a5361a2a..d7d733b7ad 100644 --- a/include/net/vhost_net.h +++ b/include/net/vhost_net.h @@ -2,6 +2,7 @@ #define VHOST_NET_H =20 #include "net/net.h" +#include "hw/virtio/virtio-features.h" #include "hw/virtio/vhost-backend.h" =20 struct vhost_net; @@ -25,8 +26,9 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *nc= s, =20 void vhost_net_cleanup(VHostNetState *net); =20 -uint64_t vhost_net_get_features(VHostNetState *net, uint64_t features); -void vhost_net_ack_features(VHostNetState *net, uint64_t features); +virtio_features_t vhost_net_get_features(VHostNetState *net, + virtio_features_t features); +void vhost_net_ack_features(VHostNetState *net, virtio_features_t features= ); =20 int vhost_net_get_config(struct vhost_net *net, uint8_t *config, uint32_t config_len); @@ -43,7 +45,7 @@ VHostNetState *get_vhost_net(NetClientState *nc); =20 int vhost_set_vring_enable(NetClientState * nc, int enable); =20 -uint64_t vhost_net_get_acked_features(VHostNetState *net); +virtio_features_t vhost_net_get_acked_features(VHostNetState *net); =20 int vhost_net_set_mtu(struct vhost_net *net, uint16_t mtu); =20 --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827484; cv=none; d=zohomail.com; s=zohoarc; b=WXgAz5mXqu5+u5Qc5DQkG4iDiXaxksBlE9UaB76smAcpCTVu0oLAkN0JqRk8r1UKg1NEqj0qPGWYd+2WyTauXAzEFIXxcDTAj7D53oY+zMD4md9QNh+sKc1y8+X166yB0drp1PWMj+scAoirPHfIDQQdnQzgmITmt16LMtZl38E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827484; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4ZpCLgvWatSfPeBcPKsV0twpfMUST5XFoEJrjxQz8ks=; b=Zl9cYDvg5FnpvBmytLTd0D/yVGPFdI2y5QTcXm6g8SuiG986lB5r7RLFI70XWSLCuY8PwcuPrq8roM25cUv/6gkc3K283utRtpQsTIZ2pgfWys6H2vaK+rq6jVkn9fCYeDE8DCHsdvDQp6IBUWWY2Kl4PnjSRN6f/q93mXPJCWw= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827484454319.5563035840174; Wed, 21 May 2025 04:38:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkB-0003qP-4T; Wed, 21 May 2025 07:36:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhk7-0003ml-82 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhk2-00018P-Qb for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:14 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-648-9cUalADxOlml1Pa-w_8PZQ-1; Wed, 21 May 2025 07:36:06 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E5C661956088; Wed, 21 May 2025 11:36:04 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7218D19560B7; Wed, 21 May 2025 11:35:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4ZpCLgvWatSfPeBcPKsV0twpfMUST5XFoEJrjxQz8ks=; b=doroJnRRg/BWirc4IWeFoABmd3aFrx0EIYyybgaxVMoWlqCtilK5e5A8THIePOwy/c1hQh RlBbU32JcQEBqr0yFSWMZUfpuXCJ4Nf0RN6qWvRkMdz/tbFJ6/Xhwes4Agw9IFsm5sz4Wb NPk9vjN38dzBypu6LNI/LZohefkI6Jw= X-MC-Unique: 9cUalADxOlml1Pa-w_8PZQ-1 X-Mimecast-MFC-AGG-ID: 9cUalADxOlml1Pa-w_8PZQ_1747827365 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 11/16] qdev-properties: add property for extended virtio features Date: Wed, 21 May 2025 13:34:05 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827486157116600 Content-Type: text/plain; charset="utf-8" Virtio features extend above the 64 bit space, and GSO over UDP tunnels support is going to use some bits in the extended space. Introduce a new Property type to handle the extended feature defined in the previous patch. Signed-off-by: Paolo Abeni --- hw/core/qdev-properties.c | 46 ++++++++++++++++++++++++++++++++++++ include/hw/qdev-properties.h | 13 ++++++++++ 2 files changed, 59 insertions(+) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 147b3ffd16..2a0182479c 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -225,6 +225,52 @@ const PropertyInfo qdev_prop_bit64 =3D { .set_default_value =3D set_default_value_bool, }; =20 +/* Bit virtio features __int128_t */ +#ifdef CONFIG_INT128 +static void vf_prop_set(Object *obj, const Property *props, bool val) +{ + __int128_t *vf =3D object_field_prop_ptr(obj, props); + assert(props->info =3D=3D &qdev_prop_bitvf); + if (val) { + *vf |=3D (__int128_t)1 << props->bitnr; + } else { + *vf &=3D ~((__int128_t)1 << props->bitnr); + } +} + +static void prop_get_bitvf(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + const Property *prop =3D opaque; + __int128_t *vf =3D object_field_prop_ptr(obj, prop); + bool value; + + assert(prop->info =3D=3D &qdev_prop_bitvf); + value =3D *vf & ((__int128_t)1 << prop->bitnr); + visit_type_bool(v, name, &value, errp); +} + +static void prop_set_bitvf(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + const Property *prop =3D opaque; + bool value; + + if (!visit_type_bool(v, name, &value, errp)) { + return; + } + vf_prop_set(obj, prop, value); +} + +const PropertyInfo qdev_prop_bitvf =3D { + .type =3D "bool", + .description =3D "on/off", + .get =3D prop_get_bitvf, + .set =3D prop_set_bitvf, + .set_default_value =3D set_default_value_bool, +}; +#endif + /* --- bool --- */ =20 static void get_bool(Object *obj, Visitor *v, const char *name, void *opaq= ue, diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h index 2c99856caa..7760dd6dbd 100644 --- a/include/hw/qdev-properties.h +++ b/include/hw/qdev-properties.h @@ -100,6 +100,19 @@ extern const PropertyInfo qdev_prop_link; .set_default =3D true, \ .defval.u =3D (bool)_defval) =20 +#ifdef CONFIG_INT128 +extern const PropertyInfo qdev_prop_bitvf; + +#define DEFINE_PROP_BITVF(_name, _state, _field, _bit, _defval) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_bitvf, \ + virtio_features_t, \ + .bitnr =3D (_bit), \ + .set_default =3D true, \ + .defval.u =3D (bool)_defval) +#else +#define qdev_prop_bitvf qdev_prop_bit64 +#endif + #define DEFINE_PROP_BOOL(_name, _state, _field, _defval) \ DEFINE_PROP(_name, _state, _field, qdev_prop_bool, bool, \ .set_default =3D true, \ --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827466; cv=none; d=zohomail.com; s=zohoarc; b=gjaUwIc1U2F8UKabGWi3h1bKU5dbqTHOaEcyoHFgTxaDQvZdFUs6KUtMERt500iXIu02ZxMgIJMVbup/e9TClxTNob9J8qG3+l2s/KvLvGsO+hzS6J224nsy/422a7EbqPkE/ED2Unmq8jFMmjAeqBH+ItjELNfh3GA5b5IkksY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827466; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4Qnkj3gk794sIguByyjpMjyUEyEFTPe94F5f1GjfOo8=; b=A1m7BTefD6ank1LwcUlss9Fv7aHjByLUlhkfvnX7fYJEzrFi0UKqOr7eAzxKbtD2bYDnMTdAo/cI2FB75HloxI47fBnkr6b80akGl4QnS1N8acCdfX+9IrCranBfCsJp5oFozTmJZTqUl5UP3c2qUfrmmH0IF/9prKtNttgzikQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827466153146.20530351972468; Wed, 21 May 2025 04:37:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkF-0003s4-9q; Wed, 21 May 2025 07:36:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkD-0003rl-P8 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhk8-00019H-T5 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:21 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-437-zSjoF4hBNNyVbJC39j5qHw-1; Wed, 21 May 2025 07:36:12 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 234431956080; Wed, 21 May 2025 11:36:11 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7251A19560B7; Wed, 21 May 2025 11:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4Qnkj3gk794sIguByyjpMjyUEyEFTPe94F5f1GjfOo8=; b=X3RRqU2iAd3Ga9WUCTF45w5q0o5y6LbWcukTDtEeluzvq631f4gWDmkgdFB/DKXZzo82/u uX4R8GEIwMULKy0tPp37UoxH+0PekESFr29C41hqKzZuHeWwyllp2uCMTo3gEUNccBaJWI 55Gcjxn1NHaB7TVjzeZ0qbMm5+P8YEc= X-MC-Unique: zSjoF4hBNNyVbJC39j5qHw-1 X-Mimecast-MFC-AGG-ID: zSjoF4hBNNyVbJC39j5qHw_1747827371 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 12/16] virtio-net: implement extended features support. Date: Wed, 21 May 2025 13:34:06 +0200 Message-ID: <8fb9f142e25a0f1b01e8cf54a6c2a0971db00d83.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827468195116600 Content-Type: text/plain; charset="utf-8" Use the extended types and helpers to manipulate the virtio_net features. Note that offloads are still 64bits wide, as per specification, and extended offloads will be mapped into such range. Signed-off-by: Paolo Abeni --- hw/net/virtio-net.c | 87 +++++++++++++++++++++------------- include/hw/virtio/virtio-net.h | 2 +- 2 files changed, 55 insertions(+), 34 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 9f500c64e7..193469fc27 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -90,6 +90,17 @@ VIRTIO_NET_RSS_HASH_TYPE_TCP_EX |= \ VIRTIO_NET_RSS_HASH_TYPE_UDP_EX) =20 +#define VIRTIO_OFFLOAD_MAP_MIN 46 +#define VIRTIO_OFFLOAD_MAP_LENGTH 4 +#define VIRTIO_OFFLOAD_MAP MAKE_64BIT_MASK(VIRTIO_OFFLOAD_MAP_MIN, \ + VIRTIO_OFFLOAD_MAP_LENGTH) +#define VIRTIO_FEATURES_MAP_MIN 65 +#define VIRTIO_O2F_DELTA (VIRTIO_FEATURES_MAP_MIN - \ + VIRTIO_OFFLOAD_MAP_MIN) + +#define VIRTIO_FEATURE_TO_OFFLOAD(fbit) (fbit >=3D 64 ? \ + fbit - VIRTIO_O2F_DELTA : fbit) + static const VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, @@ -751,44 +762,45 @@ static void virtio_net_set_queue_pairs(VirtIONet *n) =20 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue); =20 -static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t featu= res, - Error **errp) +static virtio_features_t virtio_net_get_features(VirtIODevice *vdev, + virtio_features_t feature= s, + Error **errp) { VirtIONet *n =3D VIRTIO_NET(vdev); NetClientState *nc =3D qemu_get_queue(n->nic); =20 /* Firstly sync all virtio-net possible supported features */ - features |=3D n->host_features; + features |=3D n->host_features_ex; =20 - virtio_add_feature(&features, VIRTIO_NET_F_MAC); + virtio_add_feature_ex(&features, VIRTIO_NET_F_MAC); =20 if (!peer_has_vnet_hdr(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_CSUM); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO4); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_TSO6); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_ECN); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_CSUM); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_TSO4); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_TSO6); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_ECN); =20 - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_CSUM); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO4); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_TSO6); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ECN); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_CSUM); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_TSO4); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_TSO6); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_ECN); =20 - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_USO); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO4); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO6); =20 - virtio_clear_feature(&features, VIRTIO_NET_F_HASH_REPORT); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HASH_REPORT); } =20 if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_UFO); - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_UFO); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_UFO); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_UFO); } =20 if (!peer_has_uso(n)) { - virtio_clear_feature(&features, VIRTIO_NET_F_HOST_USO); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO4); - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_USO6); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_USO); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO4); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO6); } =20 if (!get_vhost_net(nc->peer)) { @@ -796,7 +808,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, } =20 if (!ebpf_rss_is_loaded(&n->ebpf_rss)) { - virtio_clear_feature(&features, VIRTIO_NET_F_RSS); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_RSS); } features =3D vhost_net_get_features(get_vhost_net(nc->peer), features); vdev->backend_features_ex =3D features; @@ -818,7 +830,7 @@ static uint64_t virtio_net_get_features(VirtIODevice *v= dev, uint64_t features, * support it. */ if (!virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_CTRL_VQ))= { - virtio_clear_feature(&features, VIRTIO_NET_F_GUEST_ANNOUNCE); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_ANNOUNCE); } =20 return features; @@ -851,9 +863,16 @@ static void virtio_net_apply_guest_offloads(VirtIONet = *n) !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6))= ); } =20 -static uint64_t virtio_net_guest_offloads_by_features(uint64_t features) +static uint64_t virtio_net_features_to_offload(virtio_features_t features) +{ + return (features & ~VIRTIO_OFFLOAD_MAP) | + ((features >> VIRTIO_O2F_DELTA) & VIRTIO_OFFLOAD_MAP); +} + +static uint64_t +virtio_net_guest_offloads_by_features(virtio_features_t features) { - static const uint64_t guest_offloads_mask =3D + static const virtio_features_t guest_offloads_mask =3D (1ULL << VIRTIO_NET_F_GUEST_CSUM) | (1ULL << VIRTIO_NET_F_GUEST_TSO4) | (1ULL << VIRTIO_NET_F_GUEST_TSO6) | @@ -862,13 +881,13 @@ static uint64_t virtio_net_guest_offloads_by_features= (uint64_t features) (1ULL << VIRTIO_NET_F_GUEST_USO4) | (1ULL << VIRTIO_NET_F_GUEST_USO6); =20 - return guest_offloads_mask & features; + return guest_offloads_mask & virtio_net_features_to_offload(features); } =20 uint64_t virtio_net_supported_guest_offloads(const VirtIONet *n) { VirtIODevice *vdev =3D VIRTIO_DEVICE(n); - return virtio_net_guest_offloads_by_features(vdev->guest_features); + return virtio_net_guest_offloads_by_features(vdev->guest_features_ex); } =20 typedef struct { @@ -947,7 +966,8 @@ static void failover_add_primary(VirtIONet *n, Error **= errp) error_propagate(errp, err); } =20 -static void virtio_net_set_features(VirtIODevice *vdev, uint64_t features) +static void virtio_net_set_features(VirtIODevice *vdev, + virtio_features_t features) { VirtIONet *n =3D VIRTIO_NET(vdev); Error *err =3D NULL; @@ -955,7 +975,7 @@ static void virtio_net_set_features(VirtIODevice *vdev,= uint64_t features) =20 if (n->mtu_bypass_backend && !virtio_has_feature(vdev->backend_features, VIRTIO_NET_F_MTU))= { - features &=3D ~(1ULL << VIRTIO_NET_F_MTU); + features &=3D ~VIRTIO_BIT(VIRTIO_NET_F_MTU); } =20 virtio_net_set_multiqueue(n, @@ -1962,10 +1982,11 @@ static ssize_t virtio_net_receive_rcu(NetClientStat= e *nc, const uint8_t *buf, virtio_error(vdev, "virtio-net unexpected empty queue: " "i %zd mergeable %d offset %zd, size %zd, " "guest hdr len %zd, host hdr len %zd " - "guest features 0x%" PRIx64, + "guest features 0x" VIRTIO_FEATURES_FMT, i, n->mergeable_rx_bufs, offset, size, n->guest_hdr_len, n->host_hdr_len, - vdev->guest_features); + VIRTIO_FEATURES_HI(vdev->guest_features_ex), + VIRTIO_FEATURES_LOW(vdev->guest_features_ex)); } err =3D -1; goto err; @@ -4146,8 +4167,8 @@ static void virtio_net_class_init(ObjectClass *klass,= const void *data) vdc->unrealize =3D virtio_net_device_unrealize; vdc->get_config =3D virtio_net_get_config; vdc->set_config =3D virtio_net_set_config; - vdc->get_features =3D virtio_net_get_features; - vdc->set_features =3D virtio_net_set_features; + vdc->get_features_ex =3D virtio_net_get_features; + vdc->set_features_ex =3D virtio_net_set_features; vdc->bad_features =3D virtio_net_bad_features; vdc->reset =3D virtio_net_reset; vdc->queue_reset =3D virtio_net_queue_reset; diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index b9ea9e824e..5ccdbeb253 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -178,7 +178,7 @@ struct VirtIONet { uint32_t has_vnet_hdr; size_t host_hdr_len; size_t guest_hdr_len; - uint64_t host_features; + DECLARE_FEATURES(host_features); uint32_t rsc_timeout; uint8_t rsc4_enabled; uint8_t rsc6_enabled; --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827472; cv=none; d=zohomail.com; s=zohoarc; b=g88HccSCHDGTiA4JTFlpATAvbPc/hr2Aj2l7FHu2BHthDlKDaKVorSgG8RDfWCf6nWggzC9OOMDhgZjYxoPoPbGMXv1L44U7L5PFf/DeVRlSn8eteVPztUSF6cr+4+whAJPt0AiSqqDCeQpgw7YYGHncppG7jerG6c4n5tqZyas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827472; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vA1d/ZWaKK3z0tALUDfF3uh5oVonzx2JrfcgtKWPP5s=; b=U0tdRfHDPRYt3Xw2A7eW+YIfaUF2Ah8hZZi7FGZiNmSMj6udmVo/7vc/mQonzINAq+Ql9DITI1jf2qowK7rg6iMZt4oes5emUDNnE4spMk4+lOdiUEb58QvJzxvJBcmGV7tBgWgBiIjueVJEaEDdEVFqd2eHP5+JaSKN/0nysMo= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827472950261.089142081765; Wed, 21 May 2025 04:37:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkP-00042F-JM; Wed, 21 May 2025 07:36:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkN-00041X-Ei for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkK-0001AH-Ut for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:31 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-LyxuLCPpNnmhL4AgDH5d5Q-1; Wed, 21 May 2025 07:36:18 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3F795180048E; Wed, 21 May 2025 11:36:17 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A3FF3195607A; Wed, 21 May 2025 11:36:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vA1d/ZWaKK3z0tALUDfF3uh5oVonzx2JrfcgtKWPP5s=; b=Fgfrsf3GcZemxWMa1wg71FhbEGRG1XI82jZa/0qHIcsMUehgKv9SsX8TFV4TcfxzgIeMVo zzNuW6GpEwpCevE6Qv8e135djsbd8eC6UXQHr7oRKKg0RbBjZi7cV5HByu5kScgIxB2iUF 7HUimDrgcfSoiHaOpDTNyiACK7bHuoQ= X-MC-Unique: LyxuLCPpNnmhL4AgDH5d5Q-1 X-Mimecast-MFC-AGG-ID: LyxuLCPpNnmhL4AgDH5d5Q_1747827377 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 13/16] net: implement tunnel probing Date: Wed, 21 May 2025 13:34:07 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827474433116600 Content-Type: text/plain; charset="utf-8" Tap devices support GSO over UDP tunnel offload. Probe for such feature in a similar manner to other offloads. GSO over UDP tunnel needs to be enabled in addition to a "plain" offload (TSO or USO). No need to check separately for the outer header checksum offload: the kernel is going to support both of them or none. Signed-off-by: Paolo Abeni --- hw/net/virtio-net.c | 39 +++++++++++++++++++++++++++++++++++++++ include/net/net.h | 3 +++ net/net.c | 9 +++++++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 19 +++++++++++++++++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 11 +++++++++++ net/tap_int.h | 1 + 9 files changed, 97 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 193469fc27..05cf23700f 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -646,6 +646,15 @@ static int peer_has_uso(VirtIONet *n) return qemu_has_uso(qemu_get_queue(n->nic)->peer); } =20 +static int peer_has_tunnel(VirtIONet *n) +{ + if (!peer_has_vnet_hdr(n)) { + return 0; + } + + return qemu_has_tunnel(qemu_get_queue(n->nic)->peer); +} + static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, int version_1, int hash_report) { @@ -789,6 +798,15 @@ static virtio_features_t virtio_net_get_features(VirtI= ODevice *vdev, virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO4); virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO6); =20 +#ifdef CONFIG_INT128 + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_G= SO); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GS= O); + virtio_clear_feature_ex(&features, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM); + virtio_clear_feature_ex(&features, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM); +#endif + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HASH_REPORT); } =20 @@ -803,6 +821,17 @@ static virtio_features_t virtio_net_get_features(VirtI= ODevice *vdev, virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_USO6); } =20 +#ifdef CONFIG_INT128 + if (!peer_has_tunnel(n)) { + virtio_clear_feature_ex(&features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_G= SO); + virtio_clear_feature_ex(&features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GS= O); + virtio_clear_feature_ex(&features, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM); + virtio_clear_feature_ex(&features, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM); + } +#endif + if (!get_vhost_net(nc->peer)) { return features; } @@ -4153,6 +4182,16 @@ static const Property virtio_net_properties[] =3D { VIRTIO_NET_F_GUEST_USO6, true), DEFINE_PROP_BIT64("host_uso", VirtIONet, host_features, VIRTIO_NET_F_HOST_USO, true), +#ifdef CONFIG_INT128 + DEFINE_PROP_BITVF("host_tunnel", VirtIONet, host_features_ex, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO, true), + DEFINE_PROP_BITVF("host_tunnel_csum", VirtIONet, host_features_ex, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO_CSUM, true), + DEFINE_PROP_BITVF("guest_tunnel", VirtIONet, host_features_ex, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO, true), + DEFINE_PROP_BITVF("guest_tunnel_csum", VirtIONet, host_features_ex, + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM, true), +#endif }; =20 static void virtio_net_class_init(ObjectClass *klass, const void *data) diff --git a/include/net/net.h b/include/net/net.h index cdd5b109b0..391d983e49 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -55,6 +55,7 @@ typedef void (NetClientDestructor)(NetClientState *); typedef RxFilterInfo *(QueryRxFilter)(NetClientState *); typedef bool (HasUfo)(NetClientState *); typedef bool (HasUso)(NetClientState *); +typedef bool (HasTunnel)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, = int); @@ -83,6 +84,7 @@ typedef struct NetClientInfo { NetPoll *poll; HasUfo *has_ufo; HasUso *has_uso; + HasTunnel *has_tunnel; HasVnetHdr *has_vnet_hdr; HasVnetHdrLen *has_vnet_hdr_len; SetOffload *set_offload; @@ -183,6 +185,7 @@ void qemu_set_info_str(NetClientState *nc, void qemu_format_nic_info_str(NetClientState *nc, uint8_t macaddr[6]); bool qemu_has_ufo(NetClientState *nc); bool qemu_has_uso(NetClientState *nc); +bool qemu_has_tunnel(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, diff --git a/net/net.c b/net/net.c index 39d6f28158..9c83d3b137 100644 --- a/net/net.c +++ b/net/net.c @@ -522,6 +522,15 @@ bool qemu_has_uso(NetClientState *nc) return nc->info->has_uso(nc); } =20 +bool qemu_has_tunnel(NetClientState *nc) +{ + if (!nc || !nc->info->has_tunnel) { + return false; + } + + return nc->info->has_tunnel(nc); +} + bool qemu_has_vnet_hdr(NetClientState *nc) { if (!nc || !nc->info->has_vnet_hdr) { diff --git a/net/tap-bsd.c b/net/tap-bsd.c index b4c84441ba..3f01c8921e 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -217,6 +217,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +int tap_probe_has_tunnel(int fd) +{ + return 0; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap-linux.c b/net/tap-linux.c index 22ec2f45d2..2df601551e 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -37,6 +37,14 @@ =20 #define PATH_NET_TUN "/dev/net/tun" =20 +#ifndef TUN_F_UDP_TUNNEL_GSO +#define TUN_F_UDP_TUNNEL_GSO 0x080 +#endif + +#ifndef TUN_F_UDP_TUNNEL_GSO_CSUM +#define TUN_F_UDP_TUNNEL_GSO_CSUM 0x100 +#endif + int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp) { @@ -196,6 +204,17 @@ int tap_probe_has_uso(int fd) return 1; } =20 +int tap_probe_has_tunnel(int fd) +{ + unsigned offload; + + offload =3D TUN_F_CSUM | TUN_F_TSO4 | TUN_F_UDP_TUNNEL_GSO; + if (ioctl(fd, TUNSETOFFLOAD, offload) < 0) { + return 0; + } + return 1; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { if (ioctl(fd, TUNSETVNETHDRSZ, &len) =3D=3D -1) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index 51b7830bef..b1aa40d46b 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -221,6 +221,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +int tap_probe_has_tunnel(int fd) +{ + return 0; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap-stub.c b/net/tap-stub.c index 38673434cb..5f57d6baac 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -52,6 +52,11 @@ int tap_probe_has_uso(int fd) return 0; } =20 +int tap_probe_has_tunnel(int fd) +{ + return 0; +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { } diff --git a/net/tap.c b/net/tap.c index ae1c7e3983..f6e8cd5f1c 100644 --- a/net/tap.c +++ b/net/tap.c @@ -58,6 +58,7 @@ typedef struct TAPState { bool using_vnet_hdr; bool has_ufo; bool has_uso; + bool has_tunnel; bool enabled; VHostNetState *vhost_net; unsigned host_vnet_hdr_len; @@ -223,6 +224,14 @@ static bool tap_has_uso(NetClientState *nc) return s->has_uso; } =20 +static bool tap_has_tunnel(NetClientState *nc) +{ + TAPState *s =3D DO_UPCAST(TAPState, nc, nc); + + assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_TAP); + return s->has_tunnel; +} + static bool tap_has_vnet_hdr(NetClientState *nc) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); @@ -340,6 +349,7 @@ static NetClientInfo net_tap_info =3D { .cleanup =3D tap_cleanup, .has_ufo =3D tap_has_ufo, .has_uso =3D tap_has_uso, + .has_tunnel =3D tap_has_tunnel, .has_vnet_hdr =3D tap_has_vnet_hdr, .has_vnet_hdr_len =3D tap_has_vnet_hdr_len, .set_offload =3D tap_set_offload, @@ -367,6 +377,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->using_vnet_hdr =3D false; s->has_ufo =3D tap_probe_has_ufo(s->fd); s->has_uso =3D tap_probe_has_uso(s->fd); + s->has_tunnel =3D tap_probe_has_tunnel(s->fd); s->enabled =3D true; tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); /* diff --git a/net/tap_int.h b/net/tap_int.h index 8857ff299d..2a8aa3632f 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -37,6 +37,7 @@ void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, = Error **errp); int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_has_ufo(int fd); int tap_probe_has_uso(int fd); +int tap_probe_has_tunnel(int fd); void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int= ufo, int uso4, int uso6); void tap_fd_set_vnet_hdr_len(int fd, int len); --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827645; cv=none; d=zohomail.com; s=zohoarc; b=lM3BRYXriTcO7BSpjniybrIYO1yAPJjAYHGUDtAnhemHnmt0jFU4xjVdVHhA3YXkzw7fxnlssGLunrjqf9LI7roYs+rzD0g9YXn0cQgUZGE4oIyG0QNpqviR/RWzgfQLcnRnGPLUEL0XSH6N8LCn+C6bn2EtYFLfJjEWvHrznqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827645; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=wMjzeewNVky4/obxdybXw193KgJIslzO/xqBUfEBPds=; b=Hw3AhXemFYVVelLU/iFSHGDGsTAXPmaLrXFACp9Om5aSe1Rkrrzg/Xf1n9x047r48hRMU1Z6lu0Xl5iQ2bmhyupa7WmpdOQlXIGkCFfsBOCMNZl9jNYAEKjfMTIWk3GFErpRyfTVN7OG1Jg4iq55Av2meAzSWYnUTwsGW70/9tw= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827645411858.1876084715142; Wed, 21 May 2025 04:40:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkV-00043P-1r; Wed, 21 May 2025 07:36:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkT-00043A-Fr for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkN-0001Am-K7 for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:37 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-251-07EyYkpuMp6FMnF_MUBfZQ-1; Wed, 21 May 2025 07:36:24 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3862719560B4; Wed, 21 May 2025 11:36:23 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B29B519560B7; Wed, 21 May 2025 11:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827389; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMjzeewNVky4/obxdybXw193KgJIslzO/xqBUfEBPds=; b=ATvFcfNikv97VWHw6oYZWRsGC44apbRyp0wvqvSOJ6tnNNZhsAHSVSpFMsS09GDhTWdwON tiXsIDipixaC89GLYq0bi345AU6B3UA7fPoIQbrexqMlnmf1iuEgODg+RUDINOLz5fQg37 yG+by2IMB9sJLumRearDE4juV2UQFGE= X-MC-Unique: 07EyYkpuMp6FMnF_MUBfZQ-1 X-Mimecast-MFC-AGG-ID: 07EyYkpuMp6FMnF_MUBfZQ_1747827383 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 14/16] net: bundle all offloads in a single struct Date: Wed, 21 May 2025 13:34:08 +0200 Message-ID: <828ccacae4b84313327242cd716f46f711d5849b.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827652867116600 Content-Type: text/plain; charset="utf-8" The set_offload() argument list is already pretty long and we are going to introduce soon a bunch of additional offloads. Replace the offload arguments with a single struct and update all the relevant call-sites. No functional changes intended. Signed-off-by: Paolo Abeni --- hw/net/e1000e_core.c | 5 +++-- hw/net/igb_core.c | 5 +++-- hw/net/virtio-net.c | 19 +++++++++++-------- hw/net/vmxnet3.c | 13 +++++-------- include/net/net.h | 15 ++++++++++++--- net/net.c | 5 ++--- net/netmap.c | 3 +-- net/tap-bsd.c | 3 +-- net/tap-linux.c | 21 ++++++++++++--------- net/tap-solaris.c | 4 ++-- net/tap-stub.c | 3 +-- net/tap.c | 8 ++++---- net/tap_int.h | 4 ++-- 13 files changed, 59 insertions(+), 49 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 2413858790..ec90869e56 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2827,8 +2827,9 @@ e1000e_update_rx_offloads(E1000ECore *core) trace_e1000e_rx_set_cso(cso_state); =20 if (core->has_vnet) { - qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0, 0, 0); + struct NetOffloads ol =3D {.csum =3D cso_state }; + + qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, &ol); } } =20 diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 39e3ce1c8f..e940d3a8e2 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -3058,8 +3058,9 @@ igb_update_rx_offloads(IGBCore *core) trace_e1000e_rx_set_cso(cso_state); =20 if (core->has_vnet) { - qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, - cso_state, 0, 0, 0, 0, 0, 0); + struct NetOffloads ol =3D {.csum =3D cso_state }; + + qemu_set_offload(qemu_get_queue(core->owner_nic)->peer, &ol); } } =20 diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 05cf23700f..881877086e 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -882,14 +882,17 @@ static uint64_t virtio_net_bad_features(VirtIODevice = *vdev) =20 static void virtio_net_apply_guest_offloads(VirtIONet *n) { - qemu_set_offload(qemu_get_queue(n->nic)->peer, - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_CSUM)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO4)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_TSO6)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_ECN)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_UFO)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO4)), - !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_USO6))= ); + NetOffloads ol =3D { + .csum =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_C= SUM)), + .tso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_T= SO4)), + .tso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_T= SO6)), + .ecn =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_E= CN)), + .ufo =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= FO)), + .uso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO4)), + .uso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO6)), + }; + + qemu_set_offload(qemu_get_queue(n->nic)->peer, &ol); } =20 static uint64_t virtio_net_features_to_offload(virtio_features_t features) diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 83d942af17..dbacb4aa18 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -1334,14 +1334,11 @@ static void vmxnet3_update_features(VMXNET3State *s) s->lro_supported, rxcso_supported, s->rx_vlan_stripping); if (s->peer_has_vhdr) { - qemu_set_offload(qemu_get_queue(s->nic)->peer, - rxcso_supported, - s->lro_supported, - s->lro_supported, - 0, - 0, - 0, - 0); + struct NetOffloads ol =3D { .csum =3D rxcso_supported, + .tso4 =3D s->lro_supported, + .tso6 =3D s->lro_supported }; + + qemu_set_offload(qemu_get_queue(s->nic)->peer, &ol); } } =20 diff --git a/include/net/net.h b/include/net/net.h index 391d983e49..c71d7c6074 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -35,6 +35,16 @@ typedef struct NICConf { int32_t bootindex; } NICConf; =20 +typedef struct NetOffloads { + bool csum; + bool tso4; + bool tso6; + bool ecn; + bool ufo; + bool uso4; + bool uso6; +} NetOffloads; + #define DEFINE_NIC_PROPERTIES(_state, _conf) \ DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ DEFINE_PROP_NETDEV("netdev", _state, _conf.peers) @@ -58,7 +68,7 @@ typedef bool (HasUso)(NetClientState *); typedef bool (HasTunnel)(NetClientState *); typedef bool (HasVnetHdr)(NetClientState *); typedef bool (HasVnetHdrLen)(NetClientState *, int); -typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, = int); +typedef void (SetOffload)(NetClientState *, const NetOffloads *); typedef int (GetVnetHdrLen)(NetClientState *); typedef void (SetVnetHdrLen)(NetClientState *, int); typedef int (SetVnetLE)(NetClientState *, bool); @@ -188,8 +198,7 @@ bool qemu_has_uso(NetClientState *nc); bool qemu_has_tunnel(NetClientState *nc); bool qemu_has_vnet_hdr(NetClientState *nc); bool qemu_has_vnet_hdr_len(NetClientState *nc, int len); -void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo, int uso4, int uso6); +void qemu_set_offload(NetClientState *nc, const NetOffloads *ol); int qemu_get_vnet_hdr_len(NetClientState *nc); void qemu_set_vnet_hdr_len(NetClientState *nc, int len); int qemu_set_vnet_le(NetClientState *nc, bool is_le); diff --git a/net/net.c b/net/net.c index 9c83d3b137..5a2f00c108 100644 --- a/net/net.c +++ b/net/net.c @@ -549,14 +549,13 @@ bool qemu_has_vnet_hdr_len(NetClientState *nc, int le= n) return nc->info->has_vnet_hdr_len(nc, len); } =20 -void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6, - int ecn, int ufo, int uso4, int uso6) +void qemu_set_offload(NetClientState *nc, const NetOffloads *ol) { if (!nc || !nc->info->set_offload) { return; } =20 - nc->info->set_offload(nc, csum, tso4, tso6, ecn, ufo, uso4, uso6); + nc->info->set_offload(nc, ol); } =20 int qemu_get_vnet_hdr_len(NetClientState *nc) diff --git a/net/netmap.c b/net/netmap.c index 297510e190..6cd8f2bdc5 100644 --- a/net/netmap.c +++ b/net/netmap.c @@ -366,8 +366,7 @@ static void netmap_set_vnet_hdr_len(NetClientState *nc,= int len) } } =20 -static void netmap_set_offload(NetClientState *nc, int csum, int tso4, int= tso6, - int ecn, int ufo, int uso4, int uso6) +static void netmap_set_offload(NetClientState *nc, const NetOffloads *ol) { NetmapState *s =3D DO_UPCAST(NetmapState, nc, nc); =20 diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 3f01c8921e..e7de0672f4 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -236,8 +236,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap-linux.c b/net/tap-linux.c index 2df601551e..aa5f3a6e22 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -258,8 +258,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) abort(); } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { unsigned int offload =3D 0; =20 @@ -268,20 +267,24 @@ void tap_fd_set_offload(int fd, int csum, int tso4, return; } =20 - if (csum) { + if (ol->csum) { offload |=3D TUN_F_CSUM; - if (tso4) + if (ol->tso4) { offload |=3D TUN_F_TSO4; - if (tso6) + } + if (ol->tso6) { offload |=3D TUN_F_TSO6; - if ((tso4 || tso6) && ecn) + } + if ((ol->tso4 || ol->tso6) && ol->ecn) { offload |=3D TUN_F_TSO_ECN; - if (ufo) + } + if (ol->ufo) { offload |=3D TUN_F_UFO; - if (uso4) { + } + if (ol->uso4) { offload |=3D TUN_F_USO4; } - if (uso6) { + if (ol->uso6) { offload |=3D TUN_F_USO6; } } diff --git a/net/tap-solaris.c b/net/tap-solaris.c index b1aa40d46b..ac09ae03c0 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -27,6 +27,7 @@ #include "tap_int.h" #include "qemu/ctype.h" #include "qemu/cutils.h" +#include "net/net.h" =20 #include #include @@ -240,8 +241,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap-stub.c b/net/tap-stub.c index 5f57d6baac..66abbbc392 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -71,8 +71,7 @@ int tap_fd_set_vnet_be(int fd, int is_be) return -EINVAL; } =20 -void tap_fd_set_offload(int fd, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +void tap_fd_set_offload(int fd, const NetOffloads *ol) { } =20 diff --git a/net/tap.c b/net/tap.c index f6e8cd5f1c..c7612fb91b 100644 --- a/net/tap.c +++ b/net/tap.c @@ -271,15 +271,14 @@ static int tap_set_vnet_be(NetClientState *nc, bool i= s_be) return tap_fd_set_vnet_be(s->fd, is_be); } =20 -static void tap_set_offload(NetClientState *nc, int csum, int tso4, - int tso6, int ecn, int ufo, int uso4, int uso6) +static void tap_set_offload(NetClientState *nc, const NetOffloads *ol) { TAPState *s =3D DO_UPCAST(TAPState, nc, nc); if (s->fd < 0) { return; } =20 - tap_fd_set_offload(s->fd, csum, tso4, tso6, ecn, ufo, uso4, uso6); + tap_fd_set_offload(s->fd, ol); } =20 static void tap_exit_notify(Notifier *notifier, void *data) @@ -365,6 +364,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, int fd, int vnet_hdr) { + NetOffloads ol =3D {}; NetClientState *nc; TAPState *s; =20 @@ -379,7 +379,7 @@ static TAPState *net_tap_fd_init(NetClientState *peer, s->has_uso =3D tap_probe_has_uso(s->fd); s->has_tunnel =3D tap_probe_has_tunnel(s->fd); s->enabled =3D true; - tap_set_offload(&s->nc, 0, 0, 0, 0, 0, 0, 0); + tap_set_offload(&s->nc, &ol); /* * Make sure host header length is set correctly in tap: * it might have been modified by another instance of qemu. diff --git a/net/tap_int.h b/net/tap_int.h index 2a8aa3632f..327d10f68b 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -27,6 +27,7 @@ #define NET_TAP_INT_H =20 #include "qapi/qapi-types-net.h" +#include "net/net.h" =20 int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required, int mq_required, Error **errp); @@ -38,8 +39,7 @@ int tap_probe_vnet_hdr(int fd, Error **errp); int tap_probe_has_ufo(int fd); int tap_probe_has_uso(int fd); int tap_probe_has_tunnel(int fd); -void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int= ufo, - int uso4, int uso6); +void tap_fd_set_offload(int fd, const NetOffloads *ol); void tap_fd_set_vnet_hdr_len(int fd, int len); int tap_fd_set_vnet_le(int fd, int vnet_is_le); int tap_fd_set_vnet_be(int fd, int vnet_is_be); --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827656; cv=none; d=zohomail.com; s=zohoarc; b=ZO6NrI9M+rKcs6UGRXAFoCawaegGiv5B2kPeOASnlu4K0MWfdV+YOzaEWCNSnPLVspy1Ycs4LDf7FL2v6ZaT+5UC7RSffK13vS/hpYCH55NbCva9ElV7IJ+mrBroVQU9z6BH1krWCX2OTOwZm/O7MzbdJm9JCQhXTzmliNR0Qf0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827656; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ke938JlAVnXEmFCrTD9zD7lx45OmWvtzIdYYyeHEI8k=; b=bl7MaGM4CE0vD1O07q3lDgzvEteedRHTRSzdaIsDEMHapMfCkwsz6PbpJNGUkx1lDKmeqJHNz2c+NDM24o1mkHk7xDV50J7qhMRFSmbMdgJCFmfNMo/x7qd5CpC3Bt3fmkiR8xcwHgdPOBeQoVrY3+DKRjVOQLnSjYqKN5YtJHU= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827656048386.4537416890712; Wed, 21 May 2025 04:40:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkY-000499-2b; Wed, 21 May 2025 07:36:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkW-00043S-CS for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkS-0001B9-AA for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:39 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-611--tpLgiI_OimjT0_KhGDAew-1; Wed, 21 May 2025 07:36:31 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 99467180098D; Wed, 21 May 2025 11:36:29 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id B85A919560B7; Wed, 21 May 2025 11:36:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827394; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ke938JlAVnXEmFCrTD9zD7lx45OmWvtzIdYYyeHEI8k=; b=IVyLg5R9TveDLgPSVR0EpQhqsnXUKe9nCtCXVTZC72/BCVgx+d7STBHVAWThCFWY5qlX3M 86hB55HOLUJI37AFETbKpXKXPQIGOO2Q75fdLCFstCjb4g78j863kOo+g/xYFgqQDZHWDL q8SGU5tEHmyr+1K+r0VOkjoW+wqNeYw= X-MC-Unique: -tpLgiI_OimjT0_KhGDAew-1 X-Mimecast-MFC-AGG-ID: -tpLgiI_OimjT0_KhGDAew_1747827389 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 15/16] net: implement tnl feature offloading Date: Wed, 21 May 2025 13:34:09 +0200 Message-ID: <3ee26dacd91d6c12ae4fc64bc42890553739a2fe.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827665933116600 Content-Type: text/plain; charset="utf-8" When any host or guest GSO over UDP tunnel offload is enabled the virtio net header includes the additional tunnel-related fields, update the size accordingly. Push the GSO over UDP tunnel offloads all the way down to the tap device extending the newly introduced NetFeatures struct, and eventually enable the associated features. As per virtio specification, to convert features bit to offload bit, map the extended features into the reserved range. Signed-off-by: Paolo Abeni --- hw/net/virtio-net.c | 48 ++++++++++++++++++++++++++++++++++++++++----- include/net/net.h | 2 ++ net/net.c | 7 ++++++- net/tap-linux.c | 6 ++++++ 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 881877086e..758ceaffba 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -101,6 +101,27 @@ #define VIRTIO_FEATURE_TO_OFFLOAD(fbit) (fbit >=3D 64 ? \ fbit - VIRTIO_O2F_DELTA : fbit) =20 +#ifdef CONFIG_INT128 +#define VIRTIO_NET_O_GUEST_UDP_TUNNEL_GSO \ + VIRTIO_FEATURE_TO_OFFLOAD(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO) +#define VIRTIO_NET_O_GUEST_UDP_TUNNEL_GSO_CSUM \ + VIRTIO_FEATURE_TO_OFFLOAD(VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO_CSUM) + +static bool virtio_has_tnl_hdr(virtio_features_t features) +{ + return virtio_has_feature_ex(features, VIRTIO_NET_F_GUEST_UDP_TUNNEL_G= SO) | + virtio_has_feature_ex(features, VIRTIO_NET_F_HOST_UDP_TUNNEL_GS= O); +} + +#else + +static bool virtio_has_tnl_hdr(virtio_features_t features) +{ + return false; +} + +#endif + static const VirtIOFeature feature_sizes[] =3D { {.flags =3D 1ULL << VIRTIO_NET_F_MAC, .end =3D endof(struct virtio_net_config, mac)}, @@ -656,7 +677,8 @@ static int peer_has_tunnel(VirtIONet *n) } =20 static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, int mergeable_rx_bufs, - int version_1, int hash_report) + int version_1, int hash_report, + int tnl) { int i; NetClientState *nc; @@ -674,6 +696,9 @@ static void virtio_net_set_mrg_rx_bufs(VirtIONet *n, in= t mergeable_rx_bufs, sizeof(struct virtio_net_hdr); n->rss_data.populate_hash =3D false; } + if (tnl) { + n->guest_hdr_len +=3D sizeof(struct virtio_net_hdr_tunnel); + } =20 for (i =3D 0; i < n->max_queue_pairs; i++) { nc =3D qemu_get_subqueue(n->nic, i); @@ -890,6 +915,12 @@ static void virtio_net_apply_guest_offloads(VirtIONet = *n) .ufo =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= FO)), .uso4 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO4)), .uso6 =3D !!(n->curr_guest_offloads & (1ULL << VIRTIO_NET_F_GUEST_U= SO6)), +#ifdef CONFIG_INT128 + .tnl =3D !!(n->curr_guest_offloads & + (1ULL << VIRTIO_NET_O_GUEST_UDP_TUNNEL_GSO)), + .tnl_csum =3D !!(n->curr_guest_offloads & + (1ULL << VIRTIO_NET_O_GUEST_UDP_TUNNEL_GSO_CSUM)), +#endif }; =20 qemu_set_offload(qemu_get_queue(n->nic)->peer, &ol); @@ -911,7 +942,12 @@ virtio_net_guest_offloads_by_features(virtio_features_= t features) (1ULL << VIRTIO_NET_F_GUEST_ECN) | (1ULL << VIRTIO_NET_F_GUEST_UFO) | (1ULL << VIRTIO_NET_F_GUEST_USO4) | - (1ULL << VIRTIO_NET_F_GUEST_USO6); + (1ULL << VIRTIO_NET_F_GUEST_USO6) +#ifdef CONFIG_INT128 + | (1ULL << VIRTIO_NET_O_GUEST_UDP_TUNNEL_GSO) + | (1ULL << VIRTIO_NET_O_GUEST_UDP_TUNNEL_GSO_CSUM) +#endif + ; =20 return guest_offloads_mask & virtio_net_features_to_offload(features); } @@ -1020,7 +1056,8 @@ static void virtio_net_set_features(VirtIODevice *vde= v, virtio_has_feature(features, VIRTIO_F_VERSION_1), virtio_has_feature(features, - VIRTIO_NET_F_HASH_REPORT= )); + VIRTIO_NET_F_HASH_REPORT= ), + virtio_has_tnl_hdr(features)); =20 n->rsc4_enabled =3D virtio_has_feature(features, VIRTIO_NET_F_RSC_EXT)= && virtio_has_feature(features, VIRTIO_NET_F_GUEST_TSO4); @@ -3139,7 +3176,8 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1), virtio_vdev_has_feature(vdev, - VIRTIO_NET_F_HASH_R= EPORT)); + VIRTIO_NET_F_HASH_R= EPORT), + virtio_has_tnl_hdr(vdev->guest_features)); =20 /* MAC_TABLE_ENTRIES may be different from the saved image */ if (n->mac_table.in_use > MAC_TABLE_ENTRIES) { @@ -3946,7 +3984,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) =20 n->vqs[0].tx_waiting =3D 0; n->tx_burst =3D n->net_conf.txburst; - virtio_net_set_mrg_rx_bufs(n, 0, 0, 0); + virtio_net_set_mrg_rx_bufs(n, 0, 0, 0, 0); n->promisc =3D 1; /* for compatibility */ =20 n->mac_table.macs =3D g_malloc0(MAC_TABLE_ENTRIES * ETH_ALEN); diff --git a/include/net/net.h b/include/net/net.h index c71d7c6074..5049d293f2 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -43,6 +43,8 @@ typedef struct NetOffloads { bool ufo; bool uso4; bool uso6; + bool tnl; + bool tnl_csum; } NetOffloads; =20 #define DEFINE_NIC_PROPERTIES(_state, _conf) \ diff --git a/net/net.c b/net/net.c index 5a2f00c108..bd41229407 100644 --- a/net/net.c +++ b/net/net.c @@ -569,13 +569,18 @@ int qemu_get_vnet_hdr_len(NetClientState *nc) =20 void qemu_set_vnet_hdr_len(NetClientState *nc, int len) { + int len_tnl =3D len - sizeof(struct virtio_net_hdr_tunnel); + if (!nc || !nc->info->set_vnet_hdr_len) { return; } =20 assert(len =3D=3D sizeof(struct virtio_net_hdr_mrg_rxbuf) || + len_tnl =3D=3D sizeof(struct virtio_net_hdr_mrg_rxbuf) || len =3D=3D sizeof(struct virtio_net_hdr) || - len =3D=3D sizeof(struct virtio_net_hdr_v1_hash)); + len_tnl =3D=3D sizeof(struct virtio_net_hdr) || + len =3D=3D sizeof(struct virtio_net_hdr_v1_hash) || + len_tnl =3D=3D sizeof(struct virtio_net_hdr_v1_hash)); =20 nc->vnet_hdr_len =3D len; nc->info->set_vnet_hdr_len(nc, len); diff --git a/net/tap-linux.c b/net/tap-linux.c index aa5f3a6e22..b7662ece63 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -287,6 +287,12 @@ void tap_fd_set_offload(int fd, const NetOffloads *ol) if (ol->uso6) { offload |=3D TUN_F_USO6; } + if ((ol->tso4 || ol->tso6 || ol->uso4 || ol->uso6) && ol->tnl) { + offload |=3D TUN_F_UDP_TUNNEL_GSO; + } + if ((offload & TUN_F_UDP_TUNNEL_GSO) && ol->tnl_csum) { + offload |=3D TUN_F_UDP_TUNNEL_GSO_CSUM; + } } =20 if (ioctl(fd, TUNSETOFFLOAD, offload) !=3D 0) { --=20 2.49.0 From nobody Sat Nov 15 20:47:17 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1747827445; cv=none; d=zohomail.com; s=zohoarc; b=kKkkIhUM3QPZGspuHm+fWS9lGgO5HrCBnqTt8b/PNKr5dlFyju8kZEPZbyOHwGmcc48UiEpUgbPOmidO1oj1fgIO/3/829UkX+V3oA/Cx8RadM+SPnRUs5XvpSDNVQQFfXIgKlWg2BVlz3S9sNQSn9UrgGBZPFuDzqUhVSIGn04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747827445; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3YxK8j6LBqqYkiJC0TJ0eGe2qc5vLgclN5nYoBSU7ps=; b=DUNDtQWkvYMTyi3vWKlt9b5giBq39yq5jJxrrGG4mJePrC137ObCboaMULXlPbimqhbwQ4X4MlEffBBLgbJ92Kj8vOS1j+zjunw0iNbBrorN8IGycxwzMz22R/fvdo9oaza9ZFTOvMQUz7t5057b8Sn12UdJ3i+J9YXrwYnjtSQ= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1747827444924569.5712963022041; Wed, 21 May 2025 04:37:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uHhkj-0004kp-QT; Wed, 21 May 2025 07:36:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkg-0004eN-LL for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uHhkb-0001Bp-MZ for qemu-devel@nongnu.org; Wed, 21 May 2025 07:36:50 -0400 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-C8g-qaZBM5-PGt0bzAYtdQ-1; Wed, 21 May 2025 07:36:37 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CE14A1956080; Wed, 21 May 2025 11:36:35 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.45.224.39]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 29FB019560B7; Wed, 21 May 2025 11:36:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747827400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3YxK8j6LBqqYkiJC0TJ0eGe2qc5vLgclN5nYoBSU7ps=; b=XEqaIQfaEgMdW1ecCmRiXPHO565GMrchP519D/bzgz45JC0ovrvXqt5KYImqXDwVkateDN 4K1o/Q055/iu7YVo6zty6xtXbf79mrTxZ1MbmSeiF6IqUmJHOqzuHANa76CkS5JIQ4+Yt/ SrBKrb3VlM0HSPtHv6R7i243AeX6Xqk= X-MC-Unique: C8g-qaZBM5-PGt0bzAYtdQ-1 X-Mimecast-MFC-AGG-ID: C8g-qaZBM5-PGt0bzAYtdQ_1747827395 From: Paolo Abeni To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Dmitry Fleytman , Akihiko Odaki , Jason Wang , Sriram Yagnaraman , "Michael S. Tsirkin" , Stefano Garzarella , Peter Xu , Fabiano Rosas , Cornelia Huck , Luigi Rizzo , Giuseppe Lettieri , Vincenzo Maffione , Eric Blake , Markus Armbruster Subject: [PATCH RFC 16/16] net: make vhost-net aware of GSO over UDP tunnel hdr layout Date: Wed, 21 May 2025 13:34:10 +0200 Message-ID: <87d85cd2c276a43d0f7ed2d27e00427b8f4a8243.1747825544.git.pabeni@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 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=pabeni@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.184, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1747827445709116600 Content-Type: text/plain; charset="utf-8" When the GSO over UDP tunnel offload is enabled, the virtio net header includes additional fields to support such offload. The vhost backend must be aware of the exact header layout, to copy it correctly. The tunnel-related field are present if either the guest or the host negotiated any UDP tunnel related feature: add them to host kernel supported features list, to allow qemu transder to such backend the needed information. Signed-off-by: Paolo Abeni Tested-by: Lei Yang --- hw/net/vhost_net.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 58d7619fc8..c8e02d1732 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -52,6 +52,10 @@ static const int kernel_feature_bits[] =3D { VIRTIO_F_NOTIFICATION_DATA, VIRTIO_NET_F_RSC_EXT, VIRTIO_NET_F_HASH_REPORT, +#ifdef CONFIG_INT128 + VIRTIO_NET_F_GUEST_UDP_TUNNEL_GSO, + VIRTIO_NET_F_HOST_UDP_TUNNEL_GSO, +#endif VHOST_INVALID_FEATURE_BIT }; =20 --=20 2.49.0