linux-arm-kernel.lists.infradead.org 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 06/15] arm64: Make the PHYS_MASK_SHIFT dynamic
Date: Tue, 9 Jul 2024 13:55:38 +0100	[thread overview]
Message-ID: <1ce456b5-0652-4522-98ea-b32d96c1adf4@arm.com> (raw)
In-Reply-To: <20240709114337.GB13242@willie-the-truck>

On 09/07/2024 12:43, Will Deacon wrote:
> On Mon, Jul 01, 2024 at 10:54:56AM +0100, Steven Price wrote:
>> Make the PHYS_MASK_SHIFT dynamic for Realms. This is only is required
>> for masking the PFN from a pte entry. For a realm phys_mask_shift is
>> reduced if the RMM reports a smaller configured size for the guest.
>>
>> The realm configuration splits the address space into two with the top
>> half being memory shared with the host, and the bottom half being
>> protected memory. We treat the bit which controls this split as an
>> attribute bit and hence exclude it (and any higher bits) from the mask.
>>
>> 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>
>>
>> ---
>> v3: Drop the MAX_PHYS_MASK{,_SHIFT} definitions as they are no longer
>> needed.
>> ---
>>   arch/arm64/include/asm/pgtable-hwdef.h | 6 ------
>>   arch/arm64/include/asm/pgtable.h       | 5 +++++
>>   arch/arm64/kernel/rsi.c                | 5 +++++
>>   3 files changed, 10 insertions(+), 6 deletions(-)
>>
>> diff --git a/arch/arm64/include/asm/pgtable-hwdef.h b/arch/arm64/include/asm/pgtable-hwdef.h
>> index 9943ff0af4c9..2e3af0693bd8 100644
>> --- a/arch/arm64/include/asm/pgtable-hwdef.h
>> +++ b/arch/arm64/include/asm/pgtable-hwdef.h
>> @@ -203,12 +203,6 @@
>>    */
>>   #define PTE_S2_MEMATTR(t)	(_AT(pteval_t, (t)) << 2)
>>   
>> -/*
>> - * Highest possible physical address supported.
>> - */
>> -#define PHYS_MASK_SHIFT		(CONFIG_ARM64_PA_BITS)
>> -#define PHYS_MASK		((UL(1) << PHYS_MASK_SHIFT) - 1)
>> -
>>   #define TTBR_CNP_BIT		(UL(1) << 0)
>>   
>>   /*
>> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
>> index f8efbc128446..11d614d83317 100644
>> --- a/arch/arm64/include/asm/pgtable.h
>> +++ b/arch/arm64/include/asm/pgtable.h
>> @@ -39,6 +39,11 @@
>>   #include <linux/sched.h>
>>   #include <linux/page_table_check.h>
>>   
>> +extern unsigned int phys_mask_shift;
>> +
>> +#define PHYS_MASK_SHIFT		(phys_mask_shift)
>> +#define PHYS_MASK		((1UL << PHYS_MASK_SHIFT) - 1)
> 
> I tried to figure out where this is actually used so I could understand
> your comment in the commit message:
> 
>   > This is only is required for masking the PFN from a pte entry
> 
> The closest thing I could find is in arch/arm64/mm/mmap.c, where the
> mask is used as part of valid_mmap_phys_addr_range() which exists purely
> to filter accesses to /dev/mem. That's pretty niche, so why not just
> inline the RSI-specific stuff in there behind a static key instead of
> changing these definitions?
> 
> Or did I miss a subtle user somewhere else?

We need to prevent ioremap() of addresses beyond that limit too.

Suzuki

> 
> Will



  reply	other threads:[~2024-07-09 12:56 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
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 [this message]
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=1ce456b5-0652-4522-98ea-b32d96c1adf4@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).