All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
	linux-coco@lists.linux.dev, kvmarm@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, iommu@lists.linux.dev
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Jason Gunthorpe <jgg@ziepe.ca>, Marc Zyngier <maz@kernel.org>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Steven Price <steven.price@arm.com>,
	Thomas Gleixner <tglx@kernel.org>, Will Deacon <will@kernel.org>
Subject: Re: [PATCH v6 8/9] arm64: realm: Add RHI helper to query IPA state change alignment
Date: Fri, 18 Sep 2026 16:09:42 +0530	[thread overview]
Message-ID: <yq5awlsizvv5.fsf@kernel.org> (raw)
In-Reply-To: <73c921bb-9897-481d-bcb2-ef9b578a7c9f@arm.com>

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

> On 04/09/2026 11:34, Aneesh Kumar K.V (Arm) wrote:
>> Arm CCA guests need to know the granularity at which the host expects IPA
>> state changes to be performed. This can be larger than the guest page size
>> and is needed when deciding the alignment for memory shared with the host.
>> 
>> Add the Realm Host Interface host configuration definitions and an
>> get_ipa_state_change_alignment() helper. The helper uses RSI_HOST_CALL to
>> query the supported HostConf version and features, reads the IPA change
>> alignment when available, and falls back to PAGE_SIZE if the interface is
>> unavailable or returns an invalid value.
>> 
>> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
>
> It may be worth mentioning the document number and may be the link
> for RHI spec.
>
> e.g., The Realm Host Interface specification Arm DEN00148 defines ...
>
>
>
>> ---
>>   drivers/firmware/arm_rmm/rsi.c | 46 ++++++++++++++++++++++++++++++++++
>>   include/linux/arm-rsi-cmds.h   | 10 ++++++++
>>   include/linux/arm-smccc-rhi.h  | 25 ++++++++++++++++++
>>   include/linux/arm-smccc-rsi.h  |  7 ++++++
>>   4 files changed, 88 insertions(+)
>>   create mode 100644 include/linux/arm-smccc-rhi.h
>> 
>> diff --git a/drivers/firmware/arm_rmm/rsi.c b/drivers/firmware/arm_rmm/rsi.c
>> index 52f40256bd78..2cd53f82432f 100644
>> --- a/drivers/firmware/arm_rmm/rsi.c
>> +++ b/drivers/firmware/arm_rmm/rsi.c
>> @@ -9,6 +9,7 @@
>>   #include <linux/swiotlb.h>
>>   #include <linux/platform_device.h>
>>   #include <linux/arm-rsi-cmds.h>
>> +#include <linux/arm-smccc-rhi.h>
>>   #include <linux/kobject.h>
>>   #include <linux/sysfs.h>
>>   
>> @@ -164,6 +165,51 @@ static int realm_register_memory_enc_ops(void)
>>   	return arm64_mem_crypt_ops_register(&realm_crypt_ops);
>>   }
>>   
>> +/* we need an aligned struct for rsi_host_call. slab is not yet ready */
>> +static struct rsi_host_call hostconf_call __initdata;
>> +static unsigned long __maybe_unused __init get_ipa_state_change_alignment(void)
>> +{
>> +	long ret;
>> +	unsigned long shared_granule_size;
>> +
>> +	hostconf_call.imm = 0;
>> +	hostconf_call.gprs[0] = RHI_HOSTCONF_VERSION;
>
> Do we need to 0 out the other GPRs for RES0 arguments ?
>
>> +	ret = rsi_host_call(lm_alias(&hostconf_call));
>> +	if (ret != RSI_SUCCESS)
>> +		goto err_out;
>> +
>> +	if (hostconf_call.gprs[0] != RHI_HOSTCONF_VER_1_0)
>> +		goto err_out;
>> +
>> +	hostconf_call.imm = 0;
>> +	hostconf_call.gprs[0] = RHI_HOSTCONF_FEATURES;
>
> Same here, especially gprs[] could be overwritten by the results from
> the Host for the previous call.
>

 [ ... 75 lines skipped ... ] 

>> +
>> +#define RHI_HOSTCONF_VER_1_0		0x10000
>> +#define RHI_HOSTCONF_VERSION		SMC_RHI_CALL(0x004E)
>> +
>> +#define __RHI_HOSTCONF_GET_IPA_CHANGE_ALIGNMENT BIT(0)
>
> minor nit: Could this be:
>
> RHI_HOSTCONF_FEATURE_GET_IPA_CHANGE_ALIGNMENT	BIT(0)
>
> to indicate this applies to the RHI_HOSTCONF_FEATURES output ?
>


Will make this change.

-	hostconf_call.imm = 0;
+	memset(&hostconf_call, 0, sizeof(hostconf_call));
 	hostconf_call.gprs[0] = RHI_HOSTCONF_FEATURES;
 	ret = rsi_host_call(lm_alias(&hostconf_call));
 	if (ret != RSI_SUCCESS)
 		goto err_out;
 
-	if (!(hostconf_call.gprs[0] & __RHI_HOSTCONF_GET_IPA_CHANGE_ALIGNMENT))
+	if (!(hostconf_call.gprs[0] & RHI_HOSTCONF_FEATURE_GET_IPA_CHANGE_ALIGNMENT))
 		goto err_out;

-aneesh

  reply	other threads:[~2026-09-18 10:39 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04 10:34 [PATCH v6 0/9] coco: guest: Enforce host page-size alignment for shared buffers Aneesh Kumar K.V (Arm)
2026-09-04 10:34 ` [PATCH v6 1/9] mm/mem_encrypt: Add helpers for shared-buffer alignment Aneesh Kumar K.V (Arm)
2026-09-04 10:34 ` [PATCH v6 2/9] irqchip/gic-v3-its: Align shared ITS allocations to the CoCo shared granule size Aneesh Kumar K.V (Arm)
2026-09-04 10:34 ` [PATCH v6 3/9] dma-mapping: Pass allocation attrs to contiguous allocation helpers Aneesh Kumar K.V (Arm)
2026-09-04 10:34 ` [PATCH v6 4/9] dma-direct: Align CoCo shared DMA allocations to the shared granule size Aneesh Kumar K.V (Arm)
2026-09-18 14:16   ` Catalin Marinas
2026-09-04 10:34 ` [PATCH v6 5/9] swiotlb: Align shared IO TLB pools " Aneesh Kumar K.V (Arm)
2026-09-04 10:34 ` [PATCH v6 6/9] swiotlb: Reject misaligned restricted DMA pools for CoCo guests Aneesh Kumar K.V (Arm)
2026-09-04 10:34 ` [PATCH v6 7/9] dma-buf: system_heap: Enforce shared-granule alignment for cc-shared buffers Aneesh Kumar K.V (Arm)
2026-09-18 15:16   ` Catalin Marinas
2026-09-18 15:23     ` Christian König
2026-09-18 15:36       ` Jason Gunthorpe
2026-09-18 15:39         ` Christian König
2026-09-18 16:53           ` Jason Gunthorpe
2026-09-21  9:07             ` Christian König
2026-09-21 11:51               ` Jason Gunthorpe
2026-09-21 12:05                 ` Christian König
2026-09-21 12:17                   ` Jason Gunthorpe
2026-09-21 12:24                     ` Christian König
2026-09-21 12:37                       ` Jason Gunthorpe
2026-09-21 15:26                         ` Aneesh Kumar K.V
2026-09-22 15:38                           ` Catalin Marinas
2026-09-23  5:05                             ` Aneesh Kumar K.V
2026-09-19 14:57         ` Aneesh Kumar K.V
2026-09-19 21:35           ` Jason Gunthorpe
2026-09-20  7:24             ` Aneesh Kumar K.V
2026-09-21  6:57     ` Aneesh Kumar K.V
2026-09-04 10:34 ` [PATCH v6 8/9] arm64: realm: Add RHI helper to query IPA state change alignment Aneesh Kumar K.V (Arm)
2026-09-16 16:12   ` Suzuki K Poulose
2026-09-18 10:39     ` Aneesh Kumar K.V [this message]
2026-09-04 10:34 ` [PATCH v6 9/9] arm64: realm: Expose the CCA shared granule size through mem_encrypt ops Aneesh Kumar K.V (Arm)
2026-09-16 16:17   ` Suzuki K Poulose
2026-09-18 16:52 ` [PATCH v6 0/9] coco: guest: Enforce host page-size alignment for shared buffers Catalin Marinas
2026-09-18 16:57   ` Jason Gunthorpe
2026-09-18 17:10     ` Catalin Marinas
2026-09-23  5:01     ` Aneesh Kumar K.V
2026-09-23 15:58       ` Jason Gunthorpe

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=yq5awlsizvv5.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --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=m.szyprowski@samsung.com \
    --cc=maz@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tglx@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.