Skip to content

Commit 98be716

Browse files
Marc Zyngiergregkh
authored andcommitted
arm64: KVM: Make PSCI_VERSION a fast path
Commit 9034868 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 <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 45e2061 commit 98be716

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎arch/arm64/kvm/hyp/switch.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <linux/types.h>
1919
#include <linux/jump_label.h>
20+
#include <uapi/linux/psci.h>
2021

2122
#include <asm/kvm_asm.h>
2223
#include <asm/kvm_emulate.h>
@@ -322,6 +323,18 @@ int __hyp_text __kvm_vcpu_run(struct kvm_vcpu *vcpu)
322323
if (exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu))
323324
goto again;
324325

326+
if (exit_code == ARM_EXCEPTION_TRAP &&
327+
(kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_HVC64 ||
328+
kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_HVC32) &&
329+
vcpu_get_reg(vcpu, 0) == PSCI_0_2_FN_PSCI_VERSION) {
330+
u64 val = PSCI_RET_NOT_SUPPORTED;
331+
if (test_bit(KVM_ARM_VCPU_PSCI_0_2, vcpu->arch.features))
332+
val = 2;
333+
334+
vcpu_set_reg(vcpu, 0, val);
335+
goto again;
336+
}
337+
325338
if (static_branch_unlikely(&vgic_v2_cpuif_trap) &&
326339
exit_code == ARM_EXCEPTION_TRAP) {
327340
bool valid;

0 commit comments

Comments
 (0)