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, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Cc: 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>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Will Deacon <will@kernel.org>,
	Steven Price <steven.price@arm.com>,
	Andre Przywara <andre.przywara@arm.com>
Subject: Re: [PATCH v9 4/7] arm64: realm: Move Realm memory encryption ops to RSI code
Date: Mon, 10 Aug 2026 17:45:24 +0530	[thread overview]
Message-ID: <yq5apkzqi337.fsf@kernel.org> (raw)
In-Reply-To: <baa99d81-7979-4654-a030-a550ba57bb58@arm.com>

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

> On 05/08/2026 07:32, Aneesh Kumar K.V (Arm) wrote:
>> Realm memory encryption callbacks are CCA-specific. Keep the Realm callback
>> registration with the RSI initialization code instead of pageattr.c, which
>> only needs to provide the low-level page-attribute transition helper.
>> 
>> Export __set_memory_enc_dec() within arm64 so the RSI code can wrap it with
>> the Realm-specific encrypt/decrypt callbacks and warning policy.
>> 
>> No functional changes in this patch.
>> 
>> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
>> ---
>>   arch/arm64/include/asm/mem_encrypt.h |  3 +--
>>   arch/arm64/mm/pageattr.c             | 38 +---------------------------
>>   drivers/firmware/arm_rmm/rsi.c       | 34 +++++++++++++++++++++++++
>>   3 files changed, 36 insertions(+), 39 deletions(-)
>> 
>> diff --git a/arch/arm64/include/asm/mem_encrypt.h b/arch/arm64/include/asm/mem_encrypt.h
>> index f03b9d7b83b4..ef8b8463e52b 100644
>> --- a/arch/arm64/include/asm/mem_encrypt.h
>> +++ b/arch/arm64/include/asm/mem_encrypt.h
>> @@ -16,8 +16,7 @@ int arm64_mem_crypt_ops_register(const struct arm64_mem_crypt_ops *ops);
>>   
>>   int set_memory_encrypted(unsigned long addr, int numpages);
>>   int set_memory_decrypted(unsigned long addr, int numpages);
>> -
>> -int realm_register_memory_enc_ops(void);
>> +int __set_memory_enc_dec(unsigned long addr, int numpages, bool encrypt);
>>   
>>   static inline bool force_dma_unencrypted(struct device *dev)
>>   {
>> diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c
>> index bbe98ac9ad8c..14b2a3801f40 100644
>> --- a/arch/arm64/mm/pageattr.c
>> +++ b/arch/arm64/mm/pageattr.c
>> @@ -275,9 +275,7 @@ int set_direct_map_default_noflush(struct page *page)
>>   				 PAGE_SIZE, set_mask, clear_mask);
>>   }
>>   
>> -static int __set_memory_enc_dec(unsigned long addr,
>> -				int numpages,
>> -				bool encrypt)
>> +int __set_memory_enc_dec(unsigned long addr, int numpages, bool encrypt)
>>   {
>>   	unsigned long set_prot = 0, clear_prot = 0;
>>   	phys_addr_t start, end;
>> @@ -321,40 +319,6 @@ static int __set_memory_enc_dec(unsigned long addr,
>>   				      __pgprot(PTE_PRESENT_INVALID));
>>   }
>
> This calls "rsi_set_memory_range_protected/shared(). Should we add call 
> backs for those too in the arm64_mem_crypt_ops and take those away too ?
>
> something like :
>
> 	pre_enc_dec_phys_range(start, end, bool encrypt) ?
>
> and implement that in firmware/arm_rmm/rsi.c ?
>

__set_memory_enc_dec() is a helper that is only used for realms. We do
have a check:

if (!is_realm_world())
	return 0;

(We should probably change the return value to -EINVAL.)

The only reason it is in arch/arm64/mm/pageattr.c is that it calls
__change_memory_common(). That function is more of an internal helper
for the page table update routines. I wasn't sure whether we want to
expose this API which can also be used for updating linear map
attributes.

Currently, we restrict such updates to vmap mappings, with the only
exception being the Realm use case through __set_memory_enc_dec().

-aneesh


  reply	other threads:[~2026-08-10 12:15 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  6:32 [PATCH v9 0/7] Switch Arm SMCCC firmware services to an SMCCC bus Aneesh Kumar K.V (Arm)
2026-08-05  6:32 ` [PATCH v9 1/7] firmware: smccc: Add an Arm " Aneesh Kumar K.V (Arm)
2026-08-05  6:32 ` [PATCH v9 2/7] firmware: hwrng: arm_smccc_trng: Register as an SMCCC device Aneesh Kumar K.V (Arm)
2026-08-05 11:08   ` Catalin Marinas
2026-08-05  6:32 ` [PATCH v9 3/7] firmware: arm_rmm: Move RSI support out of arch/arm64 Aneesh Kumar K.V (Arm)
2026-08-05 11:21   ` Catalin Marinas
2026-08-05 13:05     ` Aneesh Kumar K.V
2026-08-10 10:03   ` Suzuki K Poulose
2026-08-05  6:32 ` [PATCH v9 4/7] arm64: realm: Move Realm memory encryption ops to RSI code Aneesh Kumar K.V (Arm)
2026-08-10 10:12   ` Suzuki K Poulose
2026-08-10 12:15     ` Aneesh Kumar K.V [this message]
2026-08-05  6:32 ` [PATCH v9 5/7] virt: coco: arm-cca-guest: Rename TSM report source file Aneesh Kumar K.V (Arm)
2026-08-05  6:32 ` [PATCH v9 6/7] firmware: smccc: arm-cca-guest: Bind the TSM provider to an SMCCC device Aneesh Kumar K.V (Arm)
2026-08-05  6:32 ` [PATCH v9 7/7] coco: guest: arm64: Replace dummy CCA device with sysfs ABI Aneesh Kumar K.V (Arm)
2026-08-05  9:51 ` [PATCH v9 0/7] Switch Arm SMCCC firmware services to an SMCCC bus Catalin Marinas
2026-08-05 12:22   ` Aneesh Kumar K.V
2026-08-10  9:35     ` Aneesh Kumar K.V
2026-08-10 10:24       ` Will Deacon

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=yq5apkzqi337.fsf@kernel.org \
    --to=aneesh.kumar@kernel.org \
    --cc=andre.przywara@arm.com \
    --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@arm.com \
    --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 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.