The assumption that kvm_host_data is the container of the host kvm_cpu_context will not be true when the migration into kvm_host_vcpu has completed. Fortunately, a reference to kvm_host_data can easily be gained as it is a percpu variable. Signed-off-by: Andrew Scull <ascull@xxxxxxxxxx> --- arch/arm64/kvm/hyp/nvhe/switch.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kvm/hyp/nvhe/switch.c b/arch/arm64/kvm/hyp/nvhe/switch.c index ac19f98bdb60..8cd280a18dc2 100644 --- a/arch/arm64/kvm/hyp/nvhe/switch.c +++ b/arch/arm64/kvm/hyp/nvhe/switch.c @@ -119,13 +119,9 @@ static void __hyp_vgic_restore_state(struct kvm_vcpu *vcpu) /** * Disable host events, enable guest events */ -static void __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt) +static void __pmu_switch_to_guest(void) { - struct kvm_host_data *host; - struct kvm_pmu_events *pmu; - - host = container_of(host_ctxt, struct kvm_host_data, host_ctxt); - pmu = &host->pmu_events; + struct kvm_pmu_events *pmu = &__hyp_this_cpu_ptr(kvm_host_data)->pmu_events; if (pmu->events_host) write_sysreg(pmu->events_host, pmcntenclr_el0); @@ -137,13 +133,9 @@ static void __pmu_switch_to_guest(struct kvm_cpu_context *host_ctxt) /** * Disable guest events, enable host events */ -static void __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt) +static void __pmu_switch_to_host(void) { - struct kvm_host_data *host; - struct kvm_pmu_events *pmu; - - host = container_of(host_ctxt, struct kvm_host_data, host_ctxt); - pmu = &host->pmu_events; + struct kvm_pmu_events *pmu = &__hyp_this_cpu_ptr(kvm_host_data)->pmu_events; if (pmu->events_guest) write_sysreg(pmu->events_guest, pmcntenclr_el0); @@ -169,7 +161,7 @@ static void __kvm_vcpu_switch_to_guest(struct kvm_cpu_context *host_ctxt, pmr_sync(); } - __pmu_switch_to_guest(host_ctxt); + __pmu_switch_to_guest(); __sysreg_save_state_nvhe(&host_vcpu->arch.ctxt); @@ -218,7 +210,7 @@ static void __kvm_vcpu_switch_to_host(struct kvm_cpu_context *host_ctxt, */ __debug_switch_to_host(vcpu); - __pmu_switch_to_host(host_ctxt); + __pmu_switch_to_host(); /* Returning to host will clear PSR.I, remask PMR if needed */ if (system_uses_irq_prio_masking()) -- 2.27.0.389.gc38d7665816-goog _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm