All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	James Morse <james.morse@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev
Subject: Re: [PATCH v5 04/12] arm64: Add ARM64_HAS_LPA2 CPU capability
Date: Wed, 22 Nov 2023 15:14:52 +0000	[thread overview]
Message-ID: <86h6ldzuoj.wl-maz@kernel.org> (raw)
In-Reply-To: <20231116142931.1675485-5-ryan.roberts@arm.com>

On Thu, 16 Nov 2023 14:29:23 +0000,
Ryan Roberts <ryan.roberts@arm.com> wrote:
> 
> Expose FEAT_LPA2 as a capability so that we can take advantage of
> alternatives patching in the hypervisor.
> 
> Although FEAT_LPA2 presence is advertised separately for stage1 and
> stage2, the expectation is that in practice both stages will either
> support or not support it. Therefore, we combine both into a single
> capability, allowing us to simplify the implementation. KVM requires
> support in both stages in order to use LPA2 since the same library is
> used for hyp stage 1 and guest stage 2 pgtables.
> 
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  5 ++++
>  arch/arm64/kernel/cpufeature.c      | 39 +++++++++++++++++++++++++++++
>  arch/arm64/tools/cpucaps            |  1 +
>  3 files changed, 45 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index f6d416fe49b0..acf109581ac0 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -819,6 +819,11 @@ static inline bool system_supports_tlb_range(void)
>  	return alternative_has_cap_unlikely(ARM64_HAS_TLB_RANGE);
>  }
>  
> +static inline bool system_supports_lpa2(void)
> +{
> +	return cpus_have_final_cap(ARM64_HAS_LPA2);
> +}
> +
>  int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);
>  bool try_emulate_mrs(struct pt_regs *regs, u32 isn);
>  
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 0e7d0c2bab36..38dfdaff8176 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1768,6 +1768,39 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
>  	return !meltdown_safe;
>  }
>  
> +#if defined(CONFIG_ARM64_4K_PAGES) || defined(CONFIG_ARM64_16K_PAGES)

nit: if you move patch #5 before this one, this can be gated by the
actual definition of ID_AA64MMFR0_EL1_TGRAN_{,2_}LPA2 instead of the
page size indirection. I personally would find it slightly more
readable.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Oliver Upton <oliver.upton@linux.dev>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	James Morse <james.morse@arm.com>,
	Zenghui Yu <yuzenghui@huawei.com>,
	Ard Biesheuvel <ardb@kernel.org>,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev
Subject: Re: [PATCH v5 04/12] arm64: Add ARM64_HAS_LPA2 CPU capability
Date: Wed, 22 Nov 2023 15:14:52 +0000	[thread overview]
Message-ID: <86h6ldzuoj.wl-maz@kernel.org> (raw)
In-Reply-To: <20231116142931.1675485-5-ryan.roberts@arm.com>

On Thu, 16 Nov 2023 14:29:23 +0000,
Ryan Roberts <ryan.roberts@arm.com> wrote:
> 
> Expose FEAT_LPA2 as a capability so that we can take advantage of
> alternatives patching in the hypervisor.
> 
> Although FEAT_LPA2 presence is advertised separately for stage1 and
> stage2, the expectation is that in practice both stages will either
> support or not support it. Therefore, we combine both into a single
> capability, allowing us to simplify the implementation. KVM requires
> support in both stages in order to use LPA2 since the same library is
> used for hyp stage 1 and guest stage 2 pgtables.
> 
> Signed-off-by: Ryan Roberts <ryan.roberts@arm.com>
> ---
>  arch/arm64/include/asm/cpufeature.h |  5 ++++
>  arch/arm64/kernel/cpufeature.c      | 39 +++++++++++++++++++++++++++++
>  arch/arm64/tools/cpucaps            |  1 +
>  3 files changed, 45 insertions(+)
> 
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index f6d416fe49b0..acf109581ac0 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -819,6 +819,11 @@ static inline bool system_supports_tlb_range(void)
>  	return alternative_has_cap_unlikely(ARM64_HAS_TLB_RANGE);
>  }
>  
> +static inline bool system_supports_lpa2(void)
> +{
> +	return cpus_have_final_cap(ARM64_HAS_LPA2);
> +}
> +
>  int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);
>  bool try_emulate_mrs(struct pt_regs *regs, u32 isn);
>  
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 0e7d0c2bab36..38dfdaff8176 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1768,6 +1768,39 @@ static bool unmap_kernel_at_el0(const struct arm64_cpu_capabilities *entry,
>  	return !meltdown_safe;
>  }
>  
> +#if defined(CONFIG_ARM64_4K_PAGES) || defined(CONFIG_ARM64_16K_PAGES)

