diff mbox series

[RFC,kvm-unit-tests,23/27] arm: realm: add RSI interface for attestation measurements

Message ID 20230127114108.10025-24-joey.gouly@arm.com (mailing list archive)
State New, archived
Headers show
Series [RFC,kvm-unit-tests,01/27] lib/string: include stddef.h for size_t | expand

Commit Message

Joey Gouly Jan. 27, 2023, 11:41 a.m. UTC
From: Suzuki K Poulose <suzuki.poulose@arm.com>

Add wrappers for the Attestation and measurement related RSI calls.
These will be later used in the test cases

Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Joey Gouly <joey.gouly@arm.com>
---
 lib/arm64/asm/rsi.h |  7 +++++++
 lib/arm64/rsi.c     | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
diff mbox series

Patch

diff --git a/lib/arm64/asm/rsi.h b/lib/arm64/asm/rsi.h
index c8179341..50bab993 100644
--- a/lib/arm64/asm/rsi.h
+++ b/lib/arm64/asm/rsi.h
@@ -27,6 +27,13 @@  int rsi_invoke(unsigned int function_id, unsigned long arg0,
 	       struct smccc_result *result);
 
 int rsi_get_version(void);
+void rsi_attest_token_init(phys_addr_t addr, unsigned long *challenge,
+			   struct smccc_result *res);
+void rsi_attest_token_continue(phys_addr_t addr, struct smccc_result *res);
+void rsi_extend_measurement(unsigned int index, unsigned long size,
+			    unsigned long *measurement,
+			    struct smccc_result *res);
+void rsi_read_measurement(unsigned int index, struct smccc_result *res);
 
 static inline bool is_realm(void)
 {
diff --git a/lib/arm64/rsi.c b/lib/arm64/rsi.c
index 08c77889..63d0620a 100644
--- a/lib/arm64/rsi.c
+++ b/lib/arm64/rsi.c
@@ -66,6 +66,38 @@  void arm_rsi_init(void)
 	prot_ns_shared = (1UL << phys_mask_shift);
 }
 
+void rsi_attest_token_init(phys_addr_t addr, unsigned long *challenge,
+			   struct smccc_result *res)
+{
+	rsi_invoke(SMC_RSI_ATTEST_TOKEN_INIT, addr,
+		   challenge[0], challenge[1], challenge[2],
+		   challenge[3], challenge[4], challenge[5],
+		   challenge[6], challenge[7], 0, 0, res);
+}
+
+void rsi_attest_token_continue(phys_addr_t addr, struct smccc_result *res)
+{
+	rsi_invoke(SMC_RSI_ATTEST_TOKEN_CONTINUE, addr,
+		   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, res);
+}
+
+void rsi_extend_measurement(unsigned int index, unsigned long size,
+			    unsigned long *measurement, struct smccc_result *res)
+{
+	rsi_invoke(SMC_RSI_MEASUREMENT_EXTEND, index, size,
+		   measurement[0], measurement[1],
+		   measurement[2], measurement[3],
+		   measurement[4], measurement[5],
+		   measurement[6], measurement[7],
+		   0, res);
+}
+
+void rsi_read_measurement(unsigned int index, struct smccc_result *res)
+{
+	rsi_invoke(SMC_RSI_MEASUREMENT_READ, index, 0,
+		   0, 0, 0, 0, 0, 0, 0, 0, 0, res);
+}
+
 static unsigned rsi_set_addr_range_state(unsigned long start, unsigned long size,
 					 enum ripas_t state, unsigned long *top)
 {