From nobody Wed Dec 4 19:15:45 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 254CC3C39 for ; Tue, 3 Dec 2024 00:02:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733184134; cv=none; b=JZqG4Ht0iBA2OiVu2N7+U7BWzz5W0vM5M0KUm3PFo4P12Yt2TSsREblzHUae+kP8zW4Tj1Byr88WpP3/7eKfwci/+JD2rnbj80v97xoPvQP4SegMwFatcS0x2zkXuwPkOpvlJqzX1yFUUeNxCHPkWTORkYc7xxNVZnpW1qvL8/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733184134; c=relaxed/simple; bh=wJjhfInZjFoDaTNQFUDxhn/mxkI98pJjiyTy72q0mx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ojFSAaZhoGE4lxPLZN0LptvqwWobSw1Qd+vsrEpwMNgxI4mcYYXOYe4l8MBVLBm2Us3axZ+KgbkjTGrkDcJg/9nO8HO1PxG2pU4B0HTWQxaTDSC214q3lv6UZZ1pZ1OwIhZETCGCugXfwUoWcOjxNqft9HuVdWdRyDfI1wNe/OA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C763B1515; Mon, 2 Dec 2024 16:02:40 -0800 (PST) Received: from u200865.usa.arm.com (U203867.austin.arm.com [10.118.30.38]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3CC583F71E; Mon, 2 Dec 2024 16:02:12 -0800 (PST) From: Jeremy Linton To: linux-arm-kernel@lists.infradead.org Cc: gshan@redhat.com, steven.price@arm.com, sami.mujawar@arm.com, suzuki.poulose@arm.com, will@kernel.org, catalin.marinas@arm.com, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH v2 1/1] arm64: rsi: Add automatic arm-cca-guest module loading Date: Mon, 2 Dec 2024 18:01:56 -0600 Message-ID: <20241203000156.72451-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203000156.72451-1-jeremy.linton@arm.com> References: <20241203000156.72451-1-jeremy.linton@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The TSM module provides both guest identification as well as attestation when a guest is run in CCA mode. Lets assure by creating a dummy platform device that the module is automatically loaded during boot. The TSM module will be loaded by udev daemon after it receives the device addition event. Once it is in place it can be used earlier in the boot process to say decrypt a LUKS rootfs. Signed-off-by: Jeremy Linton Reviewed-by: Gavin Shan --- 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 #include =20 +#define RSI_PDEV_NAME "arm-cca-dev" + DECLARE_STATIC_KEY_FALSE(rsi_present); =20 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 #include #include +#include =20 #include #include @@ -140,3 +141,17 @@ void __init arm64_rsi_init(void) static_branch_enable(&rsi_present); } =20 +static struct platform_device rsi_dev =3D { + .name =3D RSI_PDEV_NAME, + .id =3D 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..1f8d8439f617 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 #include #include +#include #include #include #include @@ -219,6 +220,13 @@ static void __exit arm_cca_guest_exit(void) } module_exit(arm_cca_guest_exit); =20 +/* modalias, so userspace can autoload this module when RSI is available */ +static const struct __maybe_unused platform_device_id arm_cca_match[] =3D { + { RSI_PDEV_NAME, 0}, + { } +}; + +MODULE_DEVICE_TABLE(platform, arm_cca_match); MODULE_AUTHOR("Sami Mujawar "); MODULE_DESCRIPTION("Arm CCA Guest TSM Driver"); MODULE_LICENSE("GPL"); --=20 2.46.0