]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
arm64: rsi: Add automatic arm-cca-guest module loading
authorJeremy Linton <jeremy.linton@arm.com>
Fri, 20 Dec 2024 18:12:36 +0000 (12:12 -0600)
committerWill Deacon <will@kernel.org>
Wed, 8 Jan 2025 13:58:49 +0000 (13:58 +0000)
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>
arch/arm64/include/asm/rsi.h
arch/arm64/kernel/rsi.c
drivers/virt/coco/arm-cca-guest/arm-cca-guest.c

index 188cbb9b23f5766c58f73e536e7bb972d6c21176..b42aeac05340edd7d41573789fb78b9d06ecc34c 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/jump_label.h>
 #include <asm/rsi_cmds.h>
 
+#define RSI_PDEV_NAME "arm-cca-dev"
+
 DECLARE_STATIC_KEY_FALSE(rsi_present);
 
 void __init arm64_rsi_init(void);
index 3031f25c32ef7545576142b310d083d5c6e51120..ce4778141ec7b8a05a49a28fdf4aa7f37bd915a7 100644 (file)
@@ -8,6 +8,7 @@
 #include <linux/psci.h>
 #include <linux/swiotlb.h>
 #include <linux/cc_platform.h>
+#include <linux/platform_device.h>
 
 #include <asm/io.h>
 #include <asm/mem_encrypt.h>
@@ -140,3 +141,17 @@ void __init arm64_rsi_init(void)
        static_branch_enable(&rsi_present);
 }
 
+static struct platform_device rsi_dev = {
+       .name = RSI_PDEV_NAME,
+       .id = PLATFORM_DEVID_NONE
+};
+
+static int __init arm64_create_dummy_rsi_dev(void)
+{
+       if (is_realm_world() &&
+           platform_device_register(&rsi_dev))
+               pr_err("failed to register rsi platform device\n");
+       return 0;
+}
+
+arch_initcall(arm64_create_dummy_rsi_dev)
index 488153879ec9a783ce424a9e5c89635b561749ec..87f162736b2edff857b3e3fd037202f51a0777c4 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/arm-smccc.h>
 #include <linux/cc_platform.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/smp.h>
 #include <linux/tsm.h>
@@ -219,6 +220,13 @@ static void __exit arm_cca_guest_exit(void)
 }
 module_exit(arm_cca_guest_exit);
 
+/* modalias, so userspace can autoload this module when RSI is available */
+static const struct platform_device_id arm_cca_match[] __maybe_unused = {
+       { RSI_PDEV_NAME, 0},
+       { }
+};
+
+MODULE_DEVICE_TABLE(platform, arm_cca_match);
 MODULE_AUTHOR("Sami Mujawar <sami.mujawar@arm.com>");
 MODULE_DESCRIPTION("Arm CCA Guest TSM Driver");
 MODULE_LICENSE("GPL");