Testing PCIe DOE in QEMU CXL/PCIe Device using openspdm
cover Testing PCIe DOE in QEMU CXL/PCIe Device using openspdm
This patch series provides an implementation of the the Data Object Exchange (DOE) for Component Measurement and Authentication (CMA) of the Security Protocol and Data Model (SPDM).
This patch is based on
[1] Openspdm: https://github.com/jyao1/openspdm.git
Openspdm is an emulator composed of an SPDM requester and an SPDM responder. The default SpdmEmu usage have the requester and responder communicate with each other via a TCP socket.
However to test PCIe DOE support in QEMU PCIe/CXL device directly, the openspdm requester is modified to use pwrite/pread for MMIO access to the QEMU CXL Device DOE capability (hw/mem/cxl_type3.c). The openspdm requester is run as user application targeting the CXL Device.
Follow the readme.md under [1] to build this enhanced version of openspdm.
This patch series is to be used with a subsequent QEMU patch series to be concurrently with this patch series. Full instructions will be included there.
hchkuo (2):
build: gcc to CC in GNUMakefile
requester: Modified for QEMU emulation
GNUmakefile.Flags | 4 +- Include/IndustryStandard/PciDoeBinding.h | 27 +++++++ SpdmEmu/SpdmEmuCommon/SpdmEmu.c | 85 ++++++++++++++++++++++ SpdmEmu/SpdmEmuCommon/SpdmEmu.h | 7 ++ SpdmEmu/SpdmRequesterEmu/SpdmRequester.c | 100 +++++++++++++++++++------ SpdmEmu/SpdmRequesterEmu/SpdmRequesterEmu.c | 109 +++++++++++++++++++++++++--- SpdmEmu/SpdmRequesterEmu/SpdmRequesterEmu.h | 5 ++ 7 files changed, 302 insertions(+), 35 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 build: gcc to CC in GNUMakefile
From: hchkuo <[email protected]>
Modified gcc to CC in GNUMakefile, so that we can specify the gcc version
--- GNUmakefile.Flags | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
GNUmakefile.Flags +2 -2
@@ -114,9 +114,9 @@ else ifeq ("$(TOOLCHAIN)","GCC") CMOCKA_FLAGS = -std=gnu99 -Wpedantic -Wall -Wshadow -Wmissing-prototypes -Wcast-align -Werror=address -Wstrict-prototypes -Werror=strict-prototypes -Wwrite-strings -Werror=write-strings -Werror-implicit-function-declaration -Wpointer-arith -Werror=pointer-arith -Wdeclaration-after-statement -Werror=declaration-after-statement -Wreturn-type -Werror=return-type -Wuninitialized -Werror=uninitialized -Werror=strict-overflow -Wstrict-overflow=2 -Wno-format-zero-length -Wmissing-field-initializers -Wformat-security -Werror=format-security -fno-common -Wformat -fno-common -fstack-protector-strong CC_FLAGS += --coverage -fprofile-arcs -ftest-coverage - SLINK = gcc-ar + SLINK = $(CC)-ar - DLINK = gcc + DLINK = $(CC) DLINK_OBJECT_FILES = -Wl,--start-group,@$(OUTPUT_DIR)/tmp.list,--end-group DLINK_FLAGS = -o $(BIN_DIR)/$(BASE_NAME) -flto -L/usr/X11R6/lib DLINK_FLAGS2 = -Wno-error -no-pie
Signature · 1 line
1.8.3.1
PATCH 2/2 requester: Modified for QEMU emulation
In reply to Chris BrowyFrom: hchkuo <[email protected]>
The requester should be used as a PCIe app to access the SPDM object in the PCEe device.
--- Include/IndustryStandard/PciDoeBinding.h | 27 +++++++ SpdmEmu/SpdmEmuCommon/SpdmEmu.c | 85 ++++++++++++++++++++++ SpdmEmu/SpdmEmuCommon/SpdmEmu.h | 7 ++ SpdmEmu/SpdmRequesterEmu/SpdmRequester.c | 100 +++++++++++++++++++------ SpdmEmu/SpdmRequesterEmu/SpdmRequesterEmu.c | 109 +++++++++++++++++++++++++--- SpdmEmu/SpdmRequesterEmu/SpdmRequesterEmu.h | 5 ++ 6 files changed, 300 insertions(+), 33 deletions(-)
Include/IndustryStandard/PciDoeBinding.h +27 -0
@@ -29,6 +29,33 @@ typedef struct {//UINT32 DataObjectDW[Length]; }PCI_DOE_DATA_OBJECT_HEADER ; +/* Extended Capabilities (PCI-X 2.0 and Express) */ +#define PCI_EXT_CAP_ID (header) (header & 0x0000ffff) +#define PCI_EXT_CAP_VER (header) ((header >> 16) & 0xf) +#define PCI_EXT_CAP_NEXT (header) ((header >> 20) & 0xffc) + +#define PCIE_EXT_CAP_OFFSET 0x100 +#define PCI_EXT_CAP_ID_DOE 0x2e/* Data Object Exchange */ + +/* DOE Capabilities Register */ +#define PCIE_DOE_CAP 0x04 +#define PCIE_DOE_CAP_INTR_SUPP 0x00000001 +/* DOE Control Register */ +#define PCIE_DOE_CTRL 0x08 +#define PCIE_DOE_CTRL_ABORT 0x00000001 +#define PCIE_DOE_CTRL_INTR_EN 0x00000002 +#define PCIE_DOE_CTRL_GO 0x80000000 +/* DOE Status Register */ +#define PCIE_DOE_STATUS 0x0c +#define PCIE_DOE_STATUS_BUSY 0x00000001 +#define PCIE_DOE_STATUS_INTR 0x00000002 +#define PCIE_DOE_STATUS_ERR 0x00000004 +#define PCIE_DOE_STATUS_DO_RDY 0x80000000 +/* DOE Write Data Mailbox Register */ +#define PCIE_DOE_WR_DATA_MBOX 0x10 +/* DOE Read Data Mailbox Register */ +#define PCIE_DOE_RD_DATA_MBOX 0x14 +#define PCI_DOE_VENDOR_ID_PCISIG 0x0001#define PCI_DOE_DATA_OBJECT_TYPE_DOE_DISCOVERY 0x00
SpdmEmu/SpdmEmuCommon/SpdmEmu.c +85 -0
109 lines not on this page · raw message
SpdmEmu/SpdmEmuCommon/SpdmEmu.h +7 -0
@@ -156,4 +156,11 @@ ProcessArgs (char *argv[ ] ); +struct pcie_dev { +int pdev; +int domain; +int bus; +int slot; +int func; +};#endif
SpdmEmu/SpdmRequesterEmu/SpdmRequester.c +78 -22
129 lines not on this page · raw message
SpdmEmu/SpdmRequesterEmu/SpdmRequesterEmu.c +98 -11
161 lines not on this page · raw message
SpdmEmu/SpdmRequesterEmu/SpdmRequesterEmu.h +5 -0
@@ -20,4 +20,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent#include "stdio.h" #include "SpdmEmu.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +extern UINT32 mDOEBaseAddress;#endif
Signature · 1 line
1.8.3.1