Magellan Linux

Annotation of /trunk/kernel-alx/patches-5.4/0173-5.4.74-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3637 - (hide annotations) (download)
Mon Oct 24 12:40:44 2022 UTC (20 months ago) by niro
File size: 50097 byte(s)
-add missing
1 niro 3637 diff --git a/Makefile b/Makefile
2     index f9a8d76a693eb..3be5a9c352b9c 100644
3     --- a/Makefile
4     +++ b/Makefile
5     @@ -1,7 +1,7 @@
6     # SPDX-License-Identifier: GPL-2.0
7     VERSION = 5
8     PATCHLEVEL = 4
9     -SUBLEVEL = 73
10     +SUBLEVEL = 74
11     EXTRAVERSION =
12     NAME = Kleptomaniac Octopus
13    
14     diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
15     index 96abe558aea8b..cd8f3cdabfd07 100644
16     --- a/arch/arm64/Makefile
17     +++ b/arch/arm64/Makefile
18     @@ -10,7 +10,7 @@
19     #
20     # Copyright (C) 1995-2001 by Russell King
21    
22     -LDFLAGS_vmlinux :=--no-undefined -X
23     +LDFLAGS_vmlinux :=--no-undefined -X -z norelro
24     CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
25     GZFLAGS :=-9
26    
27     @@ -18,7 +18,7 @@ ifeq ($(CONFIG_RELOCATABLE), y)
28     # Pass --no-apply-dynamic-relocs to restore pre-binutils-2.27 behaviour
29     # for relative relocs, since this leads to better Image compression
30     # with the relocation offsets always being zero.
31     -LDFLAGS_vmlinux += -shared -Bsymbolic -z notext -z norelro \
32     +LDFLAGS_vmlinux += -shared -Bsymbolic -z notext \
33     $(call ld-option, --no-apply-dynamic-relocs)
34     endif
35    
36     diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
37     index d2e738c455566..1e16c4e00e771 100644
38     --- a/arch/arm64/kernel/cpu_errata.c
39     +++ b/arch/arm64/kernel/cpu_errata.c
40     @@ -492,6 +492,12 @@ out_printmsg:
41     return required;
42     }
43    
44     +static void cpu_enable_ssbd_mitigation(const struct arm64_cpu_capabilities *cap)
45     +{
46     + if (ssbd_state != ARM64_SSBD_FORCE_DISABLE)
47     + cap->matches(cap, SCOPE_LOCAL_CPU);
48     +}
49     +
50     /* known invulnerable cores */
51     static const struct midr_range arm64_ssb_cpus[] = {
52     MIDR_ALL_VERSIONS(MIDR_CORTEX_A35),
53     @@ -635,6 +641,12 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope)
54     return (need_wa > 0);
55     }
56    
57     +static void
58     +cpu_enable_branch_predictor_hardening(const struct arm64_cpu_capabilities *cap)
59     +{
60     + cap->matches(cap, SCOPE_LOCAL_CPU);
61     +}
62     +
63     static const __maybe_unused struct midr_range tx2_family_cpus[] = {
64     MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
65     MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
66     @@ -894,9 +906,11 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
67     },
68     #endif
69     {
70     + .desc = "Branch predictor hardening",
71     .capability = ARM64_HARDEN_BRANCH_PREDICTOR,
72     .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
73     .matches = check_branch_predictor,
74     + .cpu_enable = cpu_enable_branch_predictor_hardening,
75     },
76     #ifdef CONFIG_HARDEN_EL2_VECTORS
77     {
78     @@ -910,6 +924,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
79     .capability = ARM64_SSBD,
80     .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
81     .matches = has_ssbd_mitigation,
82     + .cpu_enable = cpu_enable_ssbd_mitigation,
83     .midr_range_list = arm64_ssb_cpus,
84     },
85     #ifdef CONFIG_ARM64_ERRATUM_1418040
86     diff --git a/arch/openrisc/include/asm/uaccess.h b/arch/openrisc/include/asm/uaccess.h
87     index 17c24f14615fb..6839f8fcf76b2 100644
88     --- a/arch/openrisc/include/asm/uaccess.h
89     +++ b/arch/openrisc/include/asm/uaccess.h
90     @@ -164,19 +164,19 @@ struct __large_struct {
91    
92     #define __get_user_nocheck(x, ptr, size) \
93     ({ \
94     - long __gu_err, __gu_val; \
95     - __get_user_size(__gu_val, (ptr), (size), __gu_err); \
96     - (x) = (__force __typeof__(*(ptr)))__gu_val; \
97     + long __gu_err; \
98     + __get_user_size((x), (ptr), (size), __gu_err); \
99     __gu_err; \
100     })
101    
102     #define __get_user_check(x, ptr, size) \
103     ({ \
104     - long __gu_err = -EFAULT, __gu_val = 0; \
105     - const __typeof__(*(ptr)) * __gu_addr = (ptr); \
106     - if (access_ok(__gu_addr, size)) \
107     - __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
108     - (x) = (__force __typeof__(*(ptr)))__gu_val; \
109     + long __gu_err = -EFAULT; \
110     + const __typeof__(*(ptr)) *__gu_addr = (ptr); \
111     + if (access_ok(__gu_addr, size)) \
112     + __get_user_size((x), __gu_addr, (size), __gu_err); \
113     + else \
114     + (x) = (__typeof__(*(ptr))) 0; \
115     __gu_err; \
116     })
117    
118     @@ -190,11 +190,13 @@ do { \
119     case 2: __get_user_asm(x, ptr, retval, "l.lhz"); break; \
120     case 4: __get_user_asm(x, ptr, retval, "l.lwz"); break; \
121     case 8: __get_user_asm2(x, ptr, retval); break; \
122     - default: (x) = __get_user_bad(); \
123     + default: (x) = (__typeof__(*(ptr)))__get_user_bad(); \
124     } \
125     } while (0)
126    
127     #define __get_user_asm(x, addr, err, op) \
128     +{ \
129     + unsigned long __gu_tmp; \
130     __asm__ __volatile__( \
131     "1: "op" %1,0(%2)\n" \
132     "2:\n" \
133     @@ -208,10 +210,14 @@ do { \
134     " .align 2\n" \
135     " .long 1b,3b\n" \
136     ".previous" \
137     - : "=r"(err), "=r"(x) \
138     - : "r"(addr), "i"(-EFAULT), "0"(err))
139     + : "=r"(err), "=r"(__gu_tmp) \
140     + : "r"(addr), "i"(-EFAULT), "0"(err)); \
141     + (x) = (__typeof__(*(addr)))__gu_tmp; \
142     +}
143    
144     #define __get_user_asm2(x, addr, err) \
145     +{ \
146     + unsigned long long __gu_tmp; \
147     __asm__ __volatile__( \
148     "1: l.lwz %1,0(%2)\n" \
149     "2: l.lwz %H1,4(%2)\n" \
150     @@ -228,8 +234,11 @@ do { \
151     " .long 1b,4b\n" \
152     " .long 2b,4b\n" \
153     ".previous" \
154     - : "=r"(err), "=&r"(x) \
155     - : "r"(addr), "i"(-EFAULT), "0"(err))
156     + : "=r"(err), "=&r"(__gu_tmp) \
157     + : "r"(addr), "i"(-EFAULT), "0"(err)); \
158     + (x) = (__typeof__(*(addr)))( \
159     + (__typeof__((x)-(x)))__gu_tmp); \
160     +}
161    
162     /* more complex routines */
163    
164     diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
165     index d9b734d0c8cc7..3c6e01520a973 100644
166     --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
167     +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
168     @@ -170,7 +170,7 @@ continue_block:
169    
170     ## branch into array
171     lea jump_table(%rip), bufp
172     - movzxw (bufp, %rax, 2), len
173     + movzwq (bufp, %rax, 2), len
174     lea crc_array(%rip), bufp
175     lea (bufp, len, 1), bufp
176     JMP_NOSPEC bufp
177     diff --git a/arch/x86/events/amd/ibs.c b/arch/x86/events/amd/ibs.c
178     index 26c36357c4c9c..a023cbe21230a 100644
179     --- a/arch/x86/events/amd/ibs.c
180     +++ b/arch/x86/events/amd/ibs.c
181     @@ -89,6 +89,7 @@ struct perf_ibs {
182     u64 max_period;
183     unsigned long offset_mask[1];
184     int offset_max;
185     + unsigned int fetch_count_reset_broken : 1;
186     struct cpu_perf_ibs __percpu *pcpu;
187    
188     struct attribute **format_attrs;
189     @@ -363,7 +364,12 @@ perf_ibs_event_update(struct perf_ibs *perf_ibs, struct perf_event *event,
190     static inline void perf_ibs_enable_event(struct perf_ibs *perf_ibs,
191     struct hw_perf_event *hwc, u64 config)
192     {
193     - wrmsrl(hwc->config_base, hwc->config | config | perf_ibs->enable_mask);
194     + u64 tmp = hwc->config | config;
195     +
196     + if (perf_ibs->fetch_count_reset_broken)
197     + wrmsrl(hwc->config_base, tmp & ~perf_ibs->enable_mask);
198     +
199     + wrmsrl(hwc->config_base, tmp | perf_ibs->enable_mask);
200     }
201    
202     /*
203     @@ -733,6 +739,13 @@ static __init void perf_event_ibs_init(void)
204     {
205     struct attribute **attr = ibs_op_format_attrs;
206    
207     + /*
208     + * Some chips fail to reset the fetch count when it is written; instead
209     + * they need a 0-1 transition of IbsFetchEn.
210     + */
211     + if (boot_cpu_data.x86 >= 0x16 && boot_cpu_data.x86 <= 0x18)
212     + perf_ibs_fetch.fetch_count_reset_broken = 1;
213     +
214     perf_ibs_pmu_init(&perf_ibs_fetch, "ibs_fetch");
215    
216     if (ibs_caps & IBS_CAPS_OPCNT) {
217     diff --git a/arch/x86/pci/intel_mid_pci.c b/arch/x86/pci/intel_mid_pci.c
218     index 43867bc853687..eea5a0f3b959b 100644
219     --- a/arch/x86/pci/intel_mid_pci.c
220     +++ b/arch/x86/pci/intel_mid_pci.c
221     @@ -33,6 +33,7 @@
222     #include <asm/hw_irq.h>
223     #include <asm/io_apic.h>
224     #include <asm/intel-mid.h>
225     +#include <asm/acpi.h>
226    
227     #define PCIE_CAP_OFFSET 0x100
228    
229     diff --git a/arch/x86/xen/enlighten_pv.c b/arch/x86/xen/enlighten_pv.c
230     index 6d4d8a5700b71..3e66feff524a8 100644
231     --- a/arch/x86/xen/enlighten_pv.c
232     +++ b/arch/x86/xen/enlighten_pv.c
233     @@ -1382,6 +1382,15 @@ asmlinkage __visible void __init xen_start_kernel(void)
234     x86_init.mpparse.get_smp_config = x86_init_uint_noop;
235    
236     xen_boot_params_init_edd();
237     +
238     +#ifdef CONFIG_ACPI
239     + /*
240     + * Disable selecting "Firmware First mode" for correctable
241     + * memory errors, as this is the duty of the hypervisor to
242     + * decide.
243     + */
244     + acpi_disable_cmcff = 1;
245     +#endif
246     }
247    
248     if (!boot_params.screen_info.orig_video_isVGA)
249     diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
250     index 3dbf398c92eaf..9ef62e647cd20 100644
251     --- a/drivers/ata/ahci.h
252     +++ b/drivers/ata/ahci.h
253     @@ -240,6 +240,8 @@ enum {
254     as default lpm_policy */
255     AHCI_HFLAG_SUSPEND_PHYS = (1 << 26), /* handle PHYs during
256     suspend/resume */
257     + AHCI_HFLAG_IGN_NOTSUPP_POWER_ON = (1 << 27), /* ignore -EOPNOTSUPP
258     + from phy_power_on() */
259    
260     /* ap->flags bits */
261    
262     diff --git a/drivers/ata/ahci_mvebu.c b/drivers/ata/ahci_mvebu.c
263     index d4bba3ace45d7..3ad46d26d9d51 100644
264     --- a/drivers/ata/ahci_mvebu.c
265     +++ b/drivers/ata/ahci_mvebu.c
266     @@ -227,7 +227,7 @@ static const struct ahci_mvebu_plat_data ahci_mvebu_armada_380_plat_data = {
267    
268     static const struct ahci_mvebu_plat_data ahci_mvebu_armada_3700_plat_data = {
269     .plat_config = ahci_mvebu_armada_3700_config,
270     - .flags = AHCI_HFLAG_SUSPEND_PHYS,
271     + .flags = AHCI_HFLAG_SUSPEND_PHYS | AHCI_HFLAG_IGN_NOTSUPP_POWER_ON,
272     };
273    
274     static const struct of_device_id ahci_mvebu_of_match[] = {
275     diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c
276     index 129556fcf6be7..a1cbb894e5f0a 100644
277     --- a/drivers/ata/libahci_platform.c
278     +++ b/drivers/ata/libahci_platform.c
279     @@ -59,7 +59,7 @@ int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
280     }
281    
282     rc = phy_power_on(hpriv->phys[i]);
283     - if (rc) {
284     + if (rc && !(rc == -EOPNOTSUPP && (hpriv->flags & AHCI_HFLAG_IGN_NOTSUPP_POWER_ON))) {
285     phy_exit(hpriv->phys[i]);
286     goto disable_phys;
287     }
288     diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c
289     index 141ac600b64c8..44b0ed8f6bb8a 100644
290     --- a/drivers/ata/sata_rcar.c
291     +++ b/drivers/ata/sata_rcar.c
292     @@ -120,7 +120,7 @@
293     /* Descriptor table word 0 bit (when DTA32M = 1) */
294     #define SATA_RCAR_DTEND BIT(0)
295    
296     -#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFEUL
297     +#define SATA_RCAR_DMA_BOUNDARY 0x1FFFFFFFUL
298    
299     /* Gen2 Physical Layer Control Registers */
300     #define RCAR_GEN2_PHY_CTL1_REG 0x1704
301     diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.c b/drivers/crypto/chelsio/chtls/chtls_cm.c
302     index 9b410ffafc4dd..e2c64c943cfc7 100644
303     --- a/drivers/crypto/chelsio/chtls/chtls_cm.c
304     +++ b/drivers/crypto/chelsio/chtls/chtls_cm.c
305     @@ -692,14 +692,13 @@ static int chtls_pass_open_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
306     if (rpl->status != CPL_ERR_NONE) {
307     pr_info("Unexpected PASS_OPEN_RPL status %u for STID %u\n",
308     rpl->status, stid);
309     - return CPL_RET_BUF_DONE;
310     + } else {
311     + cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
312     + sock_put(listen_ctx->lsk);
313     + kfree(listen_ctx);
314     + module_put(THIS_MODULE);
315     }
316     - cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
317     - sock_put(listen_ctx->lsk);
318     - kfree(listen_ctx);
319     - module_put(THIS_MODULE);
320     -
321     - return 0;
322     + return CPL_RET_BUF_DONE;
323     }
324    
325     static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
326     @@ -716,15 +715,13 @@ static int chtls_close_listsrv_rpl(struct chtls_dev *cdev, struct sk_buff *skb)
327     if (rpl->status != CPL_ERR_NONE) {
328     pr_info("Unexpected CLOSE_LISTSRV_RPL status %u for STID %u\n",
329     rpl->status, stid);
330     - return CPL_RET_BUF_DONE;
331     + } else {
332     + cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
333     + sock_put(listen_ctx->lsk);
334     + kfree(listen_ctx);
335     + module_put(THIS_MODULE);
336     }
337     -
338     - cxgb4_free_stid(cdev->tids, stid, listen_ctx->lsk->sk_family);
339     - sock_put(listen_ctx->lsk);
340     - kfree(listen_ctx);
341     - module_put(THIS_MODULE);
342     -
343     - return 0;
344     + return CPL_RET_BUF_DONE;
345     }
346    
347     static void chtls_purge_wr_queue(struct sock *sk)
348     @@ -1369,7 +1366,6 @@ static void add_to_reap_list(struct sock *sk)
349     struct chtls_sock *csk = sk->sk_user_data;
350    
351     local_bh_disable();
352     - bh_lock_sock(sk);
353     release_tcp_port(sk); /* release the port immediately */
354    
355     spin_lock(&reap_list_lock);
356     @@ -1378,7 +1374,6 @@ static void add_to_reap_list(struct sock *sk)
357     if (!csk->passive_reap_next)
358     schedule_work(&reap_task);
359     spin_unlock(&reap_list_lock);
360     - bh_unlock_sock(sk);
361     local_bh_enable();
362     }
363    
364     diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c
365     index a5903cfc83523..4c44d7c0c2c1f 100644
366     --- a/drivers/crypto/chelsio/chtls/chtls_io.c
367     +++ b/drivers/crypto/chelsio/chtls/chtls_io.c
368     @@ -1537,6 +1537,7 @@ skip_copy:
369     tp->urg_data = 0;
370    
371     if ((avail + offset) >= skb->len) {
372     + struct sk_buff *next_skb;
373     if (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_TLS_HDR) {
374     tp->copied_seq += skb->len;
375     hws->rcvpld = skb->hdr_len;
376     @@ -1546,8 +1547,10 @@ skip_copy:
377     chtls_free_skb(sk, skb);
378     buffers_freed++;
379     hws->copied_seq = 0;
380     - if (copied >= target &&
381     - !skb_peek(&sk->sk_receive_queue))
382     + next_skb = skb_peek(&sk->sk_receive_queue);
383     + if (copied >= target && !next_skb)
384     + break;
385     + if (ULP_SKB_CB(next_skb)->flags & ULPCB_FLAG_TLS_HDR)
386     break;
387     }
388     } while (len > 0);
389     diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
390     index 1753a9801b704..8beed4197e73e 100644
391     --- a/drivers/infiniband/core/addr.c
392     +++ b/drivers/infiniband/core/addr.c
393     @@ -645,13 +645,12 @@ static void process_one_req(struct work_struct *_work)
394     req->callback = NULL;
395    
396     spin_lock_bh(&lock);
397     + /*
398     + * Although the work will normally have been canceled by the workqueue,
399     + * it can still be requeued as long as it is on the req_list.
400     + */
401     + cancel_delayed_work(&req->work);
402     if (!list_empty(&req->list)) {
403     - /*
404     - * Although the work will normally have been canceled by the
405     - * workqueue, it can still be requeued as long as it is on the
406     - * req_list.
407     - */
408     - cancel_delayed_work(&req->work);
409     list_del_init(&req->list);
410     kfree(req);
411     }
412     diff --git a/drivers/misc/cardreader/rtsx_pcr.c b/drivers/misc/cardreader/rtsx_pcr.c
413     index 4fd57052ddd3d..4c707d8dc3eb3 100644
414     --- a/drivers/misc/cardreader/rtsx_pcr.c
415     +++ b/drivers/misc/cardreader/rtsx_pcr.c
416     @@ -1189,10 +1189,6 @@ void rtsx_pci_init_ocp(struct rtsx_pcr *pcr)
417     rtsx_pci_write_register(pcr, REG_OCPGLITCH,
418     SD_OCP_GLITCH_MASK, pcr->hw_param.ocp_glitch);
419     rtsx_pci_enable_ocp(pcr);
420     - } else {
421     - /* OC power down */
422     - rtsx_pci_write_register(pcr, FPDCTL, OC_POWER_DOWN,
423     - OC_POWER_DOWN);
424     }
425     }
426     }
427     diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c
428     index 25a9dd9c0c1b5..2ba899f5659ff 100644
429     --- a/drivers/misc/cxl/pci.c
430     +++ b/drivers/misc/cxl/pci.c
431     @@ -393,8 +393,8 @@ int cxl_calc_capp_routing(struct pci_dev *dev, u64 *chipid,
432     *capp_unit_id = get_capp_unit_id(np, *phb_index);
433     of_node_put(np);
434     if (!*capp_unit_id) {
435     - pr_err("cxl: invalid capp unit id (phb_index: %d)\n",
436     - *phb_index);
437     + pr_err("cxl: No capp unit found for PHB[%lld,%d]. Make sure the adapter is on a capi-compatible slot\n",
438     + *chipid, *phb_index);
439     return -ENODEV;
440     }
441    
442     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
443     index 4f4fd80762610..cdd3764760ed9 100644
444     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
445     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
446     @@ -1160,16 +1160,6 @@ static void bnxt_queue_sp_work(struct bnxt *bp)
447     schedule_work(&bp->sp_task);
448     }
449    
450     -static void bnxt_cancel_sp_work(struct bnxt *bp)
451     -{
452     - if (BNXT_PF(bp)) {
453     - flush_workqueue(bnxt_pf_wq);
454     - } else {
455     - cancel_work_sync(&bp->sp_task);
456     - cancel_delayed_work_sync(&bp->fw_reset_task);
457     - }
458     -}
459     -
460     static void bnxt_sched_reset(struct bnxt *bp, struct bnxt_rx_ring_info *rxr)
461     {
462     if (!rxr->bnapi->in_reset) {
463     @@ -4204,7 +4194,8 @@ static int bnxt_hwrm_do_send_msg(struct bnxt *bp, void *msg, u32 msg_len,
464     u32 bar_offset = BNXT_GRCPF_REG_CHIMP_COMM;
465     u16 dst = BNXT_HWRM_CHNL_CHIMP;
466    
467     - if (BNXT_NO_FW_ACCESS(bp))
468     + if (BNXT_NO_FW_ACCESS(bp) &&
469     + le16_to_cpu(req->req_type) != HWRM_FUNC_RESET)
470     return -EBUSY;
471    
472     if (msg_len > BNXT_HWRM_MAX_REQ_LEN) {
473     @@ -9193,7 +9184,10 @@ int bnxt_open_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init)
474     {
475     int rc = 0;
476    
477     - rc = __bnxt_open_nic(bp, irq_re_init, link_re_init);
478     + if (test_bit(BNXT_STATE_ABORT_ERR, &bp->state))
479     + rc = -EIO;
480     + if (!rc)
481     + rc = __bnxt_open_nic(bp, irq_re_init, link_re_init);
482     if (rc) {
483     netdev_err(bp->dev, "nic open fail (rc: %x)\n", rc);
484     dev_close(bp->dev);
485     @@ -11392,13 +11386,15 @@ static void bnxt_remove_one(struct pci_dev *pdev)
486     if (BNXT_PF(bp))
487     bnxt_sriov_disable(bp);
488    
489     + pci_disable_pcie_error_reporting(pdev);
490     + unregister_netdev(dev);
491     clear_bit(BNXT_STATE_IN_FW_RESET, &bp->state);
492     - bnxt_cancel_sp_work(bp);
493     + /* Flush any pending tasks */
494     + cancel_work_sync(&bp->sp_task);
495     + cancel_delayed_work_sync(&bp->fw_reset_task);
496     bp->sp_event = 0;
497    
498     bnxt_dl_fw_reporters_destroy(bp, true);
499     - pci_disable_pcie_error_reporting(pdev);
500     - unregister_netdev(dev);
501     bnxt_dl_unregister(bp);
502     bnxt_shutdown_tc(bp);
503    
504     @@ -12045,6 +12041,9 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
505     return PCI_ERS_RESULT_DISCONNECT;
506     }
507    
508     + if (state == pci_channel_io_frozen)
509     + set_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN, &bp->state);
510     +
511     if (netif_running(netdev))
512     bnxt_close(netdev);
513    
514     @@ -12068,7 +12067,7 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
515     {
516     struct net_device *netdev = pci_get_drvdata(pdev);
517     struct bnxt *bp = netdev_priv(netdev);
518     - int err = 0;
519     + int err = 0, off;
520     pci_ers_result_t result = PCI_ERS_RESULT_DISCONNECT;
521    
522     netdev_info(bp->dev, "PCI Slot Reset\n");
523     @@ -12080,6 +12079,20 @@ static pci_ers_result_t bnxt_io_slot_reset(struct pci_dev *pdev)
524     "Cannot re-enable PCI device after reset.\n");
525     } else {
526     pci_set_master(pdev);
527     + /* Upon fatal error, our device internal logic that latches to
528     + * BAR value is getting reset and will restore only upon
529     + * rewritting the BARs.
530     + *
531     + * As pci_restore_state() does not re-write the BARs if the
532     + * value is same as saved value earlier, driver needs to
533     + * write the BARs to 0 to force restore, in case of fatal error.
534     + */
535     + if (test_and_clear_bit(BNXT_STATE_PCI_CHANNEL_IO_FROZEN,
536     + &bp->state)) {
537     + for (off = PCI_BASE_ADDRESS_0;
538     + off <= PCI_BASE_ADDRESS_5; off += 4)
539     + pci_write_config_dword(bp->pdev, off, 0);
540     + }
541     pci_restore_state(pdev);
542     pci_save_state(pdev);
543    
544     diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
545     index d2dd852d27da9..510ff01bdad8c 100644
546     --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
547     +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
548     @@ -1627,6 +1627,7 @@ struct bnxt {
549     #define BNXT_STATE_IN_FW_RESET 4
550     #define BNXT_STATE_ABORT_ERR 5
551     #define BNXT_STATE_FW_FATAL_COND 6
552     +#define BNXT_STATE_PCI_CHANNEL_IO_FROZEN 8
553    
554     #define BNXT_NO_FW_ACCESS(bp) \
555     (test_bit(BNXT_STATE_FW_FATAL_COND, &(bp)->state) || \
556     diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
557     index 137ff00605d94..202af8dc79662 100644
558     --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
559     +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
560     @@ -145,13 +145,13 @@ static int configure_filter_smac(struct adapter *adap, struct filter_entry *f)
561     int err;
562    
563     /* do a set-tcb for smac-sel and CWR bit.. */
564     - err = set_tcb_tflag(adap, f, f->tid, TF_CCTRL_CWR_S, 1, 1);
565     - if (err)
566     - goto smac_err;
567     -
568     err = set_tcb_field(adap, f, f->tid, TCB_SMAC_SEL_W,
569     TCB_SMAC_SEL_V(TCB_SMAC_SEL_M),
570     TCB_SMAC_SEL_V(f->smt->idx), 1);
571     + if (err)
572     + goto smac_err;
573     +
574     + err = set_tcb_tflag(adap, f, f->tid, TF_CCTRL_CWR_S, 1, 1);
575     if (!err)
576     return 0;
577    
578     @@ -612,6 +612,7 @@ int set_filter_wr(struct adapter *adapter, int fidx)
579     FW_FILTER_WR_DIRSTEERHASH_V(f->fs.dirsteerhash) |
580     FW_FILTER_WR_LPBK_V(f->fs.action == FILTER_SWITCH) |
581     FW_FILTER_WR_DMAC_V(f->fs.newdmac) |
582     + FW_FILTER_WR_SMAC_V(f->fs.newsmac) |
583     FW_FILTER_WR_INSVLAN_V(f->fs.newvlan == VLAN_INSERT ||
584     f->fs.newvlan == VLAN_REWRITE) |
585     FW_FILTER_WR_RMVLAN_V(f->fs.newvlan == VLAN_REMOVE ||
586     @@ -629,7 +630,7 @@ int set_filter_wr(struct adapter *adapter, int fidx)
587     FW_FILTER_WR_OVLAN_VLD_V(f->fs.val.ovlan_vld) |
588     FW_FILTER_WR_IVLAN_VLDM_V(f->fs.mask.ivlan_vld) |
589     FW_FILTER_WR_OVLAN_VLDM_V(f->fs.mask.ovlan_vld));
590     - fwr->smac_sel = 0;
591     + fwr->smac_sel = f->smt->idx;
592     fwr->rx_chan_rx_rpl_iq =
593     htons(FW_FILTER_WR_RX_CHAN_V(0) |
594     FW_FILTER_WR_RX_RPL_IQ_V(adapter->sge.fw_evtq.abs_id));
595     @@ -1048,11 +1049,8 @@ static void mk_act_open_req6(struct filter_entry *f, struct sk_buff *skb,
596     TX_QUEUE_V(f->fs.nat_mode) |
597     T5_OPT_2_VALID_F |
598     RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
599     - CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
600     - (f->fs.dirsteer << 1)) |
601     PACE_V((f->fs.maskhash) |
602     - ((f->fs.dirsteerhash) << 1)) |
603     - CCTRL_ECN_V(f->fs.action == FILTER_SWITCH));
604     + ((f->fs.dirsteerhash) << 1)));
605     }
606    
607     static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
608     @@ -1088,11 +1086,8 @@ static void mk_act_open_req(struct filter_entry *f, struct sk_buff *skb,
609     TX_QUEUE_V(f->fs.nat_mode) |
610     T5_OPT_2_VALID_F |
611     RX_CHANNEL_V(cxgb4_port_e2cchan(f->dev)) |
612     - CONG_CNTRL_V((f->fs.action == FILTER_DROP) |
613     - (f->fs.dirsteer << 1)) |
614     PACE_V((f->fs.maskhash) |
615     - ((f->fs.dirsteerhash) << 1)) |
616     - CCTRL_ECN_V(f->fs.action == FILTER_SWITCH));
617     + ((f->fs.dirsteerhash) << 1)));
618     }
619    
620     static int cxgb4_set_hash_filter(struct net_device *dev,
621     @@ -1748,6 +1743,20 @@ void hash_filter_rpl(struct adapter *adap, const struct cpl_act_open_rpl *rpl)
622     }
623     return;
624     }
625     + switch (f->fs.action) {
626     + case FILTER_PASS:
627     + if (f->fs.dirsteer)
628     + set_tcb_tflag(adap, f, tid,
629     + TF_DIRECT_STEER_S, 1, 1);
630     + break;
631     + case FILTER_DROP:
632     + set_tcb_tflag(adap, f, tid, TF_DROP_S, 1, 1);
633     + break;
634     + case FILTER_SWITCH:
635     + set_tcb_tflag(adap, f, tid, TF_LPBK_S, 1, 1);
636     + break;
637     + }
638     +
639     break;
640    
641     default:
642     @@ -1808,22 +1817,11 @@ void filter_rpl(struct adapter *adap, const struct cpl_set_tcb_rpl *rpl)
643     if (ctx)
644     ctx->result = 0;
645     } else if (ret == FW_FILTER_WR_FLT_ADDED) {
646     - int err = 0;
647     -
648     - if (f->fs.newsmac)
649     - err = configure_filter_smac(adap, f);
650     -
651     - if (!err) {
652     - f->pending = 0; /* async setup completed */
653     - f->valid = 1;
654     - if (ctx) {
655     - ctx->result = 0;
656     - ctx->tid = idx;
657     - }
658     - } else {
659     - clear_filter(adap, f);
660     - if (ctx)
661     - ctx->result = err;
662     + f->pending = 0; /* async setup completed */
663     + f->valid = 1;
664     + if (ctx) {
665     + ctx->result = 0;
666     + ctx->tid = idx;
667     }
668     } else {
669     /* Something went wrong. Issue a warning about the
670     diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h b/drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h
671     index 1b9afb192f7f8..358f0fe402701 100644
672     --- a/drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h
673     +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_tcb.h
674     @@ -50,6 +50,10 @@
675     #define TCB_RQ_START_M 0x3ffffffULL
676     #define TCB_RQ_START_V(x) ((x) << TCB_RQ_START_S)
677    
678     +#define TF_DROP_S 22
679     +#define TF_DIRECT_STEER_S 23
680     +#define TF_LPBK_S 59
681     +
682     #define TF_CCTRL_ECE_S 60
683     #define TF_CCTRL_CWR_S 61
684     #define TF_CCTRL_RFR_S 62
685     diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
686     index 7d7e712691b92..9b09dd95e8781 100644
687     --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
688     +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c
689     @@ -2782,8 +2782,8 @@ static void hclgevf_uninit_hdev(struct hclgevf_dev *hdev)
690     hclgevf_uninit_msi(hdev);
691     }
692    
693     - hclgevf_pci_uninit(hdev);
694     hclgevf_cmd_uninit(hdev);
695     + hclgevf_pci_uninit(hdev);
696     }
697    
698     static int hclgevf_init_ae_dev(struct hnae3_ae_dev *ae_dev)
699     diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
700     index 48105a2eebe4d..91559a52c7adb 100644
701     --- a/drivers/net/ethernet/ibm/ibmvnic.c
702     +++ b/drivers/net/ethernet/ibm/ibmvnic.c
703     @@ -1735,9 +1735,13 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p)
704     int rc;
705    
706     rc = 0;
707     - ether_addr_copy(adapter->mac_addr, addr->sa_data);
708     - if (adapter->state != VNIC_PROBED)
709     + if (!is_valid_ether_addr(addr->sa_data))
710     + return -EADDRNOTAVAIL;
711     +
712     + if (adapter->state != VNIC_PROBED) {
713     + ether_addr_copy(adapter->mac_addr, addr->sa_data);
714     rc = __ibmvnic_set_mac(netdev, addr->sa_data);
715     + }
716    
717     return rc;
718     }
719     diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.c b/drivers/net/ethernet/mellanox/mlxsw/core.c
720     index c7c3fc7d1126c..7277706847b18 100644
721     --- a/drivers/net/ethernet/mellanox/mlxsw/core.c
722     +++ b/drivers/net/ethernet/mellanox/mlxsw/core.c
723     @@ -1281,6 +1281,8 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
724     if (!reload)
725     devlink_resources_unregister(devlink, NULL);
726     mlxsw_core->bus->fini(mlxsw_core->bus_priv);
727     + if (!reload)
728     + devlink_free(devlink);
729    
730     return;
731    
732     diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
733     index f838abdb35e1d..d8881ba773dee 100644
734     --- a/drivers/net/ethernet/realtek/r8169_main.c
735     +++ b/drivers/net/ethernet/realtek/r8169_main.c
736     @@ -6264,7 +6264,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance)
737     }
738    
739     rtl_irq_disable(tp);
740     - napi_schedule_irqoff(&tp->napi);
741     + napi_schedule(&tp->napi);
742     out:
743     rtl_ack_events(tp, status);
744    
745     @@ -6470,7 +6470,7 @@ static int rtl_open(struct net_device *dev)
746     rtl_request_firmware(tp);
747    
748     retval = request_irq(pci_irq_vector(pdev, 0), rtl8169_interrupt,
749     - IRQF_NO_THREAD | IRQF_SHARED, dev->name, tp);
750     + IRQF_SHARED, dev->name, tp);
751     if (retval < 0)
752     goto err_release_fw_2;
753    
754     diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
755     index 30cdabf64ccc1..551799fb3842d 100644
756     --- a/drivers/net/ethernet/renesas/ravb_main.c
757     +++ b/drivers/net/ethernet/renesas/ravb_main.c
758     @@ -1741,12 +1741,16 @@ static int ravb_hwtstamp_get(struct net_device *ndev, struct ifreq *req)
759     config.flags = 0;
760     config.tx_type = priv->tstamp_tx_ctrl ? HWTSTAMP_TX_ON :
761     HWTSTAMP_TX_OFF;
762     - if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_V2_L2_EVENT)
763     + switch (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE) {
764     + case RAVB_RXTSTAMP_TYPE_V2_L2_EVENT:
765     config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
766     - else if (priv->tstamp_rx_ctrl & RAVB_RXTSTAMP_TYPE_ALL)
767     + break;
768     + case RAVB_RXTSTAMP_TYPE_ALL:
769     config.rx_filter = HWTSTAMP_FILTER_ALL;
770     - else
771     + break;
772     + default:
773     config.rx_filter = HWTSTAMP_FILTER_NONE;
774     + }
775    
776     return copy_to_user(req->ifr_data, &config, sizeof(config)) ?
777     -EFAULT : 0;
778     diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
779     index 634bdea38ecb3..4e19c3149848b 100644
780     --- a/drivers/net/gtp.c
781     +++ b/drivers/net/gtp.c
782     @@ -663,10 +663,6 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
783    
784     gtp = netdev_priv(dev);
785    
786     - err = gtp_encap_enable(gtp, data);
787     - if (err < 0)
788     - return err;
789     -
790     if (!data[IFLA_GTP_PDP_HASHSIZE]) {
791     hashsize = 1024;
792     } else {
793     @@ -677,12 +673,16 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
794    
795     err = gtp_hashtable_new(gtp, hashsize);
796     if (err < 0)
797     - goto out_encap;
798     + return err;
799     +
800     + err = gtp_encap_enable(gtp, data);
801     + if (err < 0)
802     + goto out_hashtable;
803    
804     err = register_netdevice(dev);
805     if (err < 0) {
806     netdev_dbg(dev, "failed to register new netdev %d\n", err);
807     - goto out_hashtable;
808     + goto out_encap;
809     }
810    
811     gn = net_generic(dev_net(dev), gtp_net_id);
812     @@ -693,11 +693,11 @@ static int gtp_newlink(struct net *src_net, struct net_device *dev,
813    
814     return 0;
815    
816     +out_encap:
817     + gtp_encap_disable(gtp);
818     out_hashtable:
819     kfree(gtp->addr_hash);
820     kfree(gtp->tid_hash);
821     -out_encap:
822     - gtp_encap_disable(gtp);
823     return err;
824     }
825    
826     diff --git a/drivers/net/wireless/intersil/p54/p54pci.c b/drivers/net/wireless/intersil/p54/p54pci.c
827     index 80ad0b7eaef43..f8c6027cab6b4 100644
828     --- a/drivers/net/wireless/intersil/p54/p54pci.c
829     +++ b/drivers/net/wireless/intersil/p54/p54pci.c
830     @@ -329,10 +329,12 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
831     struct p54p_desc *desc;
832     dma_addr_t mapping;
833     u32 idx, i;
834     + __le32 device_addr;
835    
836     spin_lock_irqsave(&priv->lock, flags);
837     idx = le32_to_cpu(ring_control->host_idx[1]);
838     i = idx % ARRAY_SIZE(ring_control->tx_data);
839     + device_addr = ((struct p54_hdr *)skb->data)->req_id;
840    
841     mapping = pci_map_single(priv->pdev, skb->data, skb->len,
842     PCI_DMA_TODEVICE);
843     @@ -346,7 +348,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
844    
845     desc = &ring_control->tx_data[i];
846     desc->host_addr = cpu_to_le32(mapping);
847     - desc->device_addr = ((struct p54_hdr *)skb->data)->req_id;
848     + desc->device_addr = device_addr;
849     desc->len = cpu_to_le16(skb->len);
850     desc->flags = 0;
851    
852     diff --git a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
853     index 1a138be8bd6a0..810f25a476321 100644
854     --- a/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
855     +++ b/drivers/phy/marvell/phy-mvebu-a3700-comphy.c
856     @@ -26,7 +26,6 @@
857     #define COMPHY_SIP_POWER_ON 0x82000001
858     #define COMPHY_SIP_POWER_OFF 0x82000002
859     #define COMPHY_SIP_PLL_LOCK 0x82000003
860     -#define COMPHY_FW_NOT_SUPPORTED (-1)
861    
862     #define COMPHY_FW_MODE_SATA 0x1
863     #define COMPHY_FW_MODE_SGMII 0x2
864     @@ -112,10 +111,19 @@ static int mvebu_a3700_comphy_smc(unsigned long function, unsigned long lane,
865     unsigned long mode)
866     {
867     struct arm_smccc_res res;
868     + s32 ret;
869    
870     arm_smccc_smc(function, lane, mode, 0, 0, 0, 0, 0, &res);
871     + ret = res.a0;
872    
873     - return res.a0;
874     + switch (ret) {
875     + case SMCCC_RET_SUCCESS:
876     + return 0;
877     + case SMCCC_RET_NOT_SUPPORTED:
878     + return -EOPNOTSUPP;
879     + default:
880     + return -EINVAL;
881     + }
882     }
883    
884     static int mvebu_a3700_comphy_get_fw_mode(int lane, int port,
885     @@ -220,7 +228,7 @@ static int mvebu_a3700_comphy_power_on(struct phy *phy)
886     }
887    
888     ret = mvebu_a3700_comphy_smc(COMPHY_SIP_POWER_ON, lane->id, fw_param);
889     - if (ret == COMPHY_FW_NOT_SUPPORTED)
890     + if (ret == -EOPNOTSUPP)
891     dev_err(lane->dev,
892     "unsupported SMC call, try updating your firmware\n");
893    
894     diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
895     index e3b87c94aaf69..849351b4805f5 100644
896     --- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
897     +++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
898     @@ -123,7 +123,6 @@
899    
900     #define COMPHY_SIP_POWER_ON 0x82000001
901     #define COMPHY_SIP_POWER_OFF 0x82000002
902     -#define COMPHY_FW_NOT_SUPPORTED (-1)
903    
904     /*
905     * A lane is described by the following bitfields:
906     @@ -273,10 +272,19 @@ static int mvebu_comphy_smc(unsigned long function, unsigned long phys,
907     unsigned long lane, unsigned long mode)
908     {
909     struct arm_smccc_res res;
910     + s32 ret;
911    
912     arm_smccc_smc(function, phys, lane, mode, 0, 0, 0, 0, &res);
913     + ret = res.a0;
914    
915     - return res.a0;
916     + switch (ret) {
917     + case SMCCC_RET_SUCCESS:
918     + return 0;
919     + case SMCCC_RET_NOT_SUPPORTED:
920     + return -EOPNOTSUPP;
921     + default:
922     + return -EINVAL;
923     + }
924     }
925    
926     static int mvebu_comphy_get_mode(bool fw_mode, int lane, int port,
927     @@ -819,7 +827,7 @@ static int mvebu_comphy_power_on(struct phy *phy)
928     if (!ret)
929     return ret;
930    
931     - if (ret == COMPHY_FW_NOT_SUPPORTED)
932     + if (ret == -EOPNOTSUPP)
933     dev_err(priv->dev,
934     "unsupported SMC call, try updating your firmware\n");
935    
936     diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
937     index a8a538b34b535..16720c97a4dde 100644
938     --- a/drivers/tty/serial/amba-pl011.c
939     +++ b/drivers/tty/serial/amba-pl011.c
940     @@ -313,8 +313,9 @@ static void pl011_write(unsigned int val, const struct uart_amba_port *uap,
941     */
942     static int pl011_fifo_to_tty(struct uart_amba_port *uap)
943     {
944     - u16 status;
945     unsigned int ch, flag, fifotaken;
946     + int sysrq;
947     + u16 status;
948    
949     for (fifotaken = 0; fifotaken != 256; fifotaken++) {
950     status = pl011_read(uap, REG_FR);
951     @@ -349,10 +350,12 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap)
952     flag = TTY_FRAME;
953     }
954    
955     - if (uart_handle_sysrq_char(&uap->port, ch & 255))
956     - continue;
957     + spin_unlock(&uap->port.lock);
958     + sysrq = uart_handle_sysrq_char(&uap->port, ch & 255);
959     + spin_lock(&uap->port.lock);
960    
961     - uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
962     + if (!sysrq)
963     + uart_insert_char(&uap->port, ch, UART011_DR_OE, ch, flag);
964     }
965    
966     return fifotaken;
967     diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
968     index 0b184256034fb..9b148f78323f0 100644
969     --- a/drivers/tty/serial/qcom_geni_serial.c
970     +++ b/drivers/tty/serial/qcom_geni_serial.c
971     @@ -970,7 +970,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
972     sampling_rate = UART_OVERSAMPLING;
973     /* Sampling rate is halved for IP versions >= 2.5 */
974     ver = geni_se_get_qup_hw_version(&port->se);
975     - if (GENI_SE_VERSION_MAJOR(ver) >= 2 && GENI_SE_VERSION_MINOR(ver) >= 5)
976     + if (ver >= QUP_SE_VERSION_2_5)
977     sampling_rate /= 2;
978    
979     clk_rate = get_clk_div_rate(baud, sampling_rate, &clk_div);
980     diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
981     index 81401f386c9ce..246864bbb3e4e 100644
982     --- a/drivers/xen/gntdev.c
983     +++ b/drivers/xen/gntdev.c
984     @@ -831,17 +831,18 @@ struct gntdev_copy_batch {
985     s16 __user *status[GNTDEV_COPY_BATCH];
986     unsigned int nr_ops;
987     unsigned int nr_pages;
988     + bool writeable;
989     };
990    
991     static int gntdev_get_page(struct gntdev_copy_batch *batch, void __user *virt,
992     - bool writeable, unsigned long *gfn)
993     + unsigned long *gfn)
994     {
995     unsigned long addr = (unsigned long)virt;
996     struct page *page;
997     unsigned long xen_pfn;
998     int ret;
999    
1000     - ret = get_user_pages_fast(addr, 1, writeable ? FOLL_WRITE : 0, &page);
1001     + ret = get_user_pages_fast(addr, 1, batch->writeable ? FOLL_WRITE : 0, &page);
1002     if (ret < 0)
1003     return ret;
1004    
1005     @@ -857,9 +858,13 @@ static void gntdev_put_pages(struct gntdev_copy_batch *batch)
1006     {
1007     unsigned int i;
1008    
1009     - for (i = 0; i < batch->nr_pages; i++)
1010     + for (i = 0; i < batch->nr_pages; i++) {
1011     + if (batch->writeable && !PageDirty(batch->pages[i]))
1012     + set_page_dirty_lock(batch->pages[i]);
1013     put_page(batch->pages[i]);
1014     + }
1015     batch->nr_pages = 0;
1016     + batch->writeable = false;
1017     }
1018    
1019     static int gntdev_copy(struct gntdev_copy_batch *batch)
1020     @@ -948,8 +953,9 @@ static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch,
1021     virt = seg->source.virt + copied;
1022     off = (unsigned long)virt & ~XEN_PAGE_MASK;
1023     len = min(len, (size_t)XEN_PAGE_SIZE - off);
1024     + batch->writeable = false;
1025    
1026     - ret = gntdev_get_page(batch, virt, false, &gfn);
1027     + ret = gntdev_get_page(batch, virt, &gfn);
1028     if (ret < 0)
1029     return ret;
1030    
1031     @@ -967,8 +973,9 @@ static int gntdev_grant_copy_seg(struct gntdev_copy_batch *batch,
1032     virt = seg->dest.virt + copied;
1033     off = (unsigned long)virt & ~XEN_PAGE_MASK;
1034     len = min(len, (size_t)XEN_PAGE_SIZE - off);
1035     + batch->writeable = true;
1036    
1037     - ret = gntdev_get_page(batch, virt, true, &gfn);
1038     + ret = gntdev_get_page(batch, virt, &gfn);
1039     if (ret < 0)
1040     return ret;
1041    
1042     diff --git a/fs/efivarfs/super.c b/fs/efivarfs/super.c
1043     index fa4f6447ddad6..9760a52800b42 100644
1044     --- a/fs/efivarfs/super.c
1045     +++ b/fs/efivarfs/super.c
1046     @@ -141,6 +141,9 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
1047    
1048     name[len + EFI_VARIABLE_GUID_LEN+1] = '\0';
1049    
1050     + /* replace invalid slashes like kobject_set_name_vargs does for /sys/firmware/efi/vars. */
1051     + strreplace(name, '/', '!');
1052     +
1053     inode = efivarfs_get_inode(sb, d_inode(root), S_IFREG | 0644, 0,
1054     is_removable);
1055     if (!inode)
1056     diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
1057     index b766c3ee5fa8c..503bea20cde26 100644
1058     --- a/fs/erofs/xattr.c
1059     +++ b/fs/erofs/xattr.c
1060     @@ -473,8 +473,6 @@ static int erofs_xattr_generic_get(const struct xattr_handler *handler,
1061     return -EOPNOTSUPP;
1062     break;
1063     case EROFS_XATTR_INDEX_TRUSTED:
1064     - if (!capable(CAP_SYS_ADMIN))
1065     - return -EPERM;
1066     break;
1067     case EROFS_XATTR_INDEX_SECURITY:
1068     break;
1069     diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
1070     index f9022b7028754..40c262b3f9ff5 100644
1071     --- a/fs/fuse/dev.c
1072     +++ b/fs/fuse/dev.c
1073     @@ -786,15 +786,16 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
1074     struct page *newpage;
1075     struct pipe_buffer *buf = cs->pipebufs;
1076    
1077     + get_page(oldpage);
1078     err = unlock_request(cs->req);
1079     if (err)
1080     - return err;
1081     + goto out_put_old;
1082    
1083     fuse_copy_finish(cs);
1084    
1085     err = pipe_buf_confirm(cs->pipe, buf);
1086     if (err)
1087     - return err;
1088     + goto out_put_old;
1089    
1090     BUG_ON(!cs->nr_segs);
1091     cs->currbuf = buf;
1092     @@ -834,7 +835,7 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
1093     err = replace_page_cache_page(oldpage, newpage, GFP_KERNEL);
1094     if (err) {
1095     unlock_page(newpage);
1096     - return err;
1097     + goto out_put_old;
1098     }
1099    
1100     get_page(newpage);
1101     @@ -853,14 +854,19 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep)
1102     if (err) {
1103     unlock_page(newpage);
1104     put_page(newpage);
1105     - return err;
1106     + goto out_put_old;
1107     }
1108    
1109     unlock_page(oldpage);
1110     + /* Drop ref for ap->pages[] array */
1111     put_page(oldpage);
1112     cs->len = 0;
1113    
1114     - return 0;
1115     + err = 0;
1116     +out_put_old:
1117     + /* Drop ref obtained in this function */
1118     + put_page(oldpage);
1119     + return err;
1120    
1121     out_fallback_unlock:
1122     unlock_page(newpage);
1123     @@ -869,10 +875,10 @@ out_fallback:
1124     cs->offset = buf->offset;
1125    
1126     err = lock_request(cs->req);
1127     - if (err)
1128     - return err;
1129     + if (!err)
1130     + err = 1;
1131    
1132     - return 1;
1133     + goto out_put_old;
1134     }
1135    
1136     static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
1137     @@ -884,14 +890,16 @@ static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page,
1138     if (cs->nr_segs == cs->pipe->buffers)
1139     return -EIO;
1140    
1141     + get_page(page);
1142     err = unlock_request(cs->req);
1143     - if (err)
1144     + if (err) {
1145     + put_page(page);
1146     return err;
1147     + }
1148    
1149     fuse_copy_finish(cs);
1150    
1151     buf = cs->pipebufs;
1152     - get_page(page);
1153     buf->page = page;
1154     buf->offset = offset;
1155     buf->len = count;
1156     diff --git a/include/linux/mtd/pfow.h b/include/linux/mtd/pfow.h
1157     index 122f3439e1af2..c65d7a3be3c69 100644
1158     --- a/include/linux/mtd/pfow.h
1159     +++ b/include/linux/mtd/pfow.h
1160     @@ -128,7 +128,7 @@ static inline void print_drs_error(unsigned dsr)
1161    
1162     if (!(dsr & DSR_AVAILABLE))
1163     printk(KERN_NOTICE"DSR.15: (0) Device not Available\n");
1164     - if (prog_status & 0x03)
1165     + if ((prog_status & 0x03) == 0x03)
1166     printk(KERN_NOTICE"DSR.9,8: (11) Attempt to program invalid "
1167     "half with 41h command\n");
1168     else if (prog_status & 0x02)
1169     diff --git a/include/linux/pm.h b/include/linux/pm.h
1170     index 4c441be03079d..c1d21e9a864f3 100644
1171     --- a/include/linux/pm.h
1172     +++ b/include/linux/pm.h
1173     @@ -598,7 +598,7 @@ struct dev_pm_info {
1174     #endif
1175     #ifdef CONFIG_PM
1176     struct hrtimer suspend_timer;
1177     - unsigned long timer_expires;
1178     + u64 timer_expires;
1179     struct work_struct work;
1180     wait_queue_head_t wait_queue;
1181     struct wake_irq *wakeirq;
1182     diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h
1183     index dd464943f717a..5b90eff50bf6e 100644
1184     --- a/include/linux/qcom-geni-se.h
1185     +++ b/include/linux/qcom-geni-se.h
1186     @@ -229,6 +229,9 @@ struct geni_se {
1187     #define GENI_SE_VERSION_MINOR(ver) ((ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT)
1188     #define GENI_SE_VERSION_STEP(ver) (ver & HW_VER_STEP_MASK)
1189    
1190     +/* QUP SE VERSION value for major number 2 and minor number 5 */
1191     +#define QUP_SE_VERSION_2_5 0x20050000
1192     +
1193     #if IS_ENABLED(CONFIG_QCOM_GENI_SE)
1194    
1195     u32 geni_se_get_qup_hw_version(struct geni_se *se);
1196     diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
1197     index bc2c73f549622..a576bcbba2fcc 100644
1198     --- a/include/net/netfilter/nf_tables.h
1199     +++ b/include/net/netfilter/nf_tables.h
1200     @@ -872,6 +872,12 @@ static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule)
1201     return (struct nft_expr *)&rule->data[rule->dlen];
1202     }
1203    
1204     +static inline bool nft_expr_more(const struct nft_rule *rule,
1205     + const struct nft_expr *expr)
1206     +{
1207     + return expr != nft_expr_last(rule) && expr->ops;
1208     +}
1209     +
1210     static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)
1211     {
1212     return (void *)&rule->data[rule->dlen];
1213     diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
1214     index 77c6be96d6762..8649422e760cc 100644
1215     --- a/include/uapi/linux/bpf.h
1216     +++ b/include/uapi/linux/bpf.h
1217     @@ -1294,8 +1294,8 @@ union bpf_attr {
1218     * Return
1219     * The return value depends on the result of the test, and can be:
1220     *
1221     - * * 0, if the *skb* task belongs to the cgroup2.
1222     - * * 1, if the *skb* task does not belong to the cgroup2.
1223     + * * 0, if current task belongs to the cgroup2.
1224     + * * 1, if current task does not belong to the cgroup2.
1225     * * A negative error code, if an error occurred.
1226     *
1227     * int bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags)
1228     diff --git a/net/core/sock.c b/net/core/sock.c
1229     index 1b765e62658f0..33543d59a10d6 100644
1230     --- a/net/core/sock.c
1231     +++ b/net/core/sock.c
1232     @@ -923,7 +923,6 @@ set_rcvbuf:
1233     } else {
1234     sock_reset_flag(sk, SOCK_RCVTSTAMP);
1235     sock_reset_flag(sk, SOCK_RCVTSTAMPNS);
1236     - sock_reset_flag(sk, SOCK_TSTAMP_NEW);
1237     }
1238     break;
1239    
1240     diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
1241     index 97f2b11ce2034..d3ced6a39bcf1 100644
1242     --- a/net/ipv4/tcp.c
1243     +++ b/net/ipv4/tcp.c
1244     @@ -484,6 +484,8 @@ static inline bool tcp_stream_is_readable(const struct tcp_sock *tp,
1245     return true;
1246     if (tcp_rmem_pressure(sk))
1247     return true;
1248     + if (tcp_receive_window(tp) <= inet_csk(sk)->icsk_ack.rcv_mss)
1249     + return true;
1250     }
1251     if (sk->sk_prot->stream_memory_read)
1252     return sk->sk_prot->stream_memory_read(sk);
1253     diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
1254     index 62f8ba4048180..54fd6bc5adcca 100644
1255     --- a/net/ipv4/tcp_input.c
1256     +++ b/net/ipv4/tcp_input.c
1257     @@ -4774,7 +4774,8 @@ void tcp_data_ready(struct sock *sk)
1258     int avail = tp->rcv_nxt - tp->copied_seq;
1259    
1260     if (avail < sk->sk_rcvlowat && !tcp_rmem_pressure(sk) &&
1261     - !sock_flag(sk, SOCK_DONE))
1262     + !sock_flag(sk, SOCK_DONE) &&
1263     + tcp_receive_window(tp) > inet_csk(sk)->icsk_ack.rcv_mss)
1264     return;
1265    
1266     sk->sk_data_ready(sk);
1267     diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
1268     index ff2d2b514506e..5a77b7a177229 100644
1269     --- a/net/netfilter/nf_tables_api.c
1270     +++ b/net/netfilter/nf_tables_api.c
1271     @@ -254,7 +254,7 @@ static void nft_rule_expr_activate(const struct nft_ctx *ctx,
1272     struct nft_expr *expr;
1273    
1274     expr = nft_expr_first(rule);
1275     - while (expr != nft_expr_last(rule) && expr->ops) {
1276     + while (nft_expr_more(rule, expr)) {
1277     if (expr->ops->activate)
1278     expr->ops->activate(ctx, expr);
1279    
1280     @@ -269,7 +269,7 @@ static void nft_rule_expr_deactivate(const struct nft_ctx *ctx,
1281     struct nft_expr *expr;
1282    
1283     expr = nft_expr_first(rule);
1284     - while (expr != nft_expr_last(rule) && expr->ops) {
1285     + while (nft_expr_more(rule, expr)) {
1286     if (expr->ops->deactivate)
1287     expr->ops->deactivate(ctx, expr, phase);
1288    
1289     @@ -2642,7 +2642,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,
1290     * is called on error from nf_tables_newrule().
1291     */
1292     expr = nft_expr_first(rule);
1293     - while (expr != nft_expr_last(rule) && expr->ops) {
1294     + while (nft_expr_more(rule, expr)) {
1295     next = nft_expr_next(expr);
1296     nf_tables_expr_destroy(ctx, expr);
1297     expr = next;
1298     diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
1299     index 914cd0618d5a6..c480549a7f946 100644
1300     --- a/net/netfilter/nf_tables_offload.c
1301     +++ b/net/netfilter/nf_tables_offload.c
1302     @@ -37,7 +37,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,
1303     struct nft_expr *expr;
1304    
1305     expr = nft_expr_first(rule);
1306     - while (expr->ops && expr != nft_expr_last(rule)) {
1307     + while (nft_expr_more(rule, expr)) {
1308     if (expr->ops->offload_flags & NFT_OFFLOAD_F_ACTION)
1309     num_actions++;
1310    
1311     @@ -61,7 +61,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,
1312     ctx->net = net;
1313     ctx->dep.type = NFT_OFFLOAD_DEP_UNSPEC;
1314    
1315     - while (expr->ops && expr != nft_expr_last(rule)) {
1316     + while (nft_expr_more(rule, expr)) {
1317     if (!expr->ops->offload) {
1318     err = -EOPNOTSUPP;
1319     goto err_out;
1320     diff --git a/net/sched/act_mpls.c b/net/sched/act_mpls.c
1321     index f496c99d98266..7954021ade33d 100644
1322     --- a/net/sched/act_mpls.c
1323     +++ b/net/sched/act_mpls.c
1324     @@ -408,6 +408,7 @@ static void __exit mpls_cleanup_module(void)
1325     module_init(mpls_init_module);
1326     module_exit(mpls_cleanup_module);
1327    
1328     +MODULE_SOFTDEP("post: mpls_gso");
1329     MODULE_AUTHOR("Netronome Systems <oss-drivers@netronome.com>");
1330     MODULE_LICENSE("GPL");
1331     MODULE_DESCRIPTION("MPLS manipulation actions");
1332     diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
1333     index 42e557d48e4e3..f4101a920d1f9 100644
1334     --- a/net/sched/sch_netem.c
1335     +++ b/net/sched/sch_netem.c
1336     @@ -330,7 +330,7 @@ static s64 tabledist(s64 mu, s32 sigma,
1337    
1338     /* default uniform distribution */
1339     if (dist == NULL)
1340     - return ((rnd % (2 * sigma)) + mu) - sigma;
1341     + return ((rnd % (2 * (u32)sigma)) + mu) - sigma;
1342    
1343     t = dist->table[rnd % dist->size];
1344     x = (sigma % NETEM_DIST_SCALE) * t;
1345     @@ -812,6 +812,10 @@ static void get_slot(struct netem_sched_data *q, const struct nlattr *attr)
1346     q->slot_config.max_packets = INT_MAX;
1347     if (q->slot_config.max_bytes == 0)
1348     q->slot_config.max_bytes = INT_MAX;
1349     +
1350     + /* capping dist_jitter to the range acceptable by tabledist() */
1351     + q->slot_config.dist_jitter = min_t(__s64, INT_MAX, abs(q->slot_config.dist_jitter));
1352     +
1353     q->slot.packets_left = q->slot_config.max_packets;
1354     q->slot.bytes_left = q->slot_config.max_bytes;
1355     if (q->slot_config.min_delay | q->slot_config.max_delay |
1356     @@ -1037,6 +1041,9 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,
1357     if (tb[TCA_NETEM_SLOT])
1358     get_slot(q, tb[TCA_NETEM_SLOT]);
1359    
1360     + /* capping jitter to the range acceptable by tabledist() */
1361     + q->jitter = min_t(s64, abs(q->jitter), INT_MAX);
1362     +
1363     return ret;
1364    
1365     get_table_failure:
1366     diff --git a/net/tipc/msg.c b/net/tipc/msg.c
1367     index b0ed3c944b2d1..46e89c992c2dc 100644
1368     --- a/net/tipc/msg.c
1369     +++ b/net/tipc/msg.c
1370     @@ -140,12 +140,11 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf)
1371     if (fragid == FIRST_FRAGMENT) {
1372     if (unlikely(head))
1373     goto err;
1374     - if (skb_cloned(frag))
1375     - frag = skb_copy(frag, GFP_ATOMIC);
1376     + *buf = NULL;
1377     + frag = skb_unshare(frag, GFP_ATOMIC);
1378     if (unlikely(!frag))
1379     goto err;
1380     head = *headbuf = frag;
1381     - *buf = NULL;
1382     TIPC_SKB_CB(head)->tail = NULL;
1383     if (skb_is_nonlinear(head)) {
1384     skb_walk_frags(head, tail) {
1385     diff --git a/scripts/setlocalversion b/scripts/setlocalversion
1386     index a2998b118ef9e..45609dba7d724 100755
1387     --- a/scripts/setlocalversion
1388     +++ b/scripts/setlocalversion
1389     @@ -45,7 +45,7 @@ scm_version()
1390    
1391     # Check for git and a git repo.
1392     if test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
1393     - head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
1394     + head=$(git rev-parse --verify HEAD 2>/dev/null); then
1395    
1396     # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
1397     # it, because this version is defined in the top level Makefile.
1398     @@ -59,11 +59,22 @@ scm_version()
1399     fi
1400     # If we are past a tagged commit (like
1401     # "v2.6.30-rc5-302-g72357d5"), we pretty print it.
1402     - if atag="`git describe 2>/dev/null`"; then
1403     - echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
1404     -
1405     - # If we don't have a tag at all we print -g{commitish}.
1406     + #
1407     + # Ensure the abbreviated sha1 has exactly 12
1408     + # hex characters, to make the output
1409     + # independent of git version, local
1410     + # core.abbrev settings and/or total number of
1411     + # objects in the current repository - passing
1412     + # --abbrev=12 ensures a minimum of 12, and the
1413     + # awk substr() then picks the 'g' and first 12
1414     + # hex chars.
1415     + if atag="$(git describe --abbrev=12 2>/dev/null)"; then
1416     + echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}'
1417     +
1418     + # If we don't have a tag at all we print -g{commitish},
1419     + # again using exactly 12 hex chars.
1420     else
1421     + head="$(echo $head | cut -c1-12)"
1422     printf '%s%s' -g $head
1423     fi
1424     fi
1425     diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
1426     index a2c393385db09..615094eda36d6 100644
1427     --- a/security/integrity/evm/evm_main.c
1428     +++ b/security/integrity/evm/evm_main.c
1429     @@ -183,6 +183,12 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
1430     break;
1431     case EVM_IMA_XATTR_DIGSIG:
1432     case EVM_XATTR_PORTABLE_DIGSIG:
1433     + /* accept xattr with non-empty signature field */
1434     + if (xattr_len <= sizeof(struct signature_v2_hdr)) {
1435     + evm_status = INTEGRITY_FAIL;
1436     + goto out;
1437     + }
1438     +
1439     hdr = (struct signature_v2_hdr *)xattr_data;
1440     digest.hdr.algo = hdr->hash_algo;
1441     rc = evm_calc_hash(dentry, xattr_name, xattr_value,
1442     diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
1443     index 77c6be96d6762..8649422e760cc 100644
1444     --- a/tools/include/uapi/linux/bpf.h
1445     +++ b/tools/include/uapi/linux/bpf.h
1446     @@ -1294,8 +1294,8 @@ union bpf_attr {
1447     * Return
1448     * The return value depends on the result of the test, and can be:
1449     *
1450     - * * 0, if the *skb* task belongs to the cgroup2.
1451     - * * 1, if the *skb* task does not belong to the cgroup2.
1452     + * * 0, if current task belongs to the cgroup2.
1453     + * * 1, if current task does not belong to the cgroup2.
1454     * * A negative error code, if an error occurred.
1455     *
1456     * int bpf_skb_change_tail(struct sk_buff *skb, u32 len, u64 flags)
1457     diff --git a/tools/objtool/orc_gen.c b/tools/objtool/orc_gen.c
1458     index 27a4112848c2b..e8c34b0a8b00c 100644
1459     --- a/tools/objtool/orc_gen.c
1460     +++ b/tools/objtool/orc_gen.c
1461     @@ -88,11 +88,6 @@ static int create_orc_entry(struct section *u_sec, struct section *ip_relasec,
1462     struct orc_entry *orc;
1463     struct rela *rela;
1464    
1465     - if (!insn_sec->sym) {
1466     - WARN("missing symbol for section %s", insn_sec->name);
1467     - return -1;
1468     - }
1469     -
1470     /* populate ORC data */
1471     orc = (struct orc_entry *)u_sec->data->d_buf + idx;
1472     memcpy(orc, o, sizeof(*orc));
1473     @@ -105,8 +100,32 @@ static int create_orc_entry(struct section *u_sec, struct section *ip_relasec,
1474     }
1475     memset(rela, 0, sizeof(*rela));
1476    
1477     - rela->sym = insn_sec->sym;
1478     - rela->addend = insn_off;
1479     + if (insn_sec->sym) {
1480     + rela->sym = insn_sec->sym;
1481     + rela->addend = insn_off;
1482     + } else {
1483     + /*
1484     + * The Clang assembler doesn't produce section symbols, so we
1485     + * have to reference the function symbol instead:
1486     + */
1487     + rela->sym = find_symbol_containing(insn_sec, insn_off);
1488     + if (!rela->sym) {
1489     + /*
1490     + * Hack alert. This happens when we need to reference
1491     + * the NOP pad insn immediately after the function.
1492     + */
1493     + rela->sym = find_symbol_containing(insn_sec,
1494     + insn_off - 1);
1495     + }
1496     + if (!rela->sym) {
1497     + WARN("missing symbol for insn at offset 0x%lx\n",
1498     + insn_off);
1499     + return -1;
1500     + }
1501     +
1502     + rela->addend = insn_off - rela->sym->offset;
1503     + }
1504     +
1505     rela->type = R_X86_64_PC32;
1506     rela->offset = idx * sizeof(int);
1507