Skip to content

Commit a1edec2

Browse files
jlintonarmwilldeacon
authored andcommitted
arm64: rsi: Add automatic arm-cca-guest module loading
The TSM module provides guest identification and attestation when a guest runs in CCA realm mode. By creating a dummy platform device, let's ensure the module is automatically loaded. The udev daemon loads the TSM module after it receives a device addition event. Once that happens, it can be used earlier in the boot process to decrypt the rootfs. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> Reviewed-by: Gavin Shan <gshan@redhat.com> Reviewed-by: Steven Price <steven.price@arm.com> Link: https://lore.kernel.org/r/20241220181236.172060-2-jeremy.linton@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent fac04ef commit a1edec2

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

arch/arm64/include/asm/rsi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <linux/jump_label.h>
1111
#include <asm/rsi_cmds.h>
1212

13+
#define RSI_PDEV_NAME "arm-cca-dev"
14+
1315
DECLARE_STATIC_KEY_FALSE(rsi_present);
1416

1517
void __init arm64_rsi_init(void);

arch/arm64/kernel/rsi.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/psci.h>
99
#include <linux/swiotlb.h>
1010
#include <linux/cc_platform.h>
11+
#include <linux/platform_device.h>
1112

1213
#include <asm/io.h>
1314
#include <asm/mem_encrypt.h>
@@ -140,3 +141,17 @@ void __init arm64_rsi_init(void)
140141
static_branch_enable(&rsi_present);
141142
}
142143

144+
static struct platform_device rsi_dev = {
145+
.name = RSI_PDEV_NAME,
146+
.id = PLATFORM_DEVID_NONE
147+
};
148+
149+
static int __init arm64_create_dummy_rsi_dev(void)
150+
{
151+
if (is_realm_world() &&
152+
platform_device_register(&rsi_dev))
153+
pr_err("failed to register rsi platform device\n");
154+
return 0;
155+
}
156+
157+
arch_initcall(arm64_create_dummy_rsi_dev)

drivers/virt/coco/arm-cca-guest/arm-cca-guest.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/arm-smccc.h>
77
#include <linux/cc_platform.h>
88
#include <linux/kernel.h>
9+
#include <linux/mod_devicetable.h>
910
#include <linux/module.h>
1011
#include <linux/smp.h>
1112
#include <linux/tsm.h>
@@ -219,6 +220,13 @@ static void __exit arm_cca_guest_exit(void)
219220
}
220221
module_exit(arm_cca_guest_exit);
221222

223+
/* modalias, so userspace can autoload this module when RSI is available */
224+
static const struct platform_device_id arm_cca_match[] __maybe_unused = {
225+
{ RSI_PDEV_NAME, 0},
226+
{ }
227+
};
228+
229+
MODULE_DEVICE_TABLE(platform, arm_cca_match);
222230
MODULE_AUTHOR("Sami Mujawar <sami.mujawar@arm.com>");
223231
MODULE_DESCRIPTION("Arm CCA Guest TSM Driver");
224232
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)