From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6789DC433DB for ; Fri, 26 Mar 2021 08:26:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A4C061A43 for ; Fri, 26 Mar 2021 08:26:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A4C061A43 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:55900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPhnH-0005a1-BN for qemu-devel@archiver.kernel.org; Fri, 26 Mar 2021 04:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPhmO-00055a-1V for qemu-devel@nongnu.org; Fri, 26 Mar 2021 04:25:16 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:38593) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPhmM-0007NO-8L for qemu-devel@nongnu.org; Fri, 26 Mar 2021 04:25:15 -0400 Received: from mail-ot1-f41.google.com ([209.85.210.41]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1M7s1M-1lLptl2cy2-004zgb for ; Fri, 26 Mar 2021 09:25:11 +0100 Received: by mail-ot1-f41.google.com with SMTP id k14-20020a9d7dce0000b02901b866632f29so4537574otn.1 for ; Fri, 26 Mar 2021 01:25:11 -0700 (PDT) X-Gm-Message-State: AOAM531TBUcAHI+VcHChb1OtRG1zOw3VvtVLUx6ehp5CK5RS2BSYiexe dYOZzenp/l5Fe9GgIVwzdOTVwr9KPXa/RODsrFA= X-Google-Smtp-Source: ABdhPJxwvWvESfPTd02t+IoFzzcp+uwHFtku6RecXmeZzQv/Ma0pYPI21NV5X2ZN/+P2KhqlfpghX55GrZwNUDFm3ZA= X-Received: by 2002:a9d:316:: with SMTP id 22mr10917006otv.210.1616747110076; Fri, 26 Mar 2021 01:25:10 -0700 (PDT) MIME-Version: 1.0 References: <20210326071451.4m6ff5on5kwznx3v@vireshk-i7> In-Reply-To: <20210326071451.4m6ff5on5kwznx3v@vireshk-i7> From: Arnd Bergmann Date: Fri, 26 Mar 2021 09:24:54 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver To: Viresh Kumar Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:4ntH6FkuIIw+Nbn4C4rfD0kXcEGTs4uuITRxGn1JwQp6VEy9y/0 Nee06UqKl7Hf5zkumDWsKyL0xYFUoNqbFJu0A1o86pzdImxvZP9Jhj1DTAGBS58gztvvu/x y61bz5nNsUUZ+uDoNaKPopZKv8XGlViCUB3OCgnyWaz8WuMCVyLJ3x3FLIuljU7AFGUHwFR B5YERZm7yNRL7fw30IWFA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ovew43WhR7g=:EMhQxa8qO1E8mkyXHdG51H H/QWb6EO+JMgAJyhG2Qm77e3sf6++JDRRH5ueApXIZAuJ1LmoWNTqkEfZy2jogBCzd+SIe3Ga fk4+WcSKiPvB9HbnrrkYjDRzrK4sJKT5zy4O4ZRhhXzg/vnb7VkDGOD0N7VhLE0qF96WDg7Te EoaYKHf/TBiRB3ENgUVZBKdkDw9KKkPdA/dWR06RtVu4A7aamteasSjukXqLIiN19bl14XD3k 5BUtF0qqDZebFvn3n0tAUyepuFia7jqaxleg/CL8l0PBwEVGCPoqEbU+Kq/bpCk8wWKZcQO3Z QTF4s3nhYxMHv14SVybLAjBFtxFTml7bpF18RET692xeilyKQZeYctwnKIwLfqiWQLwsRyeRB DQzV3YADtj4gVGVXu9N6DRfYwb2ujnRDpnNHtJuNLh+zRmGesslGfBd/d/oFpb7TBHv7bhIaV iPDEXdE1AxP8tS3QQigXX4kPj4Q0x48= Received-SPF: none client-ip=212.227.17.24; envelope-from=arnd@arndb.de; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vincent Guittot , Jie Deng , Bill Mills , QEMU Developers , Arnd Bergmann , Mike Holmes , =?UTF-8?B?QWxleCBCZW5uw6ll?= , Stratos Mailing List Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Fri, Mar 26, 2021 at 8:14 AM Viresh Kumar wrote: > On 25-03-21, 17:16, Arnd Bergmann wrote: > > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar 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