Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH kernel 0/4] PCI/TSM queue
@ 2026-11-19 12:57 Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 1/4] MAINTAINERS: Update TSM file coverage and repository Alexey Kardashevskiy
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2026-11-19 12:57 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, linux-crypto, Ashish Kalra, Tom Lendacky,
	Aneesh Kumar K.V, Jason Gunthorpe, Lukas Wunner, Herbert Xu,
	David S. Miller, Kuppuswamy Sathyanarayanan, Jonathan Cameron,
	linux-coco, Santosh Shukla, Pratik R . Sampat,
	Scott Soule Cheloha, Ackerley Tng, Sean Christopherson,
	Fuad Tabba, Xu Yilun, Alexey Kardashevskiy, aik

There is a new git repo which is set up to track TSM work.

Establish the tree and start with a set of small fixes.

Previous attempt was here:
https://lore.kernel.org/r/20261116075420.76205-1-aneesh.kumar@kernel.org

This is based on sha1
7475ea8b58616 Linus Torvalds "Linux 7.4-rc2".

Please comment. Thanks.



Alexey Kardashevskiy (3):
  crypto/ccp/tsm: Fix potential size mismatch in releasing SPDM buffers
  crypto/ccp/tsm: Remove unused header
  crypto/ccp/tsm: Use TSM API for DOE

Aneesh Kumar K.V (Arm) (1):
  MAINTAINERS: Update TSM file coverage and repository

 drivers/crypto/ccp/sev-dev-tio.c | 14 ++++++--------
 drivers/crypto/ccp/sev-dev-tsm.c |  6 +++---
 MAINTAINERS                      |  4 ++++
 3 files changed, 13 insertions(+), 11 deletions(-)

-- 
2.55.0





^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH kernel 1/4] MAINTAINERS: Update TSM file coverage and repository
  2026-11-19 12:57 [PATCH kernel 0/4] PCI/TSM queue Alexey Kardashevskiy
@ 2026-11-19 12:57 ` Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 2/4] crypto/ccp/tsm: Fix potential size mismatch in releasing SPDM buffers Alexey Kardashevskiy
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2026-11-19 12:57 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, linux-crypto, Ashish Kalra, Tom Lendacky,
	Aneesh Kumar K.V, Jason Gunthorpe, Lukas Wunner, Herbert Xu,
	David S. Miller, Kuppuswamy Sathyanarayanan, Jonathan Cameron,
	linux-coco, Santosh Shukla, Pratik R . Sampat,
	Scott Soule Cheloha, Ackerley Tng, Sean Christopherson,
	Fuad Tabba, Xu Yilun, Alexey Kardashevskiy, aik, Jason Gunthorpe

From: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>

Add drivers/virt/coco/tsm-core.c and git repository to the TSM entry.

Add the AMD TIO backend of TSM. Other arches are going to be added
next. Eventually these backends will move under drivers/attestation.

Cc: Alexey Kardashevskiy <aik@amd.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Ashish Kalra <ashish.kalra@amd.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: linux-coco@lists.linux.dev
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
[aik: added drivers/crypto/ccp/sev-dev-*]
Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
 MAINTAINERS | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 222b7fc2c3aab..e8059b3d7e6ef 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -28541,11 +28541,15 @@ M:	Jason Gunthorpe <jgg@nvidia.com>
 R:	Lukas Wunner <lukas@wunner.de>
 L:	linux-coco@lists.linux.dev
 S:	Maintained
+T:	git git://git.kernel.org/pub/scm/linux/kernel/git/tsm/linux.git
 F:	Documentation/ABI/testing/configfs-tsm-report
 F:	Documentation/driver-api/coco/
 F:	Documentation/driver-api/pci/tsm.rst
+F:	drivers/crypto/ccp/sev-dev-tio.*
+F:	drivers/crypto/ccp/sev-dev-tsm.c
 F:	drivers/pci/tsm.c
 F:	drivers/virt/coco/guest/
+F:	drivers/virt/coco/tsm-core.c
 F:	include/linux/*tsm*.h
 F:	samples/tsm-mr/
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH kernel 2/4] crypto/ccp/tsm: Fix potential size mismatch in releasing SPDM buffers
  2026-11-19 12:57 [PATCH kernel 0/4] PCI/TSM queue Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 1/4] MAINTAINERS: Update TSM file coverage and repository Alexey Kardashevskiy
@ 2026-11-19 12:57 ` Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 3/4] crypto/ccp/tsm: Remove unused header Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 4/4] crypto/ccp/tsm: Use TSM API for DOE Alexey Kardashevskiy
  3 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2026-11-19 12:57 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, linux-crypto, Ashish Kalra, Tom Lendacky,
	Aneesh Kumar K.V, Jason Gunthorpe, Lukas Wunner, Herbert Xu,
	David S. Miller, Kuppuswamy Sathyanarayanan, Jonathan Cameron,
	linux-coco, Santosh Shukla, Pratik R . Sampat,
	Scott Soule Cheloha, Ackerley Tng, Sean Christopherson,
	Fuad Tabba, Xu Yilun, Alexey Kardashevskiy, aik

