@@ -66,7 +66,7 @@ static int nr_timers(struct kvm_vcpu *vcpu)
6666
6767u32 timer_get_ctl (struct arch_timer_context * ctxt )
6868{
69- struct kvm_vcpu * vcpu = ctxt -> vcpu ;
69+ struct kvm_vcpu * vcpu = timer_context_to_vcpu ( ctxt ) ;
7070
7171 switch (arch_timer_ctx_index (ctxt )) {
7272 case TIMER_VTIMER :
@@ -85,7 +85,7 @@ u32 timer_get_ctl(struct arch_timer_context *ctxt)
8585
8686u64 timer_get_cval (struct arch_timer_context * ctxt )
8787{
88- struct kvm_vcpu * vcpu = ctxt -> vcpu ;
88+ struct kvm_vcpu * vcpu = timer_context_to_vcpu ( ctxt ) ;
8989
9090 switch (arch_timer_ctx_index (ctxt )) {
9191 case TIMER_VTIMER :
@@ -104,7 +104,7 @@ u64 timer_get_cval(struct arch_timer_context *ctxt)
104104
105105static void timer_set_ctl (struct arch_timer_context * ctxt , u32 ctl )
106106{
107- struct kvm_vcpu * vcpu = ctxt -> vcpu ;
107+ struct kvm_vcpu * vcpu = timer_context_to_vcpu ( ctxt ) ;
108108
109109 switch (arch_timer_ctx_index (ctxt )) {
110110 case TIMER_VTIMER :
@@ -126,7 +126,7 @@ static void timer_set_ctl(struct arch_timer_context *ctxt, u32 ctl)
126126
127127static void timer_set_cval (struct arch_timer_context * ctxt , u64 cval )
128128{
129- struct kvm_vcpu * vcpu = ctxt -> vcpu ;
129+ struct kvm_vcpu * vcpu = timer_context_to_vcpu ( ctxt ) ;
130130
131131 switch (arch_timer_ctx_index (ctxt )) {
132132 case TIMER_VTIMER :
@@ -343,7 +343,7 @@ static enum hrtimer_restart kvm_hrtimer_expire(struct hrtimer *hrt)
343343 u64 ns ;
344344
345345 ctx = container_of (hrt , struct arch_timer_context , hrtimer );
346- vcpu = ctx -> vcpu ;
346+ vcpu = timer_context_to_vcpu ( ctx ) ;
347347
348348 trace_kvm_timer_hrtimer_expire (ctx );
349349
@@ -436,8 +436,9 @@ static void kvm_timer_update_status(struct arch_timer_context *ctx, bool level)
436436 *
437437 * But hey, it's fast, right?
438438 */
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 ))) {
441442 unsigned long val = timer_get_ctl (ctx );
442443 __assign_bit (__ffs (ARCH_TIMER_CTRL_IT_STAT ), & val , level );
443444 timer_set_ctl (ctx , val );
@@ -470,7 +471,7 @@ static void timer_emulate(struct arch_timer_context *ctx)
470471 trace_kvm_timer_emulate (ctx , should_fire );
471472
472473 if (should_fire != ctx -> irq .level )
473- kvm_timer_update_irq (ctx -> vcpu , should_fire , ctx );
474+ kvm_timer_update_irq (timer_context_to_vcpu ( ctx ) , should_fire , ctx );
474475
475476 kvm_timer_update_status (ctx , should_fire );
476477
@@ -498,7 +499,7 @@ static void set_cntpoff(u64 cntpoff)
498499
499500static void timer_save_state (struct arch_timer_context * ctx )
500501{
501- struct arch_timer_cpu * timer = vcpu_timer (ctx -> vcpu );
502+ struct arch_timer_cpu * timer = vcpu_timer (timer_context_to_vcpu ( ctx ) );
502503 enum kvm_arch_timers index = arch_timer_ctx_index (ctx );
503504 unsigned long flags ;
504505
@@ -609,7 +610,7 @@ static void kvm_timer_unblocking(struct kvm_vcpu *vcpu)
609610
610611static void timer_restore_state (struct arch_timer_context * ctx )
611612{
612- struct arch_timer_cpu * timer = vcpu_timer (ctx -> vcpu );
613+ struct arch_timer_cpu * timer = vcpu_timer (timer_context_to_vcpu ( ctx ) );
613614 enum kvm_arch_timers index = arch_timer_ctx_index (ctx );
614615 unsigned long flags ;
615616
@@ -668,7 +669,7 @@ static inline void set_timer_irq_phys_active(struct arch_timer_context *ctx, boo
668669
669670static void kvm_timer_vcpu_load_gic (struct arch_timer_context * ctx )
670671{
671- struct kvm_vcpu * vcpu = ctx -> vcpu ;
672+ struct kvm_vcpu * vcpu = timer_context_to_vcpu ( ctx ) ;
672673 bool phys_active = false;
673674
674675 /*
@@ -677,7 +678,7 @@ static void kvm_timer_vcpu_load_gic(struct arch_timer_context *ctx)
677678 * this point and the register restoration, we'll take the
678679 * interrupt anyway.
679680 */
680- kvm_timer_update_irq (ctx -> vcpu , kvm_timer_should_fire (ctx ), ctx );
681+ kvm_timer_update_irq (vcpu , kvm_timer_should_fire (ctx ), ctx );
681682
682683 if (irqchip_in_kernel (vcpu -> kvm ))
683684 phys_active = kvm_vgic_map_is_active (vcpu , timer_irq (ctx ));
0 commit comments