Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp604678rdb; Tue, 31 Oct 2023 17:39:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoXEonAsjCQD8OnlsTb27vS+jLmH3SQclIB1a6vjHyht7R4yiSlsEx2fM48caQdTGS1+MC X-Received: by 2002:a05:6a00:1309:b0:6b1:e876:168b with SMTP id j9-20020a056a00130900b006b1e876168bmr15141962pfu.11.1698799173471; Tue, 31 Oct 2023 17:39:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698799173; cv=none; d=google.com; s=arc-20160816; b=I1j+IyDkUDqGjM8YmPn00GcU70ggjcFk8liV8KrKN3g7CtQyvU0gvXWTbLMg+KMTO8 N6wjMzdFV8a8EJC54VRdznq8aU7B25+IyHIEW5KKX4qPgvtxGPI1js2rNQHBYNjUEgIu XaBcbpxgC5HV1JPwa7Q2uld/qsarF2hxVduyyRc9Hmp45biKaczyDMvzE4GifuqE/Lna u1+zcc0Ujt4rBgmSk+fnUn9wtJGMtBf6oDTzyp6nYrLnNzg0C5gFedKfXDitJwsLas09 BCuNIWrY63kLj5m/zZRsqwyNXlwau/dFpNkHdbf26Zo1w3tOMjhaEQrsoH+R4+AmqP87 UdJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cVmhpIbbAED27w6cogZcQtjsKWbHbF+MiZXcAMDs3b8=; fh=vqLVeWOZspuWZECLvZ+E42cVs/UHhOL2HJ4nfjBaP+8=; b=SInddvStcLpsg8f5hXh9Ij1Yu005gofasKSsygVVEw16WQHQJwbIglaltuR7xTBETg jMUhGnRLQvGIgpBHCtvqMDJJDBwvY0mq6MaKhNEK99cqPtGQ8ewn2h3ILhWhuT7WI8yP J43PNf9Qo3glHBl+aXem8FvqocXxGnZtWtd1QBY7qLHUzNp4dr/3Dj8jcdk/zGym5qUF Y5RhNOlBXJiSv9oCRKT0jptCIRGqcqIDLjdeZu6fPCMWTmsSVfmvPSyPeVT4SCDRiCT0 7xg+EZ8VvFNUKC4nC1tHUjx5IveKWDmXmFURyZFfRPliN5AlvUi1HUuQm+Xrat9nnFKU d+ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DHQxtzX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id s24-20020aa78bd8000000b006be26c1be4bsi457136pfd.73.2023.10.31.17.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 17:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DHQxtzX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AA28D811F132; Tue, 31 Oct 2023 17:39:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345029AbjKAAjT (ORCPT + 99 others); Tue, 31 Oct 2023 20:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231947AbjKAAjS (ORCPT ); Tue, 31 Oct 2023 20:39:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 336A2107 for ; Tue, 31 Oct 2023 17:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698799109; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cVmhpIbbAED27w6cogZcQtjsKWbHbF+MiZXcAMDs3b8=; b=DHQxtzX00C43K8lgWaV9oBtsYzi/ad6CfDfVXCbBRd9PqXW3JBw8I12jCuCfGh/D4syJD/ 75PFiEpa044NX3BRYYu0jKYFci3kobK5VVDJmTmbOEdVvizOqn0xiH5dKKfF48ZjE7d9En 5OPcHff/W3gvWlc1kbQX1TqXt5TmdbY= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-q4ChtN6NPcG3TiwawueYQQ-1; Tue, 31 Oct 2023 20:38:18 -0400 X-MC-Unique: q4ChtN6NPcG3TiwawueYQQ-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-5079fe7cc7cso7609003e87.2 for ; Tue, 31 Oct 2023 17:38:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698799096; x=1699403896; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cVmhpIbbAED27w6cogZcQtjsKWbHbF+MiZXcAMDs3b8=; b=Tm5Qq4kO/UfhKMaTqbQAQn0f/U+JE71g9uXMInLh0fGiAHLMyw9MSegv9QzhBCDTBE TzSWDs02ncsmyh8BPU0r/Ezf1x9IG2zzIizgBLJV39aGPc0XA1ez0Hi4dqKKOiUnUxeC TG9ptQ7HleWfNqwy9FmdNkYs9Qhcz7oLHubEbrPLyxOcAf004FXpizkGKbduXbbAaPKp 6YlHM21QNW0CZZMpeksPVJaELwadetoq3n2k1xr+r8v0CHRoAwyRfjElAmqJn6R4/TNg 0fcSsGy+YJWF2ioHF4k1q4m5K2HeiBmnhLzexBkB8Abu0XwHQT9P/8LKZyNEJqTNx20z EOuQ== X-Gm-Message-State: AOJu0YyrueR5nhlToLelNEaypn53PEVURAms48xJqme817IpB+6/PpMq P0PiqidQh/u291G/MxBGGqPeP83mdcRYDInxmS/sC+PvodzkHodHtDBw8eEgOk6R6TS0s09OPBk /Gej3CFmiHPwPJJgaEKH2hw/g3VE7GvbdUQCeUE1t X-Received: by 2002:ac2:5d31:0:b0:508:1227:5a10 with SMTP id i17-20020ac25d31000000b0050812275a10mr8510925lfb.23.1698799096728; Tue, 31 Oct 2023 17:38:16 -0700 (PDT) X-Received: by 2002:ac2:5d31:0:b0:508:1227:5a10 with SMTP id i17-20020ac25d31000000b0050812275a10mr8510914lfb.23.1698799096383; Tue, 31 Oct 2023 17:38:16 -0700 (PDT) MIME-Version: 1.0 References: <110d3058179284b092722827bef4f74f8ba0c622.1698769192.git.mst@redhat.com> In-Reply-To: <110d3058179284b092722827bef4f74f8ba0c622.1698769192.git.mst@redhat.com> From: Jason Wang Date: Wed, 1 Nov 2023 08:38:05 +0800 Message-ID: Subject: Re: [PATCH] virtio_pci: move structure to a header To: "Michael S. Tsirkin" Cc: linux-kernel@vger.kernel.org, Xuan Zhuo , virtualization@lists.linux-foundation.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 31 Oct 2023 17:39:30 -0700 (PDT) On Wed, Nov 1, 2023 at 12:20=E2=80=AFAM Michael S. Tsirkin = wrote: > > These are guest/host interfaces so belong in the header > where e.g. qemu will know to find them. > Note: we added a new structure as opposed to extending existing one > because someone might be relying on the size of the existing structure > staying unchanged. Add a warning to avoid using sizeof. > > Signed-off-by: Michael S. Tsirkin Acked-by: Jason Wang Thanks > --- > drivers/virtio/virtio_pci_modern_dev.c | 7 ++++--- > include/linux/virtio_pci_modern.h | 7 ------- > include/uapi/linux/virtio_pci.h | 11 +++++++++++ > 3 files changed, 15 insertions(+), 10 deletions(-) > > diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virt= io_pci_modern_dev.c > index e2a1fe7bb66c..7de8b1ebabac 100644 > --- a/drivers/virtio/virtio_pci_modern_dev.c > +++ b/drivers/virtio/virtio_pci_modern_dev.c > @@ -294,9 +294,10 @@ int vp_modern_probe(struct virtio_pci_modern_device = *mdev) > > err =3D -EINVAL; > mdev->common =3D vp_modern_map_capability(mdev, common, > - sizeof(struct virtio_pci_common_cfg= ), 4, > - 0, sizeof(struct virtio_pci_modern_= common_cfg), > - &mdev->common_len, NULL); > + sizeof(struct virtio_pci_common_cfg), 4, 0, > + offsetofend(struct virtio_pci_modern_common= _cfg, > + queue_reset), > + &mdev->common_len, NULL); > if (!mdev->common) > goto err_map_common; > mdev->isr =3D vp_modern_map_capability(mdev, isr, sizeof(u8), 1, > diff --git a/include/linux/virtio_pci_modern.h b/include/linux/virtio_pci= _modern.h > index d0f2797420f7..a09e13a577a9 100644 > --- a/include/linux/virtio_pci_modern.h > +++ b/include/linux/virtio_pci_modern.h > @@ -5,13 +5,6 @@ > #include > #include > > -struct virtio_pci_modern_common_cfg { > - struct virtio_pci_common_cfg cfg; > - > - __le16 queue_notify_data; /* read-write */ > - __le16 queue_reset; /* read-write */ > -}; > - > /** > * struct virtio_pci_modern_device - info for modern PCI virtio > * @pci_dev: Ptr to the PCI device struct > diff --git a/include/uapi/linux/virtio_pci.h b/include/uapi/linux/virtio_= pci.h > index f703afc7ad31..44f4dd2add18 100644 > --- a/include/uapi/linux/virtio_pci.h > +++ b/include/uapi/linux/virtio_pci.h > @@ -166,6 +166,17 @@ struct virtio_pci_common_cfg { > __le32 queue_used_hi; /* read-write */ > }; > > +/* > + * Warning: do not use sizeof on this: use offsetofend for > + * specific fields you need. > + */ > +struct virtio_pci_modern_common_cfg { > + struct virtio_pci_common_cfg cfg; > + > + __le16 queue_notify_data; /* read-write */ > + __le16 queue_reset; /* read-write */ > +}; > + > /* Fields in VIRTIO_PCI_CAP_PCI_CFG: */ > struct virtio_pci_cfg_cap { > struct virtio_pci_cap cap; > -- > MST >