Compare

b7719c575dec69146f6d537fd616b27083c0cf45..0fa993581aaa58a34ae3dcebebe0fbf593fcb441

tracing: Fix simple_ring_buffer undef check on sparc64

simple_ring_buffer relies on headers that end up including
<asm/thread_info.h>. On sparc64, this emits the undefined symbol
current_thread_info_reg. Allow this symbol.

Link: https://patch.msgid.link/20260923074213.3077182-4-vdonnefort@google.com
Fixes: 1211907ac0b5 ("tracing: Generate undef symbols allowlist for simple_ring_buffer")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Closes: https://lore.kernel.org/all/5574c9e6-9ed2-4ee6-a2b2-fb6ee81e83a1@roeck-us.net/
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Vincent Donnefort <vdonnefort@google.com> · 2026-09-23 07:42 UTC · committed by Steven Rostedt

Browse files
11 files changed, +32 −49
modified drivers/gpio/gpio-mxc.c
@@ -7,7 +7,6 @@
7 7 // Authors: Daniel Mack, Juergen Beisert.
8 8 // Copyright (C) 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
9 9
10 - #include <linux/bitops.h>
11 10 #include <linux/cleanup.h>
12 11 #include <linux/clk.h>
13 12 #include <linux/err.h>
@@ -69,7 +68,7 @@ struct mxc_gpio_port {
69 68 struct irq_domain *domain;
70 69 struct gpio_generic_chip gen_gc;
71 70 struct device *dev;
72 - unsigned long both_edges;
71 + u32 both_edges;
73 72 struct mxc_gpio_reg_saved gpio_saved_reg;
74 73 bool power_off;
75 74 u32 wakeup_pads;
@@ -169,7 +168,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)
169 168 int edge;
170 169 void __iomem *reg = port->base;
171 170
172 - clear_bit(gpio_idx, &port->both_edges);
171 + port->both_edges &= ~(1 << gpio_idx);
173 172 switch (type) {
174 173 case IRQ_TYPE_EDGE_RISING:
175 174 edge = GPIO_INT_RISE_EDGE;
@@ -189,7 +188,7 @@ static int gpio_set_irq_type(struct irq_data *d, u32 type)
189 188 edge = GPIO_INT_HIGH_LEV;
190 189 pr_debug("mxc: set GPIO %d to high trigger\n", gpio_idx);
191 190 }
192 - set_bit(gpio_idx, &port->both_edges);
191 + port->both_edges |= 1 << gpio_idx;
193 192 }
194 193 break;
195 194 case IRQ_TYPE_LEVEL_LOW:
@@ -260,7 +259,7 @@ static void mxc_gpio_irq_handler(struct mxc_gpio_port *port, u32 irq_stat)
260 259 while (irq_stat != 0) {
261 260 int irqoffset = fls(irq_stat) - 1;
262 261
263 - if (test_bit(irqoffset, &port->both_edges))
262 + if (port->both_edges & (1 << irqoffset))
264 263 mxc_flip_edge(port, irqoffset);
265 264
266 265 generic_handle_domain_irq(port->domain, irqoffset);
@@ -475,6 +474,8 @@ static int mxc_gpio_probe(struct platform_device *pdev)
475 474 } else
476 475 port->mx_irq_handler = mx3_gpio_irq_handler;
477 476
477 + mxc_update_irq_chained_handler(port, true);
478 +
478 479 config.dev = &pdev->dev;
479 480 config.sz = 4;
480 481 config.dat = port->base + GPIO_PSR;
@@ -524,8 +525,6 @@ static int mxc_gpio_probe(struct platform_device *pdev)
524 525
525 526 list_add_tail(&port->node, &mxc_gpio_ports);
526 527
527 - mxc_update_irq_chained_handler(port, true);
528 -
529 528 platform_set_drvdata(pdev, port);
530 529 pm_runtime_put_autosuspend(&pdev->dev);
531 530
modified drivers/gpio/gpio-nct6694.c
@@ -444,7 +444,7 @@ static int nct6694_gpio_probe(struct platform_device *pdev)
444 444 data->gpio.set_config = nct6694_set_config;
445 445 data->gpio.init_valid_mask = nct6694_init_valid_mask;
446 446 data->gpio.base = -1;
447 - data->gpio.can_sleep = true;
447 + data->gpio.can_sleep = false;
448 448 data->gpio.owner = THIS_MODULE;
449 449 data->gpio.ngpio = NCT6694_NR_GPIO;
450 450
modified drivers/gpio/gpiolib-kunit.c
@@ -28,8 +28,6 @@
28 28
29 29 #define GPIO_TEST_PROVIDER_NGPIO 4
30 30
31 - KUNIT_DEFINE_ACTION_WRAPPER(gpio_device_put_wrapper, gpio_device_put, struct gpio_device *);
32 -
33 31 /*
34 32 * The test provider tracks per-line direction and value so that lines can be
35 33 * driven as both inputs and outputs - this is needed to exercise input as well
@@ -772,7 +770,6 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset,
772 770 struct property_entry properties[2];
773 771 struct platform_device *pdev;
774 772 struct fwnode_handle *fwnode;
775 - struct gpio_device *gdev;
776 773 struct gpio_desc *desc;
777 774 bool bound = true;
778 775 int ret;
@@ -792,12 +789,10 @@ static void gpio_hog_assert(struct kunit *test, unsigned int offset,
792 789 wait_for_device_probe();
793 790
794 791 /* The hog must have configured the line with the expected direction. */
795 - gdev = gpio_device_find_by_label(GPIO_CONSUMER_NAME);
792 + struct gpio_device *gdev __free(gpio_device_put) =
793 + gpio_device_find_by_label(GPIO_CONSUMER_NAME);
796 794 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, gdev);
797 795
798 - ret = kunit_add_action_or_reset(test, gpio_device_put_wrapper, gdev);
799 - KUNIT_ASSERT_EQ(test, ret, 0);
800 -
801 796 desc = gpio_device_get_desc(gdev, offset);
802 797 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, desc);
803 798
modified drivers/gpio/gpiolib-shared.c
@@ -449,14 +449,10 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,
449 449 int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *fwnode,
450 450 const char *con_id, unsigned long lflags)
451 451 {
452 + const char *dev_id = dev_name(consumer);
453 + struct gpiod_lookup_table *lookup;
452 454 struct gpio_shared_entry *entry;
453 455 struct gpio_shared_ref *ref;
454 - const char *dev_id;
455 -
456 - if (!consumer)
457 - return -EOPNOTSUPP;
458 -
459 - dev_id = dev_name(consumer);
460 456
461 457 list_for_each_entry(entry, &gpio_shared_list, list) {
462 458 list_for_each_entry(ref, &entry->refs, list) {
@@ -484,22 +480,18 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *
484 480 if (!key)
485 481 return -ENOMEM;
486 482
487 - struct gpiod_lookup_table *lookup __free(kfree) =
488 - kzalloc_flex(*lookup, table, 2);
483 + lookup = kzalloc_flex(*lookup, table, 2);
489 484 if (!lookup)
490 485 return -ENOMEM;
491 486
492 487 pr_debug("Adding machine lookup entry for a shared GPIO for consumer %s, with key '%s' and con_id '%s'\n",
493 488 dev_id, key, ref->con_id ?: "none");
494 489
495 - lookup->dev_id = kstrdup(dev_id, GFP_KERNEL);
496 - if (!lookup->dev_id)
497 - return -ENOMEM;
498 -
490 + lookup->dev_id = dev_id;
499 491 lookup->table[0] = GPIO_LOOKUP(no_free_ptr(key), 0,
500 492 ref->con_id, lflags);
501 493
502 - ref->lookup = no_free_ptr(lookup);
494 + ref->lookup = lookup;
503 495 gpiod_add_lookup_table(ref->lookup);
504 496
505 497 return 0;
@@ -619,7 +611,6 @@ void gpio_device_teardown_shared(struct gpio_device *gdev)
619 611 if (ref->lookup) {
620 612 gpiod_remove_lookup_table(ref->lookup);
621 613 kfree(ref->lookup->table[0].key);
622 - kfree(ref->lookup->dev_id);
623 614 kfree(ref->lookup);
624 615 ref->lookup = NULL;
625 616 }
modified drivers/gpio/gpiolib.c
@@ -3954,17 +3954,16 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,
3954 3954 } while ((i < array_size) &&
3955 3955 gpio_device_chip_cmp(desc_array[i]->gdev, guard.gc));
3956 3956 /* push collected bits to outputs */
3957 - ret = 0;
3958 - if (count != 0)
3957 + if (count != 0) {
3959 3958 ret = gpiochip_set_multiple(guard.gc, mask, bits);
3959 + if (ret)
3960 + return ret;
3961 + }
3960 3962
3961 3963 if (mask != fastpath_mask)
3962 3964 bitmap_free(mask);
3963 3965 if (bits != fastpath_bits)
3964 3966 bitmap_free(bits);
3965 -
3966 - if (ret)
3967 - return ret;
3968 3967 }
3969 3968 return 0;
3970 3969 }
modified kernel/trace/Makefile
@@ -146,11 +146,12 @@ KASAN_SANITIZE_undefsyms_base.o := y
146 146
147 147 UNDEFINED_ALLOWLIST = __asan __gcov __kasan __kcsan __hwasan __sancov __sanitizer __tsan __ubsan __msan \
148 148 __aeabi_unwind_cpp __s390_indirect_jump __x86_indirect_thunk simple_ring_buffer \
149 - $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '{print $$2}')
149 + current_thread_info_reg \
150 + $(shell $(NM) -u $(obj)/undefsyms_base.o 2>/dev/null | awk '$$2 {print $$2}')
150 151
151 152 quiet_cmd_check_undefined = NM $<
152 153 cmd_check_undefined = \
153 - undefsyms=$$($(NM) -u $< | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \
154 + undefsyms=$$($(NM) -u $< | awk '$$2 {print $$2}' | grep -v $(addprefix -e , $(UNDEFINED_ALLOWLIST)) || true); \
154 155 if [ -n "$$undefsyms" ]; then \
155 156 echo "Unexpected symbols in $<:" >&2; \
156 157 echo "$$undefsyms" >&2; \
modified kernel/trace/ring_buffer.c
@@ -2380,6 +2380,9 @@ int ring_buffer_meta_seq_init(struct file *file, struct trace_buffer *buffer, in
2380 2380 struct seq_file *m;
2381 2381 int ret;
2382 2382
2383 + if (!cpumask_test_cpu(cpu, buffer->cpumask))
2384 + return -ENODEV;
2385 +
2383 2386 ret = seq_open(file, &rb_meta_seq_ops);
2384 2387 if (ret)
2385 2388 return ret;
@@ -3627,10 +3630,8 @@ static void rb_inc_iter(struct ring_buffer_iter *iter)
3627 3630 /* Return the index into the sub-buffers for a given sub-buffer */
3628 3631 static int rb_meta_subbuf_idx(struct ring_buffer_cpu_meta *meta, void *subbuf)
3629 3632 {
3630 - void *subbuf_array;
3633 + void *subbuf_array = rb_subbufs_from_meta(meta);
3631 3634
3632 - subbuf_array = (void *)meta + sizeof(int) * meta->nr_subbufs;
3633 - subbuf_array = (void *)ALIGN((unsigned long)subbuf_array, meta->subbuf_size);
3634 3635 return (subbuf - subbuf_array) / meta->subbuf_size;
3635 3636 }
3636 3637
modified kernel/trace/trace.c
@@ -5881,7 +5881,7 @@ static int tracing_buffer_meta_open(struct inode *inode, struct file *filp)
5881 5881
5882 5882 ret = ring_buffer_meta_seq_init(filp, tr->array_buffer.buffer, cpu);
5883 5883 if (ret < 0)
5884 - __trace_array_put(tr);
5884 + trace_array_put(tr);
5885 5885 return ret;
5886 5886 }
5887 5887
modified kernel/trace/trace_events_hist.c
@@ -289,7 +289,7 @@ static u64 hist_field_log2(struct hist_field *hist_field,
289 289
290 290 u64 val = hist_fn_call(operand, elt, buffer, rbe, event);
291 291
292 - return (u64) ilog2(roundup_pow_of_two(val));
292 + return order_base_2(val);
293 293 }
294 294
295 295 static u64 hist_field_bucket(struct hist_field *hist_field,
@@ -3090,7 +3090,7 @@ create_field_var_hist(struct hist_trigger_data *target_hist_data,
3090 3090 key_field = hist_data->fields[i];
3091 3091 if (!first)
3092 3092 seq_buf_putc(&s, ',');
3093 - seq_buf_puts(&s, key_field->field->name);
3093 + expr_field_str(key_field, &s);
3094 3094 first = false;
3095 3095 }
3096 3096
modified kernel/trace/undefsyms_base.c
@@ -9,6 +9,7 @@
9 9
10 10 #include <linux/atomic.h>
11 11 #include <linux/string.h>
12 + #include <asm/local.h>
12 13 #include <asm/page.h>
13 14
14 15 void undefsyms_base(void *p, int n);
@@ -18,11 +19,13 @@ static char page[PAGE_SIZE] __aligned(PAGE_SIZE);
18 19 void undefsyms_base(void *p, int n)
19 20 {
20 21 char buffer[256] = { 0 };
21 -
22 22 u32 u = 0;
23 +
23 24 memset((char * volatile)page, 8, PAGE_SIZE);
24 25 memset((char * volatile)buffer, 8, sizeof(buffer));
25 26 memcpy((void * volatile)p, buffer, sizeof(buffer));
26 27 cmpxchg((u32 * volatile)&u, 0, 8);
28 + cmpxchg((unsigned long *)p, 0, 8);
29 + local_set((local_t *)p, 8);
27 30 WARN_ON(n == 0xdeadbeef);
28 31 }
modified tools/gpio/Makefile
@@ -7,13 +7,7 @@ bindir ?= /usr/bin
7 7 # isn't set and when invoked from selftests build, where srctree
8 8 # is set to ".". building_out_of_srctree is undefined for in srctree
9 9 # builds
10 - ifeq ($(srctree),)
11 - update_srctree := 1
12 - endif
13 10 ifndef building_out_of_srctree
14 - update_srctree := 1
15 - endif
16 - ifeq ($(update_srctree),1)
17 11 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
18 12 srctree := $(patsubst %/,%,$(dir $(srctree)))
19 13 endif