From: Marc Zyngier <maz@kernel.org>
To: Kristina Martsenko <kristina.martsenko@arm.com>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Vladimir Murzin <vladimir.murzin@arm.com>,
Colton Lewis <coltonlewis@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: arm64: Configure HCRX_EL2 dynamically
Date: Mon, 18 Sep 2023 12:10:25 +0100 [thread overview]
Message-ID: <865y47enz2.wl-maz@kernel.org> (raw)
In-Reply-To: <20230915124840.474888-2-kristina.martsenko@arm.com>
Hi Kristina,
On Fri, 15 Sep 2023 13:48:38 +0100,
Kristina Martsenko <kristina.martsenko@arm.com> wrote:
>
> At the moment the HCRX_EL2 system register is always initialized to
> HCRX_GUEST_FLAGS when running a guest. Instead, choose the configuration
> at vcpu reset time and save it in the vcpu struct, similarly to how
> HCR_EL2 is set up. This will be needed in a subsequent change to
> configure the register based on CPU features detected at runtime.
>
> Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
> ---
> arch/arm64/include/asm/kvm_emulate.h | 5 +++++
> arch/arm64/include/asm/kvm_host.h | 1 +
> arch/arm64/kvm/arm.c | 1 +
> arch/arm64/kvm/hyp/include/hyp/switch.h | 2 +-
> arch/arm64/kvm/hyp/nvhe/hyp-main.c | 1 +
> arch/arm64/kvm/hyp/nvhe/pkvm.c | 1 +
> 6 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
> index 3d6725ff0bf6..64ea27e6deb1 100644
> --- a/arch/arm64/include/asm/kvm_emulate.h
> +++ b/arch/arm64/include/asm/kvm_emulate.h
> @@ -134,6 +134,11 @@ static inline void vcpu_ptrauth_disable(struct kvm_vcpu *vcpu)
> vcpu->arch.hcr_el2 &= ~(HCR_API | HCR_APK);
> }
>
> +static inline void vcpu_reset_hcrx(struct kvm_vcpu *vcpu)
> +{
> + vcpu->arch.hcrx_el2 = HCRX_GUEST_FLAGS;
> +}
> +
> static inline unsigned long vcpu_get_vsesr(struct kvm_vcpu *vcpu)
> {
> return vcpu->arch.vsesr_el2;
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index af06ccb7ee34..2764748756a7 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -487,6 +487,7 @@ struct kvm_vcpu_arch {
>
> /* Values of trap registers for the guest. */
> u64 hcr_el2;
> + u64 hcrx_el2;
Do we really need this extra field? Yes, this is only an extra 64bit,
but they tend to accumulate...
Looking at patch #3, the change is related to this:
vcpu->arch.hcrx_el2 = HCRX_GUEST_FLAGS;
+
+ if (cpus_have_final_cap(ARM64_HAS_MOPS)) {
+ vcpu->arch.hcrx_el2 |= HCRX_EL2_MSCEn;
+ vcpu->arch.hcrx_el2 |= HCRX_EL2_MCE2;
+ }
meaning that this is a constant value for a given boot of the host.
At this stage, I'd rather you define HCRX_GUEST_FLAGS as:
#define HCRX_GUEST_FLAGS \
(HCRX_EL2_SMPME | HCRX_EL2_TCR2En | \
cpus_have_final_cap(ARM64_HAS_MOPS) ? \
(HCRX_EL2_MSCEn | HCRX_EL2_MCE2) : 0)
and drop the new field altogether, until we have something that
requires dynamic flipping of an HCRX_EL2 field.
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: Kristina Martsenko <kristina.martsenko@arm.com>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
Oliver Upton <oliver.upton@linux.dev>,
James Morse <james.morse@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Zenghui Yu <yuzenghui@huawei.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Vladimir Murzin <vladimir.murzin@arm.com>,
Colton Lewis <coltonlewis@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] KVM: arm64: Configure HCRX_EL2 dynamically
Date: Mon, 18 Sep 2023 12:10:25 +0100 [thread overview]
Message-ID: <865y47enz2.wl-maz@kernel.org> (raw)
In-Reply-To: <20230915124840.474888-2-kristina.martsenko@arm.com>
Hi Kristina,
On Fri, 15 Sep 2023 13:48:38 +0100,
Kristina Martsenko <kristina.martsenko@arm.com> wrote:
>
> At the moment the HCRX_EL2 system register is always initialized to
> HCRX_GUEST_FLAGS when running a guest. Instead, choose the configuration
> at vcpu reset time and save it in the vcpu struct, similarly to how
> HCR_EL2 is set up. This will be needed in a subsequent change to
> configure the register based on CPU features detected at runtime.
>
> Signed-off-by: Kristina Martsenko <kristina.martsenko@arm.com>
> ---
> arch/arm64/include/asm/kvm_emulate.h | 5 +++++
> arch/arm64/include/asm/kvm_host.h | 1 +
> arch/arm64/kvm/arm.c | 1 +
> arch/arm64/kvm/hyp/include/hyp/switch.h | 2 +-
> arch/arm64/kvm/hyp/nvhe/hyp-main.c | 1 +
> arch/arm64/kvm/hyp/nvhe/pkvm.c | 1 +
> 6 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h
> index 3d6725ff0bf6..64ea27e6deb1 100644
> --- a/arch/arm64/include/asm/kvm_emulate.h
> +++ b/arch/arm64/include/asm/kvm_emulate.h
> @@ -134,6 +134,11 @@ static inline void vcpu_ptrauth_disable(struct kvm_vcpu *vcpu)
> vcpu->arch.hcr_el2 &= ~(HCR_API | HCR_APK);
> }
>
> +static inline void vcpu_reset_hcrx(struct kvm_vcpu *vcpu)
> +{
> + vcpu->arch.hcrx_el2 = HCRX_GUEST_FLAGS;
> +}
> +
> static inline unsigned long vcpu_get_vsesr(struct kvm_vcpu *vcpu)
> {
> return vcpu->arch.vsesr_el2;
> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
> index af06ccb7ee34..2764748756a7 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -487,6 +487,7 @@ struct kvm_vcpu_arch {
>
> /* Values of trap registers for the guest. */
> u64 hcr_el2;
> + u64 hcrx_el2;
Do we really need this extra field? Yes, this is only an extra 64bit,
but they tend to accumulate...
Looking at patch #3, the change is related to this:
vcpu->arch.hcrx_el2 = HCRX_GUEST_FLAGS;
+
+ if (cpus_have_final_cap(ARM64_HAS_MOPS)) {
+ vcpu->arch.hcrx_el2 |= HCRX_EL2_MSCEn;
+ vcpu->arch.hcrx_el2 |= HCRX_EL2_MCE2;
+ }
meaning that this is a constant value for a given boot of the host.
At this stage, I'd rather you define HCRX_GUEST_FLAGS as:
#define HCRX_GUEST_FLAGS \
(HCRX_EL2_SMPME | HCRX_EL2_TCR2En | \
cpus_have_final_cap(ARM64_HAS_MOPS) ? \
(HCRX_EL2_MSCEn | HCRX_EL2_MCE2) : 0)
and drop the new field altogether, until we have something that
requires dynamic flipping of an HCRX_EL2 field.
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
next prev parent reply other threads:[~2023-09-18 11:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 12:48 [PATCH 0/3] KVM: arm64: Support for Arm v8.8 memcpy instructions in KVM guests Kristina Martsenko
2023-09-15 12:48 ` Kristina Martsenko
2023-09-15 12:48 ` [PATCH 1/3] KVM: arm64: Configure HCRX_EL2 dynamically Kristina Martsenko
2023-09-15 12:48 ` Kristina Martsenko
2023-09-18 11:10 ` Marc Zyngier [this message]
2023-09-18 11:10 ` Marc Zyngier
2023-09-19 11:26 ` Kristina Martsenko
2023-09-19 11:26 ` Kristina Martsenko
2023-09-15 12:48 ` [PATCH 2/3] KVM: arm64: Add handler for MOPS exceptions Kristina Martsenko
2023-09-15 12:48 ` Kristina Martsenko
2023-09-15 12:48 ` [PATCH 3/3] KVM: arm64: Expose MOPS instructions to guests Kristina Martsenko
2023-09-15 12:48 ` Kristina Martsenko
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=865y47enz2.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=coltonlewis@google.com \
--cc=james.morse@arm.com \
--cc=kristina.martsenko@arm.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oliver.upton@linux.dev \
--cc=suzuki.poulose@arm.com \
--cc=vladimir.murzin@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.