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: x86/xen: Initialize hrtimer in kvm_xen_init_vcpu()

The hrtimer is initialized in the KVM_XEN_VCPU_SET_ATTR ioctl. That caused
problem in the past, because the hrtimer can be initialized multiple times,
which was fixed by commit af735db31285 ("KVM: x86/xen: Initialize Xen timer
only once"). This commit avoids initializing the timer multiple times by
checking the field 'function' of struct hrtimer to determine if it has
already been initialized.

This is not required and in the way to make the function field private.

Move the hrtimer initialization into kvm_xen_init_vcpu() so that it will
only be initialized once.

Signed-off-by: Nam Cao <namcao@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/all/9c33c7224d97d08f4fa30d3cc8687981c1d3e953.1730386209.git.namcao@linutronix.de

authored by

Nam Cao and committed by
Thomas Gleixner
f6e12766 482a483c

+2 -10
+2 -10
arch/x86/kvm/xen.c
··· 263 263 atomic_set(&vcpu->arch.xen.timer_pending, 0); 264 264 } 265 265 266 - static void kvm_xen_init_timer(struct kvm_vcpu *vcpu) 267 - { 268 - hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC, 269 - HRTIMER_MODE_ABS_HARD); 270 - vcpu->arch.xen.timer.function = xen_timer_callback; 271 - } 272 - 273 266 static void kvm_xen_update_runstate_guest(struct kvm_vcpu *v, bool atomic) 274 267 { 275 268 struct kvm_vcpu_xen *vx = &v->arch.xen; ··· 1062 1069 r = -EINVAL; 1063 1070 break; 1064 1071 } 1065 - 1066 - if (!vcpu->arch.xen.timer.function) 1067 - kvm_xen_init_timer(vcpu); 1068 1072 1069 1073 /* Stop the timer (if it's running) before changing the vector */ 1070 1074 kvm_xen_stop_timer(vcpu); ··· 2225 2235 vcpu->arch.xen.poll_evtchn = 0; 2226 2236 2227 2237 timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0); 2238 + hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS_HARD); 2239 + vcpu->arch.xen.timer.function = xen_timer_callback; 2228 2240 2229 2241 kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm); 2230 2242 kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm);