Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

KVM: arm64: Introduce timer_context_to_vcpu() helper

We currently have a vcpu pointer nested into each timer context.

As we are about to remove this pointer, introduce a helper (aptly
named timer_context_to_vcpu()) that returns this pointer, at least
until we repaint the data structure.

Signed-off-by: Marc Zyngier <maz@kernel.org>

+14 -13
+13 -12
arch/arm64/kvm/arch_timer.c
··· 66 66 67 67 u32 timer_get_ctl(struct arch_timer_context *ctxt) 68 68 { 69 - struct kvm_vcpu *vcpu = ctxt->vcpu; 69 + struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctxt); 70 70 71 71 switch(arch_timer_ctx_index(ctxt)) { 72 72 case TIMER_VTIMER: ··· 85 85 86 86 u64 timer_get_cval(struct arch_timer_context *ctxt) 87 87 { 88 - struct kvm_vcpu *vcpu = ctxt->vcpu; 88 + struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctxt); 89 89 90 90 switch(arch_timer_ctx_index(ctxt)) { 91 91 case TIMER_VTIMER: ··· 104 104 105 105 static void timer_set_ctl(struct arch_timer_context *ctxt, u32 ctl) 106 106 { 107 - struct kvm_vcpu *vcpu = ctxt->vcpu; 107 + struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctxt); 108 108 109 109 switch(arch_timer_ctx_index(ctxt)) { 110 110 case TIMER_VTIMER: ··· 126 126 127 127 static void timer_set_cval(struct arch_timer_context *ctxt, u64 cval) 128 128 { 129 - struct kvm_vcpu *vcpu = ctxt->vcpu; 129 + struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctxt); 130 130 131 131 switch(arch_timer_ctx_index(ctxt)) { 132 132 case TIMER_VTIMER: ··· 343 343 u64 ns; 344 344 345 345 ctx = container_of(hrt, struct arch_timer_context, hrtimer); 346 - vcpu = ctx->vcpu; 346 + vcpu = timer_context_to_vcpu(ctx); 347 347 348 348 trace_kvm_timer_hrtimer_expire(ctx); 349 349 ··· 436 436 * 437 437 * But hey, it's fast, right? 438 438 */ 439 - if (is_hyp_ctxt(ctx->vcpu) && 440 - (ctx == vcpu_vtimer(ctx->vcpu) || ctx == vcpu_ptimer(ctx->vcpu))) { 439 + struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctx); 440 + if (is_hyp_ctxt(vcpu) && 441 + (ctx == vcpu_vtimer(vcpu) || ctx == vcpu_ptimer(vcpu))) { 441 442 unsigned long val = timer_get_ctl(ctx); 442 443 __assign_bit(__ffs(ARCH_TIMER_CTRL_IT_STAT), &val, level); 443 444 timer_set_ctl(ctx, val); ··· 471 470 trace_kvm_timer_emulate(ctx, should_fire); 472 471 473 472 if (should_fire != ctx->irq.level) 474 - kvm_timer_update_irq(ctx->vcpu, should_fire, ctx); 473 + kvm_timer_update_irq(timer_context_to_vcpu(ctx), should_fire, ctx); 475 474 476 475 kvm_timer_update_status(ctx, should_fire); 477 476 ··· 499 498 500 499 static void timer_save_state(struct arch_timer_context *ctx) 501 500 { 502 - struct arch_timer_cpu *timer = vcpu_timer(ctx->vcpu); 501 + struct arch_timer_cpu *timer = vcpu_timer(timer_context_to_vcpu(ctx)); 503 502 enum kvm_arch_timers index = arch_timer_ctx_index(ctx); 504 503 unsigned long flags; 505 504 ··· 610 609 611 610 static void timer_restore_state(struct arch_timer_context *ctx) 612 611 { 613 - struct arch_timer_cpu *timer = vcpu_timer(ctx->vcpu); 612 + struct arch_timer_cpu *timer = vcpu_timer(timer_context_to_vcpu(ctx)); 614 613 enum kvm_arch_timers index = arch_timer_ctx_index(ctx); 615 614 unsigned long flags; 616 615 ··· 669 668 670 669 static void kvm_timer_vcpu_load_gic(struct arch_timer_context *ctx) 671 670 { 672 - struct kvm_vcpu *vcpu = ctx->vcpu; 671 + struct kvm_vcpu *vcpu = timer_context_to_vcpu(ctx); 673 672 bool phys_active = false; 674 673 675 674 /* ··· 678 677 * this point and the register restoration, we'll take the 679 678 * interrupt anyway. 680 679 */ 681 - kvm_timer_update_irq(ctx->vcpu, kvm_timer_should_fire(ctx), ctx); 680 + kvm_timer_update_irq(vcpu, kvm_timer_should_fire(ctx), ctx); 682 681 683 682 if (irqchip_in_kernel(vcpu->kvm)) 684 683 phys_active = kvm_vgic_map_is_active(vcpu, timer_irq(ctx));
+1 -1
include/kvm/arm_arch_timer.h
··· 128 128 #define vcpu_hptimer(v) (&(v)->arch.timer_cpu.timers[TIMER_HPTIMER]) 129 129 130 130 #define arch_timer_ctx_index(ctx) ((ctx) - vcpu_timer((ctx)->vcpu)->timers) 131 - 131 + #define timer_context_to_vcpu(ctx) ((ctx)->vcpu) 132 132 #define timer_vm_data(ctx) (&(ctx)->vcpu->kvm->arch.timer_data) 133 133 #define timer_irq(ctx) (timer_vm_data(ctx)->ppi[arch_timer_ctx_index(ctx)]) 134 134