Linux Confidential Computing Development
 help / color / mirror / Atom feed
From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
	Sudeep Holla <sudeep.holla@kernel.org>
Cc: linux-coco@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	Jeremy Linton <jeremy.linton@arm.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Lorenzo Pieralisi <lpieralisi@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>,
	Steven Price <steven.price@arm.com>
Subject: Re: [PATCH v6 3/4] firmware: smccc: arm-cca-guest: Bind the TSM provider to an SMCCC device
Date: Mon, 08 Jun 2026 16:56:29 +0530	[thread overview]
Message-ID: <yq5aldcpz316.fsf@kernel.org> (raw)
In-Reply-To: <e0071e90-c2f5-4d15-b3c6-fe05bf1464e4@arm.com>

Suzuki K Poulose <suzuki.poulose@arm.com> writes:

> On 08/06/2026 09:19, Aneesh Kumar K.V wrote:
>> Sudeep Holla <sudeep.holla@kernel.org> writes:
>> 
>>> On Thu, Jun 04, 2026 at 06:56:28PM +0530, Aneesh Kumar K.V wrote:
>>>> Sudeep Holla <sudeep.holla@kernel.org> writes:
>>>>
>>>> ...

...

>>> I was trying to avoid conditional compilation altogether and hence the
>>> reason for keeping it as simple as possible. Also IS_ENABLED(CONFIG_ARM64)
>>> in above snippet must come as some condition to this generic probe.
>>>
>>> Adding any more logic or callback defeats the bus idea here if we need
>>> to rely/depend on multiple conditional compilation or callbacks IMO.
>>>
>>> Let's find see if it can work with what we are adding now and may add in
>>> near future and then decide.
>>>
>> 
>> If we move all the conditional checks to the driver probe path, then I
>> think this can work. Something like the below:
>> 
>> struct smccc_device_info {
>> 	u32 func_id;
>> 	bool requires_smc;
>> 	const char *device_name;
>> };
>> 
>> static const struct smccc_device_info smccc_devices[] __initconst = {
>> 	{
>> 		.func_id        = ARM_SMCCC_TRNG_VERSION,
>> 		.requires_smc   = false,
>> 		.device_name    = "arm-smccc-trng",
>> 	},
>> 
>> 	{
>> 		.func_id        = RSI_ABI_VERSION,
>
> Don't we need parameters passed to this (Requested Interface version for 
> e.g.) ? See more below.
>

The idea is that we only check whether the function ID is supported. All
other conditional logic should be handled in the driver probe path, as
demonstrated by the changes in drivers/char/hw_random/arm_smccc_trng.c.

>
>> 		.requires_smc   = true,
>> 		.device_name    = RSI_DEV_NAME,
>> 	},
>> };
>> 
>> static bool __init smccc_probe_smccc_device(const struct smccc_device_info *smccc_dev)
>> {
>> 	unsigned long ret;
>> 	struct arm_smccc_res res;
>> 
>> 	if (smccc_conduit == SMCCC_CONDUIT_NONE)
>> 		return false;
>> 
>> 	if (smccc_dev->requires_smc && smccc_conduit != SMCCC_CONDUIT_SMC)
>> 		return false;
>> 
>> 	arm_smccc_1_1_invoke(smccc_dev->func_id, &res);
>> 	ret = res.a0;
>> 
>> 	if ((s32)ret == SMCCC_RET_NOT_SUPPORTED)
>
> Is this a reliable check for all possible SMCCC services ? i.e., Are we 
> expected to get RET_NOT_SUPPORTED for any service for which the backend
> is not available ?
>

That is correct. That is what the SMCCC specification says

> Also, as pointed out RSI_ABI_VERSION may return other errors based on 
> the input (requested version, e.g., RSI_ERROR_INPUT) and we may still go
> ahead and register the device ?
>

Correct, and the driver probe will check for the minimum and maximum supported versions.

>> 		return false;
>> 
>> 	return true;
>> }
>> 
>> static int __init smccc_devices_init(void)
>> {
>> 	struct arm_smccc_device *sdev;
>> 	const struct smccc_device_info *smccc_dev;
>> 
>> 	for (int i = 0; i < ARRAY_SIZE(smccc_devices); i++) {
>> 		smccc_dev = &smccc_devices[i];
>> 
>> 		if (!smccc_probe_smccc_device(smccc_dev))
>> 			continue;
>> 
>>                 sdev = arm_smccc_device_register(smccc_dev->device_name);
>>                 if (IS_ERR(sdev))
>>                         pr_err("%s: could not register device: %ld\n",
>>                                smccc_dev->device_name, PTR_ERR(sdev));
>> 
>> 	}
>> 
>> 	return 0;
>> }
>> device_initcall(smccc_devices_init);
>> 
>> with the diff to hw_random/smccc_trng
>> 
>> modified   arch/arm64/include/asm/archrandom.h
>> @@ -12,7 +12,7 @@
>>   
>>   extern bool smccc_trng_available;
>>   
>> -static inline bool __init smccc_probe_trng(void)
>> +static inline bool smccc_probe_trng(void)
>>   {
>>   	struct arm_smccc_res res;
>>   
>> modified   drivers/char/hw_random/arm_smccc_trng.c
>> @@ -19,6 +19,8 @@
>>   #include <linux/arm-smccc.h>
>>   #include <linux/arm-smccc-bus.h>
>>   
>> +#include <asm/archrandom.h>
>> +
>>   #ifdef CONFIG_ARM64
>>   #define ARM_SMCCC_TRNG_RND	ARM_SMCCC_TRNG_RND64
>>   #define MAX_BITS_PER_CALL	(3 * 64UL)
>> @@ -98,6 +100,10 @@ static int smccc_trng_probe(struct arm_smccc_device *sdev)
>>   {
>>   	struct hwrng *trng;
>>   
>> +	/* validate the minimum version requirement */
>> +	if (!smccc_probe_trng())
>> +		return -ENODEV;
>> +
>>   	trng = devm_kzalloc(&sdev->dev, sizeof(*trng), GFP_KERNEL);
>>   	if (!trng)
>>   		return -ENOMEM;
>> 
>> We can also move arch/arm64/include/asm/rsi_smc.h to
>> include/linux/arm-rsi-smccc.h. There was a suggestion to move these
>
> super minor nit: arm-smccc-rsi.h ?
>

-aneesh

  reply	other threads:[~2026-06-08 11:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 10:02 [PATCH v6 0/4] Switch Arm SMCCC firmware services to an SMCCC bus Aneesh Kumar K.V (Arm)
2026-05-27 10:02 ` [PATCH v6 1/4] firmware: smccc: Add an Arm " Aneesh Kumar K.V (Arm)
2026-06-03 18:52   ` Sudeep Holla
2026-05-27 10:02 ` [PATCH v6 2/4] firmware: hwrng: arm_smccc_trng: Register as an SMCCC device Aneesh Kumar K.V (Arm)
2026-05-27 10:02 ` [PATCH v6 3/4] firmware: smccc: arm-cca-guest: Bind the TSM provider to " Aneesh Kumar K.V (Arm)
2026-06-04  9:18   ` Suzuki K Poulose
2026-06-04  9:21   ` Sudeep Holla
2026-06-04 10:24     ` Suzuki K Poulose
2026-06-04 10:55       ` Sudeep Holla
2026-06-04 13:26     ` Aneesh Kumar K.V
2026-06-04 13:45       ` Sudeep Holla
2026-06-08  8:19         ` Aneesh Kumar K.V
2026-06-08  8:39           ` Sudeep Holla
2026-06-08  9:03           ` Suzuki K Poulose
2026-06-08 11:26             ` Aneesh Kumar K.V [this message]
2026-06-08 12:32               ` Sudeep Holla
2026-05-27 10:02 ` [PATCH v6 4/4] coco: guest: arm64: Replace dummy CCA device with sysfs ABI Aneesh Kumar K.V (Arm)
2026-06-04 12:58 ` [PATCH v6 0/4] Switch Arm SMCCC firmware services to an SMCCC bus Aneesh Kumar K.V

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yq5aldcpz316.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeremy.linton@arm.com \
    --cc=jic23@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=steven.price@arm.com \
    --cc=sudeep.holla@kernel.org \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox