From: Marc Zyngier Date: Wed, 3 Jan 2018 16:38:37 +0000 (+0000) Subject: arm64: KVM: Make PSCI_VERSION a fast path X-Git-Tag: Ubuntu-4.13.0-37.41~14 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=74cf77a290118f6c6a53d62e0e78c95dbc9cc7f4;hp=b5370aaeed76dd04a9169c2d96d294185567502c;p=mirror_ubuntu-artful-kernel.git arm64: KVM: Make PSCI_VERSION a fast path Commit 90348689d500 upstream. For those CPUs that require PSCI to perform a BP invalidation, going all the way to the PSCI code for not much is a waste of precious cycles. Let's terminate that call as early as possible. Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Ard Biesheuvel Signed-off-by: Greg Kroah-Hartman (cherry picked from commit 98be7165d9f71f5df9802548b7d8ab2cf6ccb211) CVE-2017-5753 CVE-2017-5715 CVE-2017-5754 Signed-off-by: Paolo Pisati Acked-by: Brad Figg Acked-by: Kleber Sacilotto de Souza Signed-off-by: Khalid Elmously --- diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c index 0d3d3f1e348c..67f0ee24a406 100644 --- a/arch/arm64/kvm/hyp/switch.c +++ b/arch/arm64/kvm/hyp/switch.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -322,6 +323,18 @@ again: if (exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu)) goto again; + if (exit_code == ARM_EXCEPTION_TRAP && + (kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_HVC64 || + kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_HVC32) && + vcpu_get_reg(vcpu, 0) == PSCI_0_2_FN_PSCI_VERSION) { + u64 val = PSCI_RET_NOT_SUPPORTED; + if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features)) + val = 2; + + vcpu_set_reg(vcpu, 0, val); + goto again; + } + if (static_branch_unlikely(&vgic_v2_cpuif_trap) && exit_code == ARM_EXCEPTION_TRAP) { bool valid;