@@ -228,6 +228,7 @@ qemu_new_crypto_legacy_hw(CryptoClientInfo *info,
CryptoLegacyHWState *crypto;
CryptoClientState **peers = conf->peers.ccs;
int i, queues = MAX(1, conf->peers.queues);
+ int has_set = 0;
assert(info->type == CRYPTO_CLIENT_OPTIONS_KIND_LEGACY_HW);
assert(info->size >= sizeof(CryptoLegacyHWState));
@@ -242,6 +243,22 @@ qemu_new_crypto_legacy_hw(CryptoClientInfo *info,
NULL);
crypto->ccs[i].queue_index = i;
crypto->ccs[i].ready = true;
+ /* The mask bits of crypto_services and algos in
+ CryptoLegacyHWConf is set only once */
+ if (has_set == 0 && peers[i]) {
+ conf->crypto_services = peers[i]->crypto_services;
+ conf->cipher_algo_l = peers[i]->cipher_algo_l;
+ conf->cipher_algo_h = peers[i]->cipher_algo_h;
+ conf->hash_algo = peers[i]->hash_algo;
+ conf->mac_algo_l = peers[i]->mac_algo_l;
+ conf->mac_algo_h = peers[i]->mac_algo_h;
+ conf->asym_algo = peers[i]->asym_algo;
+ conf->kdf_algo = peers[i]->kdf_algo;
+ conf->aead_algo = peers[i]->aead_algo;
+ conf->primitive_algo = peers[i]->primitive_algo;
+
+ has_set = 1;
+ }
}
return crypto;
@@ -197,7 +197,33 @@ static Property virtio_crypto_properties[] = {
static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config)
{
-
+ VirtIOCrypto *c = VIRTIO_CRYPTO(vdev);
+ struct virtio_crypto_config crypto_cfg;
+
+ virtio_stl_p(vdev, &crypto_cfg.status, c->status);
+ virtio_stl_p(vdev, &crypto_cfg.max_dataqueues, c->max_queues);
+ virtio_stl_p(vdev, &crypto_cfg.crypto_services,
+ c->legacy_conf.crypto_services);
+ virtio_stl_p(vdev, &crypto_cfg.cipher_algo_l,
+ c->legacy_conf.cipher_algo_l);
+ virtio_stl_p(vdev, &crypto_cfg.cipher_algo_h,
+ c->legacy_conf.cipher_algo_h);
+ virtio_stl_p(vdev, &crypto_cfg.hash_algo,
+ c->legacy_conf.hash_algo);
+ virtio_stl_p(vdev, &crypto_cfg.mac_algo_l,
+ c->legacy_conf.mac_algo_l);
+ virtio_stl_p(vdev, &crypto_cfg.mac_algo_h,
+ c->legacy_conf.mac_algo_h);
+ virtio_stl_p(vdev, &crypto_cfg.asym_algo,
+ c->legacy_conf.asym_algo);
+ virtio_stl_p(vdev, &crypto_cfg.kdf_algo,
+ c->legacy_conf.kdf_algo);
+ virtio_stl_p(vdev, &crypto_cfg.aead_algo,
+ c->legacy_conf.aead_algo);
+ virtio_stl_p(vdev, &crypto_cfg.primitive_algo,
+ c->legacy_conf.primitive_algo);
+
+ memcpy(config, &crypto_cfg, c->config_size);
}
static void virtio_crypto_set_config(VirtIODevice *vdev, const uint8_t *config)
Set the crypto legacy hardware's capacity according to the backend peer cryptodev's capacity. We only support only one queue at present. Virtio crypto device is a kind of crypto legacy hardware. Signed-off-by: Gonglei <arei.gonglei@huawei.com> --- crypto/crypto.c | 17 +++++++++++++++++ hw/virtio/virtio-crypto.c | 28 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-)