From: Shaoqin Huang <shahuang@redhat.com>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 04/17] arm64: Add KVM_HVHE capability and has_hvhe() predicate
Date: Wed, 14 Jun 2023 15:32:32 +0800 [thread overview]
Message-ID: <ea8400f0-56c3-009c-d1ff-34f23a247ee9@redhat.com> (raw)
In-Reply-To: <20230609162200.2024064-5-maz@kernel.org>
Hi Marc,
Should we have a document about the hVHE? Because it's a sw feature,
there is no spec about it. And later people may need to read the code
itself to understand what is hVHE.
On 6/10/23 00:21, Marc Zyngier wrote:
> Expose a capability keying the hVHE feature as well as a new
> predicate testing it. Nothing is so far using it, and nothing
> is enabling it yet.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
Besides that, the code itself LGTM.
Reviewed-by: Shaoqin Huang <shahuang@redhat.com>
> ---
> arch/arm64/include/asm/cpufeature.h | 1 +
> arch/arm64/include/asm/virt.h | 8 ++++++++
> arch/arm64/kernel/cpufeature.c | 19 +++++++++++++++++++
> arch/arm64/tools/cpucaps | 1 +
> 4 files changed, 29 insertions(+)
>
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index bc1009890180..3d4b547ae312 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -16,6 +16,7 @@
> #define cpu_feature(x) KERNEL_HWCAP_ ## x
>
> #define ARM64_SW_FEATURE_OVERRIDE_NOKASLR 0
> +#define ARM64_SW_FEATURE_OVERRIDE_HVHE 4
>
> #ifndef __ASSEMBLY__
>
> diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h
> index 21e94068804d..5227db7640c8 100644
> --- a/arch/arm64/include/asm/virt.h
> +++ b/arch/arm64/include/asm/virt.h
> @@ -142,6 +142,14 @@ static __always_inline bool is_protected_kvm_enabled(void)
> return cpus_have_final_cap(ARM64_KVM_PROTECTED_MODE);
> }
>
> +static __always_inline bool has_hvhe(void)
> +{
> + if (is_vhe_hyp_code())
> + return false;
> +
> + return cpus_have_final_cap(ARM64_KVM_HVHE);
> +}
> +
> static inline bool is_hyp_nvhe(void)
> {
> return is_hyp_mode_available() && !is_kernel_in_hyp_mode();
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 2d2b7bb5fa0c..c743b1a5ae31 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1998,6 +1998,19 @@ static bool has_nested_virt_support(const struct arm64_cpu_capabilities *cap,
> return true;
> }
>
> +static bool hvhe_possible(const struct arm64_cpu_capabilities *entry,
> + int __unused)
> +{
> + u64 val;
> +
> + val = read_sysreg(id_aa64mmfr1_el1);
> + if (!cpuid_feature_extract_unsigned_field(val, ID_AA64MMFR1_EL1_VH_SHIFT))
> + return false;
> +
> + val = arm64_sw_feature_override.val & arm64_sw_feature_override.mask;
> + return cpuid_feature_extract_unsigned_field(val, ARM64_SW_FEATURE_OVERRIDE_HVHE);
> +}
> +
> #ifdef CONFIG_ARM64_PAN
> static void cpu_enable_pan(const struct arm64_cpu_capabilities *__unused)
> {
> @@ -2643,6 +2656,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
> .cpu_enable = cpu_enable_dit,
> ARM64_CPUID_FIELDS(ID_AA64PFR0_EL1, DIT, IMP)
> },
> + {
> + .desc = "VHE for hypervisor only",
> + .capability = ARM64_KVM_HVHE,
> + .type = ARM64_CPUCAP_SYSTEM_FEATURE,
> + .matches = hvhe_possible,
> + },
> {},
> };
>
> diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps
> index 40ba95472594..3c23a55d7c2f 100644
> --- a/arch/arm64/tools/cpucaps
> +++ b/arch/arm64/tools/cpucaps
> @@ -47,6 +47,7 @@ HAS_TLB_RANGE
> HAS_VIRT_HOST_EXTN
> HAS_WFXT
> HW_DBM
> +KVM_HVHE
> KVM_PROTECTED_MODE
> MISMATCHED_CACHE_TYPE
> MTE
--
Shaoqin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-06-14 7:33 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 16:21 [PATCH v3 00/17] KVM: arm64: Allow using VHE in the nVHE hypervisor Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 01/17] KVM: arm64: Drop is_kernel_in_hyp_mode() from __invalidate_icache_guest_page() Marc Zyngier
2023-06-13 8:20 ` Shaoqin Huang
2023-06-09 16:21 ` [PATCH v3 02/17] arm64: Prevent the use of is_kernel_in_hyp_mode() in hypervisor code Marc Zyngier
2023-06-12 16:59 ` Catalin Marinas
2023-06-13 8:25 ` Shaoqin Huang
2023-06-09 16:21 ` [PATCH v3 03/17] arm64: Turn kaslr_feature_override into a generic SW feature override Marc Zyngier
2023-06-12 17:16 ` Catalin Marinas
2023-06-14 7:26 ` Shaoqin Huang
2023-06-09 16:21 ` [PATCH v3 04/17] arm64: Add KVM_HVHE capability and has_hvhe() predicate Marc Zyngier
2023-06-12 17:24 ` Catalin Marinas
2023-06-14 7:32 ` Shaoqin Huang [this message]
2023-06-14 7:35 ` Shaoqin Huang
2023-06-14 16:06 ` Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 05/17] arm64: Don't enable VHE for the kernel if OVERRIDE_HVHE is set Marc Zyngier
2023-06-12 19:12 ` Catalin Marinas
2023-06-12 19:20 ` Oliver Upton
2023-06-09 16:21 ` [PATCH v3 06/17] arm64: Allow EL1 physical timer access when running VHE Marc Zyngier
2023-06-12 19:14 ` Catalin Marinas
2023-06-09 16:21 ` [PATCH v3 07/17] arm64: Use CPACR_EL1 format to set CPTR_EL2 when E2H is set Marc Zyngier
2023-06-12 19:15 ` Catalin Marinas
2023-06-09 16:21 ` [PATCH v3 08/17] KVM: arm64: Remove alternatives from sysreg accessors in VHE hypervisor context Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 09/17] KVM: arm64: Key use of VHE instructions in nVHE code off ARM64_KVM_HVHE Marc Zyngier
2023-06-13 9:57 ` Shaoqin Huang
2023-06-09 16:21 ` [PATCH v3 10/17] KVM: arm64: Force HCR_EL2.E2H when ARM64_KVM_HVHE is set Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 11/17] KVM: arm64: Disable TTBR1_EL2 when using ARM64_KVM_HVHE Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 12/17] KVM: arm64: Adjust EL2 stage-1 leaf AP bits when ARM64_KVM_HVHE is set Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 13/17] KVM: arm64: Rework CPTR_EL2 programming for HVHE configuration Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 14/17] KVM: arm64: Program the timer traps with VHE layout in hVHE mode Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 15/17] KVM: arm64: Force HCR_E2H in guest context when ARM64_KVM_HVHE is set Marc Zyngier
2023-06-09 16:21 ` [PATCH v3 16/17] arm64: Allow arm64_sw.hvhe on command line Marc Zyngier
2023-06-12 19:16 ` Catalin Marinas
2023-06-09 16:22 ` [PATCH v3 17/17] KVM: arm64: Terrible timer hack for M1 with hVHE Marc Zyngier
2023-06-09 16:54 ` [PATCH v3 00/17] KVM: arm64: Allow using VHE in the nVHE hypervisor Marc Zyngier
2023-06-14 15:31 ` (subset) " Oliver Upton
2023-06-14 16:16 ` Marc Zyngier
2024-07-10 6:45 ` Tangnianyao
2024-07-10 8:51 ` Marc Zyngier
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=ea8400f0-56c3-009c-d1ff-34f23a247ee9@redhat.com \
--to=shahuang@redhat.com \
--cc=linux-arm-kernel@lists.infradead.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 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).