@@ -43,7 +43,10 @@ See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
4343 - [ Setting the certificate] ( #setting-the-certificate )
4444 - [ Getting a Certificate Signing Request] ( #getting-a-certificate-signing-request )
4545 - [ Signing a Certificate Signing Request] ( #signing-a-certificate-signing-request )
46- - [ QEMU SPDM Device Emulation] ( #qemu-spdm-device-emulation )
46+ - [ Responder emulation with QEMU] ( #responder-emulation-with-qemu )
47+ - [ Using a QEMU emulated NVMe device with SPDM over DoE] ( #using-a-qemu-emulated-nvme-device-with-spdm-over-doe )
48+ - [ Using a QEMU emulated NVMe device with SPDM over Storage] ( #using-a-qemu-emulated-nvme-device-with-spdm-over-storage )
49+ - [ tcmu-runner SPDM Device Emulation] ( #tcmu-runner-spdm-device-emulation )
4750
4851# Dependencies
4952
@@ -57,11 +60,11 @@ Note: `dnf` commands are for Fedora, and `apt` is used for Debian/Ubuntu based
5760distributions.
5861
5962``` shell
60- $ sudo dnf install cmake clang-libs clang-devel pciutils-devel openssl openssl-devel python3-devel systemd-devel
63+ $ sudo dnf install cmake clang-libs clang-devel pciutils-devel openssl openssl-devel python3-devel systemd-devel libnvme
6164
6265or
6366
64- $ sudo apt install cmake clang libclang-dev pciutils libpci-dev openssl libssl-dev libsystemd-dev python3-dev pkg-config
67+ $ sudo apt install cmake clang libclang-dev pciutils libpci-dev openssl libssl-dev libsystemd-dev python3-dev pkg-config libnvme-dev
6568```
6669
6770### Ruby
@@ -274,6 +277,8 @@ to the responder.
274277
275278## Testing a real device
276279
280+ ### PCIe DOE
281+
277282You can run SPDM-Utils on the host to interact with a real DOE device. To do
278283that you can run the following example to get digest information
279284
@@ -298,6 +303,14 @@ invoked as below:
298303``` shell
299304./target/debug/spdm_utils --pcie-vid < VendorID> --pcie-devid < DeviceID> --doe-pci-cfg request get-digests
300305```
306+ ### SCSI/NVMe devices over the SPDM Storage Transport
307+
308+ SPDM-utils supports the SPDM over storage transport as defined by the DMTF DSP0286.
309+ For example, the following command can be used to interact with an NVMe device.
310+
311+ ``` shell
312+ $ ./target/debug/spdm_utils --blk-dev-path /dev/nvme0 --nvme --no-session request get-version,get-capabilities
313+ ```
301314
302315## Retrieving Certificates
303316
@@ -397,8 +410,7 @@ cd certs
397410./setup_certs.sh ../target/debug/spdm_utils
398411cd ../
399412```
400-
401- # QEMU SPDM Device Emulation
413+ # Responder emulation with QEMU
402414
403415SPDM-Utils supports binding to QEMU to implement an SPDM responder side to
404416an emulated device in QEMU. SPDM support for QEMU is not upstream yet, however,
@@ -409,8 +421,11 @@ over DOE.
409421For example, this may be an emulated NVMe device
410422in QEMU that binds to SPDM-Utils for the SPDM responder implementation.
411423
412- With the current SPDM implementation in QEMU, the only transport layer supported
413- is DOE. SPDM-Utils must be started before QEMU for this to work.
424+ ## Using a QEMU emulated NVMe device with SPDM over DoE
425+
426+ For this example, we are using DOE. This is the transport protocol that
427+ SPDM-Utils defaults to when not explicitly specified. SPDM-Utils must be started
428+ before QEMU for this to work.
414429
415430``` shell
416431$ ./target/debug/spdm_utils --qemu-server response
@@ -433,3 +448,78 @@ should show (ensure that INFO log level is enabled in SPDM-Utils).
433448```
434449
435450Now QEMU is ready to use SPDM-Utils as an SPDM responder for an emulated device.
451+
452+ ## Using a QEMU emulated NVMe device with SPDM over Storage
453+
454+ In this example, let's look at using the an emulated NVMe device on QEMU that
455+ uses the SPDM over Storage transport protocol. That is, SPDM messages are
456+ communicated to the NVMe device through the NVMe Security Send/Receive commands.
457+
458+ As before, we need to start SPDM-Utils before QEMU, the following options are
459+ required.
460+
461+ ``` shell
462+ $ ./target/debug/spdm_utils --qemu-server --spdm-transport-protocol=storage response
463+
464+ [2024-06-07T00:09:06Z DEBUG spdm_utils] Logger initialisation [OK]
465+ [2024-06-07T00:09:06Z INFO spdm_utils] Using Nvme transport for QEMU
466+ [2024-06-07T00:09:06Z DEBUG spdm_utils::qemu_server] Setting up a server on [port: 2323, ip: 127.0.0.1]
467+ [2024-06-07T00:09:06Z INFO spdm_utils::qemu_server] Server started, waiting for qemu on port: 2323
468+ ```
469+
470+ You can now start the QEMU guest and the connection to the SPDM-Utils responder
471+ server shall be established.
472+
473+ # tcmu-runner SPDM Device Emulation
474+
475+ tcmu-runner is a daemon that handles the user-space side of the LIO TCM-User
476+ backstore. Using ` tcmu-runner ` and the ` target_core_user ` kernel module we
477+ can emulate a ZBC block device that supports SPDM. We use SPDM-Utils to
478+ encode/decode the messages as a responder. Any tool can then be used to
479+ interact with the block device as a requester. In this example we use
480+ SPDM-Utils for this as well.
481+
482+ ### Start SPDM-Utils response server
483+
484+ First we want to start a SPDM-Utils server to act as a SPDM responder.
485+
486+ ``` shell
487+ $ ./target/debug/spdm_utils --spdm-transport-protocol=storage --qemu-server response
488+ ```
489+
490+ ### Start tcmu-runner
491+
492+ Then start ` tcmu-runner ` , it will connect to SPDM-Utils
493+
494+ ``` shell
495+ $ sudo tcmu-runner --debug
496+ ```
497+
498+ ### Create a block device
499+
500+ We can now setup the block device
501+
502+ ``` shell
503+ $ sudo ./scripts/scsi/create-disk-spdm.sh tcmudevel 2 HM 128 10
504+ ```
505+
506+ If you now run ` lsscsi ` you should see a ` TCMU ` entry
507+
508+ ```
509+ [2:0:1:0] zbc LIO-ORG TCMU ZBC device 0002 /dev/sda
510+ ```
511+
512+ ### Run a requester (SPDM-Utils)
513+
514+ ``` shell
515+ $ sudo ./target/debug/spdm_utils --scsi --blk-dev-path=/dev/sda request get-version
516+ ```
517+
518+ ### Teardown/remove the created block device.
519+
520+ To remove the block device, the following script can be used while ` tcmu-runner `
521+ is still active
522+
523+ ``` shell
524+ $ sudo ./teardown-disk.sh tcmudevel
525+ ```
0 commit comments