cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

virtio-crypto.h (2448B)


      1/*
      2 * Virtio crypto Support
      3 *
      4 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
      5 *
      6 * Authors:
      7 *    Gonglei <arei.gonglei@huawei.com>
      8 *
      9 * This work is licensed under the terms of the GNU GPL, version 2 or
     10 * (at your option) any later version.  See the COPYING file in the
     11 * top-level directory.
     12 */
     13
     14#ifndef QEMU_VIRTIO_CRYPTO_H
     15#define QEMU_VIRTIO_CRYPTO_H
     16
     17#include "standard-headers/linux/virtio_crypto.h"
     18#include "hw/virtio/virtio.h"
     19#include "sysemu/iothread.h"
     20#include "sysemu/cryptodev.h"
     21#include "qom/object.h"
     22
     23
     24#define DEBUG_VIRTIO_CRYPTO 0
     25
     26#define DPRINTF(fmt, ...) \
     27do { \
     28    if (DEBUG_VIRTIO_CRYPTO) { \
     29        fprintf(stderr, "virtio_crypto: " fmt, ##__VA_ARGS__); \
     30    } \
     31} while (0)
     32
     33
     34#define TYPE_VIRTIO_CRYPTO "virtio-crypto-device"
     35OBJECT_DECLARE_SIMPLE_TYPE(VirtIOCrypto, VIRTIO_CRYPTO)
     36#define VIRTIO_CRYPTO_GET_PARENT_CLASS(obj) \
     37        OBJECT_GET_PARENT_CLASS(obj, TYPE_VIRTIO_CRYPTO)
     38
     39
     40typedef struct VirtIOCryptoConf {
     41    CryptoDevBackend *cryptodev;
     42
     43    /* Supported service mask */
     44    uint32_t crypto_services;
     45
     46    /* Detailed algorithms mask */
     47    uint32_t cipher_algo_l;
     48    uint32_t cipher_algo_h;
     49    uint32_t hash_algo;
     50    uint32_t mac_algo_l;
     51    uint32_t mac_algo_h;
     52    uint32_t aead_algo;
     53
     54    /* Maximum length of cipher key */
     55    uint32_t max_cipher_key_len;
     56    /* Maximum length of authenticated key */
     57    uint32_t max_auth_key_len;
     58    /* Maximum size of each crypto request's content */
     59    uint64_t max_size;
     60} VirtIOCryptoConf;
     61
     62struct VirtIOCrypto;
     63
     64typedef struct VirtIOCryptoReq {
     65    VirtQueueElement elem;
     66    /* flags of operation, such as type of algorithm */
     67    uint32_t flags;
     68    struct virtio_crypto_inhdr *in;
     69    struct iovec *in_iov; /* Head address of dest iovec */
     70    unsigned int in_num; /* Number of dest iovec */
     71    size_t in_len;
     72    VirtQueue *vq;
     73    struct VirtIOCrypto *vcrypto;
     74    union {
     75        CryptoDevBackendSymOpInfo *sym_op_info;
     76    } u;
     77} VirtIOCryptoReq;
     78
     79typedef struct VirtIOCryptoQueue {
     80    VirtQueue *dataq;
     81    QEMUBH *dataq_bh;
     82    struct VirtIOCrypto *vcrypto;
     83} VirtIOCryptoQueue;
     84
     85struct VirtIOCrypto {
     86    VirtIODevice parent_obj;
     87
     88    VirtQueue *ctrl_vq;
     89    VirtIOCryptoQueue *vqs;
     90    VirtIOCryptoConf conf;
     91    CryptoDevBackend *cryptodev;
     92
     93    uint32_t max_queues;
     94    uint32_t status;
     95
     96    int multiqueue;
     97    uint32_t curr_queues;
     98    size_t config_size;
     99    uint8_t vhost_started;
    100};
    101
    102#endif /* QEMU_VIRTIO_CRYPTO_H */