[kvm-unit-tests PATCH 27/33] arm: realm: add RSI interface for attestation measurements
Suzuki K Poulose
suzuki.poulose at arm.com
Fri Apr 12 03:34:02 PDT 2024
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 at arm.com>
---
lib/arm64/asm/rsi.h | 10 +++++++++
lib/arm64/rsi.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+)
diff --git a/lib/arm64/asm/rsi.h b/lib/arm64/asm/rsi.h
index 0b726684..2566c000 100644
--- a/lib/arm64/asm/rsi.h
+++ b/lib/arm64/asm/rsi.h
@@ -29,6 +29,16 @@ int rsi_invoke(unsigned int function_id, unsigned long arg0,
int __rsi_get_version(unsigned long ver, struct smccc_result *res);
int rsi_get_version(unsigned long ver);
+int rsi_attest_token_init(unsigned long *challenge, unsigned long *max_size);
+int rsi_attest_token_continue(phys_addr_t addr,
+ unsigned long offset,
+ unsigned long size,
+ unsigned long *len);
+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)
{
return rsi_present;
diff --git a/lib/arm64/rsi.c b/lib/arm64/rsi.c
index e58d9660..8fe672fc 100644
--- a/lib/arm64/rsi.c
+++ b/lib/arm64/rsi.c
@@ -134,3 +134,55 @@ void arm_set_memory_shared(unsigned long start, unsigned long size)
{
arm_set_memory_state(start, size, RIPAS_EMPTY, RSI_CHANGE_DESTROYED);
}
+
+int rsi_attest_token_init(unsigned long *challenge, unsigned long *max_size)
+{
+ struct smccc_result res;
+
+ rsi_invoke(SMC_RSI_ATTEST_TOKEN_INIT,
+ challenge[0], challenge[1], challenge[2],
+ challenge[3], challenge[4], challenge[5],
+ challenge[6], challenge[7], 0, 0, 0, &res);
+
+ if (max_size)
+ *max_size = res.r1;
+ return res.r0;
+}
+
+int rsi_attest_token_continue(phys_addr_t addr,
+ unsigned long offset,
+ unsigned long size,
+ unsigned long *len)
+{
+ struct smccc_result res = { 0 };
+
+ rsi_invoke(SMC_RSI_ATTEST_TOKEN_CONTINUE, addr, offset, size,
+ 0, 0, 0, 0, 0, 0, 0, 0, &res);
+ switch (res.r0) {
+ case RSI_SUCCESS:
+ case RSI_INCOMPLETE:
+ if (len)
+ *len = res.r1;
+ /* Fall through */
+ default:
+ break;
+ }
+ return res.r0;
+}
+
+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);
+}
--
2.34.1
More information about the linux-arm-kernel
mailing list