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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250224175527.GF1615191@kernel.org>
Date: Mon, 24 Feb 2025 17:55:27 +0000
From: Simon Horman <horms@...nel.org>
To: Peter Hilber <quic_philber@...cinc.com>
Cc: "Michael S. Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>,
	Trilok Soni <quic_tsoni@...cinc.com>,
	Srivatsa Vaddagiri <quic_svaddagi@...cinc.com>,
	Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
	Eugenio PĂ©rez <eperezma@...hat.com>,
	Richard Cochran <richardcochran@...il.com>,
	linux-kernel@...r.kernel.org, virtualization@...ts.linux.dev,
	netdev@...r.kernel.org, David Woodhouse <dwmw2@...radead.org>,
	"Ridoux, Julien" <ridouxj@...zon.com>,
	Marc Zyngier <maz@...nel.org>, Mark Rutland <mark.rutland@....com>,
	Daniel Lezcano <daniel.lezcano@...aro.org>,
	Alexandre Belloni <alexandre.belloni@...tlin.com>,
	Parav Pandit <parav@...dia.com>,
	Matias Ezequiel Vara Larsen <mvaralar@...hat.com>,
	Cornelia Huck <cohuck@...hat.com>, virtio-dev@...ts.linux.dev,
	linux-arm-kernel@...ts.infradead.org, linux-rtc@...r.kernel.org
Subject: Re: [PATCH v5 1/4] virtio_rtc: Add module and driver core

On Wed, Feb 19, 2025 at 08:32:56PM +0100, Peter Hilber wrote:

...

> +/**
> + * VIORTC_MSG() - extract message from message handle
> + * @hdl: message handle
> + *
> + * Return: struct viortc_msg
> + */
> +#define VIORTC_MSG(hdl) ((hdl).msg)
> +
> +/**
> + * VIORTC_MSG_INIT() - initialize message handle
> + * @hdl: message handle
> + * @viortc: device data (struct viortc_dev *)
> + *
> + * Context: Process context.
> + * Return: 0 on success, -ENOMEM otherwise.
> + */
> +#define VIORTC_MSG_INIT(hdl, viortc)                                         \
> +	({                                                                   \
> +		typeof(hdl) *_hdl = &(hdl);                                  \
> +									     \
> +		_hdl->msg = viortc_msg_init((viortc), _hdl->msg_type,        \
> +					    _hdl->req_size, _hdl->resp_cap); \
> +		if (_hdl->msg) {                                             \
> +			_hdl->req = _hdl->msg->req;                          \
> +			_hdl->resp = _hdl->msg->resp;                        \
> +		}                                                            \
> +		_hdl->msg ? 0 : -ENOMEM;                                     \
> +	})
> +
> +/**
> + * VIORTC_MSG_WRITE() - write a request message field
> + * @hdl: message handle
> + * @dest_member: request message field name
> + * @src_ptr: pointer to data of compatible type
> + *
> + * Writes the field in little-endian format.
> + */
> +#define VIORTC_MSG_WRITE(hdl, dest_member, src_ptr)                         \
> +	do {                                                                \
> +		typeof(hdl) _hdl = (hdl);                                   \
> +		typeof(src_ptr) _src_ptr = (src_ptr);                       \
> +									    \
> +		/* Sanity check: must match the member's type */            \
> +		typecheck(typeof(_hdl.req->dest_member), *_src_ptr);        \

Hi Peter,

FWIIW, this trips up sparse because from it's perspective
there is an endianness mismatch between the two types.

> +									    \
> +		_hdl.req->dest_member =                                     \
> +			virtio_cpu_to_le(*_src_ptr, _hdl.req->dest_member); \
> +	} while (0)
> +
> +/**
> + * VIORTC_MSG_READ() - read from a response message field
> + * @hdl: message handle
> + * @src_member: response message field name
> + * @dest_ptr: pointer to data of compatible type
> + *
> + * Converts from little-endian format and writes to dest_ptr.
> + */
> +#define VIORTC_MSG_READ(hdl, src_member, dest_ptr)                     \
> +	do {                                                           \
> +		typeof(dest_ptr) _dest_ptr = (dest_ptr);               \
> +								       \
> +		/* Sanity check: must match the member's type */       \
> +		typecheck(typeof((hdl).resp->src_member), *_dest_ptr); \

Ditto.

> +								       \
> +		*_dest_ptr = virtio_le_to_cpu((hdl).resp->src_member); \
> +	} while (0)
> +
> +/*
> + * read requests
> + */

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