nit: if you move patch #5 before this one, this can be gated by the
actual definition of ID_AA64MMFR0_EL1_TGRAN_{,2_}LPA2 instead of the
page size indirection. I personally would find it slightly more
readable.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-11-22 15:14 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16 14:29 [PATCH v5 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2 Ryan Roberts
2023-11-16 14:29 ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 01/12] arm64/mm: Modify range-based tlbi to decrement scale Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 02/12] arm64/mm: Add lpa2_is_enabled() kvm_lpa2_is_enabled() stubs Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 03/12] arm64/mm: Update tlb invalidation routines for FEAT_LPA2 Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 04/12] arm64: Add ARM64_HAS_LPA2 CPU capability Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-22 15:14   ` Marc Zyngier [this message]
2023-11-22 15:14     ` Marc Zyngier
2023-11-16 14:29 ` [PATCH v5 05/12] arm64/mm: Add FEAT_LPA2 specific ID_AA64MMFR0.TGRAN[2] Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 06/12] KVM: arm64: Add new (V)TCR_EL2 field definitions for FEAT_LPA2 Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 07/12] KVM: arm64: Use LPA2 page-tables for stage2 and hyp stage1 Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-21 20:34   ` Oliver Upton
2023-11-21 20:34     ` Oliver Upton
2023-11-22 13:41     ` Ryan Roberts
2023-11-22 13:41       ` Ryan Roberts
2023-11-22 15:21       ` Marc Zyngier
2023-11-22 15:21         ` Marc Zyngier
2023-11-24 11:49         ` Ryan Roberts
2023-11-24 11:49           ` Ryan Roberts
2023-11-27  9:32           ` Marc Zyngier
2023-11-27  9:32             ` Marc Zyngier
2023-11-27  9:43             ` Ryan Roberts
2023-11-27  9:43               ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 08/12] KVM: arm64: Convert translation level parameter to s8 Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 09/12] KVM: arm64: Support up to 5 levels of translation in kvm_pgtable Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 10/12] KVM: arm64: Allow guests with >48-bit IPA size on FEAT_LPA2 systems Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 11/12] KVM: selftests: arm64: Determine max ipa size per-page size Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-21 23:27   ` Oliver Upton
2023-11-21 23:27     ` Oliver Upton
2023-11-22 13:47     ` Ryan Roberts
2023-11-22 13:47       ` Ryan Roberts
2023-11-21 23:34   ` Oliver Upton
2023-11-21 23:34     ` Oliver Upton
2023-11-22 13:47     ` Ryan Roberts
2023-11-22 13:47       ` Ryan Roberts
2023-11-16 14:29 ` [PATCH v5 12/12] KVM: selftests: arm64: Support P52V48 4K and 16K guest_modes Ryan Roberts
2023-11-16 14:29   ` Ryan Roberts
2023-11-21 23:38 ` [PATCH v5 00/12] KVM: arm64: Support FEAT_LPA2 at hyp s1 and vm s2 Oliver Upton
2023-11-21 23:38   ` Oliver Upton
2023-11-22 13:37   ` Ryan Roberts
2023-11-22 13:37     ` Ryan Roberts

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=86h6ldzuoj.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=oliver.upton@linux.dev \
    --cc=ryan.roberts@arm.com \
    --cc=suzuki.poulose@arm.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 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.