Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KVM: arm64: Properly restore PMU state during live-migration
Currently if a guest is live-migrated while it is actively using perf counters, then after live-migrate it will notice that all counters would suddenly start reporting 0s. This is due to the fact we are not re-creating the relevant perf events inside the kernel. Usually on live-migration guest state is restored using KVM_SET_ONE_REG ioctl interface, which simply restores the value of PMU registers values but does not re-program the perf events so that the guest can seamlessly use these counters even after live-migration like it was doing before live-migration. Instead there are two completely different code path between guest accessing PMU registers and VMM restoring counters on live-migration. In case of KVM_SET_ONE_REG: kvm_arm_set_reg() ...... kvm_arm_sys_reg_set_reg() ........... reg_from_user() but in case when guest tries to access these counters: handle_exit() ..... kvm_handle_sys_reg() ..........perform_access() ...............access_pmu_evcntr() ...................kvm_pmu_set_counter_value() .......................kvm_pmu_create_perf_event() The drawback of using the KVM_SET_ONE_REG interface is that the host pmu events which were registered for the source instance and not present for the destination instance. Thus passively restoring PMCR_EL0 using KVM_SET_ONE_REG interface would not create the necessary host pmu events which are crucial for seamless guest experience across live migration. In ordet to fix the situation, on first vcpu load we should restore PMCR_EL0 in the same exact way like the guest was trying to access these counters. And then we will also recreate the relevant host pmu events. Signed-off-by: Jinank Jain <jinankj@amazon.de> Cc: Alexander Graf (AWS) <graf@amazon.de> Cc: Marc Zyngier <maz@kernel.org> Cc: James Morse <james.morse@arm.com> Cc: Alexandru Elisei <alexandru.elisei@arm.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org>
- Loading branch information