KVM: arm64: Minor pKVM cleanups
cover KVM: arm64: Minor pKVM cleanups
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(-)
Signature · 6 lines
2.36.0.512.ge40c2bad7a-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
PATCH 1/2 KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
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.
--- arch/arm64/kvm/hyp/nvhe/switch.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
arch/arm64/kvm/hyp/nvhe/switch.c +1 -18
@@ -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,
Signature · 6 lines
2.36.0.512.ge40c2bad7a-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 1/2] KVM: arm64: pkvm: Drop unnecessary FP/SIMD trap handler
Hi Oliver,
Quoted 9 lines · 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 inpvm_init_traps_aa64pfr0(), which is likely a better home for it.No functional change intended.
Cheers,
/fuad
Quoted 46 lines
Signed-off-by Oliver Upton <[email protected]>--- arch/arm64/kvm/hyp/nvhe/switch.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)arch/arm64/kvm/hyp/nvhe/switch.c +1
-19@@ -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
PATCH 2/2 KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE
In reply to Oliver UptonFEAT_SVE is already masked by the fixed configuration for ID_AA64PFR0_EL1; don't try and mask it at runtime.
No functional change intended.
--- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 3 --- 1 file changed, 3 deletions(-)
arch/arm64/kvm/hyp/nvhe/sys_regs.c +0 -3
@@ -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 );
Signature · 6 lines
2.36.0.512.ge40c2bad7a-goog _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
Re: [PATCH 2/2] KVM: arm64: pkvm: Don't mask already zeroed FEAT_SVE
Hi Oliver,
Quoted 8 lines · Oliver Upton
FEAT_SVEis already masked by the fixed configuration forID_AA64PFR0_EL1; don't try and mask it at runtime.No functional change intended.
Signed-off-by Oliver Upton <[email protected]>---
Cheers,
/fuad
Quoted 20 lines
arch/arm64/kvm/hyp/nvhe/sys_regs.c | 3 --- 1 file changed, 3 deletions(-)arch/arm64/kvm/hyp/nvhe/sys_regs.c +0
-4@@ -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
Quoted 10 lines · 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 zeroedFEAT_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: 249838b7660ac04a67bfb017364a7f01029370a0Cheers,
M.
Signature · 1 line
Without deviation from the norm, progress is not possible.