At the moment the CCP driver allocates buffers of the maximum supported
sizes which are reported by the PSP, and potentially expands some.

The spdm_ctrl_free() helper though releases all buffers with (incorrectly)
calculated sizes.

Drop the calculation for request/response and use the maximum size
for free.

Use the actual size (potentially expanded) of scratch and output buffers.

While at this, replace the incorrect check for dev_ctx with the correct
check of the output buffer.

This did not bite so far as the maximum for request/response is 4K,
alloc and free are page aligned and the expansion is not implemented yet
in the PSP.

Fixes: 4be423572da1 ("crypto/ccp: Implement SEV-TIO PCIe IDE (phase1)")
Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
 drivers/crypto/ccp/sev-dev-tio.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/crypto/ccp/sev-dev-tio.c b/drivers/crypto/ccp/sev-dev-tio.c
index c84e23982b434..37ace91a7d4d8 100644
--- a/drivers/crypto/ccp/sev-dev-tio.c
+++ b/drivers/crypto/ccp/sev-dev-tio.c
@@ -639,25 +639,23 @@ static void spdm_ctrl_init(struct spdm_ctrl *ctrl, struct tsm_dsm_tio *dev_data)
 static void spdm_ctrl_free(struct tsm_dsm_tio *dev_data)
 {
 	struct sev_tio_status *tio_status = to_tio_status(dev_data);
-	size_t len = tio_status->spdm_req_size_max -
-		(sla_dobj_id_to_size(SPDM_DOBJ_ID_RESP) +
-		 sizeof(struct sla_buffer_hdr));
 	struct tsm_spdm *spdm = &dev_data->spdm;
 
 	sla_buffer_unmap(dev_data->resp, dev_data->respbuf);
 	sla_buffer_unmap(dev_data->req, dev_data->reqbuf);
 	spdm->rsp = NULL;
 	spdm->req = NULL;
-	sla_free(dev_data->req, len, true);
-	sla_free(dev_data->resp, len, false);
-	sla_free(dev_data->scratch, tio_status->spdm_scratch_size_max, true);
+	sla_free(dev_data->req, tio_status->spdm_req_size_max, true);
+	sla_free(dev_data->resp, tio_status->spdm_req_size_max, false);
+	sla_free(dev_data->scratch, dev_data->scratch_len, true);
 
 	dev_data->req.sla = 0;
 	dev_data->resp.sla = 0;
 	dev_data->scratch.sla = 0;
 	dev_data->respbuf = NULL;
 	dev_data->reqbuf = NULL;
-	sla_free(dev_data->output, tio_status->spdm_out_size_max, true);
+	sla_free(dev_data->output, dev_data->output_len, true);
+	dev_data->output.sla = 0;
 }
 
 static int spdm_ctrl_alloc(struct tsm_dsm_tio *dev_data)
@@ -674,7 +672,7 @@ static int spdm_ctrl_alloc(struct tsm_dsm_tio *dev_data)
 	dev_data->output = sla_alloc(dev_data->output_len, true);
 
 	if (IS_SLA_NULL(dev_data->req) || IS_SLA_NULL(dev_data->resp) ||
-	    IS_SLA_NULL(dev_data->scratch) || IS_SLA_NULL(dev_data->dev_ctx)) {
+	    IS_SLA_NULL(dev_data->scratch) || IS_SLA_NULL(dev_data->output)) {
 		ret = -ENOMEM;
 		goto free_spdm_exit;
 	}
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH kernel 3/4] crypto/ccp/tsm: Remove unused header
  2026-11-19 12:57 [PATCH kernel 0/4] PCI/TSM queue Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 1/4] MAINTAINERS: Update TSM file coverage and repository Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 2/4] crypto/ccp/tsm: Fix potential size mismatch in releasing SPDM buffers Alexey Kardashevskiy
