Received: by 2002:a05:7412:f589:b0:e2:908c:2ebd with SMTP id eh9csp627339rdb; Tue, 31 Oct 2023 18:46:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfanuW3S3xUeFK6Qjbz8dqcv/Ngz+avkVylNlfYj1JjaSpMweSrr0n9Zz1Z7zwoSV8zoa6 X-Received: by 2002:a17:90a:e516:b0:280:1dca:f699 with SMTP id t22-20020a17090ae51600b002801dcaf699mr8109049pjy.42.1698803192356; Tue, 31 Oct 2023 18:46:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698803192; cv=none; d=google.com; s=arc-20160816; b=Mq0uVvFxcaIauwmnBJsRiaSIwsA6U7nZuXaMKfIjfrkUXqOZrC5w6Bw0oRcvUM7JHr TIjagJuqrUE6zFvmzvNtanqvJKsJE5aSIe0A/TR09LDiFOmwa5p0MnHHf8HwGkfUn3Tf 86xY46hOyTBCxaVDvP22RTCC54fDeWVr6XN8swIsN/j2XiaNA0V0/HhZwvbLqkjvwG8o qSWELXF3rHrcEWwOBvl48eRUTmKiTvDWw2BMNhXt8RZjQQPoO87L4GxsCFdG+UpAbeDn 7ZrFdJ3QFDTfVVXIKOqAbtk5yuBltSU+bVXXrFuCRKQhFrmqBc+/ZvPTzUeQ4Th0+DqW FFCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:cc:to:from:date:subject :message-id; bh=O1dIjXOXNgNiCWowUUSfUsVsD+jRc9Re7fiFgd2xbyQ=; fh=fayywptzQq0fIu8cBDRnGTPXpuBEENV+IGHPlZEz2KY=; b=eJh+C5AxpdyBSVRDvi0bjj5MoS1jPfvRcFPZPMwTftRQSdx7kaT9uRHnEZp0vRm8bh uTFFvsSn5Y+Py2cLkkt6vqGiSLXCpL6kRc5RdG82CRfBDsIMD5ZXtZM7LI3kJ7gN2sJG R5d7cEX4dQ0O6W1zKnGGj3EivSsCSmxKp3d323xSNhRUr3xqBukFNnUwKpGF9uXFWhNZ Hl8z2lNZCxZQfkAKZ4LlNKq/o9xnSq8blIxWE1isYUkImhdvXW9hZyUMjhLaYg63YJNf ReH4fJ9w+Pm6gp4EF0+xqWzRacGwuIGCqUftxhTy25T+zsztGXo9Jl31r+HUbBrqSDHV p4pA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id pc8-20020a17090b3b8800b0027ffe9d16b8si2023236pjb.1.2023.10.31.18.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 18:46:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 617A680BB50A; Tue, 31 Oct 2023 18:46:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377236AbjKABpX (ORCPT + 99 others); Tue, 31 Oct 2023 21:45:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377306AbjKABpV (ORCPT ); Tue, 31 Oct 2023 21:45:21 -0400 Received: from out30-119.freemail.mail.aliyun.com (out30-119.freemail.mail.aliyun.com [115.124.30.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3EC5102 for ; Tue, 31 Oct 2023 18:45:14 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=xuanzhuo@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0VvIssn4_1698803110; Received: from localhost(mailfrom:xuanzhuo@linux.alibaba.com fp:SMTPD_---0VvIssn4_1698803110) by smtp.aliyun-inc.com; Wed, 01 Nov 2023 09:45:11 +0800 Message-ID: <1698803104.3925707-1-xuanzhuo@linux.alibaba.com> Subject: Re: [PATCH] virtio_pci: move structure to a header Date: Wed, 1 Nov 2023 09:45:04 +0800 From: Xuan Zhuo To: "Michael S. Tsirkin" Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org References: <110d3058179284b092722827bef4f74f8ba0c622.1698769192.git.mst@redhat.com> In-Reply-To: <110d3058179284b092722827bef4f74f8ba0c622.1698769192.git.mst@redhat.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 (groat.vger.email [0.0.0.0]); Tue, 31 Oct 2023 18:46:11 -0700 (PDT) On Tue, 31 Oct 2023 12:19:54 -0400, "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 Reviewed-by: Xuan Zhuo > --- > 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/virtio_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 = -EINVAL; > mdev->common = 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 = 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 > > _______________________________________________ > Virtualization mailing list > Virtualization@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/virtualization