* [PATCH v3 0/1] arm64: CCA TSM module autoloading
@ 2024-12-07 1:21 Jeremy Linton
2024-12-07 1:21 ` [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
0 siblings, 1 reply; 5+ messages in thread
From: Jeremy Linton @ 2024-12-07 1:21 UTC (permalink / raw)
To: linux-arm-kernel
Cc: suzuki.poulose, gshan, steven.price, sami.mujawar,
catalin.marinas, will, linux-kernel, Jeremy Linton
Provide module tables and a platform device so that the
CCA TSM module will autoload when needed.
v2->v3:
Fix __maybe_used placement, it does fix CLANG builds now.
Add reviewed-by tag, Thanks Gavin!
Ugly commit message cleanup.
v1->v2:
Various comment updates/variable renames
Add missing __maybe_unused to the platform_device_id
Jeremy Linton (1):
arm64: rsi: Add automatic arm-cca-guest module loading
arch/arm64/include/asm/rsi.h | 2 ++
arch/arm64/kernel/rsi.c | 15 +++++++++++++++
drivers/virt/coco/arm-cca-guest/arm-cca-guest.c | 8 ++++++++
3 files changed, 25 insertions(+)
--
2.46.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
2024-12-07 1:21 [PATCH v3 0/1] arm64: CCA TSM module autoloading Jeremy Linton
@ 2024-12-07 1:21 ` Jeremy Linton
2024-12-08 4:38 ` Itaru Kitayama
2024-12-11 21:30 ` Will Deacon
0 siblings, 2 replies; 5+ messages in thread
From: Jeremy Linton @ 2024-12-07 1:21 UTC (permalink / raw)
To: linux-arm-kernel
Cc: suzuki.poulose, gshan, steven.price, sami.mujawar,
catalin.marinas, will, linux-kernel, Jeremy Linton
The TSM module provides guest identification and attestation when a
guest runs in CCA 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>
---
arch/arm64/include/asm/rsi.h | 2 ++
arch/arm64/kernel/rsi.c | 15 +++++++++++++++
drivers/virt/coco/arm-cca-guest/arm-cca-guest.c | 8 ++++++++
3 files changed, 25 insertions(+)
diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h
index 188cbb9b23f5..b42aeac05340 100644
--- a/arch/arm64/include/asm/rsi.h
+++ b/arch/arm64/include/asm/rsi.h
@@ -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);
diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
index 3031f25c32ef..5434e5496ac2 100644
--- a/arch/arm64/kernel/rsi.c
+++ b/arch/arm64/kernel/rsi.c
@@ -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 rsi_init(void)
+{
+ if (is_realm_world() &&
+ platform_device_register(&rsi_dev))
+ pr_err("failed to register rsi platform device\n");
+ return 0;
+}
+
+arch_initcall(rsi_init)
diff --git a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
index 488153879ec9..87f162736b2e 100644
--- a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
+++ b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
@@ -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");
--
2.46.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
2024-12-07 1:21 ` [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
@ 2024-12-08 4:38 ` Itaru Kitayama
2024-12-17 20:16 ` Jeremy Linton
2024-12-11 21:30 ` Will Deacon
1 sibling, 1 reply; 5+ messages in thread
From: Itaru Kitayama @ 2024-12-08 4:38 UTC (permalink / raw)
To: Jeremy Linton
Cc: linux-arm-kernel, suzuki.poulose, gshan, steven.price,
sami.mujawar, catalin.marinas, will, linux-kernel
Hi Jeremy,
On Fri, Dec 06, 2024 at 07:21:28PM -0600, Jeremy Linton wrote:
> The TSM module provides guest identification and attestation when a
> guest runs in CCA mode. By creating a dummy platform device, let's
Perhaps could you spell out like; a guest runs in the Realm state?
Thanks,
Itaru.
> 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>
> ---
> arch/arm64/include/asm/rsi.h | 2 ++
> arch/arm64/kernel/rsi.c | 15 +++++++++++++++
> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c | 8 ++++++++
> 3 files changed, 25 insertions(+)
>
> diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h
> index 188cbb9b23f5..b42aeac05340 100644
> --- a/arch/arm64/include/asm/rsi.h
> +++ b/arch/arm64/include/asm/rsi.h
> @@ -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);
> diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
> index 3031f25c32ef..5434e5496ac2 100644
> --- a/arch/arm64/kernel/rsi.c
> +++ b/arch/arm64/kernel/rsi.c
> @@ -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 rsi_init(void)
> +{
> + if (is_realm_world() &&
> + platform_device_register(&rsi_dev))
> + pr_err("failed to register rsi platform device\n");
> + return 0;
> +}
> +
> +arch_initcall(rsi_init)
> diff --git a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
> index 488153879ec9..87f162736b2e 100644
> --- a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
> +++ b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
> @@ -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");
> --
> 2.46.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
2024-12-07 1:21 ` [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
2024-12-08 4:38 ` Itaru Kitayama
@ 2024-12-11 21:30 ` Will Deacon
1 sibling, 0 replies; 5+ messages in thread
From: Will Deacon @ 2024-12-11 21:30 UTC (permalink / raw)
To: Jeremy Linton
Cc: linux-arm-kernel, suzuki.poulose, gshan, steven.price,
sami.mujawar, catalin.marinas, linux-kernel
On Fri, Dec 06, 2024 at 07:21:28PM -0600, Jeremy Linton wrote:
> The TSM module provides guest identification and attestation when a
> guest runs in CCA 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>
> ---
> arch/arm64/include/asm/rsi.h | 2 ++
> arch/arm64/kernel/rsi.c | 15 +++++++++++++++
> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c | 8 ++++++++
> 3 files changed, 25 insertions(+)
>
> diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h
> index 188cbb9b23f5..b42aeac05340 100644
> --- a/arch/arm64/include/asm/rsi.h
> +++ b/arch/arm64/include/asm/rsi.h
> @@ -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);
> diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
> index 3031f25c32ef..5434e5496ac2 100644
> --- a/arch/arm64/kernel/rsi.c
> +++ b/arch/arm64/kernel/rsi.c
> @@ -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 rsi_init(void)
> +{
> + if (is_realm_world() &&
> + platform_device_register(&rsi_dev))
> + pr_err("failed to register rsi platform device\n");
> + return 0;
> +}
> +
> +arch_initcall(rsi_init)
This file already has an arm64_rsi_init()... Ideally, we'd hang this
off the end of that instead of the initcall but I suspect you're going
to tell me that platform_device_register() doesn't like being called
that early?
If so, perhaps arm64_create_dummy_rsi_dev() might be better?
Will
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading
2024-12-08 4:38 ` Itaru Kitayama
@ 2024-12-17 20:16 ` Jeremy Linton
0 siblings, 0 replies; 5+ messages in thread
From: Jeremy Linton @ 2024-12-17 20:16 UTC (permalink / raw)
To: Itaru Kitayama
Cc: linux-arm-kernel, suzuki.poulose, gshan, steven.price,
sami.mujawar, catalin.marinas, will, linux-kernel
Hi,
On 12/7/24 10:38 PM, Itaru Kitayama wrote:
> Hi Jeremy,
>
> On Fri, Dec 06, 2024 at 07:21:28PM -0600, Jeremy Linton wrote:
>> The TSM module provides guest identification and attestation when a
>> guest runs in CCA mode. By creating a dummy platform device, let's
>
> Perhaps could you spell out like; a guest runs in the Realm state?
Thanks for looking at this.
I thought that was evident from the rest of the commits here, but sure.
Thanks again.
>
> Thanks,
> Itaru.
>
>> 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>
>> ---
>> arch/arm64/include/asm/rsi.h | 2 ++
>> arch/arm64/kernel/rsi.c | 15 +++++++++++++++
>> drivers/virt/coco/arm-cca-guest/arm-cca-guest.c | 8 ++++++++
>> 3 files changed, 25 insertions(+)
>>
>> diff --git a/arch/arm64/include/asm/rsi.h b/arch/arm64/include/asm/rsi.h
>> index 188cbb9b23f5..b42aeac05340 100644
>> --- a/arch/arm64/include/asm/rsi.h
>> +++ b/arch/arm64/include/asm/rsi.h
>> @@ -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);
>> diff --git a/arch/arm64/kernel/rsi.c b/arch/arm64/kernel/rsi.c
>> index 3031f25c32ef..5434e5496ac2 100644
>> --- a/arch/arm64/kernel/rsi.c
>> +++ b/arch/arm64/kernel/rsi.c
>> @@ -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 rsi_init(void)
>> +{
>> + if (is_realm_world() &&
>> + platform_device_register(&rsi_dev))
>> + pr_err("failed to register rsi platform device\n");
>> + return 0;
>> +}
>> +
>> +arch_initcall(rsi_init)
>> diff --git a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
>> index 488153879ec9..87f162736b2e 100644
>> --- a/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
>> +++ b/drivers/virt/coco/arm-cca-guest/arm-cca-guest.c
>> @@ -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");
>> --
>> 2.46.0
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-12-17 20:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-07 1:21 [PATCH v3 0/1] arm64: CCA TSM module autoloading Jeremy Linton
2024-12-07 1:21 ` [PATCH v3 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Jeremy Linton
2024-12-08 4:38 ` Itaru Kitayama
2024-12-17 20:16 ` Jeremy Linton
2024-12-11 21:30 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).