Skip to content
Snippets Groups Projects
  1. Jun 16, 2022
    • Zhenwei Pi's avatar
      crypto: Introduce RSA algorithm · 0e660a6f
      Zhenwei Pi authored
      
      There are two parts in this patch:
      1, support akcipher service by cryptodev-builtin driver
      2, virtio-crypto driver supports akcipher service
      
      In principle, we should separate this into two patches, to avoid
      compiling error, merge them into one.
      
      Then virtio-crypto gets request from guest side, and forwards the
      request to builtin driver to handle it.
      
      Test with a guest linux:
      1, The self-test framework of crypto layer works fine in guest kernel
      2, Test with Linux guest(with asym support), the following script
      test(note that pkey_XXX is supported only in a newer version of keyutils):
        - both public key & private key
        - create/close session
        - encrypt/decrypt/sign/verify basic driver operation
        - also test with kernel crypto layer(pkey add/query)
      
      All the cases work fine.
      
      Run script in guest:
      rm -rf *.der *.pem *.pfx
      modprobe pkcs8_key_parser # if CONFIG_PKCS8_PRIVATE_KEY_PARSER=m
      rm -rf /tmp/data
      dd if=/dev/random of=/tmp/data count=1 bs=20
      
      openssl req -nodes -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -subj "/C=CN/ST=BJ/L=HD/O=qemu/OU=dev/CN=qemu/emailAddress=qemu@qemu.org"
      openssl pkcs8 -in key.pem -topk8 -nocrypt -outform DER -out key.der
      openssl x509 -in cert.pem -inform PEM -outform DER -out cert.der
      
      PRIV_KEY_ID=`cat key.der | keyctl padd asymmetric test_priv_key @s`
      echo "priv key id = "$PRIV_KEY_ID
      PUB_KEY_ID=`cat cert.der | keyctl padd asymmetric test_pub_key @s`
      echo "pub key id = "$PUB_KEY_ID
      
      keyctl pkey_query $PRIV_KEY_ID 0
      keyctl pkey_query $PUB_KEY_ID 0
      
      echo "Enc with priv key..."
      keyctl pkey_encrypt $PRIV_KEY_ID 0 /tmp/data enc=pkcs1 >/tmp/enc.priv
      echo "Dec with pub key..."
      keyctl pkey_decrypt $PRIV_KEY_ID 0 /tmp/enc.priv enc=pkcs1 >/tmp/dec
      cmp /tmp/data /tmp/dec
      
      echo "Sign with priv key..."
      keyctl pkey_sign $PRIV_KEY_ID 0 /tmp/data enc=pkcs1 hash=sha1 > /tmp/sig
      echo "Verify with pub key..."
      keyctl pkey_verify $PRIV_KEY_ID 0 /tmp/data /tmp/sig enc=pkcs1 hash=sha1
      
      echo "Enc with pub key..."
      keyctl pkey_encrypt $PUB_KEY_ID 0 /tmp/data enc=pkcs1 >/tmp/enc.pub
      echo "Dec with priv key..."
      keyctl pkey_decrypt $PRIV_KEY_ID 0 /tmp/enc.pub enc=pkcs1 >/tmp/dec
      cmp /tmp/data /tmp/dec
      
      echo "Verify with pub key..."
      keyctl pkey_verify $PUB_KEY_ID 0 /tmp/data /tmp/sig enc=pkcs1 hash=sha1
      
      Reviewed-by: default avatarGonglei <arei.gonglei@huawei.com>
      Signed-off-by: default avatarlei he <helei.sig11@bytedance.com>
      Signed-off-by: default avatarzhenwei pi <pizhenwei@bytedance.com>
      Message-Id: <20220611064243.24535-2-pizhenwei@bytedance.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      0e660a6f
    • Zhenzhong Duan's avatar
      virtio-iommu: Add an assert check in translate routine · 23b5f0ff
      Zhenzhong Duan authored
      
      With address space switch supported, dma access translation only
      happen after endpoint is attached to a non-bypass domain.
      
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@intel.com>
      Message-Id: <20220613061010.2674054-4-zhenzhong.duan@intel.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      23b5f0ff
    • Zhenzhong Duan's avatar
      virtio-iommu: Use recursive lock to avoid deadlock · 08f2030a
      Zhenzhong Duan authored
      
      When switching address space with mutex lock hold, mapping will be
      replayed for assigned device. This will trigger relock deadlock.
      
      Also release the mutex resource in unrealize routine.
      
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@intel.com>
      Message-Id: <20220613061010.2674054-3-zhenzhong.duan@intel.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      08f2030a
    • Zhenzhong Duan's avatar
      virtio-iommu: Add bypass mode support to assigned device · 90519b90
      Zhenzhong Duan authored
      
      Currently assigned devices can not work in virtio-iommu bypass mode.
      Guest driver fails to probe the device due to DMA failure. And the
      reason is because of lacking GPA -> HPA mappings when VM is created.
      
      Add a root container memory region to hold both bypass memory region
      and iommu memory region, so the switch between them is supported
      just like the implementation in virtual VT-d.
      
      Signed-off-by: default avatarZhenzhong Duan <zhenzhong.duan@intel.com>
      Message-Id: <20220613061010.2674054-2-zhenzhong.duan@intel.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      90519b90
    • Yajun Wu's avatar
      virtio/vhost-user: Fix wrong vhost notifier GPtrArray size · b595d627
      Yajun Wu authored
      
      In fetch_or_create_notifier, idx begins with 0. So the GPtrArray size
      should be idx + 1 and g_ptr_array_set_size should be called with idx + 1.
      
      This wrong GPtrArray size causes fetch_or_create_notifier return an invalid
      address. Passing this invalid pointer to vhost_user_host_notifier_remove
      causes assert fail:
      
          qemu/include/qemu/int128.h:27: int128_get64: Assertion `r == a' failed.
      	shutting down, reason=crashed
      
      Backends like dpdk-vdpa which sends out vhost notifier requests almost always
      hit qemu crash.
      
      Fixes: 503e3554 ("virtio/vhost-user: dynamically assign VhostUserHostNotifiers")
      Signed-off-by: default avatarYajun Wu <yajunw@nvidia.com>
      Acked-by: default avatarParav Pandit <parav@nvidia.com>
      Change-Id: I87e0f7591ca9a59d210879b260704a2d9e9d6bcd
      Message-Id: <20220526034851.683258-1-yajunw@nvidia.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarAlex Bennée <alex.bennee@linaro.org>
      Reviewed-by: default avatarEddie Dong <eddie.dong@intel.com>
      b595d627
    • Jonathan Cameron's avatar
      docs/cxl: Add switch documentation · 3afcbb7b
      Jonathan Cameron authored
      
      Switches were already introduced, but now we support them update
      the documentation to provide an example in diagram and
      qemu command line parameter forms.
      
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Message-Id: <20220616145126.8002-4-Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      3afcbb7b
    • Jonathan Cameron's avatar
      pci-bridge/cxl_downstream: Add a CXL switch downstream port · 18cef1c6
      Jonathan Cameron authored
      
      Emulation of a simple CXL Switch downstream port.
      The Device ID has been allocated for this use.
      
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Message-Id: <20220616145126.8002-3-Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      18cef1c6
    • Jonathan Cameron's avatar
      pci-bridge/cxl_upstream: Add a CXL switch upstream port · 638b752d
      Jonathan Cameron authored
      
      An initial simple upstream port emulation to allow the creation
      of CXL switches. The Device ID has been allocated for this use.
      
      Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
      Message-Id: <20220616145126.8002-2-Jonathan.Cameron@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      638b752d
    • Richard Henderson's avatar
      Merge tag 'for-upstream' of https://gitlab.com/bonzini/qemu into staging · def6fd6c
      Richard Henderson authored
      * statistics subsystem
      * virtio reset cleanups
      * build system cleanups
      * fix Cirrus CI
      
      # -----BEGIN PGP SIGNATURE-----
      #
      # iQFIBAABCAAyFiEE8TM4V0tmI4mGbHaCv/vSX3jHroMFAmKpooQUHHBib256aW5p
      # QHJlZGhhdC5jb20ACgkQv/vSX3jHroNlFwf+OugLGRZl3KVc7akQwUJe9gg2T31h
      # VkC+7Tei8FAwe8vDppVd+CYEIi0M3acxD2amRrv2etCCGSuySN1PbkfRcSfPBX01
      # pRWpasdhfqnZR8Iidi7YW1Ou5CcGqKH49nunBhW10+osb/mu5sVscMuOJgTDj/lK
      # CpsmDyk6572yGmczjNLlmhYcTU36clHpAZgazZHwk1PU+B3fCKlYYyvUpT3ItJvd
      # cK92aIUWrfofl3yTy0k4IwvZwNjTBirlstOIomZ333xzSA+mm5TR+mTvGRTZ69+a
      # v+snpMp4ILDMoB5kxQ42kK5WpdiN//LnriA9CBFDtOidsDDn8kx7gJe2RA==
      # =Dxwa
      # -----END PGP SIGNATURE-----
      # gpg: Signature made Wed 15 Jun 2022 02:12:36 AM PDT
      # gpg:                using RSA key F13338574B662389866C7682BFFBD25F78C7AE83
      # gpg:                issuer "pbonzini@redhat.com"
      # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" [undefined]
      # gpg:                 aka "Paolo Bonzini <pbonzini@redhat.com>" [undefined]
      # gpg: WARNING: This key is not certified with a trusted signature!
      # gpg:          There is no indication that the signature belongs to the owner.
      # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4  E2F7 7E15 100C CD36 69B1
      #      Subkey fingerprint: F133 3857 4B66 2389 866C  7682 BFFB D25F 78C7 AE83
      
      * tag 'for-upstream' of https://gitlab.com/bonzini/qemu
      
      : (21 commits)
        build: include pc-bios/ part in the ROMS variable
        meson: put cross compiler info in a separate section
        q35:Enable TSEG only when G_SMRAME and TSEG_EN both enabled
        build: fix check for -fsanitize-coverage-allowlist
        tests/vm: allow running tests in an unconfigured source tree
        configure: cleanup -fno-pie detection
        configure: update list of preserved environment variables
        virtio-mmio: cleanup reset
        virtio: stop ioeventfd on reset
        virtio-mmio: stop ioeventfd on legacy reset
        s390x: simplify virtio_ccw_reset_virtio
        block: add more commands to preconfig mode
        hmp: add filtering of statistics by name
        qmp: add filtering of statistics by name
        hmp: add filtering of statistics by provider
        qmp: add filtering of statistics by provider
        hmp: add basic "info stats" implementation
        cutils: add functions for IEC and SI prefixes
        qmp: add filtering of statistics by target vCPU
        kvm: Support for querying fd-based stats
        ...
      
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      def6fd6c
  2. Jun 15, 2022
  3. Jun 14, 2022
Loading