[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver
From: |
Arnd Bergmann |
Subject: |
Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver |
Date: |
Fri, 26 Mar 2021 09:24:54 +0100 |
On Fri, Mar 26, 2021 at 8:14 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 25-03-21, 17:16, Arnd Bergmann wrote:
> > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar <viresh.kumar@linaro.org>
> > wrote:
> >
> > It looks like you are not handling endianness conversion here. As far as I
> > can tell, the protocol requires little-endian data, but the code might
> > run on a big-endian CPU.
>
> I hope this is all we are required to do here, right ?
>
> @@ -442,7 +421,7 @@ static void vi2c_handle_ctrl(VuDev *dev, int qidx)
> out_hdr = elem->out_sg[0].iov_base;
>
> /* Bit 0 is reserved in virtio spec */
> - msg.addr = out_hdr->addr >> 1;
> + msg.addr = le16toh(out_hdr->addr) >> 1;
>
> /* Read Operation */
> if (elem->out_num == 1 && elem->in_num == 2) {
> @@ -489,7 +468,7 @@ static void vi2c_handle_ctrl(VuDev *dev, int qidx)
> in_hdr->status = fail_next ? VIRTIO_I2C_MSG_ERR : vi2c_xfer(dev,
> &msg);
> if (in_hdr->status == VIRTIO_I2C_MSG_ERR) {
> /* We need to fail remaining transfers as well */
> - fail_next = out_hdr->flags & VIRTIO_I2C_FLAGS_FAIL_NEXT;
> + fail_next = le32toh(out_hdr->flags) & VIRTIO_I2C_FLAGS_FAIL_NEXT;
> }
>
> These are the only fields we are passing apart from buf, which goes
> directly to the client device.
I think so, the in_hdr is only one byte long, so it doesn't have an
endianness.
Arnd
- [PATCH 2/5] hw/virtio: add vhost-user-i2c-pci boilerplate, (continued)
[PATCH 4/5] docs: add a man page for vhost-user-i2c, Viresh Kumar, 2021/03/24
[PATCH 5/5] MAINTAINERS: Add entry for virtio-i2c, Viresh Kumar, 2021/03/24
Re: [PATCH 0/5] virtio: Implement generic vhost-user-i2c backend, no-reply, 2021/03/24