]> xenbits.xensource.com Git - xen.git/commitdiff
timer: fix NR_CPUS=1 build with gcc13
authorJan Beulich <jbeulich@suse.com>
Mon, 18 Sep 2023 13:06:59 +0000 (15:06 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 18 Sep 2023 13:06:59 +0000 (15:06 +0200)
Gcc13 apparently infers from "if ( old_cpu < new_cpu )" that "new_cpu"
is >= 1, and then (on x86) complains about "per_cpu(timers, new_cpu)"
exceeding __per_cpu_offset[]'s bounds (being an array of 1 in such a
configuration). Make the code conditional upon there being at least 2
CPUs configured (otherwise there simply is nothing to migrate [to]).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@cloud.com>
xen/common/timer.c

index a2a18b2fb2136429ed6223a2b253df9e557cf2a6..0fddfa74879e5d2e6447b555efaea697f2288a54 100644 (file)
@@ -357,6 +357,7 @@ bool timer_expires_before(struct timer *timer, s_time_t t)
 void migrate_timer(struct timer *timer, unsigned int new_cpu)
 {
     unsigned int old_cpu;
+#if CONFIG_NR_CPUS > 1
     bool_t active;
     unsigned long flags;
 
@@ -404,6 +405,11 @@ void migrate_timer(struct timer *timer, unsigned int new_cpu)
 
     spin_unlock(&per_cpu(timers, old_cpu).lock);
     spin_unlock_irqrestore(&per_cpu(timers, new_cpu).lock, flags);
+#else /* CONFIG_NR_CPUS == 1 */
+    old_cpu = read_atomic(&timer->cpu);
+    if ( old_cpu != TIMER_CPU_status_killed )
+        WARN_ON(new_cpu != old_cpu);
+#endif /* CONFIG_NR_CPUS */
 }