qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [virtio-dev] Re: [PATCH v4 07/13] virtio-crypto: set ca


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [virtio-dev] Re: [PATCH v4 07/13] virtio-crypto: set capacity of algorithms supported
Date: Wed, 5 Oct 2016 13:55:22 +0100
User-agent: Mutt/1.7.0 (2016-08-17)

On Wed, Oct 05, 2016 at 03:30:42AM +0000, Gonglei (Arei) wrote:
> 
> > -----Original Message-----
> > From: address@hidden [mailto:address@hidden
> > 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
> > 
> > On Wed, Sep 28, 2016 at 04:25:46PM +0800, Gonglei wrote:
> > >  static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config)
> > >  {
> > > -
> > > +    VirtIOCrypto *c = VIRTIO_CRYPTO(vdev);
> > > +    struct virtio_crypto_config crypto_cfg;
> > > +
> > > +    crypto_cfg.status = c->status;
> > > +    crypto_cfg.max_dataqueues = c->max_queues;
> > > +    crypto_cfg.crypto_services = c->conf.crypto_services;
> > > +    crypto_cfg.cipher_algo_l = c->conf.cipher_algo_l;
> > > +    crypto_cfg.cipher_algo_h = c->conf.cipher_algo_h;
> > > +    crypto_cfg.hash_algo = c->conf.hash_algo;
> > > +    crypto_cfg.mac_algo_l = c->conf.mac_algo_l;
> > > +    crypto_cfg.mac_algo_h = c->conf.mac_algo_h;
> > > +    crypto_cfg.aead_algo = c->conf.aead_algo;
> > > +
> > > +    memcpy(config, &crypto_cfg, c->config_size);
> > >  }
> > 
> > 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().
> 
> I did that in v1. Michael told me that Virtio-1.0 devices are always 
> little-endian, so
> I removed those helper functions in the following functions. But after this 
> 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
from config[].

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]