lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200804102730-mutt-send-email-mst@kernel.org>
Date:   Tue, 4 Aug 2020 10:28:06 -0400
From:   "Michael S. Tsirkin" <mst@...hat.com>
To:     Cornelia Huck <cohuck@...hat.com>
Cc:     linux-kernel@...r.kernel.org,
        virtualization@...ts.linux-foundation.org
Subject: Re: [PATCH v2 03/24] virtio: allow __virtioXX, __leXX in config space

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@...hat.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@...hat.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@...hat.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