Skip to content

Commit 95ef1e5

Browse files
committed
KVM guest: prevent tracing recursion with kvmclock
Prevent tracing of preempt_disable() in get_cpu_var() in kvm_clock_read(). When CONFIG_DEBUG_PREEMPT is enabled, preempt_disable/enable() are traced and this causes the function_graph tracer to go into an infinite recursion. By open coding the preempt_disable() around the get_cpu_var(), we can use the notrace version which prevents preempt_disable/enable() from being traced and prevents the recursion. Based on a similar patch for Xen from Jeremy Fitzhardinge. Tested-by: Gleb Natapov <gleb@redhat.com> Acked-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Avi Kivity <avi@redhat.com>
1 parent bb75c62 commit 95ef1e5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/x86/kernel/kvmclock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,10 @@ static cycle_t kvm_clock_read(void)
7474
struct pvclock_vcpu_time_info *src;
7575
cycle_t ret;
7676

77-
src = &get_cpu_var(hv_clock);
77+
preempt_disable_notrace();
78+
src = &__get_cpu_var(hv_clock);
7879
ret = pvclock_clocksource_read(src);
79-
put_cpu_var(hv_clock);
80+
preempt_enable_notrace();
8081
return ret;
8182
}
8283

0 commit comments

Comments
 (0)