Magellan Linux

Annotation of /trunk/kernel-alx/patches-4.9/0137-4.9.38-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2956 - (hide annotations) (download)
Mon Jul 24 12:03:46 2017 UTC (6 years, 10 months ago) by niro
File size: 23424 byte(s)
-added patches-4.9
1 niro 2956 diff --git a/Makefile b/Makefile
2     index 342e19adbf7f..ad0c045d36cd 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,6 +1,6 @@
6     VERSION = 4
7     PATCHLEVEL = 9
8     -SUBLEVEL = 37
9     +SUBLEVEL = 38
10     EXTRAVERSION =
11     NAME = Roaring Lionus
12    
13     diff --git a/arch/x86/include/asm/pat.h b/arch/x86/include/asm/pat.h
14     index 0b1ff4c1c14e..fffb2794dd89 100644
15     --- a/arch/x86/include/asm/pat.h
16     +++ b/arch/x86/include/asm/pat.h
17     @@ -7,6 +7,7 @@
18     bool pat_enabled(void);
19     void pat_disable(const char *reason);
20     extern void pat_init(void);
21     +extern void init_cache_modes(void);
22    
23     extern int reserve_memtype(u64 start, u64 end,
24     enum page_cache_mode req_pcm, enum page_cache_mode *ret_pcm);
25     diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
26     index 9c337b0e8ba7..feaab07fa124 100644
27     --- a/arch/x86/kernel/setup.c
28     +++ b/arch/x86/kernel/setup.c
29     @@ -1054,6 +1054,13 @@ void __init setup_arch(char **cmdline_p)
30     max_possible_pfn = max_pfn;
31    
32     /*
33     + * This call is required when the CPU does not support PAT. If
34     + * mtrr_bp_init() invoked it already via pat_init() the call has no
35     + * effect.
36     + */
37     + init_cache_modes();
38     +
39     + /*
40     * Define random base addresses for memory sections after max_pfn is
41     * defined and before each memory section base is used.
42     */
43     diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
44     index 83e701f160a9..89d7907c4218 100644
45     --- a/arch/x86/mm/pat.c
46     +++ b/arch/x86/mm/pat.c
47     @@ -36,14 +36,14 @@
48     #undef pr_fmt
49     #define pr_fmt(fmt) "" fmt
50    
51     -static bool boot_cpu_done;
52     -
53     -static int __read_mostly __pat_enabled = IS_ENABLED(CONFIG_X86_PAT);
54     -static void init_cache_modes(void);
55     +static bool __read_mostly boot_cpu_done;
56     +static bool __read_mostly pat_disabled = !IS_ENABLED(CONFIG_X86_PAT);
57     +static bool __read_mostly pat_initialized;
58     +static bool __read_mostly init_cm_done;
59    
60     void pat_disable(const char *reason)
61     {
62     - if (!__pat_enabled)
63     + if (pat_disabled)
64     return;
65    
66     if (boot_cpu_done) {
67     @@ -51,10 +51,8 @@ void pat_disable(const char *reason)
68     return;
69     }
70    
71     - __pat_enabled = 0;
72     + pat_disabled = true;
73     pr_info("x86/PAT: %s\n", reason);
74     -
75     - init_cache_modes();
76     }
77    
78     static int __init nopat(char *str)
79     @@ -66,7 +64,7 @@ early_param("nopat", nopat);
80    
81     bool pat_enabled(void)
82     {
83     - return !!__pat_enabled;
84     + return pat_initialized;
85     }
86     EXPORT_SYMBOL_GPL(pat_enabled);
87    
88     @@ -204,6 +202,8 @@ static void __init_cache_modes(u64 pat)
89     update_cache_mode_entry(i, cache);
90     }
91     pr_info("x86/PAT: Configuration [0-7]: %s\n", pat_msg);
92     +
93     + init_cm_done = true;
94     }
95    
96     #define PAT(x, y) ((u64)PAT_ ## y << ((x)*8))
97     @@ -224,6 +224,7 @@ static void pat_bsp_init(u64 pat)
98     }
99    
100     wrmsrl(MSR_IA32_CR_PAT, pat);
101     + pat_initialized = true;
102    
103     __init_cache_modes(pat);
104     }
105     @@ -241,10 +242,9 @@ static void pat_ap_init(u64 pat)
106     wrmsrl(MSR_IA32_CR_PAT, pat);
107     }
108    
109     -static void init_cache_modes(void)
110     +void init_cache_modes(void)
111     {
112     u64 pat = 0;
113     - static int init_cm_done;
114    
115     if (init_cm_done)
116     return;
117     @@ -286,8 +286,6 @@ static void init_cache_modes(void)
118     }
119    
120     __init_cache_modes(pat);
121     -
122     - init_cm_done = 1;
123     }
124    
125     /**
126     @@ -305,10 +303,8 @@ void pat_init(void)
127     u64 pat;
128     struct cpuinfo_x86 *c = &boot_cpu_data;
129    
130     - if (!pat_enabled()) {
131     - init_cache_modes();
132     + if (pat_disabled)
133     return;
134     - }
135    
136     if ((c->x86_vendor == X86_VENDOR_INTEL) &&
137     (((c->x86 == 0x6) && (c->x86_model <= 0xd)) ||
138     diff --git a/crypto/rsa-pkcs1pad.c b/crypto/rsa-pkcs1pad.c
139     index 8baab4307f7b..7830d304dff6 100644
140     --- a/crypto/rsa-pkcs1pad.c
141     +++ b/crypto/rsa-pkcs1pad.c
142     @@ -496,7 +496,7 @@ static int pkcs1pad_verify_complete(struct akcipher_request *req, int err)
143     goto done;
144     pos++;
145    
146     - if (memcmp(out_buf + pos, digest_info->data, digest_info->size))
147     + if (crypto_memneq(out_buf + pos, digest_info->data, digest_info->size))
148     goto done;
149    
150     pos += digest_info->size;
151     diff --git a/drivers/base/core.c b/drivers/base/core.c
152     index ce057a568673..03a82d017cf1 100644
153     --- a/drivers/base/core.c
154     +++ b/drivers/base/core.c
155     @@ -2095,7 +2095,11 @@ void device_shutdown(void)
156     pm_runtime_get_noresume(dev);
157     pm_runtime_barrier(dev);
158    
159     - if (dev->bus && dev->bus->shutdown) {
160     + if (dev->class && dev->class->shutdown) {
161     + if (initcall_debug)
162     + dev_info(dev, "shutdown\n");
163     + dev->class->shutdown(dev);
164     + } else if (dev->bus && dev->bus->shutdown) {
165     if (initcall_debug)
166     dev_info(dev, "shutdown\n");
167     dev->bus->shutdown(dev);
168     diff --git a/drivers/char/tpm/tpm-chip.c b/drivers/char/tpm/tpm-chip.c
169     index a017ccd8cc3b..9ff853229957 100644
170     --- a/drivers/char/tpm/tpm-chip.c
171     +++ b/drivers/char/tpm/tpm-chip.c
172     @@ -130,6 +130,41 @@ static void tpm_dev_release(struct device *dev)
173     kfree(chip);
174     }
175    
176     +
177     +/**
178     + * tpm_class_shutdown() - prepare the TPM device for loss of power.
179     + * @dev: device to which the chip is associated.
180     + *
181     + * Issues a TPM2_Shutdown command prior to loss of power, as required by the
182     + * TPM 2.0 spec.
183     + * Then, calls bus- and device- specific shutdown code.
184     + *
185     + * XXX: This codepath relies on the fact that sysfs is not enabled for
186     + * TPM2: sysfs uses an implicit lock on chip->ops, so this could race if TPM2
187     + * has sysfs support enabled before TPM sysfs's implicit locking is fixed.
188     + */
189     +static int tpm_class_shutdown(struct device *dev)
190     +{
191     + struct tpm_chip *chip = container_of(dev, struct tpm_chip, dev);
192     +
193     + if (chip->flags & TPM_CHIP_FLAG_TPM2) {
194     + down_write(&chip->ops_sem);
195     + tpm2_shutdown(chip, TPM2_SU_CLEAR);
196     + chip->ops = NULL;
197     + up_write(&chip->ops_sem);
198     + }
199     + /* Allow bus- and device-specific code to run. Note: since chip->ops
200     + * is NULL, more-specific shutdown code will not be able to issue TPM
201     + * commands.
202     + */
203     + if (dev->bus && dev->bus->shutdown)
204     + dev->bus->shutdown(dev);
205     + else if (dev->driver && dev->driver->shutdown)
206     + dev->driver->shutdown(dev);
207     + return 0;
208     +}
209     +
210     +
211     /**
212     * tpm_chip_alloc() - allocate a new struct tpm_chip instance
213     * @pdev: device to which the chip is associated
214     @@ -168,6 +203,7 @@ struct tpm_chip *tpm_chip_alloc(struct device *pdev,
215     device_initialize(&chip->dev);
216    
217     chip->dev.class = tpm_class;
218     + chip->dev.class->shutdown = tpm_class_shutdown;
219     chip->dev.release = tpm_dev_release;
220     chip->dev.parent = pdev;
221     chip->dev.groups = chip->groups;
222     diff --git a/drivers/char/tpm/tpm-sysfs.c b/drivers/char/tpm/tpm-sysfs.c
223     index 47005840c42c..edf8c59a6ed4 100644
224     --- a/drivers/char/tpm/tpm-sysfs.c
225     +++ b/drivers/char/tpm/tpm-sysfs.c
226     @@ -285,6 +285,11 @@ static const struct attribute_group tpm_dev_group = {
227    
228     void tpm_sysfs_add_device(struct tpm_chip *chip)
229     {
230     + /* XXX: If you wish to remove this restriction, you must first update
231     + * tpm_sysfs to explicitly lock chip->ops.
232     + */
233     + if (chip->flags & TPM_CHIP_FLAG_TPM2)
234     + return;
235     /* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
236     * is called before ops is null'd and the sysfs core synchronizes this
237     * removal so that no callbacks are running or can run again
238     diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c
239     index c310318b34dd..3bda6e5e2a45 100644
240     --- a/drivers/crypto/caam/caamalg.c
241     +++ b/drivers/crypto/caam/caamalg.c
242     @@ -2601,8 +2601,7 @@ static struct ablkcipher_edesc *ablkcipher_edesc_alloc(struct ablkcipher_request
243     struct crypto_ablkcipher *ablkcipher = crypto_ablkcipher_reqtfm(req);
244     struct caam_ctx *ctx = crypto_ablkcipher_ctx(ablkcipher);
245     struct device *jrdev = ctx->jrdev;
246     - gfp_t flags = (req->base.flags & (CRYPTO_TFM_REQ_MAY_BACKLOG |
247     - CRYPTO_TFM_REQ_MAY_SLEEP)) ?
248     + gfp_t flags = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) ?
249     GFP_KERNEL : GFP_ATOMIC;
250     int src_nents, dst_nents = 0, sec4_sg_bytes;
251     struct ablkcipher_edesc *edesc;
252     diff --git a/drivers/md/md.c b/drivers/md/md.c
253     index eddd360624a1..8ebf1b97e1d2 100644
254     --- a/drivers/md/md.c
255     +++ b/drivers/md/md.c
256     @@ -1861,7 +1861,7 @@ super_1_rdev_size_change(struct md_rdev *rdev, sector_t num_sectors)
257     }
258     sb = page_address(rdev->sb_page);
259     sb->data_size = cpu_to_le64(num_sectors);
260     - sb->super_offset = rdev->sb_start;
261     + sb->super_offset = cpu_to_le64(rdev->sb_start);
262     sb->sb_csum = calc_sb_1_csum(sb);
263     md_super_write(rdev->mddev, rdev, rdev->sb_start, rdev->sb_size,
264     rdev->sb_page);
265     @@ -2270,7 +2270,7 @@ static bool does_sb_need_changing(struct mddev *mddev)
266     /* Check if any mddev parameters have changed */
267     if ((mddev->dev_sectors != le64_to_cpu(sb->size)) ||
268     (mddev->reshape_position != le64_to_cpu(sb->reshape_position)) ||
269     - (mddev->layout != le64_to_cpu(sb->layout)) ||
270     + (mddev->layout != le32_to_cpu(sb->layout)) ||
271     (mddev->raid_disks != le32_to_cpu(sb->raid_disks)) ||
272     (mddev->chunk_sectors != le32_to_cpu(sb->chunksize)))
273     return true;
274     diff --git a/drivers/media/pci/saa7134/saa7134-i2c.c b/drivers/media/pci/saa7134/saa7134-i2c.c
275     index 2dac48fa1386..dca0592c5f47 100644
276     --- a/drivers/media/pci/saa7134/saa7134-i2c.c
277     +++ b/drivers/media/pci/saa7134/saa7134-i2c.c
278     @@ -355,12 +355,43 @@ static struct i2c_client saa7134_client_template = {
279    
280     /* ----------------------------------------------------------- */
281    
282     +/* On Medion 7134 reading EEPROM needs DVB-T demod i2c gate open */
283     +static void saa7134_i2c_eeprom_md7134_gate(struct saa7134_dev *dev)
284     +{
285     + u8 subaddr = 0x7, dmdregval;
286     + u8 data[2];
287     + int ret;
288     + struct i2c_msg i2cgatemsg_r[] = { {.addr = 0x08, .flags = 0,
289     + .buf = &subaddr, .len = 1},
290     + {.addr = 0x08,
291     + .flags = I2C_M_RD,
292     + .buf = &dmdregval, .len = 1}
293     + };
294     + struct i2c_msg i2cgatemsg_w[] = { {.addr = 0x08, .flags = 0,
295     + .buf = data, .len = 2} };
296     +
297     + ret = i2c_transfer(&dev->i2c_adap, i2cgatemsg_r, 2);
298     + if ((ret == 2) && (dmdregval & 0x2)) {
299     + pr_debug("%s: DVB-T demod i2c gate was left closed\n",
300     + dev->name);
301     +
302     + data[0] = subaddr;
303     + data[1] = (dmdregval & ~0x2);
304     + if (i2c_transfer(&dev->i2c_adap, i2cgatemsg_w, 1) != 1)
305     + pr_err("%s: EEPROM i2c gate open failure\n",
306     + dev->name);
307     + }
308     +}
309     +
310     static int
311     saa7134_i2c_eeprom(struct saa7134_dev *dev, unsigned char *eedata, int len)
312     {
313     unsigned char buf;
314     int i,err;
315    
316     + if (dev->board == SAA7134_BOARD_MD7134)
317     + saa7134_i2c_eeprom_md7134_gate(dev);
318     +
319     dev->i2c_client.addr = 0xa0 >> 1;
320     buf = 0;
321     if (1 != (err = i2c_master_send(&dev->i2c_client,&buf,1))) {
322     diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
323     index 64b3966c5f1f..a34fd5afb9a8 100644
324     --- a/drivers/staging/comedi/comedi_fops.c
325     +++ b/drivers/staging/comedi/comedi_fops.c
326     @@ -2908,6 +2908,7 @@ static int __init comedi_init(void)
327     dev = comedi_alloc_board_minor(NULL);
328     if (IS_ERR(dev)) {
329     comedi_cleanup_board_minors();
330     + class_destroy(comedi_class);
331     cdev_del(&comedi_cdev);
332     unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
333     COMEDI_NUM_MINORS);
334     diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
335     index 0594828bdabf..b1955378852a 100644
336     --- a/drivers/staging/vt6656/main_usb.c
337     +++ b/drivers/staging/vt6656/main_usb.c
338     @@ -522,6 +522,9 @@ static int vnt_start(struct ieee80211_hw *hw)
339     goto free_all;
340     }
341    
342     + if (vnt_key_init_table(priv))
343     + goto free_all;
344     +
345     priv->int_interval = 1; /* bInterval is set to 1 */
346    
347     vnt_int_start_interrupt(priv);
348     diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
349     index 42145be5c6b4..5dc655e410b4 100644
350     --- a/fs/ext4/sysfs.c
351     +++ b/fs/ext4/sysfs.c
352     @@ -100,7 +100,7 @@ static ssize_t reserved_clusters_store(struct ext4_attr *a,
353     int ret;
354    
355     ret = kstrtoull(skip_spaces(buf), 0, &val);
356     - if (!ret || val >= clusters)
357     + if (ret || val >= clusters)
358     return -EINVAL;
359    
360     atomic64_set(&sbi->s_resv_clusters, val);
361     diff --git a/include/linux/device.h b/include/linux/device.h
362     index bc41e87a969b..8d732965fab7 100644
363     --- a/include/linux/device.h
364     +++ b/include/linux/device.h
365     @@ -373,6 +373,7 @@ int subsys_virtual_register(struct bus_type *subsys,
366     * @suspend: Used to put the device to sleep mode, usually to a low power
367     * state.
368     * @resume: Used to bring the device from the sleep mode.
369     + * @shutdown: Called at shut-down time to quiesce the device.
370     * @ns_type: Callbacks so sysfs can detemine namespaces.
371     * @namespace: Namespace of the device belongs to this class.
372     * @pm: The default device power management operations of this class.
373     @@ -401,6 +402,7 @@ struct class {
374    
375     int (*suspend)(struct device *dev, pm_message_t state);
376     int (*resume)(struct device *dev);
377     + int (*shutdown)(struct device *dev);
378    
379     const struct kobj_ns_type_operations *ns_type;
380     const void *(*namespace)(struct device *dev);
381     diff --git a/ipc/mqueue.c b/ipc/mqueue.c
382     index 8cbd6e6894d5..28a142f1be36 100644
383     --- a/ipc/mqueue.c
384     +++ b/ipc/mqueue.c
385     @@ -1249,8 +1249,10 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
386    
387     timeo = MAX_SCHEDULE_TIMEOUT;
388     ret = netlink_attachskb(sock, nc, &timeo, NULL);
389     - if (ret == 1)
390     + if (ret == 1) {
391     + sock = NULL;
392     goto retry;
393     + }
394     if (ret) {
395     sock = NULL;
396     nc = NULL;
397     diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c
398     index 2bef4ab94003..a608f7a8fbd1 100644
399     --- a/kernel/locking/rwsem-spinlock.c
400     +++ b/kernel/locking/rwsem-spinlock.c
401     @@ -233,8 +233,8 @@ int __sched __down_write_common(struct rw_semaphore *sem, int state)
402    
403     out_nolock:
404     list_del(&waiter.list);
405     - if (!list_empty(&sem->wait_list))
406     - __rwsem_do_wake(sem, 1);
407     + if (!list_empty(&sem->wait_list) && sem->count >= 0)
408     + __rwsem_do_wake(sem, 0);
409     raw_spin_unlock_irqrestore(&sem->wait_lock, flags);
410    
411     return -EINTR;
412     diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
413     index e33fc1df3935..d94179f94caa 100644
414     --- a/tools/include/linux/compiler.h
415     +++ b/tools/include/linux/compiler.h
416     @@ -126,4 +126,13 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
417     #define WRITE_ONCE(x, val) \
418     ({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; __write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
419    
420     +
421     +#ifndef __fallthrough
422     +# if defined(__GNUC__) && __GNUC__ >= 7
423     +# define __fallthrough __attribute__ ((fallthrough))
424     +# else
425     +# define __fallthrough
426     +# endif
427     +#endif
428     +
429     #endif /* _TOOLS_LINUX_COMPILER_H */
430     diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
431     index 8efe904e486b..9e5a02d6b9a9 100644
432     --- a/tools/perf/bench/numa.c
433     +++ b/tools/perf/bench/numa.c
434     @@ -1573,13 +1573,13 @@ static int __bench_numa(const char *name)
435     "GB/sec,", "total-speed", "GB/sec total speed");
436    
437     if (g->p.show_details >= 2) {
438     - char tname[32];
439     + char tname[14 + 2 * 10 + 1];
440     struct thread_data *td;
441     for (p = 0; p < g->p.nr_proc; p++) {
442     for (t = 0; t < g->p.nr_threads; t++) {
443     - memset(tname, 0, 32);
444     + memset(tname, 0, sizeof(tname));
445     td = g->threads + p*g->p.nr_threads + t;
446     - snprintf(tname, 32, "process%d:thread%d", p, t);
447     + snprintf(tname, sizeof(tname), "process%d:thread%d", p, t);
448     print_res(tname, td->speed_gbs,
449     "GB/sec", "thread-speed", "GB/sec/thread speed");
450     print_res(tname, td->system_time_ns / NSEC_PER_SEC,
451     diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
452     index fe3af9535e85..0b613e701736 100644
453     --- a/tools/perf/builtin-top.c
454     +++ b/tools/perf/builtin-top.c
455     @@ -643,7 +643,7 @@ static void *display_thread(void *arg)
456     case -1:
457     if (errno == EINTR)
458     continue;
459     - /* Fall trhu */
460     + __fallthrough;
461     default:
462     c = getc(stdin);
463     tcsetattr(0, TCSAFLUSH, &save);
464     diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
465     index 20c2e641c422..aa9276bfe3e9 100644
466     --- a/tools/perf/tests/parse-events.c
467     +++ b/tools/perf/tests/parse-events.c
468     @@ -1779,15 +1779,14 @@ static int test_pmu_events(void)
469     }
470    
471     while (!ret && (ent = readdir(dir))) {
472     -#define MAX_NAME 100
473     struct evlist_test e;
474     - char name[MAX_NAME];
475     + char name[2 * NAME_MAX + 1 + 12 + 3];
476    
477     /* Names containing . are special and cannot be used directly */
478     if (strchr(ent->d_name, '.'))
479     continue;
480    
481     - snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
482     + snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
483    
484     e.name = name;
485     e.check = test__checkevent_pmu_events;
486     @@ -1795,11 +1794,10 @@ static int test_pmu_events(void)
487     ret = test_event(&e);
488     if (ret)
489     break;
490     - snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
491     + snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
492     e.name = name;
493     e.check = test__checkevent_pmu_events_mix;
494     ret = test_event(&e);
495     -#undef MAX_NAME
496     }
497    
498     closedir(dir);
499     diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
500     index 2f3eded54b0c..5337f49db361 100644
501     --- a/tools/perf/util/header.c
502     +++ b/tools/perf/util/header.c
503     @@ -3184,6 +3184,7 @@ int perf_event__process_event_update(struct perf_tool *tool __maybe_unused,
504     case PERF_EVENT_UPDATE__SCALE:
505     ev_scale = (struct event_update_event_scale *) ev->data;
506     evsel->scale = ev_scale->scale;
507     + break;
508     case PERF_EVENT_UPDATE__CPUS:
509     ev_cpus = (struct event_update_event_cpus *) ev->data;
510    
511     diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
512     index 16c06d3ae577..04387ab31316 100644
513     --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
514     +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
515     @@ -22,6 +22,7 @@
516     #include <errno.h>
517     #include <stdint.h>
518     #include <inttypes.h>
519     +#include <linux/compiler.h>
520    
521     #include "../cache.h"
522     #include "../util.h"
523     @@ -1744,6 +1745,7 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
524     switch (decoder->packet.type) {
525     case INTEL_PT_TIP_PGD:
526     decoder->continuous_period = false;
527     + __fallthrough;
528     case INTEL_PT_TIP_PGE:
529     case INTEL_PT_TIP:
530     intel_pt_log("ERROR: Unexpected packet\n");
531     @@ -1797,6 +1799,8 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
532     decoder->pge = false;
533     decoder->continuous_period = false;
534     intel_pt_clear_tx_flags(decoder);
535     + __fallthrough;
536     +
537     case INTEL_PT_TNT:
538     decoder->have_tma = false;
539     intel_pt_log("ERROR: Unexpected packet\n");
540     @@ -1837,6 +1841,7 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
541     switch (decoder->packet.type) {
542     case INTEL_PT_TIP_PGD:
543     decoder->continuous_period = false;
544     + __fallthrough;
545     case INTEL_PT_TIP_PGE:
546     case INTEL_PT_TIP:
547     decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD;
548     diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
549     index 4f7b32020487..7528ae4f7e28 100644
550     --- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
551     +++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
552     @@ -17,6 +17,7 @@
553     #include <string.h>
554     #include <endian.h>
555     #include <byteswap.h>
556     +#include <linux/compiler.h>
557    
558     #include "intel-pt-pkt-decoder.h"
559    
560     @@ -498,6 +499,7 @@ int intel_pt_pkt_desc(const struct intel_pt_pkt *packet, char *buf,
561     case INTEL_PT_FUP:
562     if (!(packet->count))
563     return snprintf(buf, buf_len, "%s no ip", name);
564     + __fallthrough;
565     case INTEL_PT_CYC:
566     case INTEL_PT_VMCS:
567     case INTEL_PT_MTC:
568     diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
569     index 1d9c02bc00f1..7ea13f44178d 100644
570     --- a/tools/perf/util/probe-event.c
571     +++ b/tools/perf/util/probe-event.c
572     @@ -618,6 +618,67 @@ static int find_perf_probe_point_from_dwarf(struct probe_trace_point *tp,
573     return ret ? : -ENOENT;
574     }
575    
576     +/* Adjust symbol name and address */
577     +static int post_process_probe_trace_point(struct probe_trace_point *tp,
578     + struct map *map, unsigned long offs)
579     +{
580     + struct symbol *sym;
581     + u64 addr = tp->address + tp->offset - offs;
582     +
583     + sym = map__find_symbol(map, addr);
584     + if (!sym)
585     + return -ENOENT;
586     +
587     + if (strcmp(sym->name, tp->symbol)) {
588     + /* If we have no realname, use symbol for it */
589     + if (!tp->realname)
590     + tp->realname = tp->symbol;
591     + else
592     + free(tp->symbol);
593     + tp->symbol = strdup(sym->name);
594     + if (!tp->symbol)
595     + return -ENOMEM;
596     + }
597     + tp->offset = addr - sym->start;
598     + tp->address -= offs;
599     +
600     + return 0;
601     +}
602     +
603     +/*
604     + * Rename DWARF symbols to ELF symbols -- gcc sometimes optimizes functions
605     + * and generate new symbols with suffixes such as .constprop.N or .isra.N
606     + * etc. Since those symbols are not recorded in DWARF, we have to find
607     + * correct generated symbols from offline ELF binary.
608     + * For online kernel or uprobes we don't need this because those are
609     + * rebased on _text, or already a section relative address.
610     + */
611     +static int
612     +post_process_offline_probe_trace_events(struct probe_trace_event *tevs,
613     + int ntevs, const char *pathname)
614     +{
615     + struct map *map;
616     + unsigned long stext = 0;
617     + int i, ret = 0;
618     +
619     + /* Prepare a map for offline binary */
620     + map = dso__new_map(pathname);
621     + if (!map || get_text_start_address(pathname, &stext) < 0) {
622     + pr_warning("Failed to get ELF symbols for %s\n", pathname);
623     + return -EINVAL;
624     + }
625     +
626     + for (i = 0; i < ntevs; i++) {
627     + ret = post_process_probe_trace_point(&tevs[i].point,
628     + map, stext);
629     + if (ret < 0)
630     + break;
631     + }
632     + map__put(map);
633     +
634     + return ret;
635     +}
636     +
637     static int add_exec_to_probe_trace_events(struct probe_trace_event *tevs,
638     int ntevs, const char *exec)
639     {
640     @@ -694,7 +755,8 @@ post_process_kernel_probe_trace_events(struct probe_trace_event *tevs,
641    
642     /* Skip post process if the target is an offline kernel */
643     if (symbol_conf.ignore_vmlinux_buildid)
644     - return 0;
645     + return post_process_offline_probe_trace_events(tevs, ntevs,
646     + symbol_conf.vmlinux_name);
647    
648     reloc_sym = kernel_get_ref_reloc_sym();
649     if (!reloc_sym) {
650     diff --git a/tools/perf/util/scripting-engines/Build b/tools/perf/util/scripting-engines/Build
651     index 6516e220c247..82d28c67e0f3 100644
652     --- a/tools/perf/util/scripting-engines/Build
653     +++ b/tools/perf/util/scripting-engines/Build
654     @@ -1,6 +1,6 @@
655     libperf-$(CONFIG_LIBPERL) += trace-event-perl.o
656     libperf-$(CONFIG_LIBPYTHON) += trace-event-python.o
657    
658     -CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-undef -Wno-switch-default
659     +CFLAGS_trace-event-perl.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow -Wno-nested-externs -Wno-undef -Wno-switch-default
660    
661     CFLAGS_trace-event-python.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-shadow
662     diff --git a/tools/perf/util/strfilter.c b/tools/perf/util/strfilter.c
663     index bcae659b6546..efb53772e0ec 100644
664     --- a/tools/perf/util/strfilter.c
665     +++ b/tools/perf/util/strfilter.c
666     @@ -269,6 +269,7 @@ static int strfilter_node__sprint(struct strfilter_node *node, char *buf)
667     len = strfilter_node__sprint_pt(node->l, buf);
668     if (len < 0)
669     return len;
670     + __fallthrough;
671     case '!':
672     if (buf) {
673     *(buf + len++) = *node->p;
674     diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
675     index 7f7e072be746..f4e3444d90ab 100644
676     --- a/tools/perf/util/string.c
677     +++ b/tools/perf/util/string.c
678     @@ -21,6 +21,8 @@ s64 perf_atoll(const char *str)
679     case 'b': case 'B':
680     if (*p)
681     goto out_err;
682     +
683     + __fallthrough;
684     case '\0':
685     return length;
686     default:
687     diff --git a/tools/perf/util/thread_map.c b/tools/perf/util/thread_map.c
688     index 40585f5b7027..ddec5c583d2b 100644
689     --- a/tools/perf/util/thread_map.c
690     +++ b/tools/perf/util/thread_map.c
691     @@ -93,7 +93,7 @@ struct thread_map *thread_map__new_by_uid(uid_t uid)
692     {
693     DIR *proc;
694     int max_threads = 32, items, i;
695     - char path[256];
696     + char path[NAME_MAX + 1 + 6];
697     struct dirent *dirent, **namelist = NULL;
698     struct thread_map *threads = thread_map__alloc(max_threads);
699