Skip to contentSkip to conversation

attestation: provider: add CCA Realm Guest provider

RFC PATCH In review Yeoreum Yun 3 participants 21 messages Nov 27

Subsystems (6)
Documentation Kselftest ACPI arm64 +2 more subsystems
lore
Share & tools
lore
#0 lore raw

v3 cover attestation: provider: add CCA Realm Guest provider

This series adds support for Arm Confidential Compute Architecture (CCA) measurement registers in the Linux kernel, enabling guest Realms to access, extend, and expose measurement values for attestation and runtime integrity tracking.

The Realm Management Monitor (RMM) defines a set of measurement registers consisting of a Realm Initial Measurement (RIM) and a number of Realm Extensible Measurements (REMs). This series introduces the necessary infrastructure to interact with these registers via the RSI interface and exposes them to userspace through CTLV attestation subsystem.

Also, this seires includes the CCA attesation token generation interface and CCEL event-log exposure through CTLV attestation subsystem.

At a high level, the series includes:
- Helper interfaces for reading and extending measurement registers via RSI
- Definitions for Realm hash algorithms as defined by the RMM specification
- Support CCEL table in arm64
- Integration with attestation subsystem by introducing CCA Realm Guest provider

After applying this series, measurement registers and relative interface will be exposed ctlv interfaces.

This patch based on arm64/for-next/smccc-bus, attestation branch[0-2] and firme patch-series [3].

To: [email protected]
To: [email protected]
To: [email protected]
To: [email protected]
To: [email protected]
To: [email protected]
To: [email protected]
Cc: Catalin Marinas <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: Jason Gunthorpe <[email protected]>
Cc: Suzuki Poulose <[email protected]>
Cc: Steven Price <[email protected]>
Cc: Sami Mujawar <[email protected]>
Cc: [email protected]
Cc: Rafael J. Wysocki <[email protected]>
Cc: Maciej Wieczor-Retman <[email protected]>
Cc: Pawel Chmielewski <[email protected]>
Cc: Jiri Pirko <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Len Brown <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Mark Brown <[email protected]>

---
Changes in v3:
- rebase to attestation subsystem.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- rebase to arm64 tree's for-next/smccc-bus
- Link to v1: https://lore.kernel.org/all/[email protected]/

---
Sami Mujawar (2):
arm64: rsi: Add helpers for Arm CCA measurement register operations
arm64: rsi: Add realm hash algorithm defines

Suzuki K Poulose (1):
arm64: acpi: Enable ACPI CCEL support

Yeoreum Yun (5):
acpi: add CCtype value macros for CCEL table Documentation/ctlv: introduce ctlv-attestation-cca-guest family
ctlv: add auto-generated files for ctlv-attestation-cca-guest
attestation: providers: introduce CCA Guest attestation provider
selftest: attestation: add cca_guest_attestation_test selftest

 .../ctlv/abi/ctlv-attestation-cca-guest.yaml       |   19 +
 Documentation/ctlv/abi/families.registry.yaml      |    1 +
 Documentation/ctlv/families.yaml                   |    1 +
 Documentation/ctlv/generated-files.yaml            |   11 +
 .../ctlv/specs/ctlv-attestation-cca-guest.yaml     |   20 +
 arch/arm64/kernel/acpi.c                           |   11 +
 drivers/attestation/Kconfig                        |   10 +
 drivers/attestation/Makefile                       |    5 +
 .../generated/ctlv_attestation_cca_guest_gen.c     |   64 +
 .../generated/ctlv_attestation_cca_guest_gen.h     |   40 +
 drivers/attestation/providers/cca_guest.c          |  582 ++++++++
 include/acpi/actbl2.h                              |    7 +
 include/linux/arm-rsi-cmds.h                       |  118 +-
 include/linux/arm-smccc-rsi.h                      |    8 +
 include/uapi/ctlv/ctlv_attestation_cca_guest_gen.h |   34 +
 include/uapi/ctlv/ctlv_families_gen.h              |    1 +
 tools/testing/selftests/attestation/.gitignore     |    1 +
 tools/testing/selftests/attestation/Makefile       |    9 +-
 .../attestation/cca_guest_attestation_test.c       |  517 +++++++
 .../ctlv_attestation_cca_guest_user_gen.c          | 1547 ++++++++++++++++++++
 .../ctlv_attestation_cca_guest_user_gen.h          |   49 +
 21 files changed, 3051 insertions(+), 4 deletions(-)

---
base-commit: 55e9f5a2188b97fd2e3ef949b0e52910aa77d940
change-id: 20260929-arm_cca_mr-a194b2e92c17

Best regards,

Signature · 2 lines
Sincerely,
Yeoreum Yun
#1 lore raw

RFC PATCH v3 1/8 arm64: rsi: Add helpers for Arm CCA measurement register operations

From: Sami Mujawar <[email protected]>

Add static inline helper functions to support reading the Realm Initial Measurement (RIM) and reading/extending the Realm Extensible Measurement (REM) registers.

The indices of the Arm CCA measurement registers, as defined by the Realm Management Monitor specification, are as follows:

    Index    Register
    0        RIM
    1 - 4    REM[0 - 3]

The rsi_measurement_extend() function allows extending REM[0–3] registers with a caller-provided digest (up to 64 bytes). Index 0 (RIM) is read-only and cannot be extended.

The rsi_measurement_read() function allows reading measurement values from RIM (index 0) or REM[0–3] (indices 1–4). The returned digest is expected to be 64 bytes.

---
 include/linux/arm-rsi-cmds.h | 118 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 117 insertions(+), 1 deletion(-)
include/linux/arm-rsi-cmds.h +117 -1
index 3f7a6a833993b..188e5dc7eb587 100644
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
- * Copyright (C) 2023 ARM Ltd.
+ * Copyright (C) 2023 - 2025 ARM Ltd.
  */
 
 #ifndef __LINUX_ARM_RSI_CMDS_H_
@@ -9,6 +9,7 @@
 #include <linux/arm-smccc-rsi.h>
 #include <linux/jump_label.h>
 #include <linux/string.h>
+#include <crypto/sha2.h>
 #include <asm/memory.h>
 
 #ifdef CONFIG_ARM_RMM_RSI
@@ -36,6 +37,26 @@ static inline bool is_realm_world(void) { return false; }
 #define RSI_GRANULE_SHIFT		12
 #define RSI_GRANULE_SIZE		(_AC(1, UL) << RSI_GRANULE_SHIFT)
 
