From: Steven Price <steven.price@arm.com>
To: Gavin Shan <gshan@redhat.com>,
kvm@vger.kernel.org, kvmarm@lists.linux.dev
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
James Morse <james.morse@arm.com>,
Oliver Upton <oliver.upton@linux.dev>,
Zenghui Yu <yuzenghui@huawei.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Joey Gouly <joey.gouly@arm.com>,
Alexandru Elisei <alexandru.elisei@arm.com>,
Christoffer Dall <christoffer.dall@arm.com>,
Fuad Tabba <tabba@google.com>,
linux-coco@lists.linux.dev,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>,
Shanker Donthineni <sdonthineni@nvidia.com>,
Alper Gun <alpergun@google.com>,
"Aneesh Kumar K . V" <aneesh.kumar@kernel.org>,
Gavin Shan <gshan@redht.com>
Subject: Re: [PATCH v6 01/11] arm64: rsi: Add RSI definitions
Date: Fri, 11 Oct 2024 15:14:24 +0100 [thread overview]
Message-ID: <77030ef8-e180-46bb-872c-e41c8b25bbc2@arm.com> (raw)
In-Reply-To: <2ed92455-b97f-40ba-b5d6-695e885be62f@redhat.com>
On 08/10/2024 00:08, Gavin Shan wrote:
> On 10/5/24 12:42 AM, Steven Price wrote:
>> From: Suzuki K Poulose <suzuki.poulose@arm.com>
>>
>> The RMM (Realm Management Monitor) provides functionality that can be
>> accessed by a realm guest through SMC (Realm Services Interface) calls.
>>
>> The SMC definitions are based on DEN0137[1] version 1.0-rel0.
>>
>> [1] https://developer.arm.com/documentation/den0137/1-0rel0/
>>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>> Reviewed-by: Gavin Shan <gshan@redht.com>
>> Signed-off-by: Steven Price <steven.price@arm.com>
>> ---
>
> [...]
>
>> +
>> +static inline unsigned long rsi_set_addr_range_state(phys_addr_t start,
>> + phys_addr_t end,
>> + enum ripas state,
>> + unsigned long flags,
>> + phys_addr_t *top)
>> +{
>> + struct arm_smccc_res res;
>> +
>> + arm_smccc_smc(SMC_RSI_IPA_STATE_SET, start, end, state,
>> + flags, 0, 0, 0, &res);
>> +
>> + if (top)
>> + *top = res.a1;
>> +
>> + if (res.a2 != RSI_ACCEPT)
>> + return -EPERM;
>> +
>> + return res.a0;
>> +}
>> +
>
> Similar to rsi_attestation_token_init(), the return value type needs to
> be 'long'
> since '-EPERM' can be returned from the function.
Good spot.
>> +/**
>> + * rsi_attestation_token_init - Initialise the operation to retrieve an
>> + * attestation token.
>> + *
>> + * @challenge: The challenge data to be used in the attestation token
>> + * generation.
>> + * @size: Size of the challenge data in bytes.
>> + *
>> + * Initialises the attestation token generation and returns an upper
>> bound
>> + * on the attestation token size that can be used to allocate an
>> adequate
>> + * buffer. The caller is expected to subsequently call
>> + * rsi_attestation_token_continue() to retrieve the attestation token
>> data on
>> + * the same CPU.
>> + *
>> + * Returns:
>> + * On success, returns the upper limit of the attestation report size.
>> + * Otherwise, -EINVAL
>> + */
>> +static inline long
>> +rsi_attestation_token_init(const u8 *challenge, unsigned long size)
>> +{
>> + struct arm_smccc_1_2_regs regs = { 0 };
>> +
>> + /* The challenge must be at least 32bytes and at most 64bytes */
>> + if (!challenge || size < 32 || size > 64)
>> + return -EINVAL;
>> +
>> + regs.a0 = SMC_RSI_ATTESTATION_TOKEN_INIT;
>> + memcpy(®s.a1, challenge, size);
>> + arm_smccc_1_2_smc(®s, ®s);
>> +
>> + if (regs.a0 == RSI_SUCCESS)
>> + return regs.a1;
>> +
>> + return -EINVAL;
>> +}
>> +
>> +/**
>> + * rsi_attestation_token_continue - Continue the operation to
>> retrieve an
>> + * attestation token.
>> + *
>> + * @granule: {I}PA of the Granule to which the token will be written.
>> + * @offset: Offset within Granule to start of buffer in bytes.
>> + * @size: The size of the buffer.
>> + * @len: The number of bytes written to the buffer.
>> + *
>> + * Retrieves up to a RSI_GRANULE_SIZE worth of token data per call.
>> The caller
>> + * is expected to call rsi_attestation_token_init() before calling this
>> + * function to retrieve the attestation token.
>> + *
>> + * Return:
>> + * * %RSI_SUCCESS - Attestation token retrieved successfully.
>> + * * %RSI_INCOMPLETE - Token generation is not complete.
>> + * * %RSI_ERROR_INPUT - A parameter was not valid.
>> + * * %RSI_ERROR_STATE - Attestation not in progress.
>> + */
>> +static inline int rsi_attestation_token_continue(phys_addr_t granule,
>> + unsigned long offset,
>> + unsigned long size,
>> + unsigned long *len)
>> +{
>> + struct arm_smccc_res res;
>> +
>> + arm_smccc_1_1_invoke(SMC_RSI_ATTESTATION_TOKEN_CONTINUE,
>> + granule, offset, size, 0, &res);
>> +
>> + if (len)
>> + *len = res.a1;
>> + return res.a0;
>> +}
>> +
>
> The return value type of this function needs to be 'unsigned long' even
> it's
> converted to 'int' in arm_cca_attestation_continue(). In this way, the
> wrapper
> functions has consistent return value type, which is 'unsigned long' or
> 'long'.
Ack, seems reasonable.
Thanks,
Steve
next prev parent reply other threads:[~2024-10-11 14:14 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 14:42 [PATCH v6 00/11] arm64: Support for running as a guest in Arm CCA Steven Price
2024-10-04 14:42 ` [PATCH v6 01/11] arm64: rsi: Add RSI definitions Steven Price
2024-10-07 23:08 ` Gavin Shan
2024-10-11 14:14 ` Steven Price [this message]
2024-10-04 14:42 ` [PATCH v6 02/11] arm64: Detect if in a realm and set RIPAS RAM Steven Price
2024-10-04 15:05 ` Steven Price
2024-10-11 13:12 ` Catalin Marinas
2024-10-07 23:31 ` Gavin Shan
2024-10-11 14:14 ` Steven Price
2024-10-04 14:42 ` [PATCH v6 03/11] arm64: realm: Query IPA size from the RMM Steven Price
2024-10-07 23:33 ` Gavin Shan
2024-10-15 3:55 ` Gavin Shan
2024-10-15 9:08 ` Steven Price
2024-10-04 14:42 ` [PATCH v6 04/11] arm64: rsi: Add support for checking whether an MMIO is protected Steven Price
2024-10-08 0:24 ` Gavin Shan
2024-10-11 14:14 ` Steven Price
2024-10-04 14:43 ` [PATCH v6 05/11] arm64: rsi: Map unprotected MMIO as decrypted Steven Price
2024-10-08 0:31 ` Gavin Shan
2024-10-11 13:19 ` Catalin Marinas
2024-10-12 5:22 ` Gavin Shan
2024-10-11 13:20 ` Catalin Marinas
2024-10-04 14:43 ` [PATCH v6 06/11] efi: arm64: Map Device with Prot Shared Steven Price
2024-10-08 0:31 ` Gavin Shan
2024-10-11 13:23 ` Catalin Marinas
2024-10-04 14:43 ` [PATCH v6 07/11] arm64: Enforce bounce buffers for realm DMA Steven Price
2024-10-08 2:51 ` Gavin Shan
2024-10-04 14:43 ` [PATCH v6 08/11] arm64: mm: Avoid TLBI when marking pages as valid Steven Price
2024-10-08 2:52 ` Gavin Shan
2024-10-15 9:50 ` Suzuki K Poulose
2024-10-04 14:43 ` [PATCH v6 09/11] arm64: Enable memory encrypt for Realms Steven Price
2024-10-08 2:56 ` Gavin Shan
2024-10-04 14:43 ` [PATCH v6 10/11] virt: arm-cca-guest: TSM_REPORT support for realms Steven Price
2024-10-05 15:42 ` kernel test robot
2024-10-08 4:12 ` Gavin Shan
2024-10-11 14:14 ` Steven Price
2024-10-11 16:22 ` Suzuki K Poulose
2024-10-12 6:06 ` Gavin Shan
2024-10-14 8:56 ` Suzuki K Poulose
2024-10-14 14:41 ` Steven Price
2024-10-14 14:46 ` Suzuki K Poulose
2024-10-15 0:01 ` Gavin Shan
2024-10-04 14:43 ` [PATCH v6 11/11] arm64: Document Arm Confidential Compute Steven Price
2024-10-08 4:17 ` Gavin Shan
2024-10-08 11:05 ` Jean-Philippe Brucker
2024-10-11 14:14 ` Steven Price
2024-10-15 9:55 ` Suzuki K Poulose
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=77030ef8-e180-46bb-872c-e41c8b25bbc2@arm.com \
--to=steven.price@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=alpergun@google.com \
--cc=aneesh.kumar@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christoffer.dall@arm.com \
--cc=gankulkarni@os.amperecomputing.com \
--cc=gshan@redhat.com \
--cc=gshan@redht.com \
--cc=james.morse@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=sdonthineni@nvidia.com \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/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