]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook
authorSean Christopherson <seanjc@google.com>
Sat, 9 Oct 2021 02:12:03 +0000 (19:12 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:24:49 +0000 (04:24 -0500)
commit2a5d99835ebb6c20430e4973d138634ebe49a75a
treefdd289c70c9fe2dfbbc6c4cddc67a52b53884f01
parent2b804c65e4d8afe0be918da2ba2f8aacc83dd5a3
KVM: arm64: Move vGIC v4 handling for WFI out arch callback hook

Move the put and reload of the vGIC out of the block/unblock callbacks
and into a dedicated WFI helper.  Functionally, this is nearly a nop as
the block hook is called at the very beginning of kvm_vcpu_block(), and
the only code in kvm_vcpu_block() after the unblock hook is to update the
halt-polling controls, i.e. can only affect the next WFI.

Back when the arch (un)blocking hooks were added by commits 0c04bb75ebe2
("KVM: Add kvm_arch_vcpu_{un}blocking callbacks) and 551d6cdf7a60
("arm/arm64: KVM: arch_timer: Only schedule soft timer on vcpu_block"),
the hooks were invoked only when KVM was about to "block", i.e. schedule
out the vCPU.  The use case at the time was to schedule a timer in the
host based on the earliest timer in the guest in order to wake the
blocking vCPU when the emulated guest timer fired.  Commit 3fb9c37ea42c
("KVM: arm/arm64: Simplify bg_timer programming") reworked the timer
logic to be even more precise, by waiting until the vCPU was actually
scheduled out, and so move the timer logic from the (un)blocking hooks to
vcpu_load/put.

In the meantime, the hooks gained usage for enabling vGIC v4 doorbells in
commit 85581da3057d ("KVM: arm/arm64: GICv4: Use the doorbell interrupt
as an unblocking source"), and added related logic for the VMCR in commit
c01c5ca249fa ("KVM: arm/arm64: Sync ICH_VMCR_EL2 back when about to block").

Finally, commit 68b394f28766 ("KVM: Call kvm_arch_vcpu_blocking early
into the blocking sequence") hoisted the (un)blocking hooks so that they
wrapped KVM's halt-polling logic in addition to the core "block" logic.

In other words, the original need for arch hooks to take action _only_
in the block path is long since gone.

Cc: Oliver Upton <oupton@google.com>
Cc: Marc Zyngier <maz@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20211009021236.4122790-11-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/arm64/include/asm/kvm_emulate.h
arch/arm64/kvm/arm.c
arch/arm64/kvm/handle_exit.c