+/*
+ * Maximum measurement data size in bytes.
+ * According to the RMM Specification, the width of the RmmRealmMeasurement type
+ * is 512 bits.
+ */
+#define RSI_MAX_MEASUREMENT_DATA_SIZE_BYTES  64
+
+/*
+ * Indices for the Realm Initial Measurement register (RIM) and the Realm
+ * Extensible Measurement registers (REMs).
+ * According to the RMM Specification, Realm attributes of a Realm include
+ * an array of measurement values. The first entry in this array is a RIM.
+ * The remaining entries in this array are REMs.
+ */
+#define RSI_INDEX_RIM		0
+#define RSI_INDEX_REM0		1
+#define RSI_INDEX_REM1		2
+#define RSI_INDEX_REM2		3
+#define RSI_INDEX_REM3		4
+
 enum ripas {
 	RSI_RIPAS_EMPTY = 0,
 	RSI_RIPAS_RAM = 1,
@@ -236,4 +257,99 @@ static inline unsigned long rsi_attestation_token_continue(phys_addr_t granule,
 	return res.a0;
 }
 
+#define RSI_MAX_DIGEST_SIZE	SHA512_DIGEST_SIZE
+
+struct rsi_measurement_extend_args {
+	unsigned long fid;
+	unsigned long idx;
+	unsigned long size;
+	u8	      digest[SHA512_DIGEST_SIZE];
+};
+
+/**
+ * rsi_measurement_extend - Extend the measurement value to the Realm Extensible
+ * Measurement (REM).
+ *
+ * @idx:		Index of the REM register.
+ *				Where:
+ *				Index	Register
+ *				1 - 4	REM[0-3]
+ * @digest:		The digest data to be extended.
+ * @digest_size:	Size of the digest data in bytes.
+ *
+ * Returns:
+ *  On success, returns RSI_SUCCESS.
+ *  Otherwise, -EINVAL
+ */
+static inline unsigned long rsi_measurement_extend(u32 idx,
+						   const u8 *digest,
+						   unsigned long digest_size)
+{
+	union {
+		struct arm_smccc_1_2_regs regs;
+		struct rsi_measurement_extend_args extend;
+	} args = { 0 };
+
+	/*
+	 * Index 0 is for RIM (which is Read Only), while
+	 * REM[0-3] are indexed from 1 - 4.
+	 * The digest size can be at the most 64 bytes.
+	 */
+	if (!digest || idx < RSI_INDEX_REM0 || idx > RSI_INDEX_REM3 ||
+	    digest_size == 0 || digest_size > RSI_MAX_MEASUREMENT_DATA_SIZE_BYTES)
+		return -EINVAL;
+
+	args.extend.fid = SMC_RSI_MEASUREMENT_EXTEND;
+	args.extend.idx = idx;
+	args.extend.size = digest_size;
+	memcpy(&args.extend.digest, digest, digest_size);
+	arm_smccc_1_2_smc(&args.regs, &args.regs);
+
+	if (args.regs.a0 != RSI_SUCCESS)
+		return -EINVAL;
+
+	return RSI_SUCCESS;
+}
+
+/**
+ * rsi_measurement_read - Read the measurement value from the Realm Initial
+ * Measurement (RIM) or the Realm Extensible Measurement (REM) register.
+ *
+ * @idx:		Index of the RIM or REM register.
+ *				Where:
+ *				Index	Register
+ *				0	RIM
+ *				1 - 4	REM[0-3]
+ * @digest:			The digest data to be returned.
+ * @digest_size:	Size of the digest data buffer in bytes.
+ *
+ * Returns:
+ *  On success, returns RSI_SUCCESS.
+ *  Otherwise, -EINVAL
+ */
+static inline unsigned long rsi_measurement_read(u32 idx,
+						 u8 *digest,
+						 unsigned long digest_size)
+{
+	struct arm_smccc_1_2_regs regs = { 0 };
+
+	/*
+	 * The digest size can be at the most 64 bytes, if less then 64 bytes
+	 * it is zero padded.
+	 */
+	if (!digest || idx > RSI_INDEX_REM3 ||
+	    digest_size == 0 || digest_size > RSI_MAX_MEASUREMENT_DATA_SIZE_BYTES)
+		return -EINVAL;
+
+	regs.a0 = SMC_RSI_MEASUREMENT_READ;
+	regs.a1 = idx;
+	arm_smccc_1_2_smc(&regs, &regs);
+
+	if (regs.a0 != RSI_SUCCESS)
+		return -EINVAL;
+
+	memcpy(digest, &regs.a1, digest_size);
+	return regs.a0;
+}
+
 #endif /* __LINUX_ARM_RSI_CMDS_H_ */
Signature · 1 line
2.43.0
#2 lore raw

RFC PATCH v3 2/8 arm64: rsi: Add realm hash algorithm defines

In reply to Yeoreum Yun

From: Sami Mujawar <[email protected]>

Add macro definitions for the hash algorithm identifiers, as specified in the Realm Management Monitor (RMM) specification.

---
 include/linux/arm-smccc-rsi.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/arm-smccc-rsi.h +8 -0
index cca881ddfdbab..cf8e157269f3c 100644
@@ -144,6 +144,14 @@ struct realm_config {
 
 #endif /* __ASSEMBLER__ */
 
+/*
+ * The RSI definition of the Hash Algorithm (as specified by the Secure
+ * Hash Standard) returned in the realm_config data structure.
+ */
+#define RSI_HASH_SHA_256	0
+#define RSI_HASH_SHA_512	1
+#define RSI_HASH_SHA_384	2
+
 /*
  * Read configuration for the current Realm.
  *
Signature · 1 line
2.43.0
#3 lore raw

RFC PATCH v3 3/8 arm64: acpi: Enable ACPI CCEL support

In reply to Yeoreum Yun

From: Suzuki K Poulose <[email protected]>

Add support for ACPI CCEL by handling the EfiACPIMemoryNVS type memory. As per UEFI specifications NVS memory is reserved for Firmware use even after exiting boot services. Thus map the region as read-only.

Cc Sami Mujawar <[email protected]>
Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Aneesh Kumar K.V <[email protected]>
Cc Steven Price <[email protected]>
Cc Sudeep Holla <[email protected]>
Cc Gavin Shan <[email protected]>
---
 arch/arm64/kernel/acpi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm64/kernel/acpi.c +11 -0
index 681aa2bbc3995..3d6335db882d3 100644
@@ -354,6 +354,17 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
 			prot = PAGE_KERNEL_RO;
 			break;
 
+		case EFI_ACPI_MEMORY_NVS:
+			/*
+			 * ACPI NVS marks an area reserved for use by the
+			 * firmware, even after exiting the boot service.
+			 * This may be used by the firmware for sharing dynamic
+			 * tables/data (e.g., ACPI CCEL) with the OS. Map it
+			 * as read-only.
+			 */
+			prot = PAGE_KERNEL_RO;
+			break;
+
 		case EFI_ACPI_RECLAIM_MEMORY:
 			/*
 			 * ACPI reclaim memory is used to pass firmware tables
Signature · 1 line
2.43.0
#4 lore raw

Re: [PATCH RFC v3 3/8] arm64: acpi: Enable ACPI CCEL support

Quoted 28 lines · Yeoreum Yun

From: Suzuki K Poulose <[email protected]>

Add support for ACPI CCEL by handling the EfiACPIMemoryNVS type memory. As per UEFI specifications NVS memory is reserved for Firmware use even after exiting boot services. Thus map the region as read-only.

Cc Sami Mujawar <[email protected]>
Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Aneesh Kumar K.V <[email protected]>
Cc Steven Price <[email protected]>
Cc Sudeep Holla <[email protected]>
Cc Gavin Shan <[email protected]>
---
  arch/arm64/kernel/acpi.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
arch/arm64/kernel/acpi.c +1 -0
index 681aa2bbc3995..3d6335db882d3 100644
@@ -354,6 +354,17 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
  			prot = PAGE_KERNEL_RO;
  			break;
 
+		case EFI_ACPI_MEMORY_NVS:

arch/arm64/kernel/acpi.c void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) · line 367

Quoted 10 lines
arch/arm64/kernel/acpi.c +10 -0
+			/*
+			 * ACPI NVS marks an area reserved for use by the
+			 * firmware, even after exiting the boot service.
+			 * This may be used by the firmware for sharing dynamic
+			 * tables/data (e.g., ACPI CCEL) with the OS. Map it
+			 * as read-only.
+			 */
+			prot = PAGE_KERNEL_RO;
+			break;
+

Unfortunately this breaks some platforms, where the NVS must be mapped R/W. Thats why we dropped this patch.

https://lore.kernel.org/all/[email protected]

Cheers
Suzuki

Quoted 4 lines
arch/arm64/kernel/acpi.c +0 -0
  		case EFI_ACPI_RECLAIM_MEMORY:
  			/*
  			 * ACPI reclaim memory is used to pass firmware tables
#5 lore raw

Re: [PATCH RFC v3 3/8] arm64: acpi: Enable ACPI CCEL support

Quoted 42 lines · Suzuki K Poulose
Quoted 27 lines · Yeoreum Yun

From: Suzuki K Poulose <[email protected]>

Add support for ACPI CCEL by handling the EfiACPIMemoryNVS type memory. As per UEFI specifications NVS memory is reserved for Firmware use even after exiting boot services. Thus map the region as read-only.

Cc Sami Mujawar <[email protected]>
Cc Will Deacon <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Aneesh Kumar K.V <[email protected]>
Cc Steven Price <[email protected]>
Cc Sudeep Holla <[email protected]>
Cc Gavin Shan <[email protected]>
---
  arch/arm64/kernel/acpi.c | 11 +++++++++++
  1 file changed, 11 insertions(+)
arch/arm64/kernel/acpi.c +1 -0
index 681aa2bbc3995..3d6335db882d3 100644
@@ -354,6 +354,17 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
  			prot = PAGE_KERNEL_RO;
  			break;
+		case EFI_ACPI_MEMORY_NVS:

arch/arm64/kernel/acpi.c void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) · line 366

Quoted 10 lines
arch/arm64/kernel/acpi.c +10 -0
+			/*
+			 * ACPI NVS marks an area reserved for use by the
+			 * firmware, even after exiting the boot service.
+			 * This may be used by the firmware for sharing dynamic
+			 * tables/data (e.g., ACPI CCEL) with the OS. Map it
+			 * as read-only.
+			 */
+			prot = PAGE_KERNEL_RO;
+			break;
+

Unfortunately this breaks some platforms, where the NVS must be mapped R/W. Thats why we dropped this patch.

Quoted 1 line

https://lore.kernel.org/all/[email protected]

Thanks to share. anyway it's enough to read in this series. So I'll drop this in the next spin. Thanks!

Signature · 2 lines
Sincerely,
Yeoreum Yun
#6 lore raw

RFC PATCH v3 4/8 acpi: add CCtype value macros for CCEL table

In reply to Yeoreum Yun

Add CCtype value macros for CCEL table.

---
 include/acpi/actbl2.h | 7 +++++++
 1 file changed, 7 insertions(+)
include/acpi/actbl2.h +7 -0
index 76e4a5bc79b42..44810b9b9ddc5 100644
@@ -454,6 +454,13 @@ struct acpi_table_ccel {
 	u64 log_area_start_address;
 };
 
+/* Values for CCtype */
+#define ACPI_CCEL_CCTYPE_RESERVED	0
+#define ACPI_CCEL_CCTYPE_AMD_SEV	1
+#define ACPI_CCEL_CCTYPE_INTEL_TDX	2
+#define ACPI_CCEL_CCTYPE_RISCV_AP_TEE	3
+#define ACPI_CCEL_CCTYPE_ARM_CCA	4
+
 /*******************************************************************************
  *
  * ERDT - Enhanced Resource Director Technology (ERDT) table
Signature · 1 line
2.43.0
#7 lore raw

RFC PATCH v3 5/8 Documentation/ctlv: introduce ctlv-attestation-cca-guest family

In reply to Yeoreum Yun

Introduce ctlv-attestation-cca-guest family and auto-generated abi files via make -C tools/ctlv regen

---
 .../ctlv/abi/ctlv-attestation-cca-guest.yaml         | 19 +++++++++++++++++++
 Documentation/ctlv/abi/families.registry.yaml        |  1 +
 Documentation/ctlv/families.yaml                     |  1 +
 Documentation/ctlv/generated-files.yaml              | 11 +++++++++++
 .../ctlv/specs/ctlv-attestation-cca-guest.yaml       | 20 ++++++++++++++++++++
 include/uapi/ctlv/ctlv_families_gen.h                |  1 +
 6 files changed, 53 insertions(+)
Documentation/ctlv/abi/ctlv-attestation-cca-guest.yaml new file +19 -0
new file mode 100644
index 0000000000000..27b1977da13e8
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+%YAML 1.2
+---
+# Checked-in ABI snapshot of the ctlv-attestation-cca-guest family, from
+# Documentation/ctlv/specs/ctlv-attestation-cca-guest.yaml, written by
+# "make -C tools/ctlv regen".
+#
+# Updating the file is how a UAPI change gets reviewed; an update that
+# removes or renumbers anything, narrows a bound, or makes a member required
+# is an ABI break, whatever the file says afterwards.
+family: {name: ctlv-attestation-cca-guest, id: 7, inherits: ctlv-attestation}
+enums:
+  evidence-vendor-format: {cca-attestation-token: 1}
+records:
+  device-info:
+    id: 0x00010000
+    fields:
+      version: {number: 1, type: uint, max: s32-max}
+fills: {device-info: device-info}
Documentation/ctlv/abi/families.registry.yaml +1 -0
index 0784747a3ac87..21c6c3f978fbe 100644
@@ -11,3 +11,4 @@ families:
   - ctlv-test-child
   - ctlv-attestation-sim
   - ctlv-attestation-firme
+  - ctlv-attestation-cca-guest
Documentation/ctlv/families.yaml +1 -0
index 49121305e3282..810bc07b4e5b0 100644
@@ -21,3 +21,4 @@ families:
   - ctlv-test-child
   - ctlv-attestation-sim
   - ctlv-attestation-firme
+  - ctlv-attestation-cca-guest
Documentation/ctlv/generated-files.yaml +11 -0
index b286e28c2b5b7..d388ca3e4bdd6 100644
@@ -78,3 +78,14 @@ families:
         tools/testing/selftests/attestation/ctlv_attestation_firme_user_gen.h
       user-source: >-
         tools/testing/selftests/attestation/ctlv_attestation_firme_user_gen.c
+
+  - name: ctlv-attestation-cca-guest
+    source: Documentation/ctlv/specs/ctlv-attestation-cca-guest.yaml
+    outputs:
+      uapi-header: include/uapi/ctlv/ctlv_attestation_cca_guest_gen.h
+      kernel-header: drivers/attestation/generated/ctlv_attestation_cca_guest_gen.h
+      kernel-source: drivers/attestation/generated/ctlv_attestation_cca_guest_gen.c
+      user-header: >-
+        tools/testing/selftests/attestation/ctlv_attestation_cca_guest_user_gen.h
+      user-source: >-
+        tools/testing/selftests/attestation/ctlv_attestation_cca_guest_user_gen.c
Documentation/ctlv/specs/ctlv-attestation-cca-guest.yaml new file +20 -0
new file mode 100644
index 0000000000000..66dee6be4bb03
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+%YAML 1.2
+---
+#
+# The attestation device of cca for guest: CCA attestation token 
+#
+family: ctlv-attestation-cca-guest
+inherits: ctlv-attestation
+
+enums:
+  # Fills ctlv-attestation's evidence-vendor-format.
+  evidence-vendor-format:
+    # CCA attestation token.
+    - cca-attestation-token
+
+records:
+  # Fills ctlv-attestation's device-info.
+  device-info:
+    # RSI version.
+    version: uint(..s32-max)
include/uapi/ctlv/ctlv_families_gen.h +1 -0
index e4c0b06a6d7eb..209fbc8d61f0b 100644
@@ -18,6 +18,7 @@ enum _ctlv_family {
 	CTLV_FAMILY_TEST_CHILD = 4,
 	CTLV_FAMILY_ATTESTATION_SIM = 5,
 	CTLV_FAMILY_ATTESTATION_FIRME = 6,
+	CTLV_FAMILY_ATTESTATION_CCA_GUEST = 7,
 };
 
 #endif /* _UAPI_CTLV_CTLV_FAMILIES_GEN_H */
Signature · 1 line
2.43.0
#8 lore raw

RFC PATCH v3 6/8 ctlv: add auto-generated files for ctlv-attestation-cca-guest

In reply to Yeoreum Yun

Add auto-generated files for ctlv-attestation-cca-guest via tools/ctlv/ctlv-regen.sh.

---
 .../generated/ctlv_attestation_cca_guest_gen.c     |   64 +
 .../generated/ctlv_attestation_cca_guest_gen.h     |   40 +
 include/uapi/ctlv/ctlv_attestation_cca_guest_gen.h |   34 +
 .../ctlv_attestation_cca_guest_user_gen.c          | 1547 ++++++++++++++++++++
 .../ctlv_attestation_cca_guest_user_gen.h          |   49 +
 5 files changed, 1734 insertions(+)
drivers/attestation/generated/ctlv_attestation_cca_guest_gen.c new file +64 -0
new file mode 100644
index 0000000000000..316fb6379ff64
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+/*
+ * Generated from Documentation/ctlv/specs/ctlv-attestation-cca-guest.yaml by
+ * tools/ctlv/ctlv-regen.sh. Do not edit.
+ */
+/* CTLV-GEN kernel source */
+
+#define _CTLV_GENERATED_METADATA_ONLY
+#include <linux/array_size.h>
+#include <linux/build_bug.h>
+#include <linux/ctlv_family.h>
+#include <linux/export.h>
+#include <linux/limits.h>
+
+#include <uapi/ctlv/ctlv_gen.h>
+#include <uapi/ctlv/ctlv_attestation_cca_guest_gen.h>
+
+#include "ctlv_attestation_cca_guest_gen.h"
+
+static const struct ctlv_node_schema device_info_fill_node_schemas[] = {
+	CTLV_NODE_SCHEMA_ROOT(1, 1, 1),
+	CTLV_NODE_SCHEMA_UINT(CTLV_ATTESTATION_CCA_GUEST_T_DEVICE_INFO_VERSION, 1, 0, S32_MAX),
+};
+
+/* The extension points this family fills. */
+static const struct ctlv_ext_fill_schema ctlv_attestation_cca_guest_ext_fill_schemas[] = {
+	CTLV_EXT_FILL_SCHEMA(CTLV_FAMILY_ATTESTATION, CTLV_ATTESTATION_EXT_DEVICE_INFO,
+			     device_info),
+};
+
+/* The enum extension points this family fills. */
+static const struct ctlv_enum_fill_schema ctlv_attestation_cca_guest_enum_fill_schemas[] = {
+	CTLV_ENUM_FILL_SCHEMA(CTLV_FAMILY_ATTESTATION,
+			      CTLV_ATTESTATION_ENUM_EXT_EVIDENCE_VENDOR_FORMAT, 1),
+};
+
+/* The family ID is its position in the central registry. */
+const struct ctlv_family_schema ctlv_attestation_cca_guest_schema = {
+	.name = "ctlv-attestation-cca-guest",
+	.family_id = 7,
+	.ext_fill_schemas = ctlv_attestation_cca_guest_ext_fill_schemas,
+	.ext_fill_schemas_count = ARRAY_SIZE(ctlv_attestation_cca_guest_ext_fill_schemas),
+	.enum_fill_schemas = ctlv_attestation_cca_guest_enum_fill_schemas,
+	.enum_fill_schemas_count = ARRAY_SIZE(ctlv_attestation_cca_guest_enum_fill_schemas),
+};
+
+/* Maximum uevent cost for this family chain. */
+static_assert(162 <= CTLV_UEVENT_MAX_LEN);
+static_assert(5 <= CTLV_UEVENT_MAX_VARS);
+
+/* Extension-point callbacks. */
+static const struct ctlv_ext_ops ctlv_attestation_cca_guest_ext_ops[] = {
+	CTLV_EXT_OPS(CTLV_FAMILY_ATTESTATION, CTLV_ATTESTATION_EXT_DEVICE_INFO,
+		     ctlv_attestation_cca_guest_device_info),
+};
+
+/* Family descriptor used by ctlv_init(). */
+const struct ctlv_family ctlv_attestation_cca_guest_family = {
+	.schema = &ctlv_attestation_cca_guest_schema,
+	.parent = &ctlv_attestation_family,
+	.ext_ops = ctlv_attestation_cca_guest_ext_ops,
+	.ext_ops_count = ARRAY_SIZE(ctlv_attestation_cca_guest_ext_ops),
+};
+EXPORT_SYMBOL_NS_GPL(ctlv_attestation_cca_guest_family, "CTLV");
drivers/attestation/generated/ctlv_attestation_cca_guest_gen.h new file +40 -0
new file mode 100644
index 0000000000000..ceace64f5fe17
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/*
+ * Generated from Documentation/ctlv/specs/ctlv-attestation-cca-guest.yaml by
+ * tools/ctlv/ctlv-regen.sh. Do not edit.
+ */
+/* CTLV-GEN kernel header */
+
+/* Kernel metadata and family API of the ctlv-attestation-cca-guest CTLV family. */
+
+#ifndef _LINUX_CTLV_ATTESTATION_CCA_GUEST_GEN_H
+#define _LINUX_CTLV_ATTESTATION_CCA_GUEST_GEN_H
+
+#include <linux/ctlv_family.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+
+#include <uapi/ctlv/ctlv_attestation_cca_guest_gen.h>
+
+#include "ctlv_attestation_gen.h"
+
+extern const struct ctlv_family_schema ctlv_attestation_cca_guest_schema;
+
+/* device-info of ctlv-attestation: fill and read callbacks. */
+int ctlv_attestation_cca_guest_device_info_fill(struct ctlv *ctlv, struct ctlv_op_ctx *ctx,
+						const struct ctlv_cursor *request,
+						struct ctlv_cursor *record);
+void ctlv_attestation_cca_guest_device_info_read(struct ctlv *ctlv, struct ctlv_op_ctx *ctx,
+						 const struct ctlv_cursor *record);
+
+extern const struct ctlv_family ctlv_attestation_cca_guest_family;
+
+#ifndef _CTLV_GENERATED_METADATA_ONLY
+
+/* Writing a reply. An append is atomic; a record ends with ctlv_record_end(). */
+/* RSI version. */
+CTLV_PUT_U64(ctlv_attestation_cca_guest_device_info_version,
+	     CTLV_ATTESTATION_CCA_GUEST_T_DEVICE_INFO_VERSION, CTLV_SCHEMA_UINT)
+#endif /* _CTLV_GENERATED_METADATA_ONLY */
+
+#endif /* _LINUX_CTLV_ATTESTATION_CCA_GUEST_GEN_H */
include/uapi/ctlv/ctlv_attestation_cca_guest_gen.h new file +34 -0
new file mode 100644
index 0000000000000..405494ac956a2
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
+/*
+ * Generated from Documentation/ctlv/specs/ctlv-attestation-cca-guest.yaml by
+ * tools/ctlv/ctlv-regen.sh. Do not edit.
+ */
+/* CTLV-GEN uapi header */
+
+/*
+ * Constants of the ctlv-attestation-cca-guest CTLV family. Types and op IDs are complete; the
+ * message format carrying them is in <ctlv/ctlv.h>.
+ *
+ * The inherited ctlv-attestation header is included here, so one include covers the whole effective
+ * schema.
+ */
+
+#ifndef _UAPI_CTLV_CTLV_ATTESTATION_CCA_GUEST_GEN_H
+#define _UAPI_CTLV_CTLV_ATTESTATION_CCA_GUEST_GEN_H
+
+#include <ctlv/ctlv.h>
+#include <ctlv/ctlv_attestation_gen.h>
+#include <ctlv/ctlv_families_gen.h>
+
+/* enum evidence-vendor-format, an extension point of ctlv-attestation */
+enum _ctlv_attestation_cca_guest_evidence_vendor_format {
+	/* CCA attestation token. */
+	CTLV_ATTESTATION_CCA_GUEST_EVIDENCE_VENDOR_FORMAT_CCA_ATTESTATION_TOKEN = 1,
+};
+
+/* device-info */
+/* RSI version. */
+#define CTLV_ATTESTATION_CCA_GUEST_T_DEVICE_INFO_VERSION \
+	CTLV_TYPE(CTLV_FAMILY_ATTESTATION_CCA_GUEST, 0x00010000, 1)
+
+#endif /* _UAPI_CTLV_CTLV_ATTESTATION_CCA_GUEST_GEN_H */
tools/testing/selftests/attestation/ctlv_attestation_cca_guest_user_gen.c new file +1547 -0

1,547 lines not on this page · raw message

tools/testing/selftests/attestation/ctlv_attestation_cca_guest_user_gen.h new file +49 -0

49 lines not on this page · raw message

Signature · 1 line
2.43.0
#9 lore raw

RFC PATCH v3 7/8 attestation: providers: introduce CCA Guest attestation provider

In reply to Yeoreum Yun

Introduce CCA Realm Guest attestation provider for retrieving:

- RIM, REM0-REM3 measurement registers.
- CCA attestation token
- CCEL event log

used for CCA Realm Guest attestation.

---
 drivers/attestation/Kconfig               |  10 +
 drivers/attestation/Makefile              |   5 +
 drivers/attestation/providers/cca_guest.c | 582 ++++++++++++++++++++++++++++++
 3 files changed, 597 insertions(+)
drivers/attestation/Kconfig +10 -0
index e2391ef4aee2d..e4cfe4554ea1e 100644
@@ -52,4 +52,14 @@ config ATTESTATION_FIRME
 
 	  If you are unsure, say N.
 
+config ATTESTATION_CCA_GUEST
+	tristate "CCA Realm Guest attestation provider"
+	depends on ARM_RMM_RSI && HAVE_ARM_SMCCC_DISCOVERY
+	depends on ARM_CCA_GUEST = n
+	help
+	  Exposes getting RIM, REM, CCA attestation token and CCEL
+	  eventlog operations through the common attestation CTLV family.
+
+	  If you are unsure, say N.
+
 endif # ATTESTATION
drivers/attestation/Makefile +5 -0
index 2c7a1a09daaed..7949e067d4819 100644
@@ -17,3 +17,8 @@ obj-$(CONFIG_ATTESTATION_FIRME) += attestation-firme.o
 
 attestation-firme-y := providers/firme.o \
 		       generated/ctlv_attestation_firme_gen.o
+
+obj-$(CONFIG_ATTESTATION_CCA_GUEST) += attestation-cca-guest.o
+
+attestation-cca-guest-y := providers/cca_guest.o \
+			   generated/ctlv_attestation_cca_guest_gen.o
drivers/attestation/providers/cca_guest.c new file +582 -0

582 lines not on this page · raw message

Signature · 1 line
2.43.0
#10 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Quoted 7 lines · Yeoreum Yun

Introduce CCA Realm Guest attestation provider for retrieving:

- RIM, REM0-REM3 measurement registers.
- CCA attestation token
- CCEL event log

used for CCA Realm Guest attestation.

This is great to see positive proof that the API fits CCA!

Quoted 6 lines
---
 drivers/attestation/Kconfig               |  10 +
 drivers/attestation/Makefile              |   5 +
 drivers/attestation/providers/cca_guest.c | 582 ++++++++++++++++++++++++++++++
 3 files changed, 597 insertions(+)

But we need to do alot more work on this to make the drivers slimmer.

First, we need to pull drivers/virt/coco/arm-cca-guest/main.c which is the evidence part of this driver into drivers/attestation and build the MR stuff on top of that.

Second, things like CCEL need to be handled by core code. The driver should only indicate it "claims" the CCEL if the core code happens to find one. TDX and ARM shouldn't have any direct CCEL stuff beyond that.

Similarly the TCG log should work the same way.

I'm also wondering if too much code is leaking into to drivers to implement the uAPI. We should take a look at this vs the TDX one and make sure we have the right level of helpers and abstraction.

I also can't help but notice there isn't a single comment in any of this, it should be a bit more descriptive why some of these things are in here.

drivers/attestation/providers/cca_guest.c line 35

Quoted 3 lines
drivers/attestation/providers/cca_guest.c new file +3 -0
+static enum hash_algo cca_guest_attestation_algorithms[] = {
+	HASH_ALGO_SHA512,
+};

static const

Quoted 35 lines
drivers/attestation/providers/cca_guest.c new file +35 -0
+
+static const struct attestation_mr_props cca_guest_attestation_mrs[] = {
+	{
+		.id = 0,
+		.name = "rim",
+		.algorithms = cca_guest_attestation_algorithms,
+		.algorithms_count = ARRAY_SIZE(cca_guest_attestation_algorithms),
+	},
+	{
+		.id = 1,
+		.name = "rem0",
+		.algorithms = cca_guest_attestation_algorithms,
+		.algorithms_count = ARRAY_SIZE(cca_guest_attestation_algorithms),
+		.has_register_index = true,
+		.register_index = 0,
+		.extendable = true,
+	},
+	{
+		.id = 2,
+		.name = "rem1",
+		.algorithms = cca_guest_attestation_algorithms,
+		.algorithms_count = ARRAY_SIZE(cca_guest_attestation_algorithms),
+		.has_register_index = true,
+		.register_index = 1,
+		.extendable = true,
+	},
+	{
+		.id = 3,
+		.name = "rem2",
+		.algorithms = cca_guest_attestation_algorithms,
+		.algorithms_count = ARRAY_SIZE(cca_guest_attestation_algorithms),
+		.has_register_index = true,
+		.register_index = 2,
+		.extendable = true,
+	},

drivers/attestation/providers/cca_guest.c line 80

Quoted 10 lines
drivers/attestation/providers/cca_guest.c new file +10 -0
+	{
+		.id = 4,
+		.name = "rem3",
+		.algorithms = cca_guest_attestation_algorithms,
+		.algorithms_count = ARRAY_SIZE(cca_guest_attestation_algorithms),
+		.has_register_index = true,
+		.register_index = 3,
+		.extendable = true,
+	},
+};

Jiri this probably isn't going to scale when we get to 32 PCRs on a TPM.

drivers/attestation/providers/cca_guest.c line 84

Quoted 4 lines
drivers/attestation/providers/cca_guest.c new file +4 -0
+
+static const struct attestation_evidence_format cca_attestation_token_formats[] = {
+	{ .vendor = true, .value = CTLV_ATTESTATION_CCA_GUEST_EVIDENCE_VENDOR_FORMAT_CCA_ATTESTATION_TOKEN },
+};

should be the generic EAT token type

Quoted 20 lines
drivers/attestation/providers/cca_guest.c new file +20 -0
+
+static const struct attestation_evidence_format cca_guest_attestation_log_formats[] = {
+	{ .value = CTLV_ATTESTATION_EVIDENCE_FORMAT_CCEL },
+};
+
+static const struct attestation_evidence_challenge_length
+cca_guest_attestation_challenge_lengths[] = {
+	{ .min = RSI_ATTEST_CHALLENGE_MIN_SIZE, .max = RSI_ATTEST_CHALLENGE_MAX_SIZE },
+};
+
+static struct attestation_evidence_supported_object
+cca_guest_attestation_evidence_objects[] = {
+	{
+		.evidence_class = ATTESTATION_EVIDENCE_SIGNED,
+		.formats = cca_attestation_token_formats,
+		.formats_count = ARRAY_SIZE(cca_attestation_token_formats),
+		.challenge_lengths = cca_guest_attestation_challenge_lengths,
+		.challenge_lengths_count =
+			ARRAY_SIZE(cca_guest_attestation_challenge_lengths),
+		.max_length = 0,

drivers/attestation/providers/cca_guest.c line 114

Quoted 10 lines
drivers/attestation/providers/cca_guest.c new file +10 -0
+		.binds_mrs = true,
+	},
+#ifdef CONFIG_ACPI
+	{
+		.evidence_class = ATTESTATION_EVIDENCE_EVENT_LOG,
+		.formats = cca_guest_attestation_log_formats,
+		.formats_count = ARRAY_SIZE(cca_guest_attestation_log_formats),
+		.max_length = 0,
+	},
+#endif

Jiri, same scaling issue, CCEL should be handled by core code so it needs to be inserted dynamically into the evidence list.

Quoted 14 lines
drivers/attestation/providers/cca_guest.c new file +14 -0
+static long cca_guest_get_max_token_size(void)
+{
+	u8 dummy[RSI_ATTEST_CHALLENGE_MAX_SIZE] = { 0x00, };
+
+	return rsi_attestation_token_init(dummy, RSI_ATTEST_CHALLENGE_MAX_SIZE);
+}
+
+static int cca_guest_get_attest_tokens(const struct cca_guest_attestation *cca_guest_att,
+				       const void *challenge, size_t challenge_size,
+				       u8 *token, size_t *token_size)
+{
+	int ret;
+	long max_token_size;
+	void *buf;

drivers/attestation/providers/cca_guest.c line 285

Quoted 10 lines
drivers/attestation/providers/cca_guest.c new file +10 -0
+	unsigned long granule, offset, len, rsi_ret;
+
+	guard(migrate)();
+
+	max_token_size = rsi_attestation_token_init(challenge, challenge_size);
+	if (max_token_size <= 0)
+		return -EINVAL;
+
+	if (max_token_size != cca_guest_att->max_token_size)
+		return -ESTALE;

What is this and the related work? That isn't making sense to me. If the token size is not absolutely fixed when the driver starts then it should be fully dynamic and this just streams the variable sized token.

Ideally directly into user memory so we don't need to allocate a kvmalloc.

Quoted 7 lines
drivers/attestation/providers/cca_guest.c new file +7 -0
+static int
+cca_guest_attestation_evidence_get(struct attestation_dev *att,
+				   const struct attestation_evidence_request *request,
+				   struct attestation_evidence_result *result)
+{
+	struct cca_guest_attestation *cca_guest_att = to_cca_guest_attestation(att);
+	size_t i, length;

drivers/attestation/providers/cca_guest.c line 363

Quoted 10 lines
drivers/attestation/providers/cca_guest.c new file +10 -0
+	void *buffer;
+	int ret = 0, ccel_obj_idx;
+
+	ccel_obj_idx = cca_guest_att->ccel_obj_idx;
+
+	for (i = 0; !ret && i < request->objects_count; i++) {
+		const struct attestation_evidence_object_request *object =
+			&request->objects[i];
+		struct attestation_evidence_object_result *produced =
+			&result->objects[i];

I feel like the core code should be doing more of this for the drivers... Drivers should have an op to return a single evidence, for an ID that they control. ie the core code should be returning the CCEL for its id, and when we get to SPDM other common code will handle ids too.

Maybe the evidence itself needs an ops?

drivers/attestation/providers/cca_guest.c line 568

Quoted 5 lines
drivers/attestation/providers/cca_guest.c new file +5 -0
+static const struct arm_smccc_device_id cca_guest_attest_id_table[] = {
+	{ .func_id = SMC_RSI_ABI_VERSION, },
+	{ },
+};
+MODULE_DEVICE_TABLE(arm_smccc, cca_guest_attest_id_table);

This isn't OK.. We only get one struct device per RSI and it gets to bind to only one driver. Given there are other drivers that will need to use the RSI, like the TSM and others, this needs some other solution?

Jason

#11 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Hi Jason,

[...]

Quoted 9 lines

Similarly the TCG log should work the same way.

I'm also wondering if too much code is leaking into to drivers to implement the uAPI. We should take a look at this vs the TDX one and make sure we have the right level of helpers and abstraction.

I also can't help but notice there isn't a single comment in any of this, it should be a bit more descriptive why some of these things are in here.

Okay. might next around, try to add comments.

Quoted 6 lines

drivers/attestation/providers/cca_guest.c line 84

Quoted 4 lines
drivers/attestation/providers/cca_guest.c new file +4 -0
+
+static const struct attestation_evidence_format cca_attestation_token_formats[] = {
+	{ .vendor = true, .value = CTLV_ATTESTATION_CCA_GUEST_EVIDENCE_VENDOR_FORMAT_CCA_ATTESTATION_TOKEN },
+};

should be the generic EAT token type

Is there? but the content seems to be different according to vendor, So would it be better to keep it as vendor type format?

[...]

Quoted 30 lines
Quoted 14 lines
drivers/attestation/providers/cca_guest.c new file +14 -0
+static long cca_guest_get_max_token_size(void)
+{
+	u8 dummy[RSI_ATTEST_CHALLENGE_MAX_SIZE] = { 0x00, };
+
+	return rsi_attestation_token_init(dummy, RSI_ATTEST_CHALLENGE_MAX_SIZE);
+}
+
+static int cca_guest_get_attest_tokens(const struct cca_guest_attestation *cca_guest_att,
+				       const void *challenge, size_t challenge_size,
+				       u8 *token, size_t *token_size)
+{
+	int ret;
+	long max_token_size;
+	void *buf;

drivers/attestation/providers/cca_guest.c line 285

Quoted 10 lines
drivers/attestation/providers/cca_guest.c new file +10 -0
+	unsigned long granule, offset, len, rsi_ret;
+
+	guard(migrate)();
+
+	max_token_size = rsi_attestation_token_init(challenge, challenge_size);
+	if (max_token_size <= 0)
+		return -EINVAL;
+
+	if (max_token_size != cca_guest_att->max_token_size)
+		return -ESTALE;

What is this and the related work? That isn't making sense to me. If the token size is not absolutely fixed when the driver starts then it should be fully dynamic and this just streams the variable sized token.

Quoted 1 line

Ideally directly into user memory so we don't need to allocate a kvmalloc.

In case of live-activation. I think in that case CCA-Realm token could be different by activating the new RMM.
But, in this round might we can drop this part.

[...]

Quoted 11 lines

drivers/attestation/providers/cca_guest.c line 568

Quoted 6 lines
drivers/attestation/providers/cca_guest.c new file +5 -0
+static const struct arm_smccc_device_id cca_guest_attest_id_table[] = {
+	{ .func_id = SMC_RSI_ABI_VERSION, },
+	{ },
+};
+MODULE_DEVICE_TABLE(arm_smccc, cca_guest_attest_id_table);

This isn't OK.. We only get one struct device per RSI and it gets to bind to only one driver. Given there are other drivers that will need to use the RSI, like the TSM and others, this needs some other solution?

Currently, this attestation driver is enabled when !ARM_CCA_GUEST only (IOW, when this driver can be built only when TSM arm-cca-guest disabled).

Signature · 2 lines
Sincerely,
Yeoreum Yun
#12 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Quoted 7 lines · Yeoreum Yun
Quoted 5 lines

drivers/attestation/providers/cca_guest.c line 84

Quoted 3 lines
drivers/attestation/providers/cca_guest.c new file +3 -0
+static const struct attestation_evidence_format cca_attestation_token_formats[] = {
+	{ .vendor = true, .value = CTLV_ATTESTATION_CCA_GUEST_EVIDENCE_VENDOR_FORMAT_CCA_ATTESTATION_TOKEN },
+};

should be the generic EAT token type

Is there?

That's the idea. TDX uses EAT as well.

Quoted 2 lines

but the content seems to be different according to vendor, So would it be better to keep it as vendor type format?

EAT is intended to be self describing, so if you parse the EAT then you should understand what the vendor and content is.

Knowing the EAT came from RMM won't even tell you which ARM profile version it follows, so I'm feeling like maybe we just need to tell userspace it is an EAT and then userspace can parse it deeply to learn exactly what it is??

Quoted 9 lines
Quoted 6 lines

What is this and the related work? That isn't making sense to me. If the token size is not absolutely fixed when the driver starts then it should be fully dynamic and this just streams the variable sized token.

Ideally directly into user memory so we don't need to allocate a kvmalloc.

In case of live-activation. I think in that case CCA-Realm token could be different by activating the new RMM.

Then the size isn't static and you need to just stream it to userspace whatever you have.

I'm expecting these unsized tokens to work by streaming them into a memfd so that userspace doesn't have to try to guess how much space is required.

I also think it is pretty broken if LFA is changing the token for realms that are already running. How is that even going to work with an RSI API like that gets the length then tries to fetch into the allocated buffer? Token silently truncates? You need to loop?

Quoted 8 lines
Quoted 4 lines

This isn't OK.. We only get one struct device per RSI and it gets to bind to only one driver. Given there are other drivers that will need to use the RSI, like the TSM and others, this needs some other solution?

Currently, this attestation driver is enabled when !ARM_CCA_GUEST only (IOW, when this driver can be built only when TSM arm-cca-guest disabled).

I saw in your FIRME series a solution to this problem, I think that would be good to get out on its own and apply it first to RSI as well. We will have the core RSI stuff, the realm attestation and TSM driver at a minimum..

Jason

#13 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Quoted 14 lines · Yeoreum Yun
Quoted 7 lines
Quoted 5 lines

drivers/attestation/providers/cca_guest.c line 84

Quoted 3 lines
drivers/attestation/providers/cca_guest.c new file +3 -0
+static const struct attestation_evidence_format cca_attestation_token_formats[] = {
+	{ .vendor = true, .value = CTLV_ATTESTATION_CCA_GUEST_EVIDENCE_VENDOR_FORMAT_CCA_ATTESTATION_TOKEN },
+};

should be the generic EAT token type

Is there?

That's the idea. TDX uses EAT as well.

Quoted 2 lines

but the content seems to be different according to vendor, So would it be better to keep it as vendor type format?

Quoted 7 lines

EAT is intended to be self describing, so if you parse the EAT then you should understand what the vendor and content is.

Knowing the EAT came from RMM won't even tell you which ARM profile version it follows, so I'm feeling like maybe we just need to tell userspace it is an EAT and then userspace can parse it deeply to learn exactly what it is??

Okay. might this would be applied in the FIRME too for PAT once the attestation patchset is updated.

Quoted 14 lines
Quoted 10 lines
Quoted 7 lines

What is this and the related work? That isn't making sense to me. If the token size is not absolutely fixed when the driver starts then it should be fully dynamic and this just streams the variable sized token.

Ideally directly into user memory so we don't need to allocate a kvmalloc.

In case of live-activation. I think in that case CCA-Realm token could be different by activating the new RMM.

Then the size isn't static and you need to just stream it to userspace whatever you have.

Quoted 8 lines

I'm expecting these unsized tokens to work by streaming them into a memfd so that userspace doesn't have to try to guess how much space is required.

I also think it is pretty broken if LFA is changing the token for realms that are already running. How is that even going to work with an RSI API like that gets the length then tries to fetch into the allocated buffer? Token silently truncates? You need to loop?

I think the problem is the *max-token-size* could be changed. once the LFA updates the Realm definitely the contents of hash of firmware binary can be changed. this means the token's content could be change including the *max-token-size*.

For this, the RSI host call interface has the way to get LFA eventlog. IOW, after LFA, there will be LFA log is genreated and then for the time of re-attestation, it should deliver the LFA logs together.

And userspace to get a token, it'll check the *max-token-size*, So I think it's enough with virtual address not needing streaming.

IOW, after LFA, the max-token-size can be changed and it should re-attestat, get new token and sent with LFA eventlog.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

This isn't OK.. We only get one struct device per RSI and it gets to bind to only one driver. Given there are other drivers that will need to use the RSI, like the TSM and others, this needs some other solution?

Quoted 8 lines
Quoted 3 lines

Currently, this attestation driver is enabled when !ARM_CCA_GUEST only (IOW, when this driver can be built only when TSM arm-cca-guest disabled).

I saw in your FIRME series a solution to this problem, I think that would be good to get out on its own and apply it first to RSI as well. We will have the core RSI stuff, the realm attestation and TSM driver at a minimum..

Hm,, Does this mean do we need to create two device one for TSM and one for attestation even the functionality same?

Signature · 2 lines
Sincerely,
Yeoreum Yun
#14 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Quoted 56 lines · Yeoreum Yun
Quoted 14 lines · Yeoreum Yun
Quoted 7 lines
Quoted 5 lines

drivers/attestation/providers/cca_guest.c line 84

Quoted 3 lines
drivers/attestation/providers/cca_guest.c new file +3 -0
+static const struct attestation_evidence_format cca_attestation_token_formats[] = {
+	{ .vendor = true, .value = CTLV_ATTESTATION_CCA_GUEST_EVIDENCE_VENDOR_FORMAT_CCA_ATTESTATION_TOKEN },
+};

should be the generic EAT token type

Is there?

That's the idea. TDX uses EAT as well.

Quoted 2 lines

but the content seems to be different according to vendor, So would it be better to keep it as vendor type format?

Quoted 7 lines

EAT is intended to be self describing, so if you parse the EAT then you should understand what the vendor and content is.

Knowing the EAT came from RMM won't even tell you which ARM profile version it follows, so I'm feeling like maybe we just need to tell userspace it is an EAT and then userspace can parse it deeply to learn exactly what it is??

Okay. might this would be applied in the FIRME too for PAT once the attestation patchset is updated.

Quoted 14 lines
Quoted 10 lines
Quoted 7 lines

What is this and the related work? That isn't making sense to me. If the token size is not absolutely fixed when the driver starts then it should be fully dynamic and this just streams the variable sized token.

Ideally directly into user memory so we don't need to allocate a kvmalloc.

In case of live-activation. I think in that case CCA-Realm token could be different by activating the new RMM.

Then the size isn't static and you need to just stream it to userspace whatever you have.

Quoted 8 lines

I'm expecting these unsized tokens to work by streaming them into a memfd so that userspace doesn't have to try to guess how much space is required.

I also think it is pretty broken if LFA is changing the token for realms that are already running. How is that even going to work with an RSI API like that gets the length then tries to fetch into the allocated buffer? Token silently truncates? You need to loop?

I think the problem is the *max-token-size* could be changed. once the LFA updates the Realm definitely the contents of hash of firmware binary can be changed. this means the token's content could be change including the *max-token-size*.

For this, the RSI host call interface has the way to get LFA eventlog. IOW, after LFA, there will be LFA log is genreated and then for the time of re-attestation, it should deliver the LFA logs together.

Quoted 5 lines

And userspace to get a token, it'll check the *max-token-size*, So I think it's enough with virtual address not needing streaming.

IOW, after LFA, the max-token-size can be changed and it should re-attestat, get new token and sent with LFA eventlog.

But, currently the LFA eventlog spec quite ambiguous for LFA eventlog. So, It could be discussed later and for this RFC i think dropping this is enough.

Signature · 2 lines
Sincerely,
Yeoreum Yun
#15 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

In reply to Yeoreum Yun
Quoted 4 lines · Yeoreum Yun

I think the problem is the *max-token-size* could be changed. once the LFA updates the Realm definitely the contents of hash of firmware binary can be changed. this means the token's content could be change including the *max-token-size*.

I think that is broken, there is no good way to make that work in a sane manner.

LFA must stay under the hard wired max-token-size limit, not try to change it while a realm is running. Take this to your spec team.

Quoted 3 lines

For this, the RSI host call interface has the way to get LFA eventlog. IOW, after LFA, there will be LFA log is genreated and then for the time of re-attestation, it should deliver the LFA logs together.

The detached event log is even more reason the token should not ever be changed by a LFA.

Quoted 7 lines
Quoted 4 lines

I saw in your FIRME series a solution to this problem, I think that would be good to get out on its own and apply it first to RSI as well. We will have the core RSI stuff, the realm attestation and TSM driver at a minimum..

Hm,, Does this mean do we need to create two device one for TSM and one for attestation even the functionality same?

They won't have the same functionality. It will be the same as you had with FIRME where there is a driver doing CPU attestation and another one (the TSM driver actually) doing link IDE.

Jason

#16 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Quoted 11 lines · Jason Gunthorpe
Quoted 4 lines · Yeoreum Yun

I think the problem is the *max-token-size* could be changed. once the LFA updates the Realm definitely the contents of hash of firmware binary can be changed. this means the token's content could be change including the *max-token-size*.

I think that is broken, there is no good way to make that work in a sane manner.

LFA must stay under the hard wired max-token-size limit, not try to change it while a realm is running. Take this to your spec team.

Yeap. if max-token-size is hard wired. then will not be a problem. And need to talk them.

Thanks!

Quoted 13 lines
Quoted 4 lines

For this, the RSI host call interface has the way to get LFA eventlog. IOW, after LFA, there will be LFA log is genreated and then for the time of re-attestation, it should deliver the LFA logs together.

The detached event log is even more reason the token should not ever be changed by a LFA.

Quoted 5 lines
Quoted 4 lines

I saw in your FIRME series a solution to this problem, I think that would be good to get out on its own and apply it first to RSI as well. We will have the core RSI stuff, the realm attestation and TSM driver at a minimum..

Quoted 6 lines
Quoted 2 lines

Hm,, Does this mean do we need to create two device one for TSM and one for attestation even the functionality same?

They won't have the same functionality. It will be the same as you had with FIRME where there is a driver doing CPU attestation and another one (the TSM driver actually) doing link IDE.

Right, I've missed the link IDE.
Yeap. in the next-spin let me make two device for it.

Thanks ;)

Signature · 2 lines
Sincerely,
Yeoreum Yun
#17 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

In reply to Jason Gunthorpe

[...]

Quoted 6 lines

drivers/attestation/providers/cca_guest.c line 35

Quoted 4 lines
drivers/attestation/providers/cca_guest.c new file +3 -0
+static enum hash_algo cca_guest_attestation_algorithms[] = {
+	HASH_ALGO_SHA512,
+};

static const

No. it's a scaling issue since the attestion algorithms could be not only SHA512 but also SHA256 and SHA384....

[...]

Signature · 2 lines
Sincerely,
Yeoreum Yun
#18 lore raw

Re: [PATCH RFC v3 7/8] attestation: providers: introduce CCA Guest attestation provider

Quoted 10 lines · Yeoreum Yun

[...]

Quoted 6 lines

drivers/attestation/providers/cca_guest.c line 35

Quoted 4 lines
drivers/attestation/providers/cca_guest.c new file +3 -0
+static enum hash_algo cca_guest_attestation_algorithms[] = {
+	HASH_ALGO_SHA512,
+};

static const

No. it's a scaling issue since the attestion algorithms could be not only SHA512 but also SHA256 and SHA384....

Then don't init it here and do it entirely when you query the RSI to learn the right value

Jason

#19 lore raw

RFC PATCH v3 8/8 selftest: attestation: add cca_guest_attestation_test selftest

In reply to Yeoreum Yun

Add CCA Realm Guest attestation selftest to test evidence-get, mr_read and mr_extend interfaces.

---
 tools/testing/selftests/attestation/.gitignore     |   1 +
 tools/testing/selftests/attestation/Makefile       |   9 +-
 .../attestation/cca_guest_attestation_test.c       | 517 +++++++++++++++++++++
 3 files changed, 524 insertions(+), 3 deletions(-)
tools/testing/selftests/attestation/.gitignore +1 -0
index e10d0c9e4723c..9ae9baec654d1 100644
@@ -3,3 +3,4 @@ attestation_test
 ima_attestation_test
 tdx_attestation_test
 firme_attestation_test
+cca_guest_attestation_test
tools/testing/selftests/attestation/Makefile +6 -3
index d4875652b4a14..f5a1ae68c0c4a 100644
@@ -4,13 +4,14 @@ CFLAGS += -I../../../ctlv/libctlv
 LDLIBS += -lpthread
 
 TEST_GEN_PROGS := attestation_test ima_attestation_test tdx_attestation_test \
-		  firme_attestation_test
+		  firme_attestation_test cca_guest_attestation_test
 
 LIBCTLV_DIR := ../../../ctlv/libctlv
 BINDINGS := ctlv_attestation_user_gen.c \
 	    ctlv_attestation_sim_user_gen.c \
 	    ctlv_attestation_tdx_user_gen.c \
-	    ctlv_attestation_firme_user_gen.c
+	    ctlv_attestation_firme_user_gen.c \
+	    ctlv_attestation_cca_guest_user_gen.c
 
 EXTRA_CLEAN = $(OUTPUT)/libctlv
 
@@ -30,6 +31,9 @@ $(OUTPUT)/tdx_attestation_test: tdx_attestation_test.c $(BINDINGS) $(LIBCTLV)
 $(OUTPUT)/firme_attestation_test: firme_attestation_test.c $(BINDINGS) $(LIBCTLV)
 	$(CC) $(CFLAGS) $(CPPFLAGS) $^ $(LDLIBS) -o $@
 
+$(OUTPUT)/cca_guest_attestation_test: cca_guest_attestation_test.c $(BINDINGS) $(LIBCTLV)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $^ $(LDLIBS) -o $@
+
 $(LIBCTLV): FORCE
 	$(Q)mkdir -p $(OUTPUT)/libctlv
 	$(Q)$(MAKE) -C $(LIBCTLV_DIR) CC="$(CC)" OUTPUT=$(OUTPUT)/libctlv/ \
@@ -38,4 +42,3 @@ $(LIBCTLV): FORCE
 FORCE:
 
 .PHONY: FORCE
-
tools/testing/selftests/attestation/cca_guest_attestation_test.c new file +517 -0

517 lines not on this page · raw message

Signature · 1 line
2.43.0
#20 lore raw

Re: [PATCH RFC v3 8/8] selftest: attestation: add cca_guest_attestation_test selftest

Quoted 9 lines · Yeoreum Yun

Add CCA Realm Guest attestation selftest to test evidence-get, mr_read and mr_extend interfaces.

---
 tools/testing/selftests/attestation/.gitignore     |   1 +
 tools/testing/selftests/attestation/Makefile       |   9 +-
 .../attestation/cca_guest_attestation_test.c       | 517 +++++++++++++++++++++
 3 files changed, 524 insertions(+), 3 deletions(-)

FWIW, I really want to have an attestation userspace project and there is where stuff like this should end up living..

We haven't got to launching a github for it yet, but that's the plan anyhow.

Jason