linux-coco.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Will Deacon <will@kernel.org>, Steven Price <steven.price@arm.com>
Cc: kvm@vger.kernel.org, kvmarm@lists.linux.dev,
	Catalin Marinas <catalin.marinas@arm.com>,
	Marc Zyngier <maz@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>
Subject: Re: [PATCH v4 05/15] arm64: Mark all I/O as non-secure shared
Date: Tue, 9 Jul 2024 13:54:14 +0100	[thread overview]
Message-ID: <f8dca28c-e5d6-4a1b-8bd3-6a711dae7078@arm.com> (raw)
In-Reply-To: <20240709113925.GA13242@willie-the-truck>

Hi Will

On 09/07/2024 12:39, Will Deacon wrote:
> On Mon, Jul 01, 2024 at 10:54:55AM +0100, Steven Price wrote:
>> All I/O is by default considered non-secure for realms. As such
>> mark them as shared with the host.
>>
>> Co-developed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Signed-off-by: Steven Price <steven.price@arm.com>
>> ---
>> Changes since v3:
>>   * Add PROT_NS_SHARED to FIXMAP_PAGE_IO rather than overriding
>>     set_fixmap_io() with a custom function.
>>   * Modify ioreamp_cache() to specify PROT_NS_SHARED too.
>> ---
>>   arch/arm64/include/asm/fixmap.h | 2 +-
>>   arch/arm64/include/asm/io.h     | 8 ++++----
>>   2 files changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h
>> index 87e307804b99..f2c5e653562e 100644
>> --- a/arch/arm64/include/asm/fixmap.h
>> +++ b/arch/arm64/include/asm/fixmap.h
>> @@ -98,7 +98,7 @@ enum fixed_addresses {
>>   #define FIXADDR_TOT_SIZE	(__end_of_fixed_addresses << PAGE_SHIFT)
>>   #define FIXADDR_TOT_START	(FIXADDR_TOP - FIXADDR_TOT_SIZE)
>>   
>> -#define FIXMAP_PAGE_IO     __pgprot(PROT_DEVICE_nGnRE)
>> +#define FIXMAP_PAGE_IO     __pgprot(PROT_DEVICE_nGnRE | PROT_NS_SHARED)
>>   
>>   void __init early_fixmap_init(void);
>>   
>> diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
>> index 4ff0ae3f6d66..07fc1801c6ad 100644
>> --- a/arch/arm64/include/asm/io.h
>> +++ b/arch/arm64/include/asm/io.h
>> @@ -277,12 +277,12 @@ static inline void __const_iowrite64_copy(void __iomem *to, const void *from,
>>   
>>   #define ioremap_prot ioremap_prot
>>   
>> -#define _PAGE_IOREMAP PROT_DEVICE_nGnRE
>> +#define _PAGE_IOREMAP (PROT_DEVICE_nGnRE | PROT_NS_SHARED)
>>   
>>   #define ioremap_wc(addr, size)	\
>> -	ioremap_prot((addr), (size), PROT_NORMAL_NC)
>> +	ioremap_prot((addr), (size), (PROT_NORMAL_NC | PROT_NS_SHARED))
>>   #define ioremap_np(addr, size)	\
>> -	ioremap_prot((addr), (size), PROT_DEVICE_nGnRnE)
>> +	ioremap_prot((addr), (size), (PROT_DEVICE_nGnRnE | PROT_NS_SHARED))
> 
> Hmm. I do wonder whether you've pushed the PROT_NS_SHARED too far here.
> 
> There's nothing _architecturally_ special about the top address bit.
> Even if the RSI divides the IPA space in half, the CPU doesn't give two
> hoots about it in the hardware. In which case, it feels wrong to bake
> PROT_NS_SHARED into ioremap_prot -- it feels much better to me if the
> ioremap() code OR'd that into the physical address when passing it down

Actually we would like to push the decision of applying the 
"pgprot_decrypted" vs pgprot_encrypted into ioremap_prot(), rather
than sprinkling every user of ioremap_prot().

This could be made depending on the address that is passed on to the
ioremap_prot(). I guess we would need explicit requests from the callers
to add "encrypted vs decrypted". Is that what you guys are looking at ?

> 
> There's a selfish side of that argument, in that we need to hook
> ioremap() for pKVM protected guests, but I do genuinely feel that
> treating address bits as protection bits is arbitrary and doesn't belong
> in these low-level definitions. In a similar vein, AMD has its
> sme_{set,clr}() macros that operate on the PA (e.g. via dma_to_phys()),
> which feels like a more accurate abstraction to me.

I believe that doesn't solve all the problems. They do have a hook in
__ioremap_caller() that implicitly applies pgprot_{en,de}crypted
depending on other info.

Cheers
Suzuki

> 
> Will


  reply	other threads:[~2024-07-09 12:54 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-01  9:54 [PATCH v4 00/15] arm64: Support for running as a guest in Arm CCA Steven Price
2024-07-01  9:54 ` [PATCH v4 01/15] arm64: rsi: Add RSI definitions Steven Price
2024-07-09  5:19   ` Gavin Shan
2024-07-10 15:34     ` Steven Price
2024-07-23  5:35       ` Gavin Shan
2024-07-23  6:22   ` Gavin Shan
2024-08-16 15:56     ` Steven Price
2024-07-01  9:54 ` [PATCH v4 02/15] firmware/psci: Add psci_early_test_conduit() Steven Price
2024-07-09 10:48   ` Will Deacon
2024-07-10 15:34     ` Steven Price
2024-07-01  9:54 ` [PATCH v4 03/15] arm64: Detect if in a realm and set RIPAS RAM Steven Price
2024-07-29 23:37   ` Gavin Shan
2024-07-30 13:51     ` Suzuki K Poulose
2024-07-31  7:03       ` Gavin Shan
2024-07-31  9:05         ` Suzuki K Poulose
2024-07-01  9:54 ` [PATCH v4 04/15] arm64: realm: Query IPA size from the RMM Steven Price
2024-07-09 10:53   ` Will Deacon
2024-07-10 15:34     ` Steven Price
2024-07-01  9:54 ` [PATCH v4 05/15] arm64: Mark all I/O as non-secure shared Steven Price
2024-07-09 11:39   ` Will Deacon
2024-07-09 12:54     ` Suzuki K Poulose [this message]
2024-07-10 15:34       ` Steven Price
2024-07-30  1:36   ` Gavin Shan
2024-07-30 10:36     ` Suzuki K Poulose
2024-07-31  6:36       ` Gavin Shan
2024-07-31  9:03         ` Suzuki K Poulose
2024-07-01  9:54 ` [PATCH v4 06/15] arm64: Make the PHYS_MASK_SHIFT dynamic Steven Price
2024-07-09 11:43   ` Will Deacon
2024-07-09 12:55     ` Suzuki K Poulose
2024-07-10 15:34       ` Steven Price
2024-07-01  9:54 ` [PATCH v4 07/15] arm64: Enforce bounce buffers for realm DMA Steven Price
2024-07-09 11:56   ` Will Deacon
2024-07-10 15:43     ` Steven Price
2024-07-01  9:54 ` [PATCH v4 08/15] arm64: mm: Avoid TLBI when marking pages as valid Steven Price
2024-07-09 11:57   ` Will Deacon
2024-07-10 16:04     ` Steven Price
2024-07-01  9:54 ` [PATCH v4 09/15] arm64: Enable memory encrypt for Realms Steven Price
2024-07-01  9:55 ` [PATCH v4 10/15] arm64: Force device mappings to be non-secure shared Steven Price
2024-07-01  9:55 ` [PATCH v4 11/15] efi: arm64: Map Device with Prot Shared Steven Price
2024-07-01  9:55 ` [PATCH v4 12/15] irqchip/gic-v3-its: Share ITS tables with a non-trusted hypervisor Steven Price
2024-07-10 13:17   ` Will Deacon
2024-07-01  9:55 ` [PATCH v4 13/15] irqchip/gic-v3-its: Rely on genpool alignment Steven Price
2024-07-10 13:17   ` Will Deacon
2024-07-01  9:55 ` [PATCH v4 14/15] arm64: rsi: Interfaces to query attestation token Steven Price
2024-07-01  9:55 ` [PATCH v4 15/15] virt: arm-cca-guest: TSM_REPORT support for realms Steven Price
2024-07-09 12:04 ` [PATCH v4 00/15] arm64: Support for running as a guest in Arm CCA Will Deacon
2024-07-12  8:54 ` Matias Ezequiel Vara Larsen
2024-08-15 22:16   ` Shanker Donthineni
2024-08-16 16:06     ` Steven Price
2024-08-16 21:13       ` Shanker Donthineni

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=f8dca28c-e5d6-4a1b-8bd3-6a711dae7078@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=gankulkarni@os.amperecomputing.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=steven.price@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;
as well as URLs for NNTP newsgroup(s).