linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: arm64: Minor pKVM cleanups
@ 2022-05-09 16:25 Oliver Upton
  2022-05-09 16:25 ` [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler Oliver Upton
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Oliver Upton @ 2022-05-09 16:25 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, linux-arm-kernel, linux-kernel, maz, james.morse,
	alexandru.elisei, suzuki.poulose, tabba, qperret, will,
	Oliver Upton

I was reading through some of the pKVM stuff to get an idea of how it
handles feature registers and spotted a few minor nits.

Applies cleanly to 5.18-rc5.

Oliver Upton (2):
  KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
  KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE

 arch/arm64/kvm/hyp/nvhe/switch.c   | 19 +------------------
 arch/arm64/kvm/hyp/nvhe/sys_regs.c |  3 ---
 2 files changed, 1 insertion(+), 21 deletions(-)

-- 
2.36.0.512.ge40c2bad7a-goog


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
  2022-05-09 16:25 [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Oliver Upton
@ 2022-05-09 16:25 ` Oliver Upton
  2022-05-10  9:44   ` Fuad Tabba
  2022-05-09 16:25 ` [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE Oliver Upton
  2022-05-10 10:04 ` [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Marc Zyngier
  2 siblings, 1 reply; 6+ messages in thread
From: Oliver Upton @ 2022-05-09 16:25 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, linux-arm-kernel, linux-kernel, maz, james.morse,
	alexandru.elisei, suzuki.poulose, tabba, qperret, will,
	Oliver Upton

The pVM-specific FP/SIMD trap handler just calls straight into the
generic trap handler. Avoid the indirection and just call the hyp
handler directly.

Note that the BUILD_BUG_ON() pattern is repeated in
pvm_init_traps_aa64pfr0(), which is likely a better home for it.

No functional change intended.

Signed-off-by: Oliver Upton <oupton@google.com>
---
 arch/arm64/kvm/hyp/nvhe/switch.c | 19 +------------------
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c
index 6410d21d8695..3dee2ad96e10 100644
--- a/arch/arm64/kvm/hyp/nvhe/switch.c
+++ b/arch/arm64/kvm/hyp/nvhe/switch.c
@@ -175,23 +175,6 @@ static bool kvm_handle_pvm_sys64(struct kvm_vcpu *vcpu, u64 *exit_code)
 		kvm_handle_pvm_sysreg(vcpu, exit_code));
 }
 
-/**
- * Handler for protected floating-point and Advanced SIMD accesses.
- *
- * Returns true if the hypervisor has handled the exit, and control should go
- * back to the guest, or false if it hasn't.
- */
-static bool kvm_handle_pvm_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code)
-{
-	/* Linux guests assume support for floating-point and Advanced SIMD. */
-	BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_FP),
-				PVM_ID_AA64PFR0_ALLOW));
-	BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_ASIMD),
-				PVM_ID_AA64PFR0_ALLOW));
-
-	return kvm_hyp_handle_fpsimd(vcpu, exit_code);
-}
-
 static const exit_handler_fn hyp_exit_handlers[] = {
 	[0 ... ESR_ELx_EC_MAX]		= NULL,
 	[ESR_ELx_EC_CP15_32]		= kvm_hyp_handle_cp15_32,
@@ -207,7 +190,7 @@ static const exit_handler_fn pvm_exit_handlers[] = {
 	[0 ... ESR_ELx_EC_MAX]		= NULL,
 	[ESR_ELx_EC_SYS64]		= kvm_handle_pvm_sys64,
 	[ESR_ELx_EC_SVE]		= kvm_handle_pvm_restricted,
-	[ESR_ELx_EC_FP_ASIMD]		= kvm_handle_pvm_fpsimd,
+	[ESR_ELx_EC_FP_ASIMD]		= kvm_hyp_handle_fpsimd,
 	[ESR_ELx_EC_IABT_LOW]		= kvm_hyp_handle_iabt_low,
 	[ESR_ELx_EC_DABT_LOW]		= kvm_hyp_handle_dabt_low,
 	[ESR_ELx_EC_PAC]		= kvm_hyp_handle_ptrauth,
-- 
2.36.0.512.ge40c2bad7a-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE
  2022-05-09 16:25 [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Oliver Upton
  2022-05-09 16:25 ` [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler Oliver Upton
@ 2022-05-09 16:25 ` Oliver Upton
  2022-05-10  9:45   ` Fuad Tabba
  2022-05-10 10:04 ` [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Marc Zyngier
  2 siblings, 1 reply; 6+ messages in thread
From: Oliver Upton @ 2022-05-09 16:25 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, linux-arm-kernel, linux-kernel, maz, james.morse,
	alexandru.elisei, suzuki.poulose, tabba, qperret, will,
	Oliver Upton

FEAT_SVE is already masked by the fixed configuration for
ID_AA64PFR0_EL1; don't try and mask it at runtime.

No functional change intended.

Signed-off-by: Oliver Upton <oupton@google.com>
---
 arch/arm64/kvm/hyp/nvhe/sys_regs.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
index 33f5181af330..3f5d7bd171c5 100644
--- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c
+++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
@@ -90,9 +90,6 @@ static u64 get_pvm_id_aa64pfr0(const struct kvm_vcpu *vcpu)
 	u64 set_mask = 0;
 	u64 allow_mask = PVM_ID_AA64PFR0_ALLOW;
 
-	if (!vcpu_has_sve(vcpu))
-		allow_mask &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_SVE);
-
 	set_mask |= get_restricted_features_unsigned(id_aa64pfr0_el1_sys_val,
 		PVM_ID_AA64PFR0_RESTRICT_UNSIGNED);
 
-- 
2.36.0.512.ge40c2bad7a-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
  2022-05-09 16:25 ` [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler Oliver Upton
@ 2022-05-10  9:44   ` Fuad Tabba
  0 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2022-05-10  9:44 UTC (permalink / raw)
  To: Oliver Upton
  Cc: kvmarm, kvm, linux-arm-kernel, linux-kernel, maz, james.morse,
	alexandru.elisei, suzuki.poulose, qperret, will

Hi Oliver,

On Mon, May 9, 2022 at 5:26 PM Oliver Upton <oupton@google.com> wrote:
>
> The pVM-specific FP/SIMD trap handler just calls straight into the
> generic trap handler. Avoid the indirection and just call the hyp
> handler directly.
>
> Note that the BUILD_BUG_ON() pattern is repeated in
> pvm_init_traps_aa64pfr0(), which is likely a better home for it.
>
> No functional change intended.

Reviewed-by: Fuad Tabba <tabba@google.com>

Cheers,
/fuad

>
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---
>  arch/arm64/kvm/hyp/nvhe/switch.c | 19 +------------------
>  1 file changed, 1 insertion(+), 18 deletions(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c
> index 6410d21d8695..3dee2ad96e10 100644
> --- a/arch/arm64/kvm/hyp/nvhe/switch.c
> +++ b/arch/arm64/kvm/hyp/nvhe/switch.c
> @@ -175,23 +175,6 @@ static bool kvm_handle_pvm_sys64(struct kvm_vcpu *vcpu, u64 *exit_code)
>                 kvm_handle_pvm_sysreg(vcpu, exit_code));
>  }
>
> -/**
> - * Handler for protected floating-point and Advanced SIMD accesses.
> - *
> - * Returns true if the hypervisor has handled the exit, and control should go
> - * back to the guest, or false if it hasn't.
> - */
> -static bool kvm_handle_pvm_fpsimd(struct kvm_vcpu *vcpu, u64 *exit_code)
> -{
> -       /* Linux guests assume support for floating-point and Advanced SIMD. */
> -       BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_FP),
> -                               PVM_ID_AA64PFR0_ALLOW));
> -       BUILD_BUG_ON(!FIELD_GET(ARM64_FEATURE_MASK(ID_AA64PFR0_ASIMD),
> -                               PVM_ID_AA64PFR0_ALLOW));
> -
> -       return kvm_hyp_handle_fpsimd(vcpu, exit_code);
> -}
> -
>  static const exit_handler_fn hyp_exit_handlers[] = {
>         [0 ... ESR_ELx_EC_MAX]          = NULL,
>         [ESR_ELx_EC_CP15_32]            = kvm_hyp_handle_cp15_32,
> @@ -207,7 +190,7 @@ static const exit_handler_fn pvm_exit_handlers[] = {
>         [0 ... ESR_ELx_EC_MAX]          = NULL,
>         [ESR_ELx_EC_SYS64]              = kvm_handle_pvm_sys64,
>         [ESR_ELx_EC_SVE]                = kvm_handle_pvm_restricted,
> -       [ESR_ELx_EC_FP_ASIMD]           = kvm_handle_pvm_fpsimd,
> +       [ESR_ELx_EC_FP_ASIMD]           = kvm_hyp_handle_fpsimd,
>         [ESR_ELx_EC_IABT_LOW]           = kvm_hyp_handle_iabt_low,
>         [ESR_ELx_EC_DABT_LOW]           = kvm_hyp_handle_dabt_low,
>         [ESR_ELx_EC_PAC]                = kvm_hyp_handle_ptrauth,
> --
> 2.36.0.512.ge40c2bad7a-goog
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE
  2022-05-09 16:25 ` [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE Oliver Upton
@ 2022-05-10  9:45   ` Fuad Tabba
  0 siblings, 0 replies; 6+ messages in thread
From: Fuad Tabba @ 2022-05-10  9:45 UTC (permalink / raw)
  To: Oliver Upton
  Cc: kvmarm, kvm, linux-arm-kernel, linux-kernel, maz, james.morse,
	alexandru.elisei, suzuki.poulose, qperret, will

Hi Oliver,


On Mon, May 9, 2022 at 5:26 PM Oliver Upton <oupton@google.com> wrote:
>
> FEAT_SVE is already masked by the fixed configuration for
> ID_AA64PFR0_EL1; don't try and mask it at runtime.
>
> No functional change intended.
>
> Signed-off-by: Oliver Upton <oupton@google.com>
> ---

Reviewed-by: Fuad Tabba <tabba@google.com>

Cheers,
/fuad


>  arch/arm64/kvm/hyp/nvhe/sys_regs.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/arch/arm64/kvm/hyp/nvhe/sys_regs.c b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
> index 33f5181af330..3f5d7bd171c5 100644
> --- a/arch/arm64/kvm/hyp/nvhe/sys_regs.c
> +++ b/arch/arm64/kvm/hyp/nvhe/sys_regs.c
> @@ -90,9 +90,6 @@ static u64 get_pvm_id_aa64pfr0(const struct kvm_vcpu *vcpu)
>         u64 set_mask = 0;
>         u64 allow_mask = PVM_ID_AA64PFR0_ALLOW;
>
> -       if (!vcpu_has_sve(vcpu))
> -               allow_mask &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_SVE);
> -
>         set_mask |= get_restricted_features_unsigned(id_aa64pfr0_el1_sys_val,
>                 PVM_ID_AA64PFR0_RESTRICT_UNSIGNED);
>
> --
> 2.36.0.512.ge40c2bad7a-goog
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] KVM: arm64: Minor pKVM cleanups
  2022-05-09 16:25 [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Oliver Upton
  2022-05-09 16:25 ` [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler Oliver Upton
  2022-05-09 16:25 ` [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE Oliver Upton
@ 2022-05-10 10:04 ` Marc Zyngier
  2 siblings, 0 replies; 6+ messages in thread
From: Marc Zyngier @ 2022-05-10 10:04 UTC (permalink / raw)
  To: kvmarm, Oliver Upton
  Cc: will, tabba, qperret, james.morse, alexandru.elisei, kvm,
	suzuki.poulose, linux-arm-kernel, linux-kernel

On Mon, 9 May 2022 16:25:57 +0000, Oliver Upton wrote:
> I was reading through some of the pKVM stuff to get an idea of how it
> handles feature registers and spotted a few minor nits.
> 
> Applies cleanly to 5.18-rc5.
> 
> Oliver Upton (2):
>   KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
>   KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE
> 
> [...]

Applied to next, thanks!

[1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
      commit: 4d2e469e163ec79340b2f42c2a07838b5ff30686
[2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE
      commit: 249838b7660ac04a67bfb017364a7f01029370a0

Cheers,

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-05-10 10:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-09 16:25 [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Oliver Upton
2022-05-09 16:25 ` [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler Oliver Upton
2022-05-10  9:44   ` Fuad Tabba
2022-05-09 16:25 ` [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE Oliver Upton
2022-05-10  9:45   ` Fuad Tabba
2022-05-10 10:04 ` [PATCH 0/2] KVM: arm64: Minor pKVM cleanups Marc Zyngier

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).