From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brljO-0004sE-Hl for qemu-devel@nongnu.org; Wed, 05 Oct 2016 08:55:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1brljJ-0000mp-Gx for qemu-devel@nongnu.org; Wed, 05 Oct 2016 08:55:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1brljJ-0000ml-76 for qemu-devel@nongnu.org; Wed, 05 Oct 2016 08:55:25 -0400 Date: Wed, 5 Oct 2016 13:55:22 +0100 From: Stefan Hajnoczi Message-ID: <20161005125522.GD863@stefanha-x1.localdomain> References: <1475051152-400276-1-git-send-email-arei.gonglei@huawei.com> <1475051152-400276-8-git-send-email-arei.gonglei@huawei.com> <20161004094610.GF4587@stefanha-x1.localdomain> <33183CC9F5247A488A2544077AF19020B03E65A7@SZXEMA503-MBS.china.huawei.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eheScQNz3K90DVRs" Content-Disposition: inline In-Reply-To: <33183CC9F5247A488A2544077AF19020B03E65A7@SZXEMA503-MBS.china.huawei.com> Subject: Re: [Qemu-devel] [virtio-dev] Re: [PATCH v4 07/13] virtio-crypto: set capacity of algorithms supported List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Gonglei (Arei)" Cc: "qemu-devel@nongnu.org" , "virtio-dev@lists.oasis-open.org" , Luonengjun , "mst@redhat.com" , "pbonzini@redhat.com" , "berrange@redhat.com" , "Huangweidong (C)" , "Wubin (H)" , "mike.caraman@nxp.com" , "agraf@suse.de" , "xin.zeng@intel.com" , Claudio Fontana , "nmorey@kalray.eu" , "vincent.jardin@6wind.com" , "Zhoujian (jay, Euler)" , "Hanweidong (Randy)" , "Huangpeng (Peter)" --eheScQNz3K90DVRs Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 05, 2016 at 03:30:42AM +0000, Gonglei (Arei) wrote: >=20 > > -----Original Message----- > > From: virtio-dev@lists.oasis-open.org [mailto:virtio-dev@lists.oasis-op= en.org] > > On Behalf Of Stefan Hajnoczi > > Sent: Tuesday, October 04, 2016 5:46 PM > > Subject: [virtio-dev] Re: [PATCH v4 07/13] virtio-crypto: set capacity = of > > algorithms supported > >=20 > > On Wed, Sep 28, 2016 at 04:25:46PM +0800, Gonglei wrote: > > > static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *co= nfig) > > > { > > > - > > > + VirtIOCrypto *c =3D VIRTIO_CRYPTO(vdev); > > > + struct virtio_crypto_config crypto_cfg; > > > + > > > + crypto_cfg.status =3D c->status; > > > + crypto_cfg.max_dataqueues =3D c->max_queues; > > > + crypto_cfg.crypto_services =3D c->conf.crypto_services; > > > + crypto_cfg.cipher_algo_l =3D c->conf.cipher_algo_l; > > > + crypto_cfg.cipher_algo_h =3D c->conf.cipher_algo_h; > > > + crypto_cfg.hash_algo =3D c->conf.hash_algo; > > > + crypto_cfg.mac_algo_l =3D c->conf.mac_algo_l; > > > + crypto_cfg.mac_algo_h =3D c->conf.mac_algo_h; > > > + crypto_cfg.aead_algo =3D c->conf.aead_algo; > > > + > > > + memcpy(config, &crypto_cfg, c->config_size); > > > } > >=20 > > What about endianness? For example, if the host is big-endian then this > > VIRTIO 1.0 device needs to byteswap multi-byte fields. There is a > > family of functions to help with this: virtio_stl_p(). >=20 > I did that in v1. Michael told me that Virtio-1.0 devices are always litt= le-endian, so > I removed those helper functions in the following functions. But after th= is version, > the virtio-crypto device isn't virtio-1.0 device by default, so I should = use them again. Endian awareness is still necessary for VIRTIO 1.0-only devices. The uint8_t *config data is just a blob. Therefore nothing automatically handles little-endian conversion for us. We *must* read little-endian =66rom config[]. --eheScQNz3K90DVRs Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJX9Pg6AAoJEJykq7OBq3PIgAwIAKlhDuPXyouhhMpEKVD4xYzh 9S6O1b6lULUvYqJyI2stPOQ6CdHri0UPRGTCv26fxm1i1gCz6YlHIpIU4YkHj2O9 WEYazki04FNcSvRsWiU3xFjOVlOF0t8FzB0N2UW5Auft5osnDp7Cqm75YlhD2s+T Q30YNgk3YzP9PdKlUYgUcva5jH7Ccr0w5zBhtqxQvAQnIeHk0eQ8bBnmnZ8SLJJ+ RWlmcI4Qi2rZjxr8xzsf2ekEVj14pxISmnrWFYdlu0hIakZj9AagZtHL25bdCCJI h0K/s4QE29wGF5XYxVAHN1soX9+pyajIfV7qTXsBoJtDmyRvwW7nHHaFT10t7JM= =EJRF -----END PGP SIGNATURE----- --eheScQNz3K90DVRs--