platform/x86/intel/sdsi: Add ioctl SPDM transport
Subsystems (3)
David E. Box
maintainerPATCH v3 1/3 platform/x86/intel/sdsi: Add ioctl SPDM transport
Intel On Demand adds attestation and firmware measurement retrieval services through use of the protocols defined the Security Protocols and Data Measurement (SPDM) specification. SPDM messages exchanges are used to authenticate On Demand hardware and to retrieve signed measurements of the NVRAM state used to track feature provisioning and the NVRAM state used for metering services. These allow software to verify the authenticity of the On Demand hardware as well as the integrity of the reported silicon configuration.
Add an ioctl interface for sending SPDM messages through the On Demand mailbox. Provides commands to get a list of SPDM enabled devices, get the message size limits for SPDM Requesters and Responders, and perform an SPDM message exchange.
---
V3
- Use %zu format for size_t
- Simplify return in sdsi_spdm_ioctl()
V2
- Move size < 4 check into sdsi_spdm_exchange() and add comment clarifying return values of that function.
- Use SZ_4K and add helpers
- Use devm_kasprintf()
- Remove unnecessary parens
- Use --attest for long option
.../userspace-api/ioctl/ioctl-number.rst | 1 + MAINTAINERS | 1 + drivers/platform/x86/intel/sdsi.c | 207 +++++++++++++++++- include/uapi/linux/intel_sdsi.h | 81 +++++++ 4 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 include/uapi/linux/intel_sdsi.h
Documentation/userspace-api/ioctl/ioctl-number.rst +1 -0
@@ -384,6 +384,7 @@ Code Seq# Include File Comments <mailto:[email protected]> 0xF8 all arch/x86/include/uapi/asm/amd_hsmp.h AMD HSMP EPYC system management interface driver <mailto:[email protected]> +0xFC all linux/intel_sdsi.h 0xFD all linux/dm-ioctl.h 0xFE all linux/isst_if.h ==== ===== ======================================================= ================================================================
MAINTAINERS +1 -0
@@ -11343,6 +11343,7 @@ INTEL SDSI DRIVER M: David E. Box <[email protected]> S: Supported F: drivers/platform/x86/intel/sdsi.c +F: include/uapi/linux/intel_sdsi.h F: tools/arch/x86/intel_sdsi/ F: tools/testing/selftests/drivers/sdsi/
drivers/platform/x86/intel/sdsi.c +206 -1
273 lines not on this page · raw message
include/uapi/linux/intel_sdsi.h new file +81 -0
81 lines not on this page · raw message
base-commit: c3f38fa61af77b49866b006939479069cd451173
Signature · 1 line
2.34.1
David E. Box
maintainerPATCH v3 2/3 tools/arch/x86/intel_sdsi: Rework Makefile
In preparation for more source files, rework the Makefile to handle prerequisites more generically, making it easier to isolate future changes. Also update PHONY targets.
---
V3 - No change.
V2 - New Patch.
tools/arch/x86/intel_sdsi/Makefile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
tools/arch/x86/intel_sdsi/Makefile +14 -10
@@ -1,21 +1,25 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for Intel Software Defined Silicon provisioning tool - -intel_sdsi: intel_sdsi.c - -CFLAGS = -Wextra - +include ../../../scripts/Makefile.include BINDIR ?= /usr/sbin -override CFLAGS += -O2 -Wall +SRCS = intel_sdsi.c -%: %.c - $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) +OBJS = $(SRCS:.c=.o) + +override CFLAGS += -O2 -Wall -Wextra + +intel_sdsi: $(OBJS) + $(CC) $(CFLAGS) $(OBJS) -o $@ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ -.PHONY : clean clean : - @rm -f intel_sdsi + @rm -f intel_sdsi $(OBJS) install : intel_sdsi install -d $(DESTDIR)$(BINDIR) install -m 755 -p intel_sdsi $(DESTDIR)$(BINDIR)/intel_sdsi + +.PHONY : clean install
Signature · 1 line
2.34.1
David E. Box
maintainerPATCH v3 3/3 tools/arch/x86/intel_sdsi: Add attestation support
In reply to David E. BoxAdd support in the intel_sdsi tool to perform SPDM GET_DIGESTS and GET_CERTIFICATE commands. Output is sent to stdout.
Example reading the certificate chain from socket 0:
intel_sdsi -d 1 -attest get_certificate | openssl x509 -inform DER -nout -text
---
V3 - No change
V2 - Remove unnecessary struct packing
- Remove newline from perror()
- Add message options in --help output
- Use new SDSI_SPDM_BUF_SIZE from uapi header
- In spdm_get_certificate:
- Initialize remainder length to the minimum of the actual size or the maximum buffer size.
- Add old_remainder to test that the remaining certificate length is less than the previous length
tools/arch/x86/intel_sdsi/Makefile | 11 +- tools/arch/x86/intel_sdsi/intel_sdsi.c | 72 +++- tools/arch/x86/intel_sdsi/spdm.c | 476 +++++++++++++++++++++++++ tools/arch/x86/intel_sdsi/spdm.h | 13 + 4 files changed, 567 insertions(+), 5 deletions(-) create mode 100644 tools/arch/x86/intel_sdsi/spdm.c create mode 100644 tools/arch/x86/intel_sdsi/spdm.h
tools/arch/x86/intel_sdsi/Makefile +7 -4
@@ -3,20 +3,23 @@ include ../../../scripts/Makefile.include BINDIR ?= /usr/sbin -SRCS = intel_sdsi.c +SRCS = intel_sdsi.c spdm.c OBJS = $(SRCS:.c=.o) -override CFLAGS += -O2 -Wall -Wextra +override CFLAGS += -O2 -Wall -Wextra -I../../../include -intel_sdsi: $(OBJS) +intel_sdsi: intel_sdsi.h $(OBJS) $(CC) $(CFLAGS) $(OBJS) -o $@ +intel_sdsi.h: ../../../../include/uapi/linux/intel_sdsi.h + ln -sf ../../../../include/uapi/linux/intel_sdsi.h $@ + %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ clean : - @rm -f intel_sdsi $(OBJS) + @rm -f intel_sdsi intel_sdsi.h $(OBJS) install : intel_sdsi install -d $(DESTDIR)$(BINDIR)
tools/arch/x86/intel_sdsi/intel_sdsi.c +71 -1
137 lines not on this page · raw message
tools/arch/x86/intel_sdsi/spdm.c new file +476 -0
476 lines not on this page · raw message
tools/arch/x86/intel_sdsi/spdm.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#include <stdint.h> + +#define TPM_ALG_SHA_384_SIZE 48 + +struct cert_chain { +void *chain; +size_t len; +}; + +int spdm_get_digests (int dev_no,uint8_t digest[TPM_ALG_SHA_384_SIZE ]); +int spdm_get_certificate (int dev_no,struct cert_chain *c); +
Signature · 1 line
2.34.1
kernel test robot
build botkernel test robot noticed the following build errors:
Hi David,
kernel test robot noticed the following build errors:
[auto build test ERROR on c3f38fa61af77b49866b006939479069cd451173]
url: https://github.com/intel-lab-lkp/linux/commits/David-E-Box/tools-arch-x86-intel_sdsi-Rework-Makefile/20240606-091801 base: c3f38fa61af77b49866b006939479069cd451173 patch link: https://lore.kernel.org/r/20240606011617.557264-1-david.e.box%40linux.intel.com patch subject: [PATCH V3 1/3] platform/x86/intel/sdsi: Add ioctl SPDM transport config: i386-buildonly-randconfig-003-20240606 (https://download.01.org/0day-ci/archive/20240606/[email protected]/config) compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240606/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from <built-in>:1:
>> ./usr/include/linux/intel_sdsi.h:13:10: fatal error: 'linux/sizes.h' file not found
13 | #include <linux/sizes.h>
| ^~~~~~~~~~~~~~~1 error generated.
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi David,
kernel test robot noticed the following build errors:
[auto build test ERROR on c3f38fa61af77b49866b006939479069cd451173]
url: https://github.com/intel-lab-lkp/linux/commits/David-E-Box/tools-arch-x86-intel_sdsi-Rework-Makefile/20240606-091801 base: c3f38fa61af77b49866b006939479069cd451173 patch link: https://lore.kernel.org/r/20240606011617.557264-1-david.e.box%40linux.intel.com patch subject: [PATCH V3 1/3] platform/x86/intel/sdsi: Add ioctl SPDM transport config: x86_64-buildonly-randconfig-003-20240606 (https://download.01.org/0day-ci/archive/20240607/[email protected]/config) compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240607/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from <command-line>:
>> ./usr/include/linux/intel_sdsi.h:13:10: fatal error: linux/sizes.h: No such file or directory
13 | #include <linux/sizes.h>
| ^~~~~~~~~~~~~~~compilation terminated.
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi David,
kernel test robot noticed the following build warnings:
[auto build test WARNING on c3f38fa61af77b49866b006939479069cd451173]
url: https://github.com/intel-lab-lkp/linux/commits/David-E-Box/tools-arch-x86-intel_sdsi-Rework-Makefile/20240606-091801 base: c3f38fa61af77b49866b006939479069cd451173 patch link: https://lore.kernel.org/r/20240606011617.557264-1-david.e.box%40linux.intel.com patch subject: [PATCH V3 1/3] platform/x86/intel/sdsi: Add ioctl SPDM transport config: x86_64-randconfig-161-20240606 (https://download.01.org/0day-ci/archive/20240607/[email protected]/config) compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
smatch warnings:drivers/platform/x86/intel/sdsi.c:795 sdsi_spdm_do_command() warn: unsigned 'rsp_size' is never less than zero.
vim +/rsp_size +795 drivers/platform/x86/intel/sdsi.c
768
769 static int sdsi_spdm_do_command(struct sdsi_priv *priv,
770 struct sdsi_spdm_command __user *argp)
771 {
772 u32 req_size, rsp_size;
773
774 if (get_user(req_size, &argp->size))
775 return -EFAULT;
776
777 if (req_size < 4 || req_size > sizeof(struct sdsi_spdm_message))
778 return -EINVAL;
779
780 struct sdsi_spdm_message *request __free(kfree) =
781 kmalloc(req_size, GFP_KERNEL);
782 if (!request)
783 return -ENOMEM;
784
785 struct sdsi_spdm_command *response __free(kfree) =
786 kmalloc(SDSI_SIZE_READ_MSG, GFP_KERNEL);
787 if (!response)
788 return -ENOMEM;
789
790 if (copy_from_user(request, &argp->message, req_size))
791 return -EFAULT;
792
793 rsp_size = sdsi_spdm_exchange(priv, request, req_size, response,
794 SDSI_SIZE_READ_MSG);
> 795 if (rsp_size < 0)
796 return rsp_size;
797
798 if (put_user(rsp_size, &argp->size))
799 return -EFAULT;
800
801 if (copy_to_user(&argp->message, response, rsp_size))
802 return -EFAULT;
803
804 return 0;
805 }
806
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Ilpo Järvinen
maintainerQuoted 18 lines · David E. Box
Intel On Demand adds attestation and firmware measurement retrieval services through use of the protocols defined the Security Protocols and Data Measurement (SPDM) specification. SPDM messages exchanges are used to authenticate On Demand hardware and to retrieve signed measurements of the NVRAM state used to track feature provisioning and the NVRAM state used for metering services. These allow software to verify the authenticity of the On Demand hardware as well as the integrity of the reported silicon configuration.
Add an ioctl interface for sending SPDM messages through the On Demand mailbox. Provides commands to get a list of SPDM enabled devices, get the message size limits for SPDM Requesters and Responders, and perform an SPDM message exchange.
Signed-off-by David E. Box <[email protected]>---
drivers/platform/x86/intel/sdsi.c static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *paren · line 777
Quoted 9 lines
drivers/platform/x86/intel/sdsi.c +9
-0+static int sdsi_spdm_do_command (struct sdsi_priv *priv, +struct sdsi_spdm_command __user *argp) +{ +u32 req_size, rsp_size; + +if (get_user (req_size, &argp->size)) +return -EFAULT ; + +if (req_size <4 || req_size >sizeof (struct sdsi_spdm_message ))
Hi David,
Is that 4 actually SPDM_HEADER_SIZE?
If my guess is correct, no need to send an updated version, I'll just fix it while applying.
Signature · 1 line
i.
David E. Box
maintainerQuoted 34 lines · Ilpo Järvinen
Quoted 20 lines · David E. Box
Intel On Demand adds attestation and firmware measurement retrieval services through use of the protocols defined the Security Protocols and Data Measurement (SPDM) specification. SPDM messages exchanges are used to authenticate On Demand hardware and to retrieve signed measurements of the NVRAM state used to track feature provisioning and the NVRAM state used for metering services. These allow software to verify the authenticity of the On Demand hardware as well as the integrity of the reported silicon configuration.
Add an ioctl interface for sending SPDM messages through the On Demand mailbox. Provides commands to get a list of SPDM enabled devices, get the message size limits for SPDM Requesters and Responders, and perform an SPDM message exchange.
Signed-off-by David E. Box <[email protected]>Link:
https://www.dmtf.org/sites/default/files/standards/documents/DSP0274_1.0.1.pdf
[1]
---drivers/platform/x86/intel/sdsi.c static int sdsi_map_mbox_registers(struct sdsi_priv *priv, struct pci_dev *paren · line 777
Quoted 9 lines
drivers/platform/x86/intel/sdsi.c +9
-0+static int sdsi_spdm_do_command (struct sdsi_priv *priv, + struct sdsi_spdm_command __user *argp) +{ + u32 req_size, rsp_size; + + if (get_user(req_size, &argp->size)) + return -EFAULT; + + if (req_size < 4 || req_size > sizeof(struct sdsi_spdm_message))Hi David,
Quoted 4 lines
Is that 4 actually
SPDM_HEADER_SIZE?If my guess is correct, no need to send an updated version, I'll just fix it while applying.
It is SPDM_HEADER_SIZE but I already fixed it in V4 since I had to address an LKP report.
David