@ 2026-11-19 12:57 ` Alexey Kardashevskiy
  2026-11-19 12:57 ` [PATCH kernel 4/4] crypto/ccp/tsm: Use TSM API for DOE Alexey Kardashevskiy
  3 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2026-11-19 12:57 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, linux-crypto, Ashish Kalra, Tom Lendacky,
	Aneesh Kumar K.V, Jason Gunthorpe, Lukas Wunner, Herbert Xu,
	David S. Miller, Kuppuswamy Sathyanarayanan, Jonathan Cameron,
	linux-coco, Santosh Shukla, Pratik R . Sampat,
	Scott Soule Cheloha, Ackerley Tng, Sean Christopherson,
	Fuad Tabba, Xu Yilun, Alexey Kardashevskiy, aik

No use of IOMMU here, remove the header to avoid confusion.

Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
 drivers/crypto/ccp/sev-dev-tsm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/ccp/sev-dev-tsm.c b/drivers/crypto/ccp/sev-dev-tsm.c
index 46f2539d2d5ab..eb16948e1561b 100644
--- a/drivers/crypto/ccp/sev-dev-tsm.c
+++ b/drivers/crypto/ccp/sev-dev-tsm.c
@@ -5,7 +5,6 @@
 #include <linux/pci.h>
 #include <linux/device.h>
 #include <linux/tsm.h>
-#include <linux/iommu.h>
 #include <linux/pci-doe.h>
 #include <linux/bitfield.h>
 #include <linux/module.h>
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH kernel 4/4] crypto/ccp/tsm: Use TSM API for DOE
  2026-11-19 12:57 [PATCH kernel 0/4] PCI/TSM queue Alexey Kardashevskiy
                   ` (2 preceding siblings ...)
  2026-11-19 12:57 ` [PATCH kernel 3/4] crypto/ccp/tsm: Remove unused header Alexey Kardashevskiy
@ 2026-11-19 12:57 ` Alexey Kardashevskiy
  3 siblings, 0 replies; 5+ messages in thread
From: Alexey Kardashevskiy @ 2026-11-19 12:57 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, linux-crypto, Ashish Kalra, Tom Lendacky,
	Aneesh Kumar K.V, Jason Gunthorpe, Lukas Wunner, Herbert Xu,
	David S. Miller, Kuppuswamy Sathyanarayanan, Jonathan Cameron,
	linux-coco, Santosh Shukla, Pratik R . Sampat,
	Scott Soule Cheloha, Ackerley Tng, Sean Christopherson,
	Fuad Tabba, Xu Yilun, Alexey Kardashevskiy, aik

Compared to the currently used pci_doe(), the pci_tsm_doe_transfer() helper
performs a few more sanity checks, use that helper now.

Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
 drivers/crypto/ccp/sev-dev-tsm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/ccp/sev-dev-tsm.c b/drivers/crypto/ccp/sev-dev-tsm.c
index eb16948e1561b..70aa26efd6a6c 100644
--- a/drivers/crypto/ccp/sev-dev-tsm.c
+++ b/drivers/crypto/ccp/sev-dev-tsm.c
@@ -39,8 +39,9 @@ static int sev_tio_spdm_cmd(struct tio_dsm *dsm, int ret)
 
 	/* ret > 0 means "SPDM requested" */
 	while (ret == PCI_DOE_FEATURE_CMA || ret == PCI_DOE_FEATURE_SSESSION) {
-		ret = pci_doe(dsm->tsm.doe_mb, PCI_VENDOR_ID_PCI_SIG, ret,
-			      spdm->req, spdm->req_len, spdm->rsp, spdm->rsp_len);
+		ret = pci_tsm_doe_transfer(dsm->tsm.base_tsm.pdev, ret,
+					   spdm->req, spdm->req_len,
+					   spdm->rsp, spdm->rsp_len);
 		if (ret < 0)
 			break;
 
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-19 12:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 12:57 [PATCH kernel 0/4] PCI/TSM queue Alexey Kardashevskiy
2026-11-19 12:57 ` [PATCH kernel 1/4] MAINTAINERS: Update TSM file coverage and repository Alexey Kardashevskiy
2026-11-19 12:57 ` [PATCH kernel 2/4] crypto/ccp/tsm: Fix potential size mismatch in releasing SPDM buffers Alexey Kardashevskiy
2026-11-19 12:57 ` [PATCH kernel 3/4] crypto/ccp/tsm: Remove unused header Alexey Kardashevskiy
2026-11-19 12:57 ` [PATCH kernel 4/4] crypto/ccp/tsm: Use TSM API for DOE Alexey Kardashevskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox