From: "Michael S. Tsirkin" <mst@redhat.com> To: Cornelia Huck <cohuck@redhat.com> Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space Date: Tue, 4 Aug 2020 10:28:06 -0400 [thread overview] Message-ID: <20200804102730-mutt-send-email-mst@kernel.org> (raw) In-Reply-To: <20200804162340.046b719b.cohuck@redhat.com> On Tue, Aug 04, 2020 at 04:23:40PM +0200, Cornelia Huck wrote: > On Mon, 3 Aug 2020 16:58:46 -0400 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > Currently all config space fields are of the type __uXX. > > This confuses people and some drivers (notably vdpa) > > access them using CPU endian-ness - which only > > works well for legacy or LE platforms. > > > > Update virtio_cread/virtio_cwrite macros to allow __virtioXX > > and __leXX field types. Follow-up patches will convert > > config space to use these types. > > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > include/linux/virtio_config.h | 50 +++++++++++++++++++++++++++++++++-- > > 1 file changed, 48 insertions(+), 2 deletions(-) > > (...) > > > @@ -287,12 +288,57 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) > > return __cpu_to_virtio64(virtio_is_little_endian(vdev), val); > > } > > > > +/* > > + * Only the checker differentiates between __virtioXX and __uXX types. But we > > + * try to share as much code as we can with the regular GCC build. > > + */ > > +#if !defined(CONFIG_CC_IS_GCC) && !defined(__CHECKER__) > > + > > +/* Not a checker - we can keep things simple */ > > +#define __virtio_native_typeof(x) typeof(x) > > + > > +#else > > + > > +/* > > + * We build this out of a couple of helper macros in a vain attempt to > > + * help you keep your lunch down while reading it. > > + */ > > It might help with the lunch, but it still gives a slight queasiness. > No ideas for a better version, though. A later patch fixes this. Hopefully :) > > +#define __virtio_pick_value(x, type, then, otherwise) \ > > + __builtin_choose_expr(__same_type(x, type), then, otherwise) > > + > > +#define __virtio_pick_type(x, type, then, otherwise) \ > > + __virtio_pick_value(x, type, (then)0, otherwise) > > + > > +#define __virtio_pick_endian(x, x16, x32, x64, otherwise) \ > > + __virtio_pick_type(x, x16, __u16, \ > > + __virtio_pick_type(x, x32, __u32, \ > > + __virtio_pick_type(x, x64, __u64, \ > > + otherwise))) > > + > > +#define __virtio_native_typeof(x) typeof( \ > > + __virtio_pick_type(x, __u8, __u8, \ > > + __virtio_pick_endian(x, __virtio16, __virtio32, __virtio64, \ > > + __virtio_pick_endian(x, __le16, __le32, __le64, \ > > + __virtio_pick_endian(x, __u16, __u32, __u64, \ > > + /* No other type allowed */ \ > > + (void)0))))) > > + > > +#endif > > + > > +#define __virtio_native_type(structname, member) \ > > + __virtio_native_typeof(((structname*)0)->member) > > + > > +#define __virtio_typecheck(structname, member, val) \ > > + /* Must match the member's type, and be integer */ \ > > + typecheck(__virtio_native_type(structname, member), (val)) > > + > > + > > Acked-by: Cornelia Huck <cohuck@redhat.com>
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com> To: Cornelia Huck <cohuck@redhat.com> Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space Date: Tue, 4 Aug 2020 10:28:06 -0400 [thread overview] Message-ID: <20200804102730-mutt-send-email-mst@kernel.org> (raw) In-Reply-To: <20200804162340.046b719b.cohuck@redhat.com> On Tue, Aug 04, 2020 at 04:23:40PM +0200, Cornelia Huck wrote: > On Mon, 3 Aug 2020 16:58:46 -0400 > "Michael S. Tsirkin" <mst@redhat.com> wrote: > > > Currently all config space fields are of the type __uXX. > > This confuses people and some drivers (notably vdpa) > > access them using CPU endian-ness - which only > > works well for legacy or LE platforms. > > > > Update virtio_cread/virtio_cwrite macros to allow __virtioXX > > and __leXX field types. Follow-up patches will convert > > config space to use these types. > > > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > include/linux/virtio_config.h | 50 +++++++++++++++++++++++++++++++++-- > > 1 file changed, 48 insertions(+), 2 deletions(-) > > (...) > > > @@ -287,12 +288,57 @@ static inline __virtio64 cpu_to_virtio64(struct virtio_device *vdev, u64 val) > > return __cpu_to_virtio64(virtio_is_little_endian(vdev), val); > > } > > > > +/* > > + * Only the checker differentiates between __virtioXX and __uXX types. But we > > + * try to share as much code as we can with the regular GCC build. > > + */ > > +#if !defined(CONFIG_CC_IS_GCC) && !defined(__CHECKER__) > > + > > +/* Not a checker - we can keep things simple */ > > +#define __virtio_native_typeof(x) typeof(x) > > + > > +#else > > + > > +/* > > + * We build this out of a couple of helper macros in a vain attempt to > > + * help you keep your lunch down while reading it. > > + */ > > It might help with the lunch, but it still gives a slight queasiness. > No ideas for a better version, though. A later patch fixes this. Hopefully :) > > +#define __virtio_pick_value(x, type, then, otherwise) \ > > + __builtin_choose_expr(__same_type(x, type), then, otherwise) > > + > > +#define __virtio_pick_type(x, type, then, otherwise) \ > > + __virtio_pick_value(x, type, (then)0, otherwise) > > + > > +#define __virtio_pick_endian(x, x16, x32, x64, otherwise) \ > > + __virtio_pick_type(x, x16, __u16, \ > > + __virtio_pick_type(x, x32, __u32, \ > > + __virtio_pick_type(x, x64, __u64, \ > > + otherwise))) > > + > > +#define __virtio_native_typeof(x) typeof( \ > > + __virtio_pick_type(x, __u8, __u8, \ > > + __virtio_pick_endian(x, __virtio16, __virtio32, __virtio64, \ > > + __virtio_pick_endian(x, __le16, __le32, __le64, \ > > + __virtio_pick_endian(x, __u16, __u32, __u64, \ > > + /* No other type allowed */ \ > > + (void)0))))) > > + > > +#endif > > + > > +#define __virtio_native_type(structname, member) \ > > + __virtio_native_typeof(((structname*)0)->member) > > + > > +#define __virtio_typecheck(structname, member, val) \ > > + /* Must match the member's type, and be integer */ \ > > + typecheck(__virtio_native_type(structname, member), (val)) > > + > > + > > Acked-by: Cornelia Huck <cohuck@redhat.com> _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next prev parent reply other threads:[~2020-08-04 14:29 UTC|newest] Thread overview: 143+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-03 20:58 [PATCH v2 00/24] virtio: config space endian-ness cleanup Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-03 20:58 ` [PATCH v2 01/24] virtio_balloon: fix sparse warning Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-03 21:25 ` David Hildenbrand 2020-08-03 21:25 ` David Hildenbrand 2020-08-04 14:16 ` Cornelia Huck 2020-08-04 14:16 ` Cornelia Huck 2020-08-03 20:58 ` [PATCH v2 02/24] virtio_ring: sparse warning fixup Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-04 14:18 ` Cornelia Huck 2020-08-04 14:18 ` Cornelia Huck 2020-08-03 20:58 ` [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-04 14:23 ` Cornelia Huck 2020-08-04 14:23 ` Cornelia Huck 2020-08-04 14:28 ` Michael S. Tsirkin [this message] 2020-08-04 14:28 ` Michael S. Tsirkin 2020-08-05 6:28 ` Jason Wang 2020-08-05 6:28 ` Jason Wang 2020-08-05 11:45 ` Michael S. Tsirkin 2020-08-05 11:45 ` Michael S. Tsirkin 2020-08-06 3:37 ` Jason Wang 2020-08-06 3:37 ` Jason Wang 2020-08-06 5:58 ` Michael S. Tsirkin 2020-08-06 5:58 ` Michael S. Tsirkin 2020-08-07 3:26 ` Jason Wang 2020-08-07 3:26 ` Jason Wang 2020-08-03 20:58 ` [PATCH v2 04/24] virtio_9p: correct tags for config space fields Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-04 14:25 ` Cornelia Huck 2020-08-04 14:25 ` Cornelia Huck 2020-08-03 20:58 ` [PATCH v2 05/24] virtio_balloon: " Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-03 21:26 ` David Hildenbrand 2020-08-03 21:26 ` David Hildenbrand 2020-08-04 14:26 ` Cornelia Huck 2020-08-04 14:26 ` Cornelia Huck 2020-08-03 20:58 ` [PATCH v2 06/24] virtio_blk: " Michael S. Tsirkin 2020-08-03 20:58 ` Michael S. Tsirkin 2020-08-04 14:29 ` Cornelia Huck 2020-08-04 14:29 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 07/24] virtio_console: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:31 ` Cornelia Huck 2020-08-04 14:31 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 08/24] virtio_crypto: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:32 ` Cornelia Huck 2020-08-04 14:32 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 09/24] virtio_fs: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 13:36 ` Vivek Goyal 2020-08-04 13:36 ` Vivek Goyal 2020-08-04 14:33 ` Cornelia Huck 2020-08-04 14:33 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 10/24] virtio_gpu: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:34 ` Cornelia Huck 2020-08-04 14:34 ` Cornelia Huck 2020-08-04 14:34 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 11/24] virtio_input: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 6:01 ` Gerd Hoffmann 2020-08-04 6:01 ` Gerd Hoffmann 2020-08-04 14:35 ` Cornelia Huck 2020-08-04 14:35 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 12/24] virtio_iommu: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 8:00 ` Jean-Philippe Brucker 2020-08-04 8:00 ` Jean-Philippe Brucker 2020-08-04 14:36 ` Cornelia Huck 2020-08-04 14:36 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 13/24] virtio_mem: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-03 21:23 ` David Hildenbrand 2020-08-03 21:23 ` David Hildenbrand 2020-08-04 14:37 ` Cornelia Huck 2020-08-04 14:37 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 14/24] virtio_net: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:44 ` Cornelia Huck 2020-08-04 14:44 ` Cornelia Huck 2020-08-05 13:26 ` Michael S. Tsirkin 2020-08-05 13:26 ` Michael S. Tsirkin 2020-08-03 20:59 ` [PATCH v2 15/24] virtio_pmem: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:46 ` Cornelia Huck 2020-08-04 14:46 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 16/24] virtio_scsi: " Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:48 ` Cornelia Huck 2020-08-04 14:48 ` Cornelia Huck 2020-08-03 20:59 ` [PATCH v2 17/24] virtio_config: disallow native type fields Michael S. Tsirkin 2020-08-03 20:59 ` Michael S. Tsirkin 2020-08-04 14:50 ` Cornelia Huck 2020-08-04 14:50 ` Cornelia Huck 2020-08-05 13:29 ` Michael S. Tsirkin 2020-08-05 13:29 ` Michael S. Tsirkin 2020-08-03 21:00 ` [PATCH v2 18/24] mlxbf-tmfifo: sparse tags for config access Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-04 14:56 ` Cornelia Huck 2020-08-04 14:56 ` Cornelia Huck 2020-08-04 14:56 ` Cornelia Huck 2020-08-05 13:29 ` Michael S. Tsirkin 2020-08-05 13:29 ` Michael S. Tsirkin 2020-08-05 13:29 ` Michael S. Tsirkin 2020-08-03 21:00 ` [PATCH v2 19/24] vdpa: make sure set_features in invoked for legacy Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-05 6:14 ` Jason Wang 2020-08-05 6:14 ` Jason Wang 2020-08-05 11:40 ` Michael S. Tsirkin 2020-08-05 11:40 ` Michael S. Tsirkin 2020-08-06 3:23 ` Jason Wang 2020-08-06 3:23 ` Jason Wang 2020-08-06 5:53 ` Michael S. Tsirkin 2020-08-06 5:53 ` Michael S. Tsirkin 2020-08-06 7:27 ` Jason Wang 2020-08-06 7:27 ` Jason Wang 2020-08-06 10:00 ` Michael S. Tsirkin 2020-08-06 10:00 ` Michael S. Tsirkin 2020-08-07 3:00 ` Jason Wang 2020-08-07 3:00 ` Jason Wang 2020-08-03 21:00 ` [PATCH v2 20/24] vhost/vdpa: switch to new helpers Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-03 21:00 ` [PATCH v2 21/24] virtio_vdpa: legacy features handling Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-03 21:00 ` [PATCH v2 22/24] vdpa_sim: fix endian-ness of config space Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-05 6:21 ` Jason Wang 2020-08-05 6:21 ` Jason Wang 2020-08-05 11:44 ` Michael S. Tsirkin 2020-08-05 11:44 ` Michael S. Tsirkin 2020-08-05 12:06 ` Michael S. Tsirkin 2020-08-05 12:06 ` Michael S. Tsirkin 2020-08-06 3:23 ` Jason Wang 2020-08-06 3:23 ` Jason Wang 2020-08-03 21:00 ` [PATCH v2 23/24] virtio_config: cread/write cleanup Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin 2020-08-03 21:00 ` [PATCH v2 24/24] virtio_config: rewrite using _Generic Michael S. Tsirkin 2020-08-03 21:00 ` Michael S. Tsirkin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200804102730-mutt-send-email-mst@kernel.org \ --to=mst@redhat.com \ --cc=cohuck@redhat.com \ --cc=linux-kernel@vger.kernel.org \ --cc=virtualization@lists.linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.