diff options
289 files changed, 3258 insertions, 1385 deletions
diff --git a/Documentation/devicetree/bindings/net/brcm,amac.txt b/Documentation/devicetree/bindings/net/brcm,amac.txt index 2fefa1a44afd..ad16c1f481f7 100644 --- a/Documentation/devicetree/bindings/net/brcm,amac.txt +++ b/Documentation/devicetree/bindings/net/brcm,amac.txt | |||
@@ -11,6 +11,7 @@ Required properties: | |||
11 | - reg-names: Names of the registers. | 11 | - reg-names: Names of the registers. |
12 | "amac_base": Address and length of the GMAC registers | 12 | "amac_base": Address and length of the GMAC registers |
13 | "idm_base": Address and length of the GMAC IDM registers | 13 | "idm_base": Address and length of the GMAC IDM registers |
14 | (required for NSP and Northstar2) | ||
14 | "nicpm_base": Address and length of the NIC Port Manager | 15 | "nicpm_base": Address and length of the NIC Port Manager |
15 | registers (required for Northstar2) | 16 | registers (required for Northstar2) |
16 | - interrupts: Interrupt number | 17 | - interrupts: Interrupt number |
diff --git a/Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt b/Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt deleted file mode 100644 index 022946caa7e2..000000000000 --- a/Documentation/devicetree/bindings/net/brcm,bgmac-nsp.txt +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | Broadcom GMAC Ethernet Controller Device Tree Bindings | ||
2 | ------------------------------------------------------------- | ||
3 | |||
4 | Required properties: | ||
5 | - compatible: "brcm,bgmac-nsp" | ||
6 | - reg: Address and length of the GMAC registers, | ||
7 | Address and length of the GMAC IDM registers | ||
8 | - reg-names: Names of the registers. Must have both "gmac_base" and | ||
9 | "idm_base" | ||
10 | - interrupts: Interrupt number | ||
11 | |||
12 | Optional properties: | ||
13 | - mac-address: See ethernet.txt file in the same directory | ||
14 | |||
15 | Examples: | ||
16 | |||
17 | gmac0: ethernet@18022000 { | ||
18 | compatible = "brcm,bgmac-nsp"; | ||
19 | reg = <0x18022000 0x1000>, | ||
20 | <0x18110000 0x1000>; | ||
21 | reg-names = "gmac_base", "idm_base"; | ||
22 | interrupts = <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>; | ||
23 | status = "disabled"; | ||
24 | }; | ||
diff --git a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt index 07590bcdad15..7c04e22a5d6a 100644 --- a/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt +++ b/Documentation/devicetree/bindings/ptp/brcm,ptp-dte.txt | |||
@@ -1,13 +1,20 @@ | |||
1 | * Broadcom Digital Timing Engine(DTE) based PTP clock driver | 1 | * Broadcom Digital Timing Engine(DTE) based PTP clock |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: should be "brcm,ptp-dte" | 4 | - compatible: should contain the core compatibility string |
5 | and the SoC compatibility string. The SoC | ||
6 | compatibility string is to handle SoC specific | ||
7 | hardware differences. | ||
8 | Core compatibility string: | ||
9 | "brcm,ptp-dte" | ||
10 | SoC compatibility strings: | ||
11 | "brcm,iproc-ptp-dte" - for iproc based SoC's | ||
5 | - reg: address and length of the DTE block's NCO registers | 12 | - reg: address and length of the DTE block's NCO registers |
6 | 13 | ||
7 | Example: | 14 | Example: |
8 | 15 | ||
9 | ptp_dte: ptp_dte@180af650 { | 16 | ptp: ptp-dte@180af650 { |
10 | compatible = "brcm,ptp-dte"; | 17 | compatible = "brcm,iproc-ptp-dte", "brcm,ptp-dte"; |
11 | reg = <0x180af650 0x10>; | 18 | reg = <0x180af650 0x10>; |
12 | status = "okay"; | 19 | status = "okay"; |
13 | }; | 20 | }; |
diff --git a/MAINTAINERS b/MAINTAINERS index 205d3977ac46..2784ac59801d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -7730,6 +7730,7 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ | |||
7730 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git | 7730 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm.git |
7731 | S: Supported | 7731 | S: Supported |
7732 | F: drivers/nvdimm/* | 7732 | F: drivers/nvdimm/* |
7733 | F: drivers/acpi/nfit/* | ||
7733 | F: include/linux/nd.h | 7734 | F: include/linux/nd.h |
7734 | F: include/linux/libnvdimm.h | 7735 | F: include/linux/libnvdimm.h |
7735 | F: include/uapi/linux/ndctl.h | 7736 | F: include/uapi/linux/ndctl.h |
@@ -7741,7 +7742,6 @@ Q: https://patchwork.kernel.org/project/linux-nvdimm/list/ | |||
7741 | S: Supported | 7742 | S: Supported |
7742 | F: drivers/nvdimm/blk.c | 7743 | F: drivers/nvdimm/blk.c |
7743 | F: drivers/nvdimm/region_devs.c | 7744 | F: drivers/nvdimm/region_devs.c |
7744 | F: drivers/acpi/nfit* | ||
7745 | 7745 | ||
7746 | LIBNVDIMM BTT: BLOCK TRANSLATION TABLE | 7746 | LIBNVDIMM BTT: BLOCK TRANSLATION TABLE |
7747 | M: Vishal Verma <vishal.l.verma@intel.com> | 7747 | M: Vishal Verma <vishal.l.verma@intel.com> |
@@ -10684,7 +10684,6 @@ F: drivers/ptp/* | |||
10684 | F: include/linux/ptp_cl* | 10684 | F: include/linux/ptp_cl* |
10685 | 10685 | ||
10686 | PTRACE SUPPORT | 10686 | PTRACE SUPPORT |
10687 | M: Roland McGrath <roland@hack.frob.com> | ||
10688 | M: Oleg Nesterov <oleg@redhat.com> | 10687 | M: Oleg Nesterov <oleg@redhat.com> |
10689 | S: Maintained | 10688 | S: Maintained |
10690 | F: include/asm-generic/syscall.h | 10689 | F: include/asm-generic/syscall.h |
@@ -10692,7 +10691,12 @@ F: include/linux/ptrace.h | |||
10692 | F: include/linux/regset.h | 10691 | F: include/linux/regset.h |
10693 | F: include/linux/tracehook.h | 10692 | F: include/linux/tracehook.h |
10694 | F: include/uapi/linux/ptrace.h | 10693 | F: include/uapi/linux/ptrace.h |
10694 | F: include/uapi/linux/ptrace.h | ||
10695 | F: include/asm-generic/ptrace.h | ||
10695 | F: kernel/ptrace.c | 10696 | F: kernel/ptrace.c |
10697 | F: arch/*/ptrace*.c | ||
10698 | F: arch/*/*/ptrace*.c | ||
10699 | F: arch/*/include/asm/ptrace*.h | ||
10696 | 10700 | ||
10697 | PULSE8-CEC DRIVER | 10701 | PULSE8-CEC DRIVER |
10698 | M: Hans Verkuil <hverkuil@xs4all.nl> | 10702 | M: Hans Verkuil <hverkuil@xs4all.nl> |
@@ -10868,6 +10872,14 @@ L: linux-scsi@vger.kernel.org | |||
10868 | S: Supported | 10872 | S: Supported |
10869 | F: drivers/scsi/qedf/ | 10873 | F: drivers/scsi/qedf/ |
10870 | 10874 | ||
10875 | QLOGIC QL4xxx RDMA DRIVER | ||
10876 | M: Ram Amrani <Ram.Amrani@cavium.com> | ||
10877 | M: Ariel Elior <Ariel.Elior@cavium.com> | ||
10878 | L: linux-rdma@vger.kernel.org | ||
10879 | S: Supported | ||
10880 | F: drivers/infiniband/hw/qedr/ | ||
10881 | F: include/uapi/rdma/qedr-abi.h | ||
10882 | |||
10871 | QNX4 FILESYSTEM | 10883 | QNX4 FILESYSTEM |
10872 | M: Anders Larsen <al@alarsen.net> | 10884 | M: Anders Larsen <al@alarsen.net> |
10873 | W: http://www.alarsen.net/linux/qnx4fs/ | 10885 | W: http://www.alarsen.net/linux/qnx4fs/ |
diff --git a/arch/arm/include/asm/bug.h b/arch/arm/include/asm/bug.h index 4e6e88a6b2f4..2244a94ed9c9 100644 --- a/arch/arm/include/asm/bug.h +++ b/arch/arm/include/asm/bug.h | |||
@@ -37,7 +37,7 @@ do { \ | |||
37 | ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ | 37 | ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \ |
38 | "2:\t.asciz " #__file "\n" \ | 38 | "2:\t.asciz " #__file "\n" \ |
39 | ".popsection\n" \ | 39 | ".popsection\n" \ |
40 | ".pushsection __bug_table,\"a\"\n" \ | 40 | ".pushsection __bug_table,\"aw\"\n" \ |
41 | ".align 2\n" \ | 41 | ".align 2\n" \ |
42 | "3:\t.word 1b, 2b\n" \ | 42 | "3:\t.word 1b, 2b\n" \ |
43 | "\t.hword " #__line ", 0\n" \ | 43 | "\t.hword " #__line ", 0\n" \ |
diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h index d69bebf697e7..74504b154256 100644 --- a/arch/arm/include/asm/cacheflush.h +++ b/arch/arm/include/asm/cacheflush.h | |||
@@ -116,7 +116,7 @@ struct cpu_cache_fns { | |||
116 | void (*dma_unmap_area)(const void *, size_t, int); | 116 | void (*dma_unmap_area)(const void *, size_t, int); |
117 | 117 | ||
118 | void (*dma_flush_range)(const void *, const void *); | 118 | void (*dma_flush_range)(const void *, const void *); |
119 | }; | 119 | } __no_randomize_layout; |
120 | 120 | ||
121 | /* | 121 | /* |
122 | * Select the calling method | 122 | * Select the calling method |
diff --git a/arch/arm64/include/asm/bug.h b/arch/arm64/include/asm/bug.h index 366448eb0fb7..a02a57186f56 100644 --- a/arch/arm64/include/asm/bug.h +++ b/arch/arm64/include/asm/bug.h | |||
@@ -36,7 +36,7 @@ | |||
36 | #ifdef CONFIG_GENERIC_BUG | 36 | #ifdef CONFIG_GENERIC_BUG |
37 | 37 | ||
38 | #define __BUG_ENTRY(flags) \ | 38 | #define __BUG_ENTRY(flags) \ |
39 | ".pushsection __bug_table,\"a\"\n\t" \ | 39 | ".pushsection __bug_table,\"aw\"\n\t" \ |
40 | ".align 2\n\t" \ | 40 | ".align 2\n\t" \ |
41 | "0: .long 1f - 0b\n\t" \ | 41 | "0: .long 1f - 0b\n\t" \ |
42 | _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ | 42 | _BUGVERBOSE_LOCATION(__FILE__, __LINE__) \ |
diff --git a/arch/blackfin/include/asm/bug.h b/arch/blackfin/include/asm/bug.h index 8d9b1eba89c4..76b2e82ee730 100644 --- a/arch/blackfin/include/asm/bug.h +++ b/arch/blackfin/include/asm/bug.h | |||
@@ -21,7 +21,7 @@ | |||
21 | #define _BUG_OR_WARN(flags) \ | 21 | #define _BUG_OR_WARN(flags) \ |
22 | asm volatile( \ | 22 | asm volatile( \ |
23 | "1: .hword %0\n" \ | 23 | "1: .hword %0\n" \ |
24 | " .section __bug_table,\"a\",@progbits\n" \ | 24 | " .section __bug_table,\"aw\",@progbits\n" \ |
25 | "2: .long 1b\n" \ | 25 | "2: .long 1b\n" \ |
26 | " .long %1\n" \ | 26 | " .long %1\n" \ |
27 | " .short %2\n" \ | 27 | " .short %2\n" \ |
@@ -38,7 +38,7 @@ | |||
38 | #define _BUG_OR_WARN(flags) \ | 38 | #define _BUG_OR_WARN(flags) \ |
39 | asm volatile( \ | 39 | asm volatile( \ |
40 | "1: .hword %0\n" \ | 40 | "1: .hword %0\n" \ |
41 | " .section __bug_table,\"a\",@progbits\n" \ | 41 | " .section __bug_table,\"aw\",@progbits\n" \ |
42 | "2: .long 1b\n" \ | 42 | "2: .long 1b\n" \ |
43 | " .short %1\n" \ | 43 | " .short %1\n" \ |
44 | " .org 2b + %2\n" \ | 44 | " .org 2b + %2\n" \ |
diff --git a/arch/blackfin/include/asm/flat.h b/arch/blackfin/include/asm/flat.h index 296d7f56fbfd..f1d6ba7afbf2 100644 --- a/arch/blackfin/include/asm/flat.h +++ b/arch/blackfin/include/asm/flat.h | |||
@@ -44,8 +44,7 @@ flat_get_relocate_addr (unsigned long relval) | |||
44 | return relval & 0x03ffffff; /* Mask out top 6 bits */ | 44 | return relval & 0x03ffffff; /* Mask out top 6 bits */ |
45 | } | 45 | } |
46 | 46 | ||
47 | static inline int flat_set_persistent(unsigned long relval, | 47 | static inline int flat_set_persistent(u32 relval, u32 *persistent) |
48 | unsigned long *persistent) | ||
49 | { | 48 | { |
50 | int type = (relval >> 26) & 7; | 49 | int type = (relval >> 26) & 7; |
51 | if (type == 3) { | 50 | if (type == 3) { |
diff --git a/arch/blackfin/kernel/flat.c b/arch/blackfin/kernel/flat.c index d29ab6a2e909..8ebc54daaa8e 100644 --- a/arch/blackfin/kernel/flat.c +++ b/arch/blackfin/kernel/flat.c | |||
@@ -32,7 +32,7 @@ unsigned long bfin_get_addr_from_rp(u32 *ptr, | |||
32 | break; | 32 | break; |
33 | 33 | ||
34 | case FLAT_BFIN_RELOC_TYPE_32_BIT: | 34 | case FLAT_BFIN_RELOC_TYPE_32_BIT: |
35 | pr_debug("*ptr = %lx", get_unaligned(ptr)); | 35 | pr_debug("*ptr = %x", get_unaligned(ptr)); |
36 | val = get_unaligned(ptr); | 36 | val = get_unaligned(ptr); |
37 | break; | 37 | break; |
38 | 38 | ||
@@ -77,7 +77,7 @@ void bfin_put_addr_at_rp(u32 *ptr, u32 addr, u32 relval) | |||
77 | 77 | ||
78 | case FLAT_BFIN_RELOC_TYPE_32_BIT: | 78 | case FLAT_BFIN_RELOC_TYPE_32_BIT: |
79 | put_unaligned(addr, ptr); | 79 | put_unaligned(addr, ptr); |
80 | pr_debug("new ptr =%lx", get_unaligned(ptr)); | 80 | pr_debug("new ptr =%x", get_unaligned(ptr)); |
81 | break; | 81 | break; |
82 | } | 82 | } |
83 | } | 83 | } |
diff --git a/arch/h8300/include/asm/flat.h b/arch/h8300/include/asm/flat.h index 18d024251738..7e0bd6fa1532 100644 --- a/arch/h8300/include/asm/flat.h +++ b/arch/h8300/include/asm/flat.h | |||
@@ -24,7 +24,7 @@ static inline int flat_get_addr_from_rp(u32 __user *rp, u32 relval, u32 flags, | |||
24 | u32 *addr, u32 *persistent) | 24 | u32 *addr, u32 *persistent) |
25 | { | 25 | { |
26 | u32 val = get_unaligned((__force u32 *)rp); | 26 | u32 val = get_unaligned((__force u32 *)rp); |
27 | if (!(flags & FLAT_FLAG_GOTPIC) | 27 | if (!(flags & FLAT_FLAG_GOTPIC)) |
28 | val &= 0x00ffffff; | 28 | val &= 0x00ffffff; |
29 | *addr = val; | 29 | *addr = val; |
30 | return 0; | 30 | return 0; |
diff --git a/arch/m68k/include/asm/flat.h b/arch/m68k/include/asm/flat.h index 48b62790fe70..b2a41f5b3890 100644 --- a/arch/m68k/include/asm/flat.h +++ b/arch/m68k/include/asm/flat.h | |||
@@ -30,8 +30,7 @@ static inline int flat_put_addr_at_rp(u32 __user *rp, u32 addr, u32 rel) | |||
30 | } | 30 | } |
31 | #define flat_get_relocate_addr(rel) (rel) | 31 | #define flat_get_relocate_addr(rel) (rel) |
32 | 32 | ||
33 | static inline int flat_set_persistent(unsigned long relval, | 33 | static inline int flat_set_persistent(u32 relval, u32 *persistent) |
34 | unsigned long *persistent) | ||
35 | { | 34 | { |
36 | return 0; | 35 | return 0; |
37 | } | 36 | } |
diff --git a/arch/mn10300/include/asm/bug.h b/arch/mn10300/include/asm/bug.h index aa6a38886391..811414fb002d 100644 --- a/arch/mn10300/include/asm/bug.h +++ b/arch/mn10300/include/asm/bug.h | |||
@@ -21,7 +21,7 @@ do { \ | |||
21 | asm volatile( \ | 21 | asm volatile( \ |
22 | " syscall 15 \n" \ | 22 | " syscall 15 \n" \ |
23 | "0: \n" \ | 23 | "0: \n" \ |
24 | " .section __bug_table,\"a\" \n" \ | 24 | " .section __bug_table,\"aw\" \n" \ |
25 | " .long 0b,%0,%1 \n" \ | 25 | " .long 0b,%0,%1 \n" \ |
26 | " .previous \n" \ | 26 | " .previous \n" \ |
27 | : \ | 27 | : \ |
diff --git a/arch/parisc/include/asm/bug.h b/arch/parisc/include/asm/bug.h index d2742273a685..07ea467f22fc 100644 --- a/arch/parisc/include/asm/bug.h +++ b/arch/parisc/include/asm/bug.h | |||
@@ -27,7 +27,7 @@ | |||
27 | do { \ | 27 | do { \ |
28 | asm volatile("\n" \ | 28 | asm volatile("\n" \ |
29 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ | 29 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
30 | "\t.pushsection __bug_table,\"a\"\n" \ | 30 | "\t.pushsection __bug_table,\"aw\"\n" \ |
31 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ | 31 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
32 | "\t.short %c1, %c2\n" \ | 32 | "\t.short %c1, %c2\n" \ |
33 | "\t.org 2b+%c3\n" \ | 33 | "\t.org 2b+%c3\n" \ |
@@ -50,7 +50,7 @@ | |||
50 | do { \ | 50 | do { \ |
51 | asm volatile("\n" \ | 51 | asm volatile("\n" \ |
52 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ | 52 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
53 | "\t.pushsection __bug_table,\"a\"\n" \ | 53 | "\t.pushsection __bug_table,\"aw\"\n" \ |
54 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ | 54 | "2:\t" ASM_WORD_INSN "1b, %c0\n" \ |
55 | "\t.short %c1, %c2\n" \ | 55 | "\t.short %c1, %c2\n" \ |
56 | "\t.org 2b+%c3\n" \ | 56 | "\t.org 2b+%c3\n" \ |
@@ -64,7 +64,7 @@ | |||
64 | do { \ | 64 | do { \ |
65 | asm volatile("\n" \ | 65 | asm volatile("\n" \ |
66 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ | 66 | "1:\t" PARISC_BUG_BREAK_ASM "\n" \ |
67 | "\t.pushsection __bug_table,\"a\"\n" \ | 67 | "\t.pushsection __bug_table,\"aw\"\n" \ |
68 | "2:\t" ASM_WORD_INSN "1b\n" \ | 68 | "2:\t" ASM_WORD_INSN "1b\n" \ |
69 | "\t.short %c0\n" \ | 69 | "\t.short %c0\n" \ |
70 | "\t.org 2b+%c1\n" \ | 70 | "\t.org 2b+%c1\n" \ |
diff --git a/arch/powerpc/include/asm/book3s/64/hash.h b/arch/powerpc/include/asm/book3s/64/hash.h index 0ce513f2926f..36fc7bfe9e11 100644 --- a/arch/powerpc/include/asm/book3s/64/hash.h +++ b/arch/powerpc/include/asm/book3s/64/hash.h | |||
@@ -91,6 +91,7 @@ static inline int hash__pgd_bad(pgd_t pgd) | |||
91 | } | 91 | } |
92 | #ifdef CONFIG_STRICT_KERNEL_RWX | 92 | #ifdef CONFIG_STRICT_KERNEL_RWX |
93 | extern void hash__mark_rodata_ro(void); | 93 | extern void hash__mark_rodata_ro(void); |
94 | extern void hash__mark_initmem_nx(void); | ||
94 | #endif | 95 | #endif |
95 | 96 | ||
96 | extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr, | 97 | extern void hpte_need_flush(struct mm_struct *mm, unsigned long addr, |
diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index c0737c86a362..d1da415e283c 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h | |||
@@ -1192,5 +1192,6 @@ static inline const int pud_pfn(pud_t pud) | |||
1192 | BUILD_BUG(); | 1192 | BUILD_BUG(); |
1193 | return 0; | 1193 | return 0; |
1194 | } | 1194 | } |
1195 | |||
1195 | #endif /* __ASSEMBLY__ */ | 1196 | #endif /* __ASSEMBLY__ */ |
1196 | #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */ | 1197 | #endif /* _ASM_POWERPC_BOOK3S_64_PGTABLE_H_ */ |
diff --git a/arch/powerpc/include/asm/book3s/64/radix.h b/arch/powerpc/include/asm/book3s/64/radix.h index 487709ff6875..544440b5aff3 100644 --- a/arch/powerpc/include/asm/book3s/64/radix.h +++ b/arch/powerpc/include/asm/book3s/64/radix.h | |||
@@ -118,6 +118,7 @@ | |||
118 | 118 | ||
119 | #ifdef CONFIG_STRICT_KERNEL_RWX | 119 | #ifdef CONFIG_STRICT_KERNEL_RWX |
120 | extern void radix__mark_rodata_ro(void); | 120 | extern void radix__mark_rodata_ro(void); |
121 | extern void radix__mark_initmem_nx(void); | ||
121 | #endif | 122 | #endif |
122 | 123 | ||
123 | static inline unsigned long __radix_pte_update(pte_t *ptep, unsigned long clr, | 124 | static inline unsigned long __radix_pte_update(pte_t *ptep, unsigned long clr, |
diff --git a/arch/powerpc/include/asm/bug.h b/arch/powerpc/include/asm/bug.h index 0151af6c2a50..87fcc1948817 100644 --- a/arch/powerpc/include/asm/bug.h +++ b/arch/powerpc/include/asm/bug.h | |||
@@ -18,7 +18,7 @@ | |||
18 | #include <asm/asm-offsets.h> | 18 | #include <asm/asm-offsets.h> |
19 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 19 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
20 | .macro EMIT_BUG_ENTRY addr,file,line,flags | 20 | .macro EMIT_BUG_ENTRY addr,file,line,flags |
21 | .section __bug_table,"a" | 21 | .section __bug_table,"aw" |
22 | 5001: PPC_LONG \addr, 5002f | 22 | 5001: PPC_LONG \addr, 5002f |
23 | .short \line, \flags | 23 | .short \line, \flags |
24 | .org 5001b+BUG_ENTRY_SIZE | 24 | .org 5001b+BUG_ENTRY_SIZE |
@@ -29,7 +29,7 @@ | |||
29 | .endm | 29 | .endm |
30 | #else | 30 | #else |
31 | .macro EMIT_BUG_ENTRY addr,file,line,flags | 31 | .macro EMIT_BUG_ENTRY addr,file,line,flags |
32 | .section __bug_table,"a" | 32 | .section __bug_table,"aw" |
33 | 5001: PPC_LONG \addr | 33 | 5001: PPC_LONG \addr |
34 | .short \flags | 34 | .short \flags |
35 | .org 5001b+BUG_ENTRY_SIZE | 35 | .org 5001b+BUG_ENTRY_SIZE |
@@ -42,14 +42,14 @@ | |||
42 | sizeof(struct bug_entry), respectively */ | 42 | sizeof(struct bug_entry), respectively */ |
43 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 43 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
44 | #define _EMIT_BUG_ENTRY \ | 44 | #define _EMIT_BUG_ENTRY \ |
45 | ".section __bug_table,\"a\"\n" \ | 45 | ".section __bug_table,\"aw\"\n" \ |
46 | "2:\t" PPC_LONG "1b, %0\n" \ | 46 | "2:\t" PPC_LONG "1b, %0\n" \ |
47 | "\t.short %1, %2\n" \ | 47 | "\t.short %1, %2\n" \ |
48 | ".org 2b+%3\n" \ | 48 | ".org 2b+%3\n" \ |
49 | ".previous\n" | 49 | ".previous\n" |
50 | #else | 50 | #else |
51 | #define _EMIT_BUG_ENTRY \ | 51 | #define _EMIT_BUG_ENTRY \ |
52 | ".section __bug_table,\"a\"\n" \ | 52 | ".section __bug_table,\"aw\"\n" \ |
53 | "2:\t" PPC_LONG "1b\n" \ | 53 | "2:\t" PPC_LONG "1b\n" \ |
54 | "\t.short %2\n" \ | 54 | "\t.short %2\n" \ |
55 | ".org 2b+%3\n" \ | 55 | ".org 2b+%3\n" \ |
diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h index dd01212935ac..afae9a336136 100644 --- a/arch/powerpc/include/asm/pgtable.h +++ b/arch/powerpc/include/asm/pgtable.h | |||
@@ -80,6 +80,13 @@ unsigned long vmalloc_to_phys(void *vmalloc_addr); | |||
80 | 80 | ||
81 | void pgtable_cache_add(unsigned shift, void (*ctor)(void *)); | 81 | void pgtable_cache_add(unsigned shift, void (*ctor)(void *)); |
82 | void pgtable_cache_init(void); | 82 | void pgtable_cache_init(void); |
83 | |||
84 | #ifdef CONFIG_STRICT_KERNEL_RWX | ||
85 | void mark_initmem_nx(void); | ||
86 | #else | ||
87 | static inline void mark_initmem_nx(void) { } | ||
88 | #endif | ||
89 | |||
83 | #endif /* __ASSEMBLY__ */ | 90 | #endif /* __ASSEMBLY__ */ |
84 | 91 | ||
85 | #endif /* _ASM_POWERPC_PGTABLE_H */ | 92 | #endif /* _ASM_POWERPC_PGTABLE_H */ |
diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index e6d8354d79ef..9029afd1fa2a 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S | |||
@@ -824,7 +824,7 @@ EXC_COMMON(trap_0b_common, 0xb00, unknown_exception) | |||
824 | * r3 volatile parameter and return value for status | 824 | * r3 volatile parameter and return value for status |
825 | * r4-r10 volatile input and output value | 825 | * r4-r10 volatile input and output value |
826 | * r11 volatile hypercall number and output value | 826 | * r11 volatile hypercall number and output value |
827 | * r12 volatile | 827 | * r12 volatile input and output value |
828 | * r13-r31 nonvolatile | 828 | * r13-r31 nonvolatile |
829 | * LR nonvolatile | 829 | * LR nonvolatile |
830 | * CTR volatile | 830 | * CTR volatile |
@@ -834,25 +834,26 @@ EXC_COMMON(trap_0b_common, 0xb00, unknown_exception) | |||
834 | * Other registers nonvolatile | 834 | * Other registers nonvolatile |
835 | * | 835 | * |
836 | * The intersection of volatile registers that don't contain possible | 836 | * The intersection of volatile registers that don't contain possible |
837 | * inputs is: r12, cr0, xer, ctr. We may use these as scratch regs | 837 | * inputs is: cr0, xer, ctr. We may use these as scratch regs upon entry |
838 | * upon entry without saving. | 838 | * without saving, though xer is not a good idea to use, as hardware may |
839 | * interpret some bits so it may be costly to change them. | ||
839 | */ | 840 | */ |
840 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER | 841 | #ifdef CONFIG_KVM_BOOK3S_64_HANDLER |
841 | /* | 842 | /* |
842 | * There is a little bit of juggling to get syscall and hcall | 843 | * There is a little bit of juggling to get syscall and hcall |
843 | * working well. Save r10 in ctr to be restored in case it is a | 844 | * working well. Save r13 in ctr to avoid using SPRG scratch |
844 | * hcall. | 845 | * register. |
845 | * | 846 | * |
846 | * Userspace syscalls have already saved the PPR, hcalls must save | 847 | * Userspace syscalls have already saved the PPR, hcalls must save |
847 | * it before setting HMT_MEDIUM. | 848 | * it before setting HMT_MEDIUM. |
848 | */ | 849 | */ |
849 | #define SYSCALL_KVMTEST \ | 850 | #define SYSCALL_KVMTEST \ |
850 | mr r12,r13; \ | 851 | mtctr r13; \ |
851 | GET_PACA(r13); \ | 852 | GET_PACA(r13); \ |
852 | mtctr r10; \ | 853 | std r10,PACA_EXGEN+EX_R10(r13); \ |
853 | KVMTEST_PR(0xc00); /* uses r10, branch to do_kvm_0xc00_system_call */ \ | 854 | KVMTEST_PR(0xc00); /* uses r10, branch to do_kvm_0xc00_system_call */ \ |
854 | HMT_MEDIUM; \ | 855 | HMT_MEDIUM; \ |
855 | mr r9,r12; \ | 856 | mfctr r9; |
856 | 857 | ||
857 | #else | 858 | #else |
858 | #define SYSCALL_KVMTEST \ | 859 | #define SYSCALL_KVMTEST \ |
@@ -935,8 +936,8 @@ EXC_VIRT_END(system_call, 0x4c00, 0x100) | |||
935 | * This is a hcall, so register convention is as above, with these | 936 | * This is a hcall, so register convention is as above, with these |
936 | * differences: | 937 | * differences: |
937 | * r13 = PACA | 938 | * r13 = PACA |
938 | * r12 = orig r13 | 939 | * ctr = orig r13 |
939 | * ctr = orig r10 | 940 | * orig r10 saved in PACA |
940 | */ | 941 | */ |
941 | TRAMP_KVM_BEGIN(do_kvm_0xc00) | 942 | TRAMP_KVM_BEGIN(do_kvm_0xc00) |
942 | /* | 943 | /* |
@@ -944,14 +945,13 @@ TRAMP_KVM_BEGIN(do_kvm_0xc00) | |||
944 | * HMT_MEDIUM. That allows the KVM code to save that value into the | 945 | * HMT_MEDIUM. That allows the KVM code to save that value into the |
945 | * guest state (it is the guest's PPR value). | 946 | * guest state (it is the guest's PPR value). |
946 | */ | 947 | */ |
947 | OPT_GET_SPR(r0, SPRN_PPR, CPU_FTR_HAS_PPR) | 948 | OPT_GET_SPR(r10, SPRN_PPR, CPU_FTR_HAS_PPR) |
948 | HMT_MEDIUM | 949 | HMT_MEDIUM |
949 | OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r0, CPU_FTR_HAS_PPR) | 950 | OPT_SAVE_REG_TO_PACA(PACA_EXGEN+EX_PPR, r10, CPU_FTR_HAS_PPR) |
950 | mfctr r10 | 951 | mfctr r10 |
951 | SET_SCRATCH0(r12) | 952 | SET_SCRATCH0(r10) |
952 | std r9,PACA_EXGEN+EX_R9(r13) | 953 | std r9,PACA_EXGEN+EX_R9(r13) |
953 | mfcr r9 | 954 | mfcr r9 |
954 | std r10,PACA_EXGEN+EX_R10(r13) | ||
955 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00) | 955 | KVM_HANDLER(PACA_EXGEN, EXC_STD, 0xc00) |
956 | #endif | 956 | #endif |
957 | 957 | ||
diff --git a/arch/powerpc/kernel/idle_book3s.S b/arch/powerpc/kernel/idle_book3s.S index 5adb390e773b..516ebef905c0 100644 --- a/arch/powerpc/kernel/idle_book3s.S +++ b/arch/powerpc/kernel/idle_book3s.S | |||
@@ -30,6 +30,7 @@ | |||
30 | * Use unused space in the interrupt stack to save and restore | 30 | * Use unused space in the interrupt stack to save and restore |
31 | * registers for winkle support. | 31 | * registers for winkle support. |
32 | */ | 32 | */ |
33 | #define _MMCR0 GPR0 | ||
33 | #define _SDR1 GPR3 | 34 | #define _SDR1 GPR3 |
34 | #define _PTCR GPR3 | 35 | #define _PTCR GPR3 |
35 | #define _RPR GPR4 | 36 | #define _RPR GPR4 |
@@ -272,6 +273,14 @@ power_enter_stop: | |||
272 | b pnv_wakeup_noloss | 273 | b pnv_wakeup_noloss |
273 | 274 | ||
274 | .Lhandle_esl_ec_set: | 275 | .Lhandle_esl_ec_set: |
276 | /* | ||
277 | * POWER9 DD2 can incorrectly set PMAO when waking up after a | ||
278 | * state-loss idle. Saving and restoring MMCR0 over idle is a | ||
279 | * workaround. | ||
280 | */ | ||
281 | mfspr r4,SPRN_MMCR0 | ||
282 | std r4,_MMCR0(r1) | ||
283 | |||
275 | /* | 284 | /* |
276 | * Check if the requested state is a deep idle state. | 285 | * Check if the requested state is a deep idle state. |
277 | */ | 286 | */ |
@@ -450,10 +459,14 @@ ALT_FTR_SECTION_END_IFSET(CPU_FTR_ARCH_300) | |||
450 | pnv_restore_hyp_resource_arch300: | 459 | pnv_restore_hyp_resource_arch300: |
451 | /* | 460 | /* |
452 | * Workaround for POWER9, if we lost resources, the ERAT | 461 | * Workaround for POWER9, if we lost resources, the ERAT |
453 | * might have been mixed up and needs flushing. | 462 | * might have been mixed up and needs flushing. We also need |
463 | * to reload MMCR0 (see comment above). | ||
454 | */ | 464 | */ |
455 | blt cr3,1f | 465 | blt cr3,1f |
456 | PPC_INVALIDATE_ERAT | 466 | PPC_INVALIDATE_ERAT |
467 | ld r1,PACAR1(r13) | ||
468 | ld r4,_MMCR0(r1) | ||
469 | mtspr SPRN_MMCR0,r4 | ||
457 | 1: | 470 | 1: |
458 | /* | 471 | /* |
459 | * POWER ISA 3. Use PSSCR to determine if we | 472 | * POWER ISA 3. Use PSSCR to determine if we |
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 8541f18694a4..46b4e67d2372 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c | |||
@@ -402,6 +402,7 @@ void __init mem_init(void) | |||
402 | void free_initmem(void) | 402 | void free_initmem(void) |
403 | { | 403 | { |
404 | ppc_md.progress = ppc_printk_progress; | 404 | ppc_md.progress = ppc_printk_progress; |
405 | mark_initmem_nx(); | ||
405 | free_initmem_default(POISON_FREE_INITMEM); | 406 | free_initmem_default(POISON_FREE_INITMEM); |
406 | } | 407 | } |
407 | 408 | ||
diff --git a/arch/powerpc/mm/pgtable-hash64.c b/arch/powerpc/mm/pgtable-hash64.c index 188b4107584d..443a2c66a304 100644 --- a/arch/powerpc/mm/pgtable-hash64.c +++ b/arch/powerpc/mm/pgtable-hash64.c | |||
@@ -425,33 +425,51 @@ int hash__has_transparent_hugepage(void) | |||
425 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ | 425 | #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ |
426 | 426 | ||
427 | #ifdef CONFIG_STRICT_KERNEL_RWX | 427 | #ifdef CONFIG_STRICT_KERNEL_RWX |
428 | void hash__mark_rodata_ro(void) | 428 | static bool hash__change_memory_range(unsigned long start, unsigned long end, |
429 | unsigned long newpp) | ||
429 | { | 430 | { |
430 | unsigned long start = (unsigned long)_stext; | ||
431 | unsigned long end = (unsigned long)__init_begin; | ||
432 | unsigned long idx; | 431 | unsigned long idx; |
433 | unsigned int step, shift; | 432 | unsigned int step, shift; |
434 | unsigned long newpp = PP_RXXX; | ||
435 | 433 | ||
436 | shift = mmu_psize_defs[mmu_linear_psize].shift; | 434 | shift = mmu_psize_defs[mmu_linear_psize].shift; |
437 | step = 1 << shift; | 435 | step = 1 << shift; |
438 | 436 | ||
439 | start = ((start + step - 1) >> shift) << shift; | 437 | start = ALIGN_DOWN(start, step); |
440 | end = (end >> shift) << shift; | 438 | end = ALIGN(end, step); // aligns up |
441 | 439 | ||
442 | pr_devel("marking ro start %lx, end %lx, step %x\n", | 440 | if (start >= end) |
443 | start, end, step); | 441 | return false; |
444 | 442 | ||
445 | if (start == end) { | 443 | pr_debug("Changing page protection on range 0x%lx-0x%lx, to 0x%lx, step 0x%x\n", |
446 | pr_warn("could not set rodata ro, relocate the start" | 444 | start, end, newpp, step); |
447 | " of the kernel to a 0x%x boundary\n", step); | ||
448 | return; | ||
449 | } | ||
450 | 445 | ||
451 | for (idx = start; idx < end; idx += step) | 446 | for (idx = start; idx < end; idx += step) |
452 | /* Not sure if we can do much with the return value */ | 447 | /* Not sure if we can do much with the return value */ |
453 | mmu_hash_ops.hpte_updateboltedpp(newpp, idx, mmu_linear_psize, | 448 | mmu_hash_ops.hpte_updateboltedpp(newpp, idx, mmu_linear_psize, |
454 | mmu_kernel_ssize); | 449 | mmu_kernel_ssize); |
455 | 450 | ||
451 | return true; | ||
452 | } | ||
453 | |||
454 | void hash__mark_rodata_ro(void) | ||
455 | { | ||
456 | unsigned long start, end; | ||
457 | |||
458 | start = (unsigned long)_stext; | ||
459 | end = (unsigned long)__init_begin; | ||
460 | |||
461 | WARN_ON(!hash__change_memory_range(start, end, PP_RXXX)); | ||
462 | } | ||
463 | |||
464 | void hash__mark_initmem_nx(void) | ||
465 | { | ||
466 | unsigned long start, end, pp; | ||
467 | |||
468 | start = (unsigned long)__init_begin; | ||
469 | end = (unsigned long)__init_end; | ||
470 | |||
471 | pp = htab_convert_pte_flags(pgprot_val(PAGE_KERNEL)); | ||
472 | |||
473 | WARN_ON(!hash__change_memory_range(start, end, pp)); | ||
456 | } | 474 | } |
457 | #endif | 475 | #endif |
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c index 8c13e4282308..5cc50d47ce3f 100644 --- a/arch/powerpc/mm/pgtable-radix.c +++ b/arch/powerpc/mm/pgtable-radix.c | |||
@@ -112,10 +112,9 @@ set_the_pte: | |||
112 | } | 112 | } |
113 | 113 | ||
114 | #ifdef CONFIG_STRICT_KERNEL_RWX | 114 | #ifdef CONFIG_STRICT_KERNEL_RWX |
115 | void radix__mark_rodata_ro(void) | 115 | void radix__change_memory_range(unsigned long start, unsigned long end, |
116 | unsigned long clear) | ||
116 | { | 117 | { |
117 | unsigned long start = (unsigned long)_stext; | ||
118 | unsigned long end = (unsigned long)__init_begin; | ||
119 | unsigned long idx; | 118 | unsigned long idx; |
120 | pgd_t *pgdp; | 119 | pgd_t *pgdp; |
121 | pud_t *pudp; | 120 | pud_t *pudp; |
@@ -125,7 +124,8 @@ void radix__mark_rodata_ro(void) | |||
125 | start = ALIGN_DOWN(start, PAGE_SIZE); | 124 | start = ALIGN_DOWN(start, PAGE_SIZE); |
126 | end = PAGE_ALIGN(end); // aligns up | 125 | end = PAGE_ALIGN(end); // aligns up |
127 | 126 | ||
128 | pr_devel("marking ro start %lx, end %lx\n", start, end); | 127 | pr_debug("Changing flags on range %lx-%lx removing 0x%lx\n", |
128 | start, end, clear); | ||
129 | 129 | ||
130 | for (idx = start; idx < end; idx += PAGE_SIZE) { | 130 | for (idx = start; idx < end; idx += PAGE_SIZE) { |
131 | pgdp = pgd_offset_k(idx); | 131 | pgdp = pgd_offset_k(idx); |
@@ -147,11 +147,29 @@ void radix__mark_rodata_ro(void) | |||
147 | if (!ptep) | 147 | if (!ptep) |
148 | continue; | 148 | continue; |
149 | update_the_pte: | 149 | update_the_pte: |
150 | radix__pte_update(&init_mm, idx, ptep, _PAGE_WRITE, 0, 0); | 150 | radix__pte_update(&init_mm, idx, ptep, clear, 0, 0); |
151 | } | 151 | } |
152 | 152 | ||
153 | radix__flush_tlb_kernel_range(start, end); | 153 | radix__flush_tlb_kernel_range(start, end); |
154 | } | 154 | } |
155 | |||
156 | void radix__mark_rodata_ro(void) | ||
157 | { | ||
158 | unsigned long start, end; | ||
159 | |||
160 | start = (unsigned long)_stext; | ||
161 | end = (unsigned long)__init_begin; | ||
162 | |||
163 | radix__change_memory_range(start, end, _PAGE_WRITE); | ||
164 | } | ||
165 | |||
166 | void radix__mark_initmem_nx(void) | ||
167 | { | ||
168 | unsigned long start = (unsigned long)__init_begin; | ||
169 | unsigned long end = (unsigned long)__init_end; | ||
170 | |||
171 | radix__change_memory_range(start, end, _PAGE_EXEC); | ||
172 | } | ||
155 | #endif /* CONFIG_STRICT_KERNEL_RWX */ | 173 | #endif /* CONFIG_STRICT_KERNEL_RWX */ |
156 | 174 | ||
157 | static inline void __meminit print_mapping(unsigned long start, | 175 | static inline void __meminit print_mapping(unsigned long start, |
diff --git a/arch/powerpc/mm/pgtable_64.c b/arch/powerpc/mm/pgtable_64.c index 5c0b795d656c..0736e94c7615 100644 --- a/arch/powerpc/mm/pgtable_64.c +++ b/arch/powerpc/mm/pgtable_64.c | |||
@@ -505,4 +505,12 @@ void mark_rodata_ro(void) | |||
505 | else | 505 | else |
506 | hash__mark_rodata_ro(); | 506 | hash__mark_rodata_ro(); |
507 | } | 507 | } |
508 | |||
509 | void mark_initmem_nx(void) | ||
510 | { | ||
511 | if (radix_enabled()) | ||
512 | radix__mark_initmem_nx(); | ||
513 | else | ||
514 | hash__mark_initmem_nx(); | ||
515 | } | ||
508 | #endif | 516 | #endif |
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c index 9b87abb178f0..cad6b57ce494 100644 --- a/arch/powerpc/platforms/powernv/opal.c +++ b/arch/powerpc/platforms/powernv/opal.c | |||
@@ -78,7 +78,7 @@ void opal_configure_cores(void) | |||
78 | * ie. Host hash supports hash guests | 78 | * ie. Host hash supports hash guests |
79 | * Host radix supports hash/radix guests | 79 | * Host radix supports hash/radix guests |
80 | */ | 80 | */ |
81 | if (cpu_has_feature(CPU_FTR_ARCH_300)) { | 81 | if (early_cpu_has_feature(CPU_FTR_ARCH_300)) { |
82 | reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH; | 82 | reinit_flags |= OPAL_REINIT_CPUS_MMU_HASH; |
83 | if (early_radix_enabled()) | 83 | if (early_radix_enabled()) |
84 | reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX; | 84 | reinit_flags |= OPAL_REINIT_CPUS_MMU_RADIX; |
diff --git a/arch/s390/include/asm/bug.h b/arch/s390/include/asm/bug.h index 1bbd9dbfe4e0..ce9cc123988b 100644 --- a/arch/s390/include/asm/bug.h +++ b/arch/s390/include/asm/bug.h | |||
@@ -14,7 +14,7 @@ | |||
14 | ".section .rodata.str,\"aMS\",@progbits,1\n" \ | 14 | ".section .rodata.str,\"aMS\",@progbits,1\n" \ |
15 | "2: .asciz \""__FILE__"\"\n" \ | 15 | "2: .asciz \""__FILE__"\"\n" \ |
16 | ".previous\n" \ | 16 | ".previous\n" \ |
17 | ".section __bug_table,\"a\"\n" \ | 17 | ".section __bug_table,\"aw\"\n" \ |
18 | "3: .long 1b-3b,2b-3b\n" \ | 18 | "3: .long 1b-3b,2b-3b\n" \ |
19 | " .short %0,%1\n" \ | 19 | " .short %0,%1\n" \ |
20 | " .org 3b+%2\n" \ | 20 | " .org 3b+%2\n" \ |
@@ -30,7 +30,7 @@ | |||
30 | asm volatile( \ | 30 | asm volatile( \ |
31 | "0: j 0b+2\n" \ | 31 | "0: j 0b+2\n" \ |
32 | "1:\n" \ | 32 | "1:\n" \ |
33 | ".section __bug_table,\"a\"\n" \ | 33 | ".section __bug_table,\"aw\"\n" \ |
34 | "2: .long 1b-2b\n" \ | 34 | "2: .long 1b-2b\n" \ |
35 | " .short %0\n" \ | 35 | " .short %0\n" \ |
36 | " .org 2b+%1\n" \ | 36 | " .org 2b+%1\n" \ |
diff --git a/arch/sh/include/asm/bug.h b/arch/sh/include/asm/bug.h index c9828f785ca0..5b5086367639 100644 --- a/arch/sh/include/asm/bug.h +++ b/arch/sh/include/asm/bug.h | |||
@@ -24,14 +24,14 @@ | |||
24 | */ | 24 | */ |
25 | #ifdef CONFIG_DEBUG_BUGVERBOSE | 25 | #ifdef CONFIG_DEBUG_BUGVERBOSE |
26 | #define _EMIT_BUG_ENTRY \ | 26 | #define _EMIT_BUG_ENTRY \ |
27 | "\t.pushsection __bug_table,\"a\"\n" \ | 27 | "\t.pushsection __bug_table,\"aw\"\n" \ |
28 | "2:\t.long 1b, %O1\n" \ | 28 | "2:\t.long 1b, %O1\n" \ |
29 | "\t.short %O2, %O3\n" \ | 29 | "\t.short %O2, %O3\n" \ |
30 | "\t.org 2b+%O4\n" \ | 30 | "\t.org 2b+%O4\n" \ |
31 | "\t.popsection\n" | 31 | "\t.popsection\n" |
32 | #else | 32 | #else |
33 | #define _EMIT_BUG_ENTRY \ | 33 | #define _EMIT_BUG_ENTRY \ |
34 | "\t.pushsection __bug_table,\"a\"\n" \ | 34 | "\t.pushsection __bug_table,\"aw\"\n" \ |
35 | "2:\t.long 1b\n" \ | 35 | "2:\t.long 1b\n" \ |
36 | "\t.short %O3\n" \ | 36 | "\t.short %O3\n" \ |
37 | "\t.org 2b+%O4\n" \ | 37 | "\t.org 2b+%O4\n" \ |
diff --git a/arch/sparc/include/asm/trap_block.h b/arch/sparc/include/asm/trap_block.h index ec9c04de3664..ff05992dae7a 100644 --- a/arch/sparc/include/asm/trap_block.h +++ b/arch/sparc/include/asm/trap_block.h | |||
@@ -54,6 +54,7 @@ extern struct trap_per_cpu trap_block[NR_CPUS]; | |||
54 | void init_cur_cpu_trap(struct thread_info *); | 54 | void init_cur_cpu_trap(struct thread_info *); |
55 | void setup_tba(void); | 55 | void setup_tba(void); |
56 | extern int ncpus_probed; | 56 | extern int ncpus_probed; |
57 | extern u64 cpu_mondo_counter[NR_CPUS]; | ||
57 | 58 | ||
58 | unsigned long real_hard_smp_processor_id(void); | 59 | unsigned long real_hard_smp_processor_id(void); |
59 | 60 | ||
diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 24f21c726dfa..f10e2f712394 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c | |||
@@ -673,12 +673,14 @@ static void dma_4v_unmap_sg(struct device *dev, struct scatterlist *sglist, | |||
673 | static int dma_4v_supported(struct device *dev, u64 device_mask) | 673 | static int dma_4v_supported(struct device *dev, u64 device_mask) |
674 | { | 674 | { |
675 | struct iommu *iommu = dev->archdata.iommu; | 675 | struct iommu *iommu = dev->archdata.iommu; |
676 | u64 dma_addr_mask; | 676 | u64 dma_addr_mask = iommu->dma_addr_mask; |
677 | 677 | ||
678 | if (device_mask > DMA_BIT_MASK(32) && iommu->atu) | 678 | if (device_mask > DMA_BIT_MASK(32)) { |
679 | dma_addr_mask = iommu->atu->dma_addr_mask; | 679 | if (iommu->atu) |
680 | else | 680 | dma_addr_mask = iommu->atu->dma_addr_mask; |
681 | dma_addr_mask = iommu->dma_addr_mask; | 681 | else |
682 | return 0; | ||
683 | } | ||
682 | 684 | ||
683 | if ((device_mask & dma_addr_mask) == dma_addr_mask) | 685 | if ((device_mask & dma_addr_mask) == dma_addr_mask) |
684 | return 1; | 686 | return 1; |
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index fdf31040a7dc..3218bc43302e 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c | |||
@@ -622,22 +622,48 @@ retry: | |||
622 | } | 622 | } |
623 | } | 623 | } |
624 | 624 | ||
625 | /* Multi-cpu list version. */ | 625 | #define CPU_MONDO_COUNTER(cpuid) (cpu_mondo_counter[cpuid]) |
626 | #define MONDO_USEC_WAIT_MIN 2 | ||
627 | #define MONDO_USEC_WAIT_MAX 100 | ||
628 | #define MONDO_RETRY_LIMIT 500000 | ||
629 | |||
630 | /* Multi-cpu list version. | ||
631 | * | ||
632 | * Deliver xcalls to 'cnt' number of cpus in 'cpu_list'. | ||
633 | * Sometimes not all cpus receive the mondo, requiring us to re-send | ||
634 | * the mondo until all cpus have received, or cpus are truly stuck | ||
635 | * unable to receive mondo, and we timeout. | ||
636 | * Occasionally a target cpu strand is borrowed briefly by hypervisor to | ||
637 | * perform guest service, such as PCIe error handling. Consider the | ||
638 | * service time, 1 second overall wait is reasonable for 1 cpu. | ||
639 | * Here two in-between mondo check wait time are defined: 2 usec for | ||
640 | * single cpu quick turn around and up to 100usec for large cpu count. | ||
641 | * Deliver mondo to large number of cpus could take longer, we adjusts | ||
642 | * the retry count as long as target cpus are making forward progress. | ||
643 | */ | ||
626 | static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) | 644 | static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) |
627 | { | 645 | { |
628 | int retries, this_cpu, prev_sent, i, saw_cpu_error; | 646 | int this_cpu, tot_cpus, prev_sent, i, rem; |
647 | int usec_wait, retries, tot_retries; | ||
648 | u16 first_cpu = 0xffff; | ||
649 | unsigned long xc_rcvd = 0; | ||
629 | unsigned long status; | 650 | unsigned long status; |
651 | int ecpuerror_id = 0; | ||
652 | int enocpu_id = 0; | ||
630 | u16 *cpu_list; | 653 | u16 *cpu_list; |
654 | u16 cpu; | ||
631 | 655 | ||
632 | this_cpu = smp_processor_id(); | 656 | this_cpu = smp_processor_id(); |
633 | |||
634 | cpu_list = __va(tb->cpu_list_pa); | 657 | cpu_list = __va(tb->cpu_list_pa); |
635 | 658 | usec_wait = cnt * MONDO_USEC_WAIT_MIN; | |
636 | saw_cpu_error = 0; | 659 | if (usec_wait > MONDO_USEC_WAIT_MAX) |
637 | retries = 0; | 660 | usec_wait = MONDO_USEC_WAIT_MAX; |
661 | retries = tot_retries = 0; | ||
662 | tot_cpus = cnt; | ||
638 | prev_sent = 0; | 663 | prev_sent = 0; |
664 | |||
639 | do { | 665 | do { |
640 | int forward_progress, n_sent; | 666 | int n_sent, mondo_delivered, target_cpu_busy; |
641 | 667 | ||
642 | status = sun4v_cpu_mondo_send(cnt, | 668 | status = sun4v_cpu_mondo_send(cnt, |
643 | tb->cpu_list_pa, | 669 | tb->cpu_list_pa, |
@@ -645,94 +671,113 @@ static void hypervisor_xcall_deliver(struct trap_per_cpu *tb, int cnt) | |||
645 | 671 | ||
646 | /* HV_EOK means all cpus received the xcall, we're done. */ | 672 | /* HV_EOK means all cpus received the xcall, we're done. */ |
647 | if (likely(status == HV_EOK)) | 673 | if (likely(status == HV_EOK)) |
648 | break; | 674 | goto xcall_done; |
675 | |||
676 | /* If not these non-fatal errors, panic */ | ||
677 | if (unlikely((status != HV_EWOULDBLOCK) && | ||
678 | (status != HV_ECPUERROR) && | ||
679 | (status != HV_ENOCPU))) | ||
680 | goto fatal_errors; | ||
649 | 681 | ||
650 | /* First, see if we made any forward progress. | 682 | /* First, see if we made any forward progress. |
651 | * | 683 | * |
684 | * Go through the cpu_list, count the target cpus that have | ||
685 | * received our mondo (n_sent), and those that did not (rem). | ||
686 | * Re-pack cpu_list with the cpus remain to be retried in the | ||
687 | * front - this simplifies tracking the truly stalled cpus. | ||
688 | * | ||
652 | * The hypervisor indicates successful sends by setting | 689 | * The hypervisor indicates successful sends by setting |
653 | * cpu list entries to the value 0xffff. | 690 | * cpu list entries to the value 0xffff. |
691 | * | ||
692 | * EWOULDBLOCK means some target cpus did not receive the | ||
693 | * mondo and retry usually helps. | ||
694 | * | ||
695 | * ECPUERROR means at least one target cpu is in error state, | ||
696 | * it's usually safe to skip the faulty cpu and retry. | ||
697 | * | ||
698 | * ENOCPU means one of the target cpu doesn't belong to the | ||
699 | * domain, perhaps offlined which is unexpected, but not | ||
700 | * fatal and it's okay to skip the offlined cpu. | ||
654 | */ | 701 | */ |
702 | rem = 0; | ||
655 | n_sent = 0; | 703 | n_sent = 0; |
656 | for (i = 0; i < cnt; i++) { | 704 | for (i = 0; i < cnt; i++) { |
657 | if (likely(cpu_list[i] == 0xffff)) | 705 | cpu = cpu_list[i]; |
706 | if (likely(cpu == 0xffff)) { | ||
658 | n_sent++; | 707 | n_sent++; |
708 | } else if ((status == HV_ECPUERROR) && | ||
709 | (sun4v_cpu_state(cpu) == HV_CPU_STATE_ERROR)) { | ||
710 | ecpuerror_id = cpu + 1; | ||
711 | } else if (status == HV_ENOCPU && !cpu_online(cpu)) { | ||
712 | enocpu_id = cpu + 1; | ||
713 | } else { | ||
714 | cpu_list[rem++] = cpu; | ||
715 | } | ||
659 | } | 716 | } |
660 | 717 | ||
661 | forward_progress = 0; | 718 | /* No cpu remained, we're done. */ |
662 | if (n_sent > prev_sent) | 719 | if (rem == 0) |
663 | forward_progress = 1; | 720 | break; |
664 | 721 | ||
665 | prev_sent = n_sent; | 722 | /* Otherwise, update the cpu count for retry. */ |
723 | cnt = rem; | ||
666 | 724 | ||
667 | /* If we get a HV_ECPUERROR, then one or more of the cpus | 725 | /* Record the overall number of mondos received by the |
668 | * in the list are in error state. Use the cpu_state() | 726 | * first of the remaining cpus. |
669 | * hypervisor call to find out which cpus are in error state. | ||
670 | */ | 727 | */ |
671 | if (unlikely(status == HV_ECPUERROR)) { | 728 | if (first_cpu != cpu_list[0]) { |
672 | for (i = 0; i < cnt; i++) { | 729 | first_cpu = cpu_list[0]; |
673 | long err; | 730 | xc_rcvd = CPU_MONDO_COUNTER(first_cpu); |
674 | u16 cpu; | 731 | } |
675 | 732 | ||
676 | cpu = cpu_list[i]; | 733 | /* Was any mondo delivered successfully? */ |
677 | if (cpu == 0xffff) | 734 | mondo_delivered = (n_sent > prev_sent); |
678 | continue; | 735 | prev_sent = n_sent; |
679 | 736 | ||
680 | err = sun4v_cpu_state(cpu); | 737 | /* or, was any target cpu busy processing other mondos? */ |
681 | if (err == HV_CPU_STATE_ERROR) { | 738 | target_cpu_busy = (xc_rcvd < CPU_MONDO_COUNTER(first_cpu)); |
682 | saw_cpu_error = (cpu + 1); | 739 | xc_rcvd = CPU_MONDO_COUNTER(first_cpu); |
683 | cpu_list[i] = 0xffff; | ||
684 | } | ||
685 | } | ||
686 | } else if (unlikely(status != HV_EWOULDBLOCK)) | ||
687 | goto fatal_mondo_error; | ||
688 | 740 | ||
689 | /* Don't bother rewriting the CPU list, just leave the | 741 | /* Retry count is for no progress. If we're making progress, |
690 | * 0xffff and non-0xffff entries in there and the | 742 | * reset the retry count. |
691 | * hypervisor will do the right thing. | ||
692 | * | ||
693 | * Only advance timeout state if we didn't make any | ||
694 | * forward progress. | ||
695 | */ | 743 | */ |
696 | if (unlikely(!forward_progress)) { | 744 | if (likely(mondo_delivered || target_cpu_busy)) { |
697 | if (unlikely(++retries > 10000)) | 745 | tot_retries += retries; |
698 | goto fatal_mondo_timeout; | 746 | retries = 0; |
699 | 747 | } else if (unlikely(retries > MONDO_RETRY_LIMIT)) { | |
700 | /* Delay a little bit to let other cpus catch up | 748 | goto fatal_mondo_timeout; |
701 | * on their cpu mondo queue work. | ||
702 | */ | ||
703 | udelay(2 * cnt); | ||
704 | } | 749 | } |
705 | } while (1); | ||
706 | 750 | ||
707 | if (unlikely(saw_cpu_error)) | 751 | /* Delay a little bit to let other cpus catch up on |
708 | goto fatal_mondo_cpu_error; | 752 | * their cpu mondo queue work. |
753 | */ | ||
754 | if (!mondo_delivered) | ||
755 | udelay(usec_wait); | ||
709 | 756 | ||
710 | return; | 757 | retries++; |
758 | } while (1); | ||
711 | 759 | ||
712 | fatal_mondo_cpu_error: | 760 | xcall_done: |
713 | printk(KERN_CRIT "CPU[%d]: SUN4V mondo cpu error, some target cpus " | 761 | if (unlikely(ecpuerror_id > 0)) { |
714 | "(including %d) were in error state\n", | 762 | pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) was in error state\n", |
715 | this_cpu, saw_cpu_error - 1); | 763 | this_cpu, ecpuerror_id - 1); |
764 | } else if (unlikely(enocpu_id > 0)) { | ||
765 | pr_crit("CPU[%d]: SUN4V mondo cpu error, target cpu(%d) does not belong to the domain\n", | ||
766 | this_cpu, enocpu_id - 1); | ||
767 | } | ||
716 | return; | 768 | return; |
717 | 769 | ||
770 | fatal_errors: | ||
771 | /* fatal errors include bad alignment, etc */ | ||
772 | pr_crit("CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) mondo_block_pa(%lx)\n", | ||
773 | this_cpu, tot_cpus, tb->cpu_list_pa, tb->cpu_mondo_block_pa); | ||
774 | panic("Unexpected SUN4V mondo error %lu\n", status); | ||
775 | |||
718 | fatal_mondo_timeout: | 776 | fatal_mondo_timeout: |
719 | printk(KERN_CRIT "CPU[%d]: SUN4V mondo timeout, no forward " | 777 | /* some cpus being non-responsive to the cpu mondo */ |
720 | " progress after %d retries.\n", | 778 | pr_crit("CPU[%d]: SUN4V mondo timeout, cpu(%d) made no forward progress after %d retries. Total target cpus(%d).\n", |
721 | this_cpu, retries); | 779 | this_cpu, first_cpu, (tot_retries + retries), tot_cpus); |
722 | goto dump_cpu_list_and_out; | 780 | panic("SUN4V mondo timeout panic\n"); |
723 | |||
724 | fatal_mondo_error: | ||
725 | printk(KERN_CRIT "CPU[%d]: Unexpected SUN4V mondo error %lu\n", | ||
726 | this_cpu, status); | ||
727 | printk(KERN_CRIT "CPU[%d]: Args were cnt(%d) cpulist_pa(%lx) " | ||
728 | "mondo_block_pa(%lx)\n", | ||
729 | this_cpu, cnt, tb->cpu_list_pa, tb->cpu_mondo_block_pa); | ||
730 | |||
731 | dump_cpu_list_and_out: | ||
732 | printk(KERN_CRIT "CPU[%d]: CPU list [ ", this_cpu); | ||
733 | for (i = 0; i < cnt; i++) | ||
734 | printk("%u ", cpu_list[i]); | ||
735 | printk("]\n"); | ||
736 | } | 781 | } |
737 | 782 | ||
738 | static void (*xcall_deliver_impl)(struct trap_per_cpu *, int); | 783 | static void (*xcall_deliver_impl)(struct trap_per_cpu *, int); |
diff --git a/arch/sparc/kernel/sun4v_ivec.S b/arch/sparc/kernel/sun4v_ivec.S index 559bc5e9c199..34631995859a 100644 --- a/arch/sparc/kernel/sun4v_ivec.S +++ b/arch/sparc/kernel/sun4v_ivec.S | |||
@@ -26,6 +26,21 @@ sun4v_cpu_mondo: | |||
26 | ldxa [%g0] ASI_SCRATCHPAD, %g4 | 26 | ldxa [%g0] ASI_SCRATCHPAD, %g4 |
27 | sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 | 27 | sub %g4, TRAP_PER_CPU_FAULT_INFO, %g4 |
28 | 28 | ||
29 | /* Get smp_processor_id() into %g3 */ | ||
30 | sethi %hi(trap_block), %g5 | ||
31 | or %g5, %lo(trap_block), %g5 | ||
32 | sub %g4, %g5, %g3 | ||
33 | srlx %g3, TRAP_BLOCK_SZ_SHIFT, %g3 | ||
34 | |||
35 | /* Increment cpu_mondo_counter[smp_processor_id()] */ | ||
36 | sethi %hi(cpu_mondo_counter), %g5 | ||
37 | or %g5, %lo(cpu_mondo_counter), %g5 | ||
38 | sllx %g3, 3, %g3 | ||
39 | add %g5, %g3, %g5 | ||
40 | ldx [%g5], %g3 | ||
41 | add %g3, 1, %g3 | ||
42 | stx %g3, [%g5] | ||
43 | |||
29 | /* Get CPU mondo queue base phys address into %g7. */ | 44 | /* Get CPU mondo queue base phys address into %g7. */ |
30 | ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7 | 45 | ldx [%g4 + TRAP_PER_CPU_CPU_MONDO_PA], %g7 |
31 | 46 | ||
diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c index 196ee5eb4d48..ad31af1dd726 100644 --- a/arch/sparc/kernel/traps_64.c +++ b/arch/sparc/kernel/traps_64.c | |||
@@ -2733,6 +2733,7 @@ void do_getpsr(struct pt_regs *regs) | |||
2733 | } | 2733 | } |
2734 | } | 2734 | } |
2735 | 2735 | ||
2736 | u64 cpu_mondo_counter[NR_CPUS] = {0}; | ||
2736 | struct trap_per_cpu trap_block[NR_CPUS]; | 2737 | struct trap_per_cpu trap_block[NR_CPUS]; |
2737 | EXPORT_SYMBOL(trap_block); | 2738 | EXPORT_SYMBOL(trap_block); |
2738 | 2739 | ||
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index fcb7604172ce..cd20ca0b4043 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug | |||
@@ -348,6 +348,7 @@ config X86_DEBUG_FPU | |||
348 | 348 | ||
349 | config PUNIT_ATOM_DEBUG | 349 | config PUNIT_ATOM_DEBUG |
350 | tristate "ATOM Punit debug driver" | 350 | tristate "ATOM Punit debug driver" |
351 | depends on PCI | ||
351 | select DEBUG_FS | 352 | select DEBUG_FS |
352 | select IOSF_MBI | 353 | select IOSF_MBI |
353 | ---help--- | 354 | ---help--- |
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 0d810fb15eac..d88a2fddba8c 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile | |||
@@ -73,12 +73,13 @@ UBSAN_SANITIZE := n | |||
73 | $(obj)/bzImage: asflags-y := $(SVGA_MODE) | 73 | $(obj)/bzImage: asflags-y := $(SVGA_MODE) |
74 | 74 | ||
75 | quiet_cmd_image = BUILD $@ | 75 | quiet_cmd_image = BUILD $@ |
76 | silent_redirect_image = >/dev/null | ||
76 | cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \ | 77 | cmd_image = $(obj)/tools/build $(obj)/setup.bin $(obj)/vmlinux.bin \ |
77 | $(obj)/zoffset.h $@ | 78 | $(obj)/zoffset.h $@ $($(quiet)redirect_image) |
78 | 79 | ||
79 | $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE | 80 | $(obj)/bzImage: $(obj)/setup.bin $(obj)/vmlinux.bin $(obj)/tools/build FORCE |
80 | $(call if_changed,image) | 81 | $(call if_changed,image) |
81 | @echo 'Kernel: $@ is ready' ' (#'`cat .version`')' | 82 | @$(kecho) 'Kernel: $@ is ready' ' (#'`cat .version`')' |
82 | 83 | ||
83 | OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S | 84 | OBJCOPYFLAGS_vmlinux.bin := -O binary -R .note -R .comment -S |
84 | $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE | 85 | $(obj)/vmlinux.bin: $(obj)/compressed/vmlinux FORCE |
diff --git a/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig index 6cf79e1a6830..0eb9f92f3717 100644 --- a/arch/x86/configs/i386_defconfig +++ b/arch/x86/configs/i386_defconfig | |||
@@ -1,5 +1,4 @@ | |||
1 | # CONFIG_64BIT is not set | 1 | # CONFIG_64BIT is not set |
2 | CONFIG_EXPERIMENTAL=y | ||
3 | # CONFIG_LOCALVERSION_AUTO is not set | 2 | # CONFIG_LOCALVERSION_AUTO is not set |
4 | CONFIG_SYSVIPC=y | 3 | CONFIG_SYSVIPC=y |
5 | CONFIG_POSIX_MQUEUE=y | 4 | CONFIG_POSIX_MQUEUE=y |
@@ -125,7 +124,6 @@ CONFIG_NF_CONNTRACK_IPV4=y | |||
125 | CONFIG_IP_NF_IPTABLES=y | 124 | CONFIG_IP_NF_IPTABLES=y |
126 | CONFIG_IP_NF_FILTER=y | 125 | CONFIG_IP_NF_FILTER=y |
127 | CONFIG_IP_NF_TARGET_REJECT=y | 126 | CONFIG_IP_NF_TARGET_REJECT=y |
128 | CONFIG_IP_NF_TARGET_ULOG=y | ||
129 | CONFIG_NF_NAT=y | 127 | CONFIG_NF_NAT=y |
130 | CONFIG_IP_NF_TARGET_MASQUERADE=y | 128 | CONFIG_IP_NF_TARGET_MASQUERADE=y |
131 | CONFIG_IP_NF_MANGLE=y | 129 | CONFIG_IP_NF_MANGLE=y |
@@ -255,7 +253,6 @@ CONFIG_USB_OHCI_HCD=y | |||
255 | CONFIG_USB_UHCI_HCD=y | 253 | CONFIG_USB_UHCI_HCD=y |
256 | CONFIG_USB_PRINTER=y | 254 | CONFIG_USB_PRINTER=y |
257 | CONFIG_USB_STORAGE=y | 255 | CONFIG_USB_STORAGE=y |
258 | CONFIG_USB_LIBUSUAL=y | ||
259 | CONFIG_EDAC=y | 256 | CONFIG_EDAC=y |
260 | CONFIG_RTC_CLASS=y | 257 | CONFIG_RTC_CLASS=y |
261 | # CONFIG_RTC_HCTOSYS is not set | 258 | # CONFIG_RTC_HCTOSYS is not set |
diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig index de45f57b410d..4a4b16e56d35 100644 --- a/arch/x86/configs/x86_64_defconfig +++ b/arch/x86/configs/x86_64_defconfig | |||
@@ -1,4 +1,3 @@ | |||
1 | CONFIG_EXPERIMENTAL=y | ||
2 | # CONFIG_LOCALVERSION_AUTO is not set | 1 | # CONFIG_LOCALVERSION_AUTO is not set |
3 | CONFIG_SYSVIPC=y | 2 | CONFIG_SYSVIPC=y |
4 | CONFIG_POSIX_MQUEUE=y | 3 | CONFIG_POSIX_MQUEUE=y |
@@ -124,7 +123,6 @@ CONFIG_NF_CONNTRACK_IPV4=y | |||
124 | CONFIG_IP_NF_IPTABLES=y | 123 | CONFIG_IP_NF_IPTABLES=y |
125 | CONFIG_IP_NF_FILTER=y | 124 | CONFIG_IP_NF_FILTER=y |
126 | CONFIG_IP_NF_TARGET_REJECT=y | 125 | CONFIG_IP_NF_TARGET_REJECT=y |
127 | CONFIG_IP_NF_TARGET_ULOG=y | ||
128 | CONFIG_NF_NAT=y | 126 | CONFIG_NF_NAT=y |
129 | CONFIG_IP_NF_TARGET_MASQUERADE=y | 127 | CONFIG_IP_NF_TARGET_MASQUERADE=y |
130 | CONFIG_IP_NF_MANGLE=y | 128 | CONFIG_IP_NF_MANGLE=y |
@@ -251,7 +249,6 @@ CONFIG_USB_OHCI_HCD=y | |||
251 | CONFIG_USB_UHCI_HCD=y | 249 | CONFIG_USB_UHCI_HCD=y |
252 | CONFIG_USB_PRINTER=y | 250 | CONFIG_USB_PRINTER=y |
253 | CONFIG_USB_STORAGE=y | 251 | CONFIG_USB_STORAGE=y |
254 | CONFIG_USB_LIBUSUAL=y | ||
255 | CONFIG_EDAC=y | 252 | CONFIG_EDAC=y |
256 | CONFIG_RTC_CLASS=y | 253 | CONFIG_RTC_CLASS=y |
257 | # CONFIG_RTC_HCTOSYS is not set | 254 | # CONFIG_RTC_HCTOSYS is not set |
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index ff1ea2fb9705..8e3db8f642a7 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
@@ -191,8 +191,8 @@ static void release_pmc_hardware(void) {} | |||
191 | 191 | ||
192 | static bool check_hw_exists(void) | 192 | static bool check_hw_exists(void) |
193 | { | 193 | { |
194 | u64 val, val_fail, val_new= ~0; | 194 | u64 val, val_fail = -1, val_new= ~0; |
195 | int i, reg, reg_fail, ret = 0; | 195 | int i, reg, reg_fail = -1, ret = 0; |
196 | int bios_fail = 0; | 196 | int bios_fail = 0; |
197 | int reg_safe = -1; | 197 | int reg_safe = -1; |
198 | 198 | ||
diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index aa62437d1aa1..98b0f0729527 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c | |||
@@ -1708,6 +1708,120 @@ static __initconst const u64 glm_hw_cache_extra_regs | |||
1708 | }, | 1708 | }, |
1709 | }; | 1709 | }; |
1710 | 1710 | ||
1711 | static __initconst const u64 glp_hw_cache_event_ids | ||
1712 | [PERF_COUNT_HW_CACHE_MAX] | ||
1713 | [PERF_COUNT_HW_CACHE_OP_MAX] | ||
1714 | [PERF_COUNT_HW_CACHE_RESULT_MAX] = { | ||
1715 | [C(L1D)] = { | ||
1716 | [C(OP_READ)] = { | ||
1717 | [C(RESULT_ACCESS)] = 0x81d0, /* MEM_UOPS_RETIRED.ALL_LOADS */ | ||
1718 | [C(RESULT_MISS)] = 0x0, | ||
1719 | }, | ||
1720 | [C(OP_WRITE)] = { | ||
1721 | [C(RESULT_ACCESS)] = 0x82d0, /* MEM_UOPS_RETIRED.ALL_STORES */ | ||
1722 | [C(RESULT_MISS)] = 0x0, | ||
1723 | }, | ||
1724 | [C(OP_PREFETCH)] = { | ||
1725 | [C(RESULT_ACCESS)] = 0x0, | ||
1726 | [C(RESULT_MISS)] = 0x0, | ||
1727 | }, | ||
1728 | }, | ||
1729 | [C(L1I)] = { | ||
1730 | [C(OP_READ)] = { | ||
1731 | [C(RESULT_ACCESS)] = 0x0380, /* ICACHE.ACCESSES */ | ||
1732 | [C(RESULT_MISS)] = 0x0280, /* ICACHE.MISSES */ | ||
1733 | }, | ||
1734 | [C(OP_WRITE)] = { | ||
1735 | [C(RESULT_ACCESS)] = -1, | ||
1736 | [C(RESULT_MISS)] = -1, | ||
1737 | }, | ||
1738 | [C(OP_PREFETCH)] = { | ||
1739 | [C(RESULT_ACCESS)] = 0x0, | ||
1740 | [C(RESULT_MISS)] = 0x0, | ||
1741 | }, | ||
1742 | }, | ||
1743 | [C(LL)] = { | ||
1744 | [C(OP_READ)] = { | ||
1745 | [C(RESULT_ACCESS)] = 0x1b7, /* OFFCORE_RESPONSE */ | ||
1746 | [C(RESULT_MISS)] = 0x1b7, /* OFFCORE_RESPONSE */ | ||
1747 | }, | ||
1748 | [C(OP_WRITE)] = { | ||
1749 | [C(RESULT_ACCESS)] = 0x1b7, /* OFFCORE_RESPONSE */ | ||
1750 | [C(RESULT_MISS)] = 0x1b7, /* OFFCORE_RESPONSE */ | ||
1751 | }, | ||
1752 | [C(OP_PREFETCH)] = { | ||
1753 | [C(RESULT_ACCESS)] = 0x0, | ||
1754 | [C(RESULT_MISS)] = 0x0, | ||
1755 | }, | ||
1756 | }, | ||
1757 | [C(DTLB)] = { | ||
1758 | [C(OP_READ)] = { | ||
1759 | [C(RESULT_ACCESS)] = 0x81d0, /* MEM_UOPS_RETIRED.ALL_LOADS */ | ||
1760 | [C(RESULT_MISS)] = 0xe08, /* DTLB_LOAD_MISSES.WALK_COMPLETED */ | ||
1761 | }, | ||
1762 | [C(OP_WRITE)] = { | ||
1763 | [C(RESULT_ACCESS)] = 0x82d0, /* MEM_UOPS_RETIRED.ALL_STORES */ | ||
1764 | [C(RESULT_MISS)] = 0xe49, /* DTLB_STORE_MISSES.WALK_COMPLETED */ | ||
1765 | }, | ||
1766 | [C(OP_PREFETCH)] = { | ||
1767 | [C(RESULT_ACCESS)] = 0x0, | ||
1768 | [C(RESULT_MISS)] = 0x0, | ||
1769 | }, | ||
1770 | }, | ||
1771 | [C(ITLB)] = { | ||
1772 | [C(OP_READ)] = { | ||
1773 | [C(RESULT_ACCESS)] = 0x00c0, /* INST_RETIRED.ANY_P */ | ||
1774 | [C(RESULT_MISS)] = 0x0481, /* ITLB.MISS */ | ||
1775 | }, | ||
1776 | [C(OP_WRITE)] = { | ||
1777 | [C(RESULT_ACCESS)] = -1, | ||
1778 | [C(RESULT_MISS)] = -1, | ||
1779 | }, | ||
1780 | [C(OP_PREFETCH)] = { | ||
1781 | [C(RESULT_ACCESS)] = -1, | ||
1782 | [C(RESULT_MISS)] = -1, | ||
1783 | }, | ||
1784 | }, | ||
1785 | [C(BPU)] = { | ||
1786 | [C(OP_READ)] = { | ||
1787 | [C(RESULT_ACCESS)] = 0x00c4, /* BR_INST_RETIRED.ALL_BRANCHES */ | ||
1788 | [C(RESULT_MISS)] = 0x00c5, /* BR_MISP_RETIRED.ALL_BRANCHES */ | ||
1789 | }, | ||
1790 | [C(OP_WRITE)] = { | ||
1791 | [C(RESULT_ACCESS)] = -1, | ||
1792 | [C(RESULT_MISS)] = -1, | ||
1793 | }, | ||
1794 | [C(OP_PREFETCH)] = { | ||
1795 | [C(RESULT_ACCESS)] = -1, | ||
1796 | [C(RESULT_MISS)] = -1, | ||
1797 | }, | ||
1798 | }, | ||
1799 | }; | ||
1800 | |||
1801 | static __initconst const u64 glp_hw_cache_extra_regs | ||
1802 | [PERF_COUNT_HW_CACHE_MAX] | ||
1803 | [PERF_COUNT_HW_CACHE_OP_MAX] | ||
1804 | [PERF_COUNT_HW_CACHE_RESULT_MAX] = { | ||
1805 | [C(LL)] = { | ||
1806 | [C(OP_READ)] = { | ||
1807 | [C(RESULT_ACCESS)] = GLM_DEMAND_READ| | ||
1808 | GLM_LLC_ACCESS, | ||
1809 | [C(RESULT_MISS)] = GLM_DEMAND_READ| | ||
1810 | GLM_LLC_MISS, | ||
1811 | }, | ||
1812 | [C(OP_WRITE)] = { | ||
1813 | [C(RESULT_ACCESS)] = GLM_DEMAND_WRITE| | ||
1814 | GLM_LLC_ACCESS, | ||
1815 | [C(RESULT_MISS)] = GLM_DEMAND_WRITE| | ||
1816 | GLM_LLC_MISS, | ||
1817 | }, | ||
1818 | [C(OP_PREFETCH)] = { | ||
1819 | [C(RESULT_ACCESS)] = 0x0, | ||
1820 | [C(RESULT_MISS)] = 0x0, | ||
1821 | }, | ||
1822 | }, | ||
1823 | }; | ||
1824 | |||
1711 | #define KNL_OT_L2_HITE BIT_ULL(19) /* Other Tile L2 Hit */ | 1825 | #define KNL_OT_L2_HITE BIT_ULL(19) /* Other Tile L2 Hit */ |
1712 | #define KNL_OT_L2_HITF BIT_ULL(20) /* Other Tile L2 Hit */ | 1826 | #define KNL_OT_L2_HITF BIT_ULL(20) /* Other Tile L2 Hit */ |
1713 | #define KNL_MCDRAM_LOCAL BIT_ULL(21) | 1827 | #define KNL_MCDRAM_LOCAL BIT_ULL(21) |
@@ -3016,6 +3130,9 @@ static int hsw_hw_config(struct perf_event *event) | |||
3016 | return 0; | 3130 | return 0; |
3017 | } | 3131 | } |
3018 | 3132 | ||
3133 | static struct event_constraint counter0_constraint = | ||
3134 | INTEL_ALL_EVENT_CONSTRAINT(0, 0x1); | ||
3135 | |||
3019 | static struct event_constraint counter2_constraint = | 3136 | static struct event_constraint counter2_constraint = |
3020 | EVENT_CONSTRAINT(0, 0x4, 0); | 3137 | EVENT_CONSTRAINT(0, 0x4, 0); |
3021 | 3138 | ||
@@ -3037,6 +3154,21 @@ hsw_get_event_constraints(struct cpu_hw_events *cpuc, int idx, | |||
3037 | return c; | 3154 | return c; |
3038 | } | 3155 | } |
3039 | 3156 | ||
3157 | static struct event_constraint * | ||
3158 | glp_get_event_constraints(struct cpu_hw_events *cpuc, int idx, | ||
3159 | struct perf_event *event) | ||
3160 | { | ||
3161 | struct event_constraint *c; | ||
3162 | |||
3163 | /* :ppp means to do reduced skid PEBS which is PMC0 only. */ | ||
3164 | if (event->attr.precise_ip == 3) | ||
3165 | return &counter0_constraint; | ||
3166 | |||
3167 | c = intel_get_event_constraints(cpuc, idx, event); | ||
3168 | |||
3169 | return c; | ||
3170 | } | ||
3171 | |||
3040 | /* | 3172 | /* |
3041 | * Broadwell: | 3173 | * Broadwell: |
3042 | * | 3174 | * |
@@ -3265,10 +3397,8 @@ static void intel_pmu_cpu_dying(int cpu) | |||
3265 | static void intel_pmu_sched_task(struct perf_event_context *ctx, | 3397 | static void intel_pmu_sched_task(struct perf_event_context *ctx, |
3266 | bool sched_in) | 3398 | bool sched_in) |
3267 | { | 3399 | { |
3268 | if (x86_pmu.pebs_active) | 3400 | intel_pmu_pebs_sched_task(ctx, sched_in); |
3269 | intel_pmu_pebs_sched_task(ctx, sched_in); | 3401 | intel_pmu_lbr_sched_task(ctx, sched_in); |
3270 | if (x86_pmu.lbr_nr) | ||
3271 | intel_pmu_lbr_sched_task(ctx, sched_in); | ||
3272 | } | 3402 | } |
3273 | 3403 | ||
3274 | PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63"); | 3404 | PMU_FORMAT_ATTR(offcore_rsp, "config1:0-63"); |
@@ -3838,6 +3968,32 @@ __init int intel_pmu_init(void) | |||
3838 | pr_cont("Goldmont events, "); | 3968 | pr_cont("Goldmont events, "); |
3839 | break; | 3969 | break; |
3840 | 3970 | ||
3971 | case INTEL_FAM6_ATOM_GEMINI_LAKE: | ||
3972 | memcpy(hw_cache_event_ids, glp_hw_cache_event_ids, | ||
3973 | sizeof(hw_cache_event_ids)); | ||
3974 | memcpy(hw_cache_extra_regs, glp_hw_cache_extra_regs, | ||
3975 | sizeof(hw_cache_extra_regs)); | ||
3976 | |||
3977 | intel_pmu_lbr_init_skl(); | ||
3978 | |||
3979 | x86_pmu.event_constraints = intel_slm_event_constraints; | ||
3980 | x86_pmu.pebs_constraints = intel_glp_pebs_event_constraints; | ||
3981 | x86_pmu.extra_regs = intel_glm_extra_regs; | ||
3982 | /* | ||
3983 | * It's recommended to use CPU_CLK_UNHALTED.CORE_P + NPEBS | ||
3984 | * for precise cycles. | ||
3985 | */ | ||
3986 | x86_pmu.pebs_aliases = NULL; | ||
3987 | x86_pmu.pebs_prec_dist = true; | ||
3988 | x86_pmu.lbr_pt_coexist = true; | ||
3989 | x86_pmu.flags |= PMU_FL_HAS_RSP_1; | ||
3990 | x86_pmu.get_event_constraints = glp_get_event_constraints; | ||
3991 | x86_pmu.cpu_events = glm_events_attrs; | ||
3992 | /* Goldmont Plus has 4-wide pipeline */ | ||
3993 | event_attr_td_total_slots_scale_glm.event_str = "4"; | ||
3994 | pr_cont("Goldmont plus events, "); | ||
3995 | break; | ||
3996 | |||
3841 | case INTEL_FAM6_WESTMERE: | 3997 | case INTEL_FAM6_WESTMERE: |
3842 | case INTEL_FAM6_WESTMERE_EP: | 3998 | case INTEL_FAM6_WESTMERE_EP: |
3843 | case INTEL_FAM6_WESTMERE_EX: | 3999 | case INTEL_FAM6_WESTMERE_EX: |
diff --git a/arch/x86/events/intel/cstate.c b/arch/x86/events/intel/cstate.c index 238ae3248ba5..4cf100ff2a37 100644 --- a/arch/x86/events/intel/cstate.c +++ b/arch/x86/events/intel/cstate.c | |||
@@ -40,16 +40,16 @@ | |||
40 | * Model specific counters: | 40 | * Model specific counters: |
41 | * MSR_CORE_C1_RES: CORE C1 Residency Counter | 41 | * MSR_CORE_C1_RES: CORE C1 Residency Counter |
42 | * perf code: 0x00 | 42 | * perf code: 0x00 |
43 | * Available model: SLM,AMT | 43 | * Available model: SLM,AMT,GLM |
44 | * Scope: Core (each processor core has a MSR) | 44 | * Scope: Core (each processor core has a MSR) |
45 | * MSR_CORE_C3_RESIDENCY: CORE C3 Residency Counter | 45 | * MSR_CORE_C3_RESIDENCY: CORE C3 Residency Counter |
46 | * perf code: 0x01 | 46 | * perf code: 0x01 |
47 | * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL | 47 | * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL,GLM |
48 | * Scope: Core | 48 | * Scope: Core |
49 | * MSR_CORE_C6_RESIDENCY: CORE C6 Residency Counter | 49 | * MSR_CORE_C6_RESIDENCY: CORE C6 Residency Counter |
50 | * perf code: 0x02 | 50 | * perf code: 0x02 |
51 | * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW | 51 | * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW |
52 | * SKL,KNL | 52 | * SKL,KNL,GLM |
53 | * Scope: Core | 53 | * Scope: Core |
54 | * MSR_CORE_C7_RESIDENCY: CORE C7 Residency Counter | 54 | * MSR_CORE_C7_RESIDENCY: CORE C7 Residency Counter |
55 | * perf code: 0x03 | 55 | * perf code: 0x03 |
@@ -57,16 +57,17 @@ | |||
57 | * Scope: Core | 57 | * Scope: Core |
58 | * MSR_PKG_C2_RESIDENCY: Package C2 Residency Counter. | 58 | * MSR_PKG_C2_RESIDENCY: Package C2 Residency Counter. |
59 | * perf code: 0x00 | 59 | * perf code: 0x00 |
60 | * Available model: SNB,IVB,HSW,BDW,SKL,KNL | 60 | * Available model: SNB,IVB,HSW,BDW,SKL,KNL,GLM |
61 | * Scope: Package (physical package) | 61 | * Scope: Package (physical package) |
62 | * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter. | 62 | * MSR_PKG_C3_RESIDENCY: Package C3 Residency Counter. |
63 | * perf code: 0x01 | 63 | * perf code: 0x01 |
64 | * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL,KNL | 64 | * Available model: NHM,WSM,SNB,IVB,HSW,BDW,SKL,KNL |
65 | * GLM | ||
65 | * Scope: Package (physical package) | 66 | * Scope: Package (physical package) |
66 | * MSR_PKG_C6_RESIDENCY: Package C6 Residency Counter. | 67 | * MSR_PKG_C6_RESIDENCY: Package C6 Residency Counter. |
67 | * perf code: 0x02 | 68 | * perf code: 0x02 |
68 | * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW | 69 | * Available model: SLM,AMT,NHM,WSM,SNB,IVB,HSW,BDW |
69 | * SKL,KNL | 70 | * SKL,KNL,GLM |
70 | * Scope: Package (physical package) | 71 | * Scope: Package (physical package) |
71 | * MSR_PKG_C7_RESIDENCY: Package C7 Residency Counter. | 72 | * MSR_PKG_C7_RESIDENCY: Package C7 Residency Counter. |
72 | * perf code: 0x03 | 73 | * perf code: 0x03 |
@@ -82,7 +83,7 @@ | |||
82 | * Scope: Package (physical package) | 83 | * Scope: Package (physical package) |
83 | * MSR_PKG_C10_RESIDENCY: Package C10 Residency Counter. | 84 | * MSR_PKG_C10_RESIDENCY: Package C10 Residency Counter. |
84 | * perf code: 0x06 | 85 | * perf code: 0x06 |
85 | * Available model: HSW ULT only | 86 | * Available model: HSW ULT, GLM |
86 | * Scope: Package (physical package) | 87 | * Scope: Package (physical package) |
87 | * | 88 | * |
88 | */ | 89 | */ |
@@ -504,6 +505,17 @@ static const struct cstate_model knl_cstates __initconst = { | |||
504 | }; | 505 | }; |
505 | 506 | ||
506 | 507 | ||
508 | static const struct cstate_model glm_cstates __initconst = { | ||
509 | .core_events = BIT(PERF_CSTATE_CORE_C1_RES) | | ||
510 | BIT(PERF_CSTATE_CORE_C3_RES) | | ||
511 | BIT(PERF_CSTATE_CORE_C6_RES), | ||
512 | |||
513 | .pkg_events = BIT(PERF_CSTATE_PKG_C2_RES) | | ||
514 | BIT(PERF_CSTATE_PKG_C3_RES) | | ||
515 | BIT(PERF_CSTATE_PKG_C6_RES) | | ||
516 | BIT(PERF_CSTATE_PKG_C10_RES), | ||
517 | }; | ||
518 | |||
507 | 519 | ||
508 | #define X86_CSTATES_MODEL(model, states) \ | 520 | #define X86_CSTATES_MODEL(model, states) \ |
509 | { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long) &(states) } | 521 | { X86_VENDOR_INTEL, 6, model, X86_FEATURE_ANY, (unsigned long) &(states) } |
@@ -546,6 +558,8 @@ static const struct x86_cpu_id intel_cstates_match[] __initconst = { | |||
546 | 558 | ||
547 | X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNL, knl_cstates), | 559 | X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNL, knl_cstates), |
548 | X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNM, knl_cstates), | 560 | X86_CSTATES_MODEL(INTEL_FAM6_XEON_PHI_KNM, knl_cstates), |
561 | |||
562 | X86_CSTATES_MODEL(INTEL_FAM6_ATOM_GOLDMONT, glm_cstates), | ||
549 | { }, | 563 | { }, |
550 | }; | 564 | }; |
551 | MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match); | 565 | MODULE_DEVICE_TABLE(x86cpu, intel_cstates_match); |
diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index c6d23ffe422d..a322fed5f8ed 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c | |||
@@ -606,12 +606,6 @@ static inline void intel_pmu_drain_pebs_buffer(void) | |||
606 | x86_pmu.drain_pebs(®s); | 606 | x86_pmu.drain_pebs(®s); |
607 | } | 607 | } |
608 | 608 | ||
609 | void intel_pmu_pebs_sched_task(struct perf_event_context *ctx, bool sched_in) | ||
610 | { | ||
611 | if (!sched_in) | ||
612 | intel_pmu_drain_pebs_buffer(); | ||
613 | } | ||
614 | |||
615 | /* | 609 | /* |
616 | * PEBS | 610 | * PEBS |
617 | */ | 611 | */ |
@@ -651,6 +645,12 @@ struct event_constraint intel_glm_pebs_event_constraints[] = { | |||
651 | EVENT_CONSTRAINT_END | 645 | EVENT_CONSTRAINT_END |
652 | }; | 646 | }; |
653 | 647 | ||
648 | struct event_constraint intel_glp_pebs_event_constraints[] = { | ||
649 | /* Allow all events as PEBS with no flags */ | ||
650 | INTEL_ALL_EVENT_CONSTRAINT(0, 0xf), | ||
651 | EVENT_CONSTRAINT_END | ||
652 | }; | ||
653 | |||
654 | struct event_constraint intel_nehalem_pebs_event_constraints[] = { | 654 | struct event_constraint intel_nehalem_pebs_event_constraints[] = { |
655 | INTEL_PLD_CONSTRAINT(0x100b, 0xf), /* MEM_INST_RETIRED.* */ | 655 | INTEL_PLD_CONSTRAINT(0x100b, 0xf), /* MEM_INST_RETIRED.* */ |
656 | INTEL_FLAGS_EVENT_CONSTRAINT(0x0f, 0xf), /* MEM_UNCORE_RETIRED.* */ | 656 | INTEL_FLAGS_EVENT_CONSTRAINT(0x0f, 0xf), /* MEM_UNCORE_RETIRED.* */ |
@@ -816,6 +816,14 @@ static inline bool pebs_needs_sched_cb(struct cpu_hw_events *cpuc) | |||
816 | return cpuc->n_pebs && (cpuc->n_pebs == cpuc->n_large_pebs); | 816 | return cpuc->n_pebs && (cpuc->n_pebs == cpuc->n_large_pebs); |
817 | } | 817 | } |
818 | 818 | ||
819 | void intel_pmu_pebs_sched_task(struct perf_event_context *ctx, bool sched_in) | ||
820 | { | ||
821 | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | ||
822 | |||
823 | if (!sched_in && pebs_needs_sched_cb(cpuc)) | ||
824 | intel_pmu_drain_pebs_buffer(); | ||
825 | } | ||
826 | |||
819 | static inline void pebs_update_threshold(struct cpu_hw_events *cpuc) | 827 | static inline void pebs_update_threshold(struct cpu_hw_events *cpuc) |
820 | { | 828 | { |
821 | struct debug_store *ds = cpuc->ds; | 829 | struct debug_store *ds = cpuc->ds; |
@@ -889,6 +897,8 @@ void intel_pmu_pebs_enable(struct perf_event *event) | |||
889 | if (hwc->flags & PERF_X86_EVENT_AUTO_RELOAD) { | 897 | if (hwc->flags & PERF_X86_EVENT_AUTO_RELOAD) { |
890 | ds->pebs_event_reset[hwc->idx] = | 898 | ds->pebs_event_reset[hwc->idx] = |
891 | (u64)(-hwc->sample_period) & x86_pmu.cntval_mask; | 899 | (u64)(-hwc->sample_period) & x86_pmu.cntval_mask; |
900 | } else { | ||
901 | ds->pebs_event_reset[hwc->idx] = 0; | ||
892 | } | 902 | } |
893 | } | 903 | } |
894 | 904 | ||
diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index eb261656a320..955457a30197 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c | |||
@@ -380,8 +380,12 @@ static void __intel_pmu_lbr_save(struct x86_perf_task_context *task_ctx) | |||
380 | 380 | ||
381 | void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in) | 381 | void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in) |
382 | { | 382 | { |
383 | struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); | ||
383 | struct x86_perf_task_context *task_ctx; | 384 | struct x86_perf_task_context *task_ctx; |
384 | 385 | ||
386 | if (!cpuc->lbr_users) | ||
387 | return; | ||
388 | |||
385 | /* | 389 | /* |
386 | * If LBR callstack feature is enabled and the stack was saved when | 390 | * If LBR callstack feature is enabled and the stack was saved when |
387 | * the task was scheduled out, restore the stack. Otherwise flush | 391 | * the task was scheduled out, restore the stack. Otherwise flush |
diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 53728eea1bed..476aec3a4cab 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h | |||
@@ -879,6 +879,8 @@ extern struct event_constraint intel_slm_pebs_event_constraints[]; | |||
879 | 879 | ||
880 | extern struct event_constraint intel_glm_pebs_event_constraints[]; | 880 | extern struct event_constraint intel_glm_pebs_event_constraints[]; |
881 | 881 | ||
882 | extern struct event_constraint intel_glp_pebs_event_constraints[]; | ||
883 | |||
882 | extern struct event_constraint intel_nehalem_pebs_event_constraints[]; | 884 | extern struct event_constraint intel_nehalem_pebs_event_constraints[]; |
883 | 885 | ||
884 | extern struct event_constraint intel_westmere_pebs_event_constraints[]; | 886 | extern struct event_constraint intel_westmere_pebs_event_constraints[]; |
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h index 39e702d90cdb..aa6b2023d8f8 100644 --- a/arch/x86/include/asm/bug.h +++ b/arch/x86/include/asm/bug.h | |||
@@ -35,7 +35,7 @@ | |||
35 | #define _BUG_FLAGS(ins, flags) \ | 35 | #define _BUG_FLAGS(ins, flags) \ |
36 | do { \ | 36 | do { \ |
37 | asm volatile("1:\t" ins "\n" \ | 37 | asm volatile("1:\t" ins "\n" \ |
38 | ".pushsection __bug_table,\"a\"\n" \ | 38 | ".pushsection __bug_table,\"aw\"\n" \ |
39 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ | 39 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ |
40 | "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ | 40 | "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ |
41 | "\t.word %c1" "\t# bug_entry::line\n" \ | 41 | "\t.word %c1" "\t# bug_entry::line\n" \ |
@@ -52,7 +52,7 @@ do { \ | |||
52 | #define _BUG_FLAGS(ins, flags) \ | 52 | #define _BUG_FLAGS(ins, flags) \ |
53 | do { \ | 53 | do { \ |
54 | asm volatile("1:\t" ins "\n" \ | 54 | asm volatile("1:\t" ins "\n" \ |
55 | ".pushsection __bug_table,\"a\"\n" \ | 55 | ".pushsection __bug_table,\"aw\"\n" \ |
56 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ | 56 | "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ |
57 | "\t.word %c0" "\t# bug_entry::flags\n" \ | 57 | "\t.word %c0" "\t# bug_entry::flags\n" \ |
58 | "\t.org 2b+%c1\n" \ | 58 | "\t.org 2b+%c1\n" \ |
diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 7afb0e2f07f4..48febf07e828 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h | |||
@@ -328,13 +328,13 @@ static inline unsigned type in##bwl##_p(int port) \ | |||
328 | static inline void outs##bwl(int port, const void *addr, unsigned long count) \ | 328 | static inline void outs##bwl(int port, const void *addr, unsigned long count) \ |
329 | { \ | 329 | { \ |
330 | asm volatile("rep; outs" #bwl \ | 330 | asm volatile("rep; outs" #bwl \ |
331 | : "+S"(addr), "+c"(count) : "d"(port)); \ | 331 | : "+S"(addr), "+c"(count) : "d"(port) : "memory"); \ |
332 | } \ | 332 | } \ |
333 | \ | 333 | \ |
334 | static inline void ins##bwl(int port, void *addr, unsigned long count) \ | 334 | static inline void ins##bwl(int port, void *addr, unsigned long count) \ |
335 | { \ | 335 | { \ |
336 | asm volatile("rep; ins" #bwl \ | 336 | asm volatile("rep; ins" #bwl \ |
337 | : "+D"(addr), "+c"(count) : "d"(port)); \ | 337 | : "+D"(addr), "+c"(count) : "d"(port) : "memory"); \ |
338 | } | 338 | } |
339 | 339 | ||
340 | BUILDIO(b, b, char) | 340 | BUILDIO(b, b, char) |
diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h index 34b984c60790..6cf65437b5e5 100644 --- a/arch/x86/include/asm/kprobes.h +++ b/arch/x86/include/asm/kprobes.h | |||
@@ -52,10 +52,10 @@ typedef u8 kprobe_opcode_t; | |||
52 | #define flush_insn_slot(p) do { } while (0) | 52 | #define flush_insn_slot(p) do { } while (0) |
53 | 53 | ||
54 | /* optinsn template addresses */ | 54 | /* optinsn template addresses */ |
55 | extern __visible kprobe_opcode_t optprobe_template_entry; | 55 | extern __visible kprobe_opcode_t optprobe_template_entry[]; |
56 | extern __visible kprobe_opcode_t optprobe_template_val; | 56 | extern __visible kprobe_opcode_t optprobe_template_val[]; |
57 | extern __visible kprobe_opcode_t optprobe_template_call; | 57 | extern __visible kprobe_opcode_t optprobe_template_call[]; |
58 | extern __visible kprobe_opcode_t optprobe_template_end; | 58 | extern __visible kprobe_opcode_t optprobe_template_end[]; |
59 | #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + RELATIVE_ADDR_SIZE) | 59 | #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + RELATIVE_ADDR_SIZE) |
60 | #define MAX_OPTINSN_SIZE \ | 60 | #define MAX_OPTINSN_SIZE \ |
61 | (((unsigned long)&optprobe_template_end - \ | 61 | (((unsigned long)&optprobe_template_end - \ |
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index ecfcb6643c9b..265c907d7d4c 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -293,7 +293,7 @@ static inline unsigned long __get_current_cr3_fast(void) | |||
293 | unsigned long cr3 = __pa(this_cpu_read(cpu_tlbstate.loaded_mm)->pgd); | 293 | unsigned long cr3 = __pa(this_cpu_read(cpu_tlbstate.loaded_mm)->pgd); |
294 | 294 | ||
295 | /* For now, be very restrictive about when this can be called. */ | 295 | /* For now, be very restrictive about when this can be called. */ |
296 | VM_WARN_ON(in_nmi() || !in_atomic()); | 296 | VM_WARN_ON(in_nmi() || preemptible()); |
297 | 297 | ||
298 | VM_BUG_ON(cr3 != __read_cr3()); | 298 | VM_BUG_ON(cr3 != __read_cr3()); |
299 | return cr3; | 299 | return cr3; |
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h index cb976bab6299..9ffc36bfe4cd 100644 --- a/arch/x86/include/asm/paravirt_types.h +++ b/arch/x86/include/asm/paravirt_types.h | |||
@@ -84,7 +84,7 @@ struct pv_init_ops { | |||
84 | */ | 84 | */ |
85 | unsigned (*patch)(u8 type, u16 clobber, void *insnbuf, | 85 | unsigned (*patch)(u8 type, u16 clobber, void *insnbuf, |
86 | unsigned long addr, unsigned len); | 86 | unsigned long addr, unsigned len); |
87 | }; | 87 | } __no_randomize_layout; |
88 | 88 | ||
89 | 89 | ||
90 | struct pv_lazy_ops { | 90 | struct pv_lazy_ops { |
@@ -92,12 +92,12 @@ struct pv_lazy_ops { | |||
92 | void (*enter)(void); | 92 | void (*enter)(void); |
93 | void (*leave)(void); | 93 | void (*leave)(void); |
94 | void (*flush)(void); | 94 | void (*flush)(void); |
95 | }; | 95 | } __no_randomize_layout; |
96 | 96 | ||
97 | struct pv_time_ops { | 97 | struct pv_time_ops { |
98 | unsigned long long (*sched_clock)(void); | 98 | unsigned long long (*sched_clock)(void); |
99 | unsigned long long (*steal_clock)(int cpu); | 99 | unsigned long long (*steal_clock)(int cpu); |
100 | }; | 100 | } __no_randomize_layout; |
101 | 101 | ||
102 | struct pv_cpu_ops { | 102 | struct pv_cpu_ops { |
103 | /* hooks for various privileged instructions */ | 103 | /* hooks for various privileged instructions */ |
@@ -176,7 +176,7 @@ struct pv_cpu_ops { | |||
176 | 176 | ||
177 | void (*start_context_switch)(struct task_struct *prev); | 177 | void (*start_context_switch)(struct task_struct *prev); |
178 | void (*end_context_switch)(struct task_struct *next); | 178 | void (*end_context_switch)(struct task_struct *next); |
179 | }; | 179 | } __no_randomize_layout; |
180 | 180 | ||
181 | struct pv_irq_ops { | 181 | struct pv_irq_ops { |
182 | /* | 182 | /* |
@@ -199,7 +199,7 @@ struct pv_irq_ops { | |||
199 | #ifdef CONFIG_X86_64 | 199 | #ifdef CONFIG_X86_64 |
200 | void (*adjust_exception_frame)(void); | 200 | void (*adjust_exception_frame)(void); |
201 | #endif | 201 | #endif |
202 | }; | 202 | } __no_randomize_layout; |
203 | 203 | ||
204 | struct pv_mmu_ops { | 204 | struct pv_mmu_ops { |
205 | unsigned long (*read_cr2)(void); | 205 | unsigned long (*read_cr2)(void); |
@@ -305,7 +305,7 @@ struct pv_mmu_ops { | |||
305 | an mfn. We can tell which is which from the index. */ | 305 | an mfn. We can tell which is which from the index. */ |
306 | void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, | 306 | void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx, |
307 | phys_addr_t phys, pgprot_t flags); | 307 | phys_addr_t phys, pgprot_t flags); |
308 | }; | 308 | } __no_randomize_layout; |
309 | 309 | ||
310 | struct arch_spinlock; | 310 | struct arch_spinlock; |
311 | #ifdef CONFIG_SMP | 311 | #ifdef CONFIG_SMP |
@@ -322,7 +322,7 @@ struct pv_lock_ops { | |||
322 | void (*kick)(int cpu); | 322 | void (*kick)(int cpu); |
323 | 323 | ||
324 | struct paravirt_callee_save vcpu_is_preempted; | 324 | struct paravirt_callee_save vcpu_is_preempted; |
325 | }; | 325 | } __no_randomize_layout; |
326 | 326 | ||
327 | /* This contains all the paravirt structures: we get a convenient | 327 | /* This contains all the paravirt structures: we get a convenient |
328 | * number for each function using the offset which we use to indicate | 328 | * number for each function using the offset which we use to indicate |
@@ -334,7 +334,7 @@ struct paravirt_patch_template { | |||
334 | struct pv_irq_ops pv_irq_ops; | 334 | struct pv_irq_ops pv_irq_ops; |
335 | struct pv_mmu_ops pv_mmu_ops; | 335 | struct pv_mmu_ops pv_mmu_ops; |
336 | struct pv_lock_ops pv_lock_ops; | 336 | struct pv_lock_ops pv_lock_ops; |
337 | }; | 337 | } __no_randomize_layout; |
338 | 338 | ||
339 | extern struct pv_info pv_info; | 339 | extern struct pv_info pv_info; |
340 | extern struct pv_init_ops pv_init_ops; | 340 | extern struct pv_init_ops pv_init_ops; |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 6a79547e8ee0..028245e1c42b 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -129,7 +129,7 @@ struct cpuinfo_x86 { | |||
129 | /* Index into per_cpu list: */ | 129 | /* Index into per_cpu list: */ |
130 | u16 cpu_index; | 130 | u16 cpu_index; |
131 | u32 microcode; | 131 | u32 microcode; |
132 | }; | 132 | } __randomize_layout; |
133 | 133 | ||
134 | struct cpuid_regs { | 134 | struct cpuid_regs { |
135 | u32 eax, ebx, ecx, edx; | 135 | u32 eax, ebx, ecx, edx; |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 6bb680671088..7491e73d9253 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -347,6 +347,14 @@ static void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, | |||
347 | struct mpc_intsrc mp_irq; | 347 | struct mpc_intsrc mp_irq; |
348 | 348 | ||
349 | /* | 349 | /* |
350 | * Check bus_irq boundary. | ||
351 | */ | ||
352 | if (bus_irq >= NR_IRQS_LEGACY) { | ||
353 | pr_warn("Invalid bus_irq %u for legacy override\n", bus_irq); | ||
354 | return; | ||
355 | } | ||
356 | |||
357 | /* | ||
350 | * Convert 'gsi' to 'ioapic.pin'. | 358 | * Convert 'gsi' to 'ioapic.pin'. |
351 | */ | 359 | */ |
352 | ioapic = mp_find_ioapic(gsi); | 360 | ioapic = mp_find_ioapic(gsi); |
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index b4f5f73febdb..237e9c2341c7 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -2093,7 +2093,7 @@ static inline void __init check_timer(void) | |||
2093 | int idx; | 2093 | int idx; |
2094 | idx = find_irq_entry(apic1, pin1, mp_INT); | 2094 | idx = find_irq_entry(apic1, pin1, mp_INT); |
2095 | if (idx != -1 && irq_trigger(idx)) | 2095 | if (idx != -1 && irq_trigger(idx)) |
2096 | unmask_ioapic_irq(irq_get_chip_data(0)); | 2096 | unmask_ioapic_irq(irq_get_irq_data(0)); |
2097 | } | 2097 | } |
2098 | irq_domain_deactivate_irq(irq_data); | 2098 | irq_domain_deactivate_irq(irq_data); |
2099 | irq_domain_activate_irq(irq_data); | 2099 | irq_domain_activate_irq(irq_data); |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index bb5abe8f5fd4..3b9e220621f8 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -134,6 +134,7 @@ static void init_amd_k6(struct cpuinfo_x86 *c) | |||
134 | 134 | ||
135 | n = K6_BUG_LOOP; | 135 | n = K6_BUG_LOOP; |
136 | f_vide = vide; | 136 | f_vide = vide; |
137 | OPTIMIZER_HIDE_VAR(f_vide); | ||
137 | d = rdtsc(); | 138 | d = rdtsc(); |
138 | while (n--) | 139 | while (n--) |
139 | f_vide(); | 140 | f_vide(); |
diff --git a/arch/x86/kernel/devicetree.c b/arch/x86/kernel/devicetree.c index 3fe45f84ced4..cbf1f6ba39a8 100644 --- a/arch/x86/kernel/devicetree.c +++ b/arch/x86/kernel/devicetree.c | |||
@@ -235,8 +235,7 @@ static void __init dtb_add_ioapic(struct device_node *dn) | |||
235 | 235 | ||
236 | ret = of_address_to_resource(dn, 0, &r); | 236 | ret = of_address_to_resource(dn, 0, &r); |
237 | if (ret) { | 237 | if (ret) { |
238 | printk(KERN_ERR "Can't obtain address from node %s.\n", | 238 | printk(KERN_ERR "Can't obtain address from device node %pOF.\n", dn); |
239 | dn->full_name); | ||
240 | return; | 239 | return; |
241 | } | 240 | } |
242 | mp_register_ioapic(++ioapic_id, r.start, gsi_top, &cfg); | 241 | mp_register_ioapic(++ioapic_id, r.start, gsi_top, &cfg); |
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 760433b2574a..2688c7dc5323 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig | |||
@@ -22,7 +22,7 @@ config KVM | |||
22 | depends on HAVE_KVM | 22 | depends on HAVE_KVM |
23 | depends on HIGH_RES_TIMERS | 23 | depends on HIGH_RES_TIMERS |
24 | # for TASKSTATS/TASK_DELAY_ACCT: | 24 | # for TASKSTATS/TASK_DELAY_ACCT: |
25 | depends on NET | 25 | depends on NET && MULTIUSER |
26 | select PREEMPT_NOTIFIERS | 26 | select PREEMPT_NOTIFIERS |
27 | select MMU_NOTIFIER | 27 | select MMU_NOTIFIER |
28 | select ANON_INODES | 28 | select ANON_INODES |
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 2695a34fa1c5..337b6d2730fa 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c | |||
@@ -649,9 +649,10 @@ void kvm_hv_process_stimers(struct kvm_vcpu *vcpu) | |||
649 | } | 649 | } |
650 | 650 | ||
651 | if ((stimer->config & HV_STIMER_ENABLE) && | 651 | if ((stimer->config & HV_STIMER_ENABLE) && |
652 | stimer->count) | 652 | stimer->count) { |
653 | stimer_start(stimer); | 653 | if (!stimer->msg_pending) |
654 | else | 654 | stimer_start(stimer); |
655 | } else | ||
655 | stimer_cleanup(stimer); | 656 | stimer_cleanup(stimer); |
656 | } | 657 | } |
657 | } | 658 | } |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 84e62acf2dd8..29fd8af5c347 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -198,7 +198,8 @@ struct loaded_vmcs { | |||
198 | struct vmcs *vmcs; | 198 | struct vmcs *vmcs; |
199 | struct vmcs *shadow_vmcs; | 199 | struct vmcs *shadow_vmcs; |
200 | int cpu; | 200 | int cpu; |
201 | int launched; | 201 | bool launched; |
202 | bool nmi_known_unmasked; | ||
202 | struct list_head loaded_vmcss_on_cpu_link; | 203 | struct list_head loaded_vmcss_on_cpu_link; |
203 | }; | 204 | }; |
204 | 205 | ||
@@ -2326,6 +2327,11 @@ static void vmx_vcpu_put(struct kvm_vcpu *vcpu) | |||
2326 | __vmx_load_host_state(to_vmx(vcpu)); | 2327 | __vmx_load_host_state(to_vmx(vcpu)); |
2327 | } | 2328 | } |
2328 | 2329 | ||
2330 | static bool emulation_required(struct kvm_vcpu *vcpu) | ||
2331 | { | ||
2332 | return emulate_invalid_guest_state && !guest_state_valid(vcpu); | ||
2333 | } | ||
2334 | |||
2329 | static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu); | 2335 | static void vmx_decache_cr0_guest_bits(struct kvm_vcpu *vcpu); |
2330 | 2336 | ||
2331 | /* | 2337 | /* |
@@ -2363,6 +2369,8 @@ static unsigned long vmx_get_rflags(struct kvm_vcpu *vcpu) | |||
2363 | 2369 | ||
2364 | static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) | 2370 | static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) |
2365 | { | 2371 | { |
2372 | unsigned long old_rflags = vmx_get_rflags(vcpu); | ||
2373 | |||
2366 | __set_bit(VCPU_EXREG_RFLAGS, (ulong *)&vcpu->arch.regs_avail); | 2374 | __set_bit(VCPU_EXREG_RFLAGS, (ulong *)&vcpu->arch.regs_avail); |
2367 | to_vmx(vcpu)->rflags = rflags; | 2375 | to_vmx(vcpu)->rflags = rflags; |
2368 | if (to_vmx(vcpu)->rmode.vm86_active) { | 2376 | if (to_vmx(vcpu)->rmode.vm86_active) { |
@@ -2370,6 +2378,9 @@ static void vmx_set_rflags(struct kvm_vcpu *vcpu, unsigned long rflags) | |||
2370 | rflags |= X86_EFLAGS_IOPL | X86_EFLAGS_VM; | 2378 | rflags |= X86_EFLAGS_IOPL | X86_EFLAGS_VM; |
2371 | } | 2379 | } |
2372 | vmcs_writel(GUEST_RFLAGS, rflags); | 2380 | vmcs_writel(GUEST_RFLAGS, rflags); |
2381 | |||
2382 | if ((old_rflags ^ to_vmx(vcpu)->rflags) & X86_EFLAGS_VM) | ||
2383 | to_vmx(vcpu)->emulation_required = emulation_required(vcpu); | ||
2373 | } | 2384 | } |
2374 | 2385 | ||
2375 | static u32 vmx_get_pkru(struct kvm_vcpu *vcpu) | 2386 | static u32 vmx_get_pkru(struct kvm_vcpu *vcpu) |
@@ -3857,11 +3868,6 @@ static __init int alloc_kvm_area(void) | |||
3857 | return 0; | 3868 | return 0; |
3858 | } | 3869 | } |
3859 | 3870 | ||
3860 | static bool emulation_required(struct kvm_vcpu *vcpu) | ||
3861 | { | ||
3862 | return emulate_invalid_guest_state && !guest_state_valid(vcpu); | ||
3863 | } | ||
3864 | |||
3865 | static void fix_pmode_seg(struct kvm_vcpu *vcpu, int seg, | 3871 | static void fix_pmode_seg(struct kvm_vcpu *vcpu, int seg, |
3866 | struct kvm_segment *save) | 3872 | struct kvm_segment *save) |
3867 | { | 3873 | { |
@@ -5510,10 +5516,8 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu) | |||
5510 | { | 5516 | { |
5511 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 5517 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
5512 | 5518 | ||
5513 | if (!is_guest_mode(vcpu)) { | 5519 | ++vcpu->stat.nmi_injections; |
5514 | ++vcpu->stat.nmi_injections; | 5520 | vmx->loaded_vmcs->nmi_known_unmasked = false; |
5515 | vmx->nmi_known_unmasked = false; | ||
5516 | } | ||
5517 | 5521 | ||
5518 | if (vmx->rmode.vm86_active) { | 5522 | if (vmx->rmode.vm86_active) { |
5519 | if (kvm_inject_realmode_interrupt(vcpu, NMI_VECTOR, 0) != EMULATE_DONE) | 5523 | if (kvm_inject_realmode_interrupt(vcpu, NMI_VECTOR, 0) != EMULATE_DONE) |
@@ -5527,16 +5531,21 @@ static void vmx_inject_nmi(struct kvm_vcpu *vcpu) | |||
5527 | 5531 | ||
5528 | static bool vmx_get_nmi_mask(struct kvm_vcpu *vcpu) | 5532 | static bool vmx_get_nmi_mask(struct kvm_vcpu *vcpu) |
5529 | { | 5533 | { |
5530 | if (to_vmx(vcpu)->nmi_known_unmasked) | 5534 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
5535 | bool masked; | ||
5536 | |||
5537 | if (vmx->loaded_vmcs->nmi_known_unmasked) | ||
5531 | return false; | 5538 | return false; |
5532 | return vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & GUEST_INTR_STATE_NMI; | 5539 | masked = vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & GUEST_INTR_STATE_NMI; |
5540 | vmx->loaded_vmcs->nmi_known_unmasked = !masked; | ||
5541 | return masked; | ||
5533 | } | 5542 | } |
5534 | 5543 | ||
5535 | static void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked) | 5544 | static void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked) |
5536 | { | 5545 | { |
5537 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 5546 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
5538 | 5547 | ||
5539 | vmx->nmi_known_unmasked = !masked; | 5548 | vmx->loaded_vmcs->nmi_known_unmasked = !masked; |
5540 | if (masked) | 5549 | if (masked) |
5541 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, | 5550 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, |
5542 | GUEST_INTR_STATE_NMI); | 5551 | GUEST_INTR_STATE_NMI); |
@@ -8736,7 +8745,7 @@ static void vmx_recover_nmi_blocking(struct vcpu_vmx *vmx) | |||
8736 | 8745 | ||
8737 | idtv_info_valid = vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK; | 8746 | idtv_info_valid = vmx->idt_vectoring_info & VECTORING_INFO_VALID_MASK; |
8738 | 8747 | ||
8739 | if (vmx->nmi_known_unmasked) | 8748 | if (vmx->loaded_vmcs->nmi_known_unmasked) |
8740 | return; | 8749 | return; |
8741 | /* | 8750 | /* |
8742 | * Can't use vmx->exit_intr_info since we're not sure what | 8751 | * Can't use vmx->exit_intr_info since we're not sure what |
@@ -8760,7 +8769,7 @@ static void vmx_recover_nmi_blocking(struct vcpu_vmx *vmx) | |||
8760 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, | 8769 | vmcs_set_bits(GUEST_INTERRUPTIBILITY_INFO, |
8761 | GUEST_INTR_STATE_NMI); | 8770 | GUEST_INTR_STATE_NMI); |
8762 | else | 8771 | else |
8763 | vmx->nmi_known_unmasked = | 8772 | vmx->loaded_vmcs->nmi_known_unmasked = |
8764 | !(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) | 8773 | !(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) |
8765 | & GUEST_INTR_STATE_NMI); | 8774 | & GUEST_INTR_STATE_NMI); |
8766 | } | 8775 | } |
@@ -10488,6 +10497,7 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) | |||
10488 | { | 10497 | { |
10489 | struct vmcs12 *vmcs12; | 10498 | struct vmcs12 *vmcs12; |
10490 | struct vcpu_vmx *vmx = to_vmx(vcpu); | 10499 | struct vcpu_vmx *vmx = to_vmx(vcpu); |
10500 | u32 interrupt_shadow = vmx_get_interrupt_shadow(vcpu); | ||
10491 | u32 exit_qual; | 10501 | u32 exit_qual; |
10492 | int ret; | 10502 | int ret; |
10493 | 10503 | ||
@@ -10512,6 +10522,12 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch) | |||
10512 | * for misconfigurations which will anyway be caught by the processor | 10522 | * for misconfigurations which will anyway be caught by the processor |
10513 | * when using the merged vmcs02. | 10523 | * when using the merged vmcs02. |
10514 | */ | 10524 | */ |
10525 | if (interrupt_shadow & KVM_X86_SHADOW_INT_MOV_SS) { | ||
10526 | nested_vmx_failValid(vcpu, | ||
10527 | VMXERR_ENTRY_EVENTS_BLOCKED_BY_MOV_SS); | ||
10528 | goto out; | ||
10529 | } | ||
10530 | |||
10515 | if (vmcs12->launch_state == launch) { | 10531 | if (vmcs12->launch_state == launch) { |
10516 | nested_vmx_failValid(vcpu, | 10532 | nested_vmx_failValid(vcpu, |
10517 | launch ? VMXERR_VMLAUNCH_NONCLEAR_VMCS | 10533 | launch ? VMXERR_VMLAUNCH_NONCLEAR_VMCS |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 5b8f07889f6a..82a63c59f77b 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -597,8 +597,8 @@ bool pdptrs_changed(struct kvm_vcpu *vcpu) | |||
597 | (unsigned long *)&vcpu->arch.regs_avail)) | 597 | (unsigned long *)&vcpu->arch.regs_avail)) |
598 | return true; | 598 | return true; |
599 | 599 | ||
600 | gfn = (kvm_read_cr3(vcpu) & ~31u) >> PAGE_SHIFT; | 600 | gfn = (kvm_read_cr3(vcpu) & ~31ul) >> PAGE_SHIFT; |
601 | offset = (kvm_read_cr3(vcpu) & ~31u) & (PAGE_SIZE - 1); | 601 | offset = (kvm_read_cr3(vcpu) & ~31ul) & (PAGE_SIZE - 1); |
602 | r = kvm_read_nested_guest_page(vcpu, gfn, pdpte, offset, sizeof(pdpte), | 602 | r = kvm_read_nested_guest_page(vcpu, gfn, pdpte, offset, sizeof(pdpte), |
603 | PFERR_USER_MASK | PFERR_WRITE_MASK); | 603 | PFERR_USER_MASK | PFERR_WRITE_MASK); |
604 | if (r < 0) | 604 | if (r < 0) |
diff --git a/arch/x86/math-emu/Makefile b/arch/x86/math-emu/Makefile index 9b0c63b60302..1b2dac174321 100644 --- a/arch/x86/math-emu/Makefile +++ b/arch/x86/math-emu/Makefile | |||
@@ -5,8 +5,8 @@ | |||
5 | #DEBUG = -DDEBUGGING | 5 | #DEBUG = -DDEBUGGING |
6 | DEBUG = | 6 | DEBUG = |
7 | PARANOID = -DPARANOID | 7 | PARANOID = -DPARANOID |
8 | EXTRA_CFLAGS := $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION) | 8 | ccflags-y += $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION) |
9 | EXTRA_AFLAGS := $(PARANOID) | 9 | asflags-y += $(PARANOID) |
10 | 10 | ||
11 | # From 'C' language sources: | 11 | # From 'C' language sources: |
12 | C_OBJS =fpu_entry.o errors.o \ | 12 | C_OBJS =fpu_entry.o errors.o \ |
diff --git a/arch/x86/math-emu/fpu_emu.h b/arch/x86/math-emu/fpu_emu.h index afbc4d805d66..c9c320dccca1 100644 --- a/arch/x86/math-emu/fpu_emu.h +++ b/arch/x86/math-emu/fpu_emu.h | |||
@@ -157,7 +157,7 @@ extern u_char const data_sizes_16[32]; | |||
157 | 157 | ||
158 | #define signbyte(a) (((u_char *)(a))[9]) | 158 | #define signbyte(a) (((u_char *)(a))[9]) |
159 | #define getsign(a) (signbyte(a) & 0x80) | 159 | #define getsign(a) (signbyte(a) & 0x80) |
160 | #define setsign(a,b) { if (b) signbyte(a) |= 0x80; else signbyte(a) &= 0x7f; } | 160 | #define setsign(a,b) { if ((b) != 0) signbyte(a) |= 0x80; else signbyte(a) &= 0x7f; } |
161 | #define copysign(a,b) { if (getsign(a)) signbyte(b) |= 0x80; \ | 161 | #define copysign(a,b) { if (getsign(a)) signbyte(b) |= 0x80; \ |
162 | else signbyte(b) &= 0x7f; } | 162 | else signbyte(b) &= 0x7f; } |
163 | #define changesign(a) { signbyte(a) ^= 0x80; } | 163 | #define changesign(a) { signbyte(a) ^= 0x80; } |
diff --git a/arch/x86/math-emu/reg_compare.c b/arch/x86/math-emu/reg_compare.c index b77360fdbf4a..19b33b50adfa 100644 --- a/arch/x86/math-emu/reg_compare.c +++ b/arch/x86/math-emu/reg_compare.c | |||
@@ -168,7 +168,7 @@ static int compare(FPU_REG const *b, int tagb) | |||
168 | /* This function requires that st(0) is not empty */ | 168 | /* This function requires that st(0) is not empty */ |
169 | int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) | 169 | int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) |
170 | { | 170 | { |
171 | int f = 0, c; | 171 | int f, c; |
172 | 172 | ||
173 | c = compare(loaded_data, loaded_tag); | 173 | c = compare(loaded_data, loaded_tag); |
174 | 174 | ||
@@ -189,12 +189,12 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) | |||
189 | case COMP_No_Comp: | 189 | case COMP_No_Comp: |
190 | f = SW_C3 | SW_C2 | SW_C0; | 190 | f = SW_C3 | SW_C2 | SW_C0; |
191 | break; | 191 | break; |
192 | #ifdef PARANOID | ||
193 | default: | 192 | default: |
193 | #ifdef PARANOID | ||
194 | EXCEPTION(EX_INTERNAL | 0x121); | 194 | EXCEPTION(EX_INTERNAL | 0x121); |
195 | #endif /* PARANOID */ | ||
195 | f = SW_C3 | SW_C2 | SW_C0; | 196 | f = SW_C3 | SW_C2 | SW_C0; |
196 | break; | 197 | break; |
197 | #endif /* PARANOID */ | ||
198 | } | 198 | } |
199 | setcc(f); | 199 | setcc(f); |
200 | if (c & COMP_Denormal) { | 200 | if (c & COMP_Denormal) { |
@@ -205,7 +205,7 @@ int FPU_compare_st_data(FPU_REG const *loaded_data, u_char loaded_tag) | |||
205 | 205 | ||
206 | static int compare_st_st(int nr) | 206 | static int compare_st_st(int nr) |
207 | { | 207 | { |
208 | int f = 0, c; | 208 | int f, c; |
209 | FPU_REG *st_ptr; | 209 | FPU_REG *st_ptr; |
210 | 210 | ||
211 | if (!NOT_EMPTY(0) || !NOT_EMPTY(nr)) { | 211 | if (!NOT_EMPTY(0) || !NOT_EMPTY(nr)) { |
@@ -235,12 +235,12 @@ static int compare_st_st(int nr) | |||
235 | case COMP_No_Comp: | 235 | case COMP_No_Comp: |
236 | f = SW_C3 | SW_C2 | SW_C0; | 236 | f = SW_C3 | SW_C2 | SW_C0; |
237 | break; | 237 | break; |
238 | #ifdef PARANOID | ||
239 | default: | 238 | default: |
239 | #ifdef PARANOID | ||
240 | EXCEPTION(EX_INTERNAL | 0x122); | 240 | EXCEPTION(EX_INTERNAL | 0x122); |
241 | #endif /* PARANOID */ | ||
241 | f = SW_C3 | SW_C2 | SW_C0; | 242 | f = SW_C3 | SW_C2 | SW_C0; |
242 | break; | 243 | break; |
243 | #endif /* PARANOID */ | ||
244 | } | 244 | } |
245 | setcc(f); | 245 | setcc(f); |
246 | if (c & COMP_Denormal) { | 246 | if (c & COMP_Denormal) { |
@@ -283,12 +283,12 @@ static int compare_i_st_st(int nr) | |||
283 | case COMP_No_Comp: | 283 | case COMP_No_Comp: |
284 | f = X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF; | 284 | f = X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF; |
285 | break; | 285 | break; |
286 | #ifdef PARANOID | ||
287 | default: | 286 | default: |
287 | #ifdef PARANOID | ||
288 | EXCEPTION(EX_INTERNAL | 0x122); | 288 | EXCEPTION(EX_INTERNAL | 0x122); |
289 | #endif /* PARANOID */ | ||
289 | f = 0; | 290 | f = 0; |
290 | break; | 291 | break; |
291 | #endif /* PARANOID */ | ||
292 | } | 292 | } |
293 | FPU_EFLAGS = (FPU_EFLAGS & ~(X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF)) | f; | 293 | FPU_EFLAGS = (FPU_EFLAGS & ~(X86_EFLAGS_ZF | X86_EFLAGS_PF | X86_EFLAGS_CF)) | f; |
294 | if (c & COMP_Denormal) { | 294 | if (c & COMP_Denormal) { |
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c index 6e075afa7877..58337b2bc682 100644 --- a/arch/x86/platform/intel-mid/device_libs/platform_max7315.c +++ b/arch/x86/platform/intel-mid/device_libs/platform_max7315.c | |||
@@ -38,8 +38,10 @@ static void __init *max7315_platform_data(void *info) | |||
38 | */ | 38 | */ |
39 | strcpy(i2c_info->type, "max7315"); | 39 | strcpy(i2c_info->type, "max7315"); |
40 | if (nr++) { | 40 | if (nr++) { |
41 | sprintf(base_pin_name, "max7315_%d_base", nr); | 41 | snprintf(base_pin_name, sizeof(base_pin_name), |
42 | sprintf(intr_pin_name, "max7315_%d_int", nr); | 42 | "max7315_%d_base", nr); |
43 | snprintf(intr_pin_name, sizeof(intr_pin_name), | ||
44 | "max7315_%d_int", nr); | ||
43 | } else { | 45 | } else { |
44 | strcpy(base_pin_name, "max7315_base"); | 46 | strcpy(base_pin_name, "max7315_base"); |
45 | strcpy(intr_pin_name, "max7315_int"); | 47 | strcpy(intr_pin_name, "max7315_int"); |
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c index d4a61ddf9e62..3e4bdb442fbc 100644 --- a/arch/x86/platform/uv/tlb_uv.c +++ b/arch/x86/platform/uv/tlb_uv.c | |||
@@ -40,7 +40,6 @@ static int timeout_base_ns[] = { | |||
40 | static int timeout_us; | 40 | static int timeout_us; |
41 | static bool nobau = true; | 41 | static bool nobau = true; |
42 | static int nobau_perm; | 42 | static int nobau_perm; |
43 | static cycles_t congested_cycles; | ||
44 | 43 | ||
45 | /* tunables: */ | 44 | /* tunables: */ |
46 | static int max_concurr = MAX_BAU_CONCURRENT; | 45 | static int max_concurr = MAX_BAU_CONCURRENT; |
@@ -829,10 +828,10 @@ static void record_send_stats(cycles_t time1, cycles_t time2, | |||
829 | if ((completion_status == FLUSH_COMPLETE) && (try == 1)) { | 828 | if ((completion_status == FLUSH_COMPLETE) && (try == 1)) { |
830 | bcp->period_requests++; | 829 | bcp->period_requests++; |
831 | bcp->period_time += elapsed; | 830 | bcp->period_time += elapsed; |
832 | if ((elapsed > congested_cycles) && | 831 | if ((elapsed > usec_2_cycles(bcp->cong_response_us)) && |
833 | (bcp->period_requests > bcp->cong_reps) && | 832 | (bcp->period_requests > bcp->cong_reps) && |
834 | ((bcp->period_time / bcp->period_requests) > | 833 | ((bcp->period_time / bcp->period_requests) > |
835 | congested_cycles)) { | 834 | usec_2_cycles(bcp->cong_response_us))) { |
836 | stat->s_congested++; | 835 | stat->s_congested++; |
837 | disable_for_period(bcp, stat); | 836 | disable_for_period(bcp, stat); |
838 | } | 837 | } |
@@ -2222,14 +2221,17 @@ static int __init uv_bau_init(void) | |||
2222 | else if (is_uv1_hub()) | 2221 | else if (is_uv1_hub()) |
2223 | ops = uv1_bau_ops; | 2222 | ops = uv1_bau_ops; |
2224 | 2223 | ||
2224 | nuvhubs = uv_num_possible_blades(); | ||
2225 | if (nuvhubs < 2) { | ||
2226 | pr_crit("UV: BAU disabled - insufficient hub count\n"); | ||
2227 | goto err_bau_disable; | ||
2228 | } | ||
2229 | |||
2225 | for_each_possible_cpu(cur_cpu) { | 2230 | for_each_possible_cpu(cur_cpu) { |
2226 | mask = &per_cpu(uv_flush_tlb_mask, cur_cpu); | 2231 | mask = &per_cpu(uv_flush_tlb_mask, cur_cpu); |
2227 | zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu)); | 2232 | zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu)); |
2228 | } | 2233 | } |
2229 | 2234 | ||
2230 | nuvhubs = uv_num_possible_blades(); | ||
2231 | congested_cycles = usec_2_cycles(congested_respns_us); | ||
2232 | |||
2233 | uv_base_pnode = 0x7fffffff; | 2235 | uv_base_pnode = 0x7fffffff; |
2234 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) { | 2236 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) { |
2235 | cpus = uv_blade_nr_possible_cpus(uvhub); | 2237 | cpus = uv_blade_nr_possible_cpus(uvhub); |
@@ -2242,9 +2244,8 @@ static int __init uv_bau_init(void) | |||
2242 | enable_timeouts(); | 2244 | enable_timeouts(); |
2243 | 2245 | ||
2244 | if (init_per_cpu(nuvhubs, uv_base_pnode)) { | 2246 | if (init_per_cpu(nuvhubs, uv_base_pnode)) { |
2245 | set_bau_off(); | 2247 | pr_crit("UV: BAU disabled - per CPU init failed\n"); |
2246 | nobau_perm = 1; | 2248 | goto err_bau_disable; |
2247 | return 0; | ||
2248 | } | 2249 | } |
2249 | 2250 | ||
2250 | vector = UV_BAU_MESSAGE; | 2251 | vector = UV_BAU_MESSAGE; |
@@ -2270,6 +2271,16 @@ static int __init uv_bau_init(void) | |||
2270 | } | 2271 | } |
2271 | 2272 | ||
2272 | return 0; | 2273 | return 0; |
2274 | |||
2275 | err_bau_disable: | ||
2276 | |||
2277 | for_each_possible_cpu(cur_cpu) | ||
2278 | free_cpumask_var(per_cpu(uv_flush_tlb_mask, cur_cpu)); | ||
2279 | |||
2280 | set_bau_off(); | ||
2281 | nobau_perm = 1; | ||
2282 | |||
2283 | return -EINVAL; | ||
2273 | } | 2284 | } |
2274 | core_initcall(uv_bau_init); | 2285 | core_initcall(uv_bau_init); |
2275 | fs_initcall(uv_ptc_init); | 2286 | fs_initcall(uv_ptc_init); |
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index b75b734ee73a..19182d091587 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
@@ -3160,6 +3160,8 @@ static struct acpi_driver acpi_nfit_driver = { | |||
3160 | 3160 | ||
3161 | static __init int nfit_init(void) | 3161 | static __init int nfit_init(void) |
3162 | { | 3162 | { |
3163 | int ret; | ||
3164 | |||
3163 | BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40); | 3165 | BUILD_BUG_ON(sizeof(struct acpi_table_nfit) != 40); |
3164 | BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56); | 3166 | BUILD_BUG_ON(sizeof(struct acpi_nfit_system_address) != 56); |
3165 | BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48); | 3167 | BUILD_BUG_ON(sizeof(struct acpi_nfit_memory_map) != 48); |
@@ -3187,8 +3189,14 @@ static __init int nfit_init(void) | |||
3187 | return -ENOMEM; | 3189 | return -ENOMEM; |
3188 | 3190 | ||
3189 | nfit_mce_register(); | 3191 | nfit_mce_register(); |
3192 | ret = acpi_bus_register_driver(&acpi_nfit_driver); | ||
3193 | if (ret) { | ||
3194 | nfit_mce_unregister(); | ||
3195 | destroy_workqueue(nfit_wq); | ||
3196 | } | ||
3197 | |||
3198 | return ret; | ||
3190 | 3199 | ||
3191 | return acpi_bus_register_driver(&acpi_nfit_driver); | ||
3192 | } | 3200 | } |
3193 | 3201 | ||
3194 | static __exit void nfit_exit(void) | 3202 | static __exit void nfit_exit(void) |
diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c index 292dec18ffb8..07bdd51b3b9a 100644 --- a/drivers/atm/zatm.c +++ b/drivers/atm/zatm.c | |||
@@ -1613,7 +1613,7 @@ static int zatm_init_one(struct pci_dev *pci_dev, | |||
1613 | 1613 | ||
1614 | ret = dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32)); | 1614 | ret = dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(32)); |
1615 | if (ret < 0) | 1615 | if (ret < 0) |
1616 | goto out_disable; | 1616 | goto out_release; |
1617 | 1617 | ||
1618 | zatm_dev->pci_dev = pci_dev; | 1618 | zatm_dev->pci_dev = pci_dev; |
1619 | dev->dev_data = zatm_dev; | 1619 | dev->dev_data = zatm_dev; |
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c index 3b8210ebb50e..60303aa28587 100644 --- a/drivers/base/power/domain.c +++ b/drivers/base/power/domain.c | |||
@@ -1222,8 +1222,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, | |||
1222 | 1222 | ||
1223 | spin_unlock_irq(&dev->power.lock); | 1223 | spin_unlock_irq(&dev->power.lock); |
1224 | 1224 | ||
1225 | dev_pm_domain_set(dev, &genpd->domain); | ||
1226 | |||
1227 | return gpd_data; | 1225 | return gpd_data; |
1228 | 1226 | ||
1229 | err_free: | 1227 | err_free: |
@@ -1237,8 +1235,6 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, | |||
1237 | static void genpd_free_dev_data(struct device *dev, | 1235 | static void genpd_free_dev_data(struct device *dev, |
1238 | struct generic_pm_domain_data *gpd_data) | 1236 | struct generic_pm_domain_data *gpd_data) |
1239 | { | 1237 | { |
1240 | dev_pm_domain_set(dev, NULL); | ||
1241 | |||
1242 | spin_lock_irq(&dev->power.lock); | 1238 | spin_lock_irq(&dev->power.lock); |
1243 | 1239 | ||
1244 | dev->power.subsys_data->domain_data = NULL; | 1240 | dev->power.subsys_data->domain_data = NULL; |
@@ -1275,6 +1271,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev, | |||
1275 | if (ret) | 1271 | if (ret) |
1276 | goto out; | 1272 | goto out; |
1277 | 1273 | ||
1274 | dev_pm_domain_set(dev, &genpd->domain); | ||
1275 | |||
1278 | genpd->device_count++; | 1276 | genpd->device_count++; |
1279 | genpd->max_off_time_changed = true; | 1277 | genpd->max_off_time_changed = true; |
1280 | 1278 | ||
@@ -1336,6 +1334,8 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, | |||
1336 | if (genpd->detach_dev) | 1334 | if (genpd->detach_dev) |
1337 | genpd->detach_dev(genpd, dev); | 1335 | genpd->detach_dev(genpd, dev); |
1338 | 1336 | ||
1337 | dev_pm_domain_set(dev, NULL); | ||
1338 | |||
1339 | list_del_init(&pdd->list_node); | 1339 | list_del_init(&pdd->list_node); |
1340 | 1340 | ||
1341 | genpd_unlock(genpd); | 1341 | genpd_unlock(genpd); |
diff --git a/drivers/base/regmap/regmap-w1.c b/drivers/base/regmap/regmap-w1.c index 5f04e7bf063e..e6c64b0be5b2 100644 --- a/drivers/base/regmap/regmap-w1.c +++ b/drivers/base/regmap/regmap-w1.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Register map access API - W1 (1-Wire) support | 2 | * Register map access API - W1 (1-Wire) support |
3 | * | 3 | * |
4 | * Copyright (C) 2017 OAO Radioavionica | 4 | * Copyright (c) 2017 Radioavionica Corporation |
5 | * Author: Alex A. Mihaylov <minimumlaw@rambler.ru> | 5 | * Author: Alex A. Mihaylov <minimumlaw@rambler.ru> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | #include <linux/regmap.h> | 12 | #include <linux/regmap.h> |
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include "../../w1/w1.h" | 14 | #include <linux/w1.h> |
15 | 15 | ||
16 | #include "internal.h" | 16 | #include "internal.h" |
17 | 17 | ||
diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c index f6e7491c873c..d509b500a7b5 100644 --- a/drivers/clocksource/timer-of.c +++ b/drivers/clocksource/timer-of.c | |||
@@ -41,8 +41,16 @@ static __init int timer_irq_init(struct device_node *np, | |||
41 | struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); | 41 | struct timer_of *to = container_of(of_irq, struct timer_of, of_irq); |
42 | struct clock_event_device *clkevt = &to->clkevt; | 42 | struct clock_event_device *clkevt = &to->clkevt; |
43 | 43 | ||
44 | of_irq->irq = of_irq->name ? of_irq_get_byname(np, of_irq->name): | 44 | if (of_irq->name) { |
45 | irq_of_parse_and_map(np, of_irq->index); | 45 | of_irq->irq = ret = of_irq_get_byname(np, of_irq->name); |
46 | if (ret < 0) { | ||
47 | pr_err("Failed to get interrupt %s for %s\n", | ||
48 | of_irq->name, np->full_name); | ||
49 | return ret; | ||
50 | } | ||
51 | } else { | ||
52 | of_irq->irq = irq_of_parse_and_map(np, of_irq->index); | ||
53 | } | ||
46 | if (!of_irq->irq) { | 54 | if (!of_irq->irq) { |
47 | pr_err("Failed to map interrupt for %s\n", np->full_name); | 55 | pr_err("Failed to map interrupt for %s\n", np->full_name); |
48 | return -EINVAL; | 56 | return -EINVAL; |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index b7fb8b7c980d..6cd503525638 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
@@ -225,6 +225,9 @@ struct global_params { | |||
225 | * @vid: Stores VID limits for this CPU | 225 | * @vid: Stores VID limits for this CPU |
226 | * @pid: Stores PID parameters for this CPU | 226 | * @pid: Stores PID parameters for this CPU |
227 | * @last_sample_time: Last Sample time | 227 | * @last_sample_time: Last Sample time |
228 | * @aperf_mperf_shift: Number of clock cycles after aperf, merf is incremented | ||
229 | * This shift is a multiplier to mperf delta to | ||
230 | * calculate CPU busy. | ||
228 | * @prev_aperf: Last APERF value read from APERF MSR | 231 | * @prev_aperf: Last APERF value read from APERF MSR |
229 | * @prev_mperf: Last MPERF value read from MPERF MSR | 232 | * @prev_mperf: Last MPERF value read from MPERF MSR |
230 | * @prev_tsc: Last timestamp counter (TSC) value | 233 | * @prev_tsc: Last timestamp counter (TSC) value |
@@ -259,6 +262,7 @@ struct cpudata { | |||
259 | 262 | ||
260 | u64 last_update; | 263 | u64 last_update; |
261 | u64 last_sample_time; | 264 | u64 last_sample_time; |
265 | u64 aperf_mperf_shift; | ||
262 | u64 prev_aperf; | 266 | u64 prev_aperf; |
263 | u64 prev_mperf; | 267 | u64 prev_mperf; |
264 | u64 prev_tsc; | 268 | u64 prev_tsc; |
@@ -321,6 +325,7 @@ struct pstate_funcs { | |||
321 | int (*get_min)(void); | 325 | int (*get_min)(void); |
322 | int (*get_turbo)(void); | 326 | int (*get_turbo)(void); |
323 | int (*get_scaling)(void); | 327 | int (*get_scaling)(void); |
328 | int (*get_aperf_mperf_shift)(void); | ||
324 | u64 (*get_val)(struct cpudata*, int pstate); | 329 | u64 (*get_val)(struct cpudata*, int pstate); |
325 | void (*get_vid)(struct cpudata *); | 330 | void (*get_vid)(struct cpudata *); |
326 | void (*update_util)(struct update_util_data *data, u64 time, | 331 | void (*update_util)(struct update_util_data *data, u64 time, |
@@ -1486,6 +1491,11 @@ static u64 core_get_val(struct cpudata *cpudata, int pstate) | |||
1486 | return val; | 1491 | return val; |
1487 | } | 1492 | } |
1488 | 1493 | ||
1494 | static int knl_get_aperf_mperf_shift(void) | ||
1495 | { | ||
1496 | return 10; | ||
1497 | } | ||
1498 | |||
1489 | static int knl_get_turbo_pstate(void) | 1499 | static int knl_get_turbo_pstate(void) |
1490 | { | 1500 | { |
1491 | u64 value; | 1501 | u64 value; |
@@ -1543,6 +1553,9 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) | |||
1543 | cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; | 1553 | cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; |
1544 | cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; | 1554 | cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; |
1545 | 1555 | ||
1556 | if (pstate_funcs.get_aperf_mperf_shift) | ||
1557 | cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); | ||
1558 | |||
1546 | if (pstate_funcs.get_vid) | 1559 | if (pstate_funcs.get_vid) |
1547 | pstate_funcs.get_vid(cpu); | 1560 | pstate_funcs.get_vid(cpu); |
1548 | 1561 | ||
@@ -1616,7 +1629,8 @@ static inline int32_t get_target_pstate_use_cpu_load(struct cpudata *cpu) | |||
1616 | int32_t busy_frac, boost; | 1629 | int32_t busy_frac, boost; |
1617 | int target, avg_pstate; | 1630 | int target, avg_pstate; |
1618 | 1631 | ||
1619 | busy_frac = div_fp(sample->mperf, sample->tsc); | 1632 | busy_frac = div_fp(sample->mperf << cpu->aperf_mperf_shift, |
1633 | sample->tsc); | ||
1620 | 1634 | ||
1621 | boost = cpu->iowait_boost; | 1635 | boost = cpu->iowait_boost; |
1622 | cpu->iowait_boost >>= 1; | 1636 | cpu->iowait_boost >>= 1; |
@@ -1675,7 +1689,8 @@ static inline int32_t get_target_pstate_use_performance(struct cpudata *cpu) | |||
1675 | sample_ratio = div_fp(pid_params.sample_rate_ns, duration_ns); | 1689 | sample_ratio = div_fp(pid_params.sample_rate_ns, duration_ns); |
1676 | perf_scaled = mul_fp(perf_scaled, sample_ratio); | 1690 | perf_scaled = mul_fp(perf_scaled, sample_ratio); |
1677 | } else { | 1691 | } else { |
1678 | sample_ratio = div_fp(100 * cpu->sample.mperf, cpu->sample.tsc); | 1692 | sample_ratio = div_fp(100 * (cpu->sample.mperf << cpu->aperf_mperf_shift), |
1693 | cpu->sample.tsc); | ||
1679 | if (sample_ratio < int_tofp(1)) | 1694 | if (sample_ratio < int_tofp(1)) |
1680 | perf_scaled = 0; | 1695 | perf_scaled = 0; |
1681 | } | 1696 | } |
@@ -1807,6 +1822,7 @@ static const struct pstate_funcs knl_funcs = { | |||
1807 | .get_max_physical = core_get_max_pstate_physical, | 1822 | .get_max_physical = core_get_max_pstate_physical, |
1808 | .get_min = core_get_min_pstate, | 1823 | .get_min = core_get_min_pstate, |
1809 | .get_turbo = knl_get_turbo_pstate, | 1824 | .get_turbo = knl_get_turbo_pstate, |
1825 | .get_aperf_mperf_shift = knl_get_aperf_mperf_shift, | ||
1810 | .get_scaling = core_get_scaling, | 1826 | .get_scaling = core_get_scaling, |
1811 | .get_val = core_get_val, | 1827 | .get_val = core_get_val, |
1812 | .update_util = intel_pstate_update_util_pid, | 1828 | .update_util = intel_pstate_update_util_pid, |
@@ -2403,6 +2419,7 @@ static void __init copy_cpu_funcs(struct pstate_funcs *funcs) | |||
2403 | pstate_funcs.get_val = funcs->get_val; | 2419 | pstate_funcs.get_val = funcs->get_val; |
2404 | pstate_funcs.get_vid = funcs->get_vid; | 2420 | pstate_funcs.get_vid = funcs->get_vid; |
2405 | pstate_funcs.update_util = funcs->update_util; | 2421 | pstate_funcs.update_util = funcs->update_util; |
2422 | pstate_funcs.get_aperf_mperf_shift = funcs->get_aperf_mperf_shift; | ||
2406 | 2423 | ||
2407 | intel_pstate_use_acpi_profile(); | 2424 | intel_pstate_use_acpi_profile(); |
2408 | } | 2425 | } |
diff --git a/drivers/dax/device-dax.h b/drivers/dax/device-dax.h index fdcd9769ffde..688b051750bd 100644 --- a/drivers/dax/device-dax.h +++ b/drivers/dax/device-dax.h | |||
@@ -21,5 +21,5 @@ struct dax_region *alloc_dax_region(struct device *parent, | |||
21 | int region_id, struct resource *res, unsigned int align, | 21 | int region_id, struct resource *res, unsigned int align, |
22 | void *addr, unsigned long flags); | 22 | void *addr, unsigned long flags); |
23 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | 23 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, |
24 | struct resource *res, int count); | 24 | int id, struct resource *res, int count); |
25 | #endif /* __DEVICE_DAX_H__ */ | 25 | #endif /* __DEVICE_DAX_H__ */ |
diff --git a/drivers/dax/device.c b/drivers/dax/device.c index 12943d19bfc4..e9f3b3e4bbf4 100644 --- a/drivers/dax/device.c +++ b/drivers/dax/device.c | |||
@@ -529,7 +529,8 @@ static void dev_dax_release(struct device *dev) | |||
529 | struct dax_region *dax_region = dev_dax->region; | 529 | struct dax_region *dax_region = dev_dax->region; |
530 | struct dax_device *dax_dev = dev_dax->dax_dev; | 530 | struct dax_device *dax_dev = dev_dax->dax_dev; |
531 | 531 | ||
532 | ida_simple_remove(&dax_region->ida, dev_dax->id); | 532 | if (dev_dax->id >= 0) |
533 | ida_simple_remove(&dax_region->ida, dev_dax->id); | ||
533 | dax_region_put(dax_region); | 534 | dax_region_put(dax_region); |
534 | put_dax(dax_dev); | 535 | put_dax(dax_dev); |
535 | kfree(dev_dax); | 536 | kfree(dev_dax); |
@@ -559,7 +560,7 @@ static void unregister_dev_dax(void *dev) | |||
559 | } | 560 | } |
560 | 561 | ||
561 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | 562 | struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, |
562 | struct resource *res, int count) | 563 | int id, struct resource *res, int count) |
563 | { | 564 | { |
564 | struct device *parent = dax_region->dev; | 565 | struct device *parent = dax_region->dev; |
565 | struct dax_device *dax_dev; | 566 | struct dax_device *dax_dev; |
@@ -567,7 +568,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
567 | struct inode *inode; | 568 | struct inode *inode; |
568 | struct device *dev; | 569 | struct device *dev; |
569 | struct cdev *cdev; | 570 | struct cdev *cdev; |
570 | int rc = 0, i; | 571 | int rc, i; |
572 | |||
573 | if (!count) | ||
574 | return ERR_PTR(-EINVAL); | ||
571 | 575 | ||
572 | dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL); | 576 | dev_dax = kzalloc(sizeof(*dev_dax) + sizeof(*res) * count, GFP_KERNEL); |
573 | if (!dev_dax) | 577 | if (!dev_dax) |
@@ -587,10 +591,16 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
587 | if (i < count) | 591 | if (i < count) |
588 | goto err_id; | 592 | goto err_id; |
589 | 593 | ||
590 | dev_dax->id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL); | 594 | if (id < 0) { |
591 | if (dev_dax->id < 0) { | 595 | id = ida_simple_get(&dax_region->ida, 0, 0, GFP_KERNEL); |
592 | rc = dev_dax->id; | 596 | dev_dax->id = id; |
593 | goto err_id; | 597 | if (id < 0) { |
598 | rc = id; | ||
599 | goto err_id; | ||
600 | } | ||
601 | } else { | ||
602 | /* region provider owns @id lifetime */ | ||
603 | dev_dax->id = -1; | ||
594 | } | 604 | } |
595 | 605 | ||
596 | /* | 606 | /* |
@@ -598,8 +608,10 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
598 | * device outside of mmap of the resulting character device. | 608 | * device outside of mmap of the resulting character device. |
599 | */ | 609 | */ |
600 | dax_dev = alloc_dax(dev_dax, NULL, NULL); | 610 | dax_dev = alloc_dax(dev_dax, NULL, NULL); |
601 | if (!dax_dev) | 611 | if (!dax_dev) { |
612 | rc = -ENOMEM; | ||
602 | goto err_dax; | 613 | goto err_dax; |
614 | } | ||
603 | 615 | ||
604 | /* from here on we're committed to teardown via dax_dev_release() */ | 616 | /* from here on we're committed to teardown via dax_dev_release() */ |
605 | dev = &dev_dax->dev; | 617 | dev = &dev_dax->dev; |
@@ -620,7 +632,7 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
620 | dev->parent = parent; | 632 | dev->parent = parent; |
621 | dev->groups = dax_attribute_groups; | 633 | dev->groups = dax_attribute_groups; |
622 | dev->release = dev_dax_release; | 634 | dev->release = dev_dax_release; |
623 | dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); | 635 | dev_set_name(dev, "dax%d.%d", dax_region->id, id); |
624 | 636 | ||
625 | rc = cdev_device_add(cdev, dev); | 637 | rc = cdev_device_add(cdev, dev); |
626 | if (rc) { | 638 | if (rc) { |
@@ -636,7 +648,8 @@ struct dev_dax *devm_create_dev_dax(struct dax_region *dax_region, | |||
636 | return dev_dax; | 648 | return dev_dax; |
637 | 649 | ||
638 | err_dax: | 650 | err_dax: |
639 | ida_simple_remove(&dax_region->ida, dev_dax->id); | 651 | if (dev_dax->id >= 0) |
652 | ida_simple_remove(&dax_region->ida, dev_dax->id); | ||
640 | err_id: | 653 | err_id: |
641 | kfree(dev_dax); | 654 | kfree(dev_dax); |
642 | 655 | ||
diff --git a/drivers/dax/pmem.c b/drivers/dax/pmem.c index 9f2a0b4fd801..8d8c852ba8f2 100644 --- a/drivers/dax/pmem.c +++ b/drivers/dax/pmem.c | |||
@@ -58,13 +58,12 @@ static void dax_pmem_percpu_kill(void *data) | |||
58 | 58 | ||
59 | static int dax_pmem_probe(struct device *dev) | 59 | static int dax_pmem_probe(struct device *dev) |
60 | { | 60 | { |
61 | int rc; | ||
62 | void *addr; | 61 | void *addr; |
63 | struct resource res; | 62 | struct resource res; |
63 | int rc, id, region_id; | ||
64 | struct nd_pfn_sb *pfn_sb; | 64 | struct nd_pfn_sb *pfn_sb; |
65 | struct dev_dax *dev_dax; | 65 | struct dev_dax *dev_dax; |
66 | struct dax_pmem *dax_pmem; | 66 | struct dax_pmem *dax_pmem; |
67 | struct nd_region *nd_region; | ||
68 | struct nd_namespace_io *nsio; | 67 | struct nd_namespace_io *nsio; |
69 | struct dax_region *dax_region; | 68 | struct dax_region *dax_region; |
70 | struct nd_namespace_common *ndns; | 69 | struct nd_namespace_common *ndns; |
@@ -123,14 +122,17 @@ static int dax_pmem_probe(struct device *dev) | |||
123 | /* adjust the dax_region resource to the start of data */ | 122 | /* adjust the dax_region resource to the start of data */ |
124 | res.start += le64_to_cpu(pfn_sb->dataoff); | 123 | res.start += le64_to_cpu(pfn_sb->dataoff); |
125 | 124 | ||
126 | nd_region = to_nd_region(dev->parent); | 125 | rc = sscanf(dev_name(&ndns->dev), "namespace%d.%d", ®ion_id, &id); |
127 | dax_region = alloc_dax_region(dev, nd_region->id, &res, | 126 | if (rc != 2) |
127 | return -EINVAL; | ||
128 | |||
129 | dax_region = alloc_dax_region(dev, region_id, &res, | ||
128 | le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); | 130 | le32_to_cpu(pfn_sb->align), addr, PFN_DEV|PFN_MAP); |
129 | if (!dax_region) | 131 | if (!dax_region) |
130 | return -ENOMEM; | 132 | return -ENOMEM; |
131 | 133 | ||
132 | /* TODO: support for subdividing a dax region... */ | 134 | /* TODO: support for subdividing a dax region... */ |
133 | dev_dax = devm_create_dev_dax(dax_region, &res, 1); | 135 | dev_dax = devm_create_dev_dax(dax_region, id, &res, 1); |
134 | 136 | ||
135 | /* child dev_dax instances now own the lifetime of the dax_region */ | 137 | /* child dev_dax instances now own the lifetime of the dax_region */ |
136 | dax_region_put(dax_region); | 138 | dax_region_put(dax_region); |
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c index 41b39464ded8..501e16a9227d 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c | |||
@@ -2732,6 +2732,9 @@ static int hidpp_initialize_battery(struct hidpp_device *hidpp) | |||
2732 | hidpp_battery_props, | 2732 | hidpp_battery_props, |
2733 | sizeof(hidpp_battery_props), | 2733 | sizeof(hidpp_battery_props), |
2734 | GFP_KERNEL); | 2734 | GFP_KERNEL); |
2735 | if (!battery_props) | ||
2736 | return -ENOMEM; | ||
2737 | |||
2735 | num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2; | 2738 | num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2; |
2736 | 2739 | ||
2737 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) | 2740 | if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE) |
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c index f3e35e7a189d..aff20f4b6d97 100644 --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c | |||
@@ -620,16 +620,6 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
620 | return 0; | 620 | return 0; |
621 | } | 621 | } |
622 | 622 | ||
623 | static int mt_touch_input_mapped(struct hid_device *hdev, struct hid_input *hi, | ||
624 | struct hid_field *field, struct hid_usage *usage, | ||
625 | unsigned long **bit, int *max) | ||
626 | { | ||
627 | if (usage->type == EV_KEY || usage->type == EV_ABS) | ||
628 | set_bit(usage->type, hi->input->evbit); | ||
629 | |||
630 | return -1; | ||
631 | } | ||
632 | |||
633 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) | 623 | static int mt_compute_slot(struct mt_device *td, struct input_dev *input) |
634 | { | 624 | { |
635 | __s32 quirks = td->mtclass.quirks; | 625 | __s32 quirks = td->mtclass.quirks; |
@@ -969,8 +959,10 @@ static int mt_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |||
969 | return 0; | 959 | return 0; |
970 | 960 | ||
971 | if (field->application == HID_DG_TOUCHSCREEN || | 961 | if (field->application == HID_DG_TOUCHSCREEN || |
972 | field->application == HID_DG_TOUCHPAD) | 962 | field->application == HID_DG_TOUCHPAD) { |
973 | return mt_touch_input_mapped(hdev, hi, field, usage, bit, max); | 963 | /* We own these mappings, tell hid-input to ignore them */ |
964 | return -1; | ||
965 | } | ||
974 | 966 | ||
975 | /* let hid-core decide for the others */ | 967 | /* let hid-core decide for the others */ |
976 | return 0; | 968 | return 0; |
diff --git a/drivers/ide/ide-timings.c b/drivers/ide/ide-timings.c index 0e05f75934c9..1858e3ce3993 100644 --- a/drivers/ide/ide-timings.c +++ b/drivers/ide/ide-timings.c | |||
@@ -104,19 +104,19 @@ u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio) | |||
104 | EXPORT_SYMBOL_GPL(ide_pio_cycle_time); | 104 | EXPORT_SYMBOL_GPL(ide_pio_cycle_time); |
105 | 105 | ||
106 | #define ENOUGH(v, unit) (((v) - 1) / (unit) + 1) | 106 | #define ENOUGH(v, unit) (((v) - 1) / (unit) + 1) |
107 | #define EZ(v, unit) ((v) ? ENOUGH(v, unit) : 0) | 107 | #define EZ(v, unit) ((v) ? ENOUGH((v) * 1000, unit) : 0) |
108 | 108 | ||
109 | static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, | 109 | static void ide_timing_quantize(struct ide_timing *t, struct ide_timing *q, |
110 | int T, int UT) | 110 | int T, int UT) |
111 | { | 111 | { |
112 | q->setup = EZ(t->setup * 1000, T); | 112 | q->setup = EZ(t->setup, T); |
113 | q->act8b = EZ(t->act8b * 1000, T); | 113 | q->act8b = EZ(t->act8b, T); |
114 | q->rec8b = EZ(t->rec8b * 1000, T); | 114 | q->rec8b = EZ(t->rec8b, T); |
115 | q->cyc8b = EZ(t->cyc8b * 1000, T); | 115 | q->cyc8b = EZ(t->cyc8b, T); |
116 | q->active = EZ(t->active * 1000, T); | 116 | q->active = EZ(t->active, T); |
117 | q->recover = EZ(t->recover * 1000, T); | 117 | q->recover = EZ(t->recover, T); |
118 | q->cycle = EZ(t->cycle * 1000, T); | 118 | q->cycle = EZ(t->cycle, T); |
119 | q->udma = EZ(t->udma * 1000, UT); | 119 | q->udma = EZ(t->udma, UT); |
120 | } | 120 | } |
121 | 121 | ||
122 | void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, | 122 | void ide_timing_merge(struct ide_timing *a, struct ide_timing *b, |
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index a6cb379a4ebc..01236cef7bfb 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c | |||
@@ -268,6 +268,7 @@ int rdma_translate_ip(const struct sockaddr *addr, | |||
268 | return ret; | 268 | return ret; |
269 | 269 | ||
270 | ret = rdma_copy_addr(dev_addr, dev, NULL); | 270 | ret = rdma_copy_addr(dev_addr, dev, NULL); |
271 | dev_addr->bound_dev_if = dev->ifindex; | ||
271 | if (vlan_id) | 272 | if (vlan_id) |
272 | *vlan_id = rdma_vlan_dev_vlan_id(dev); | 273 | *vlan_id = rdma_vlan_dev_vlan_id(dev); |
273 | dev_put(dev); | 274 | dev_put(dev); |
@@ -280,6 +281,7 @@ int rdma_translate_ip(const struct sockaddr *addr, | |||
280 | &((const struct sockaddr_in6 *)addr)->sin6_addr, | 281 | &((const struct sockaddr_in6 *)addr)->sin6_addr, |
281 | dev, 1)) { | 282 | dev, 1)) { |
282 | ret = rdma_copy_addr(dev_addr, dev, NULL); | 283 | ret = rdma_copy_addr(dev_addr, dev, NULL); |
284 | dev_addr->bound_dev_if = dev->ifindex; | ||
283 | if (vlan_id) | 285 | if (vlan_id) |
284 | *vlan_id = rdma_vlan_dev_vlan_id(dev); | 286 | *vlan_id = rdma_vlan_dev_vlan_id(dev); |
285 | break; | 287 | break; |
@@ -405,10 +407,10 @@ static int addr4_resolve(struct sockaddr_in *src_in, | |||
405 | fl4.saddr = src_ip; | 407 | fl4.saddr = src_ip; |
406 | fl4.flowi4_oif = addr->bound_dev_if; | 408 | fl4.flowi4_oif = addr->bound_dev_if; |
407 | rt = ip_route_output_key(addr->net, &fl4); | 409 | rt = ip_route_output_key(addr->net, &fl4); |
408 | if (IS_ERR(rt)) { | 410 | ret = PTR_ERR_OR_ZERO(rt); |
409 | ret = PTR_ERR(rt); | 411 | if (ret) |
410 | goto out; | 412 | return ret; |
411 | } | 413 | |
412 | src_in->sin_family = AF_INET; | 414 | src_in->sin_family = AF_INET; |
413 | src_in->sin_addr.s_addr = fl4.saddr; | 415 | src_in->sin_addr.s_addr = fl4.saddr; |
414 | 416 | ||
@@ -423,8 +425,6 @@ static int addr4_resolve(struct sockaddr_in *src_in, | |||
423 | 425 | ||
424 | *prt = rt; | 426 | *prt = rt; |
425 | return 0; | 427 | return 0; |
426 | out: | ||
427 | return ret; | ||
428 | } | 428 | } |
429 | 429 | ||
430 | #if IS_ENABLED(CONFIG_IPV6) | 430 | #if IS_ENABLED(CONFIG_IPV6) |
@@ -509,6 +509,11 @@ static int addr_resolve(struct sockaddr *src_in, | |||
509 | struct dst_entry *dst; | 509 | struct dst_entry *dst; |
510 | int ret; | 510 | int ret; |
511 | 511 | ||
512 | if (!addr->net) { | ||
513 | pr_warn_ratelimited("%s: missing namespace\n", __func__); | ||
514 | return -EINVAL; | ||
515 | } | ||
516 | |||
512 | if (src_in->sa_family == AF_INET) { | 517 | if (src_in->sa_family == AF_INET) { |
513 | struct rtable *rt = NULL; | 518 | struct rtable *rt = NULL; |
514 | const struct sockaddr_in *dst_in4 = | 519 | const struct sockaddr_in *dst_in4 = |
@@ -522,8 +527,12 @@ static int addr_resolve(struct sockaddr *src_in, | |||
522 | if (resolve_neigh) | 527 | if (resolve_neigh) |
523 | ret = addr_resolve_neigh(&rt->dst, dst_in, addr, seq); | 528 | ret = addr_resolve_neigh(&rt->dst, dst_in, addr, seq); |
524 | 529 | ||
525 | ndev = rt->dst.dev; | 530 | if (addr->bound_dev_if) { |
526 | dev_hold(ndev); | 531 | ndev = dev_get_by_index(addr->net, addr->bound_dev_if); |
532 | } else { | ||
533 | ndev = rt->dst.dev; | ||
534 | dev_hold(ndev); | ||
535 | } | ||
527 | 536 | ||
528 | ip_rt_put(rt); | 537 | ip_rt_put(rt); |
529 | } else { | 538 | } else { |
@@ -539,14 +548,27 @@ static int addr_resolve(struct sockaddr *src_in, | |||
539 | if (resolve_neigh) | 548 | if (resolve_neigh) |
540 | ret = addr_resolve_neigh(dst, dst_in, addr, seq); | 549 | ret = addr_resolve_neigh(dst, dst_in, addr, seq); |
541 | 550 | ||
542 | ndev = dst->dev; | 551 | if (addr->bound_dev_if) { |
543 | dev_hold(ndev); | 552 | ndev = dev_get_by_index(addr->net, addr->bound_dev_if); |
553 | } else { | ||
554 | ndev = dst->dev; | ||
555 | dev_hold(ndev); | ||
556 | } | ||
544 | 557 | ||
545 | dst_release(dst); | 558 | dst_release(dst); |
546 | } | 559 | } |
547 | 560 | ||
548 | addr->bound_dev_if = ndev->ifindex; | 561 | if (ndev->flags & IFF_LOOPBACK) { |
549 | addr->net = dev_net(ndev); | 562 | ret = rdma_translate_ip(dst_in, addr, NULL); |
563 | /* | ||
564 | * Put the loopback device and get the translated | ||
565 | * device instead. | ||
566 | */ | ||
567 | dev_put(ndev); | ||
568 | ndev = dev_get_by_index(addr->net, addr->bound_dev_if); | ||
569 | } else { | ||
570 | addr->bound_dev_if = ndev->ifindex; | ||
571 | } | ||
550 | dev_put(ndev); | 572 | dev_put(ndev); |
551 | 573 | ||
552 | return ret; | 574 | return ret; |
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 31bb82d8ecd7..11aff923b633 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
@@ -623,22 +623,11 @@ static inline int cma_validate_port(struct ib_device *device, u8 port, | |||
623 | if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) | 623 | if ((dev_type != ARPHRD_INFINIBAND) && rdma_protocol_ib(device, port)) |
624 | return ret; | 624 | return ret; |
625 | 625 | ||
626 | if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) { | 626 | if (dev_type == ARPHRD_ETHER && rdma_protocol_roce(device, port)) |
627 | ndev = dev_get_by_index(&init_net, bound_if_index); | 627 | ndev = dev_get_by_index(&init_net, bound_if_index); |
628 | if (ndev && ndev->flags & IFF_LOOPBACK) { | 628 | else |
629 | pr_info("detected loopback device\n"); | ||
630 | dev_put(ndev); | ||
631 | |||
632 | if (!device->get_netdev) | ||
633 | return -EOPNOTSUPP; | ||
634 | |||
635 | ndev = device->get_netdev(device, port); | ||
636 | if (!ndev) | ||
637 | return -ENODEV; | ||
638 | } | ||
639 | } else { | ||
640 | gid_type = IB_GID_TYPE_IB; | 629 | gid_type = IB_GID_TYPE_IB; |
641 | } | 630 | |
642 | 631 | ||
643 | ret = ib_find_cached_gid_by_port(device, gid, gid_type, port, | 632 | ret = ib_find_cached_gid_by_port(device, gid, gid_type, port, |
644 | ndev, NULL); | 633 | ndev, NULL); |
@@ -2569,21 +2558,6 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) | |||
2569 | goto err2; | 2558 | goto err2; |
2570 | } | 2559 | } |
2571 | 2560 | ||
2572 | if (ndev->flags & IFF_LOOPBACK) { | ||
2573 | dev_put(ndev); | ||
2574 | if (!id_priv->id.device->get_netdev) { | ||
2575 | ret = -EOPNOTSUPP; | ||
2576 | goto err2; | ||
2577 | } | ||
2578 | |||
2579 | ndev = id_priv->id.device->get_netdev(id_priv->id.device, | ||
2580 | id_priv->id.port_num); | ||
2581 | if (!ndev) { | ||
2582 | ret = -ENODEV; | ||
2583 | goto err2; | ||
2584 | } | ||
2585 | } | ||
2586 | |||
2587 | supported_gids = roce_gid_type_mask_support(id_priv->id.device, | 2561 | supported_gids = roce_gid_type_mask_support(id_priv->id.device, |
2588 | id_priv->id.port_num); | 2562 | id_priv->id.port_num); |
2589 | gid_type = cma_route_gid_type(addr->dev_addr.network, | 2563 | gid_type = cma_route_gid_type(addr->dev_addr.network, |
diff --git a/drivers/infiniband/core/roce_gid_mgmt.c b/drivers/infiniband/core/roce_gid_mgmt.c index db958d3207ef..94a9eefb3cfc 100644 --- a/drivers/infiniband/core/roce_gid_mgmt.c +++ b/drivers/infiniband/core/roce_gid_mgmt.c | |||
@@ -42,6 +42,8 @@ | |||
42 | #include <rdma/ib_cache.h> | 42 | #include <rdma/ib_cache.h> |
43 | #include <rdma/ib_addr.h> | 43 | #include <rdma/ib_addr.h> |
44 | 44 | ||
45 | static struct workqueue_struct *gid_cache_wq; | ||
46 | |||
45 | enum gid_op_type { | 47 | enum gid_op_type { |
46 | GID_DEL = 0, | 48 | GID_DEL = 0, |
47 | GID_ADD | 49 | GID_ADD |
@@ -560,7 +562,7 @@ static int netdevice_queue_work(struct netdev_event_work_cmd *cmds, | |||
560 | } | 562 | } |
561 | INIT_WORK(&ndev_work->work, netdevice_event_work_handler); | 563 | INIT_WORK(&ndev_work->work, netdevice_event_work_handler); |
562 | 564 | ||
563 | queue_work(ib_wq, &ndev_work->work); | 565 | queue_work(gid_cache_wq, &ndev_work->work); |
564 | 566 | ||
565 | return NOTIFY_DONE; | 567 | return NOTIFY_DONE; |
566 | } | 568 | } |
@@ -693,7 +695,7 @@ static int addr_event(struct notifier_block *this, unsigned long event, | |||
693 | dev_hold(ndev); | 695 | dev_hold(ndev); |
694 | work->gid_attr.ndev = ndev; | 696 | work->gid_attr.ndev = ndev; |
695 | 697 | ||
696 | queue_work(ib_wq, &work->work); | 698 | queue_work(gid_cache_wq, &work->work); |
697 | 699 | ||
698 | return NOTIFY_DONE; | 700 | return NOTIFY_DONE; |
699 | } | 701 | } |
@@ -740,6 +742,10 @@ static struct notifier_block nb_inet6addr = { | |||
740 | 742 | ||
741 | int __init roce_gid_mgmt_init(void) | 743 | int __init roce_gid_mgmt_init(void) |
742 | { | 744 | { |
745 | gid_cache_wq = alloc_ordered_workqueue("gid-cache-wq", 0); | ||
746 | if (!gid_cache_wq) | ||
747 | return -ENOMEM; | ||
748 | |||
743 | register_inetaddr_notifier(&nb_inetaddr); | 749 | register_inetaddr_notifier(&nb_inetaddr); |
744 | if (IS_ENABLED(CONFIG_IPV6)) | 750 | if (IS_ENABLED(CONFIG_IPV6)) |
745 | register_inet6addr_notifier(&nb_inet6addr); | 751 | register_inet6addr_notifier(&nb_inet6addr); |
@@ -764,4 +770,5 @@ void __exit roce_gid_mgmt_cleanup(void) | |||
764 | * ib-core is removed, all physical devices have been removed, | 770 | * ib-core is removed, all physical devices have been removed, |
765 | * so no issue with remaining hardware contexts. | 771 | * so no issue with remaining hardware contexts. |
766 | */ | 772 | */ |
773 | destroy_workqueue(gid_cache_wq); | ||
767 | } | 774 | } |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 8ba9bfb073d1..3f55d18a3791 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -2005,28 +2005,13 @@ static int modify_qp(struct ib_uverbs_file *file, | |||
2005 | rdma_ah_set_port_num(&attr->alt_ah_attr, | 2005 | rdma_ah_set_port_num(&attr->alt_ah_attr, |
2006 | cmd->base.alt_dest.port_num); | 2006 | cmd->base.alt_dest.port_num); |
2007 | 2007 | ||
2008 | if (qp->real_qp == qp) { | 2008 | ret = ib_modify_qp_with_udata(qp, attr, |
2009 | if (cmd->base.attr_mask & IB_QP_AV) { | 2009 | modify_qp_mask(qp->qp_type, |
2010 | ret = ib_resolve_eth_dmac(qp->device, &attr->ah_attr); | 2010 | cmd->base.attr_mask), |
2011 | if (ret) | 2011 | udata); |
2012 | goto release_qp; | ||
2013 | } | ||
2014 | ret = ib_security_modify_qp(qp, | ||
2015 | attr, | ||
2016 | modify_qp_mask(qp->qp_type, | ||
2017 | cmd->base.attr_mask), | ||
2018 | udata); | ||
2019 | } else { | ||
2020 | ret = ib_security_modify_qp(qp, | ||
2021 | attr, | ||
2022 | modify_qp_mask(qp->qp_type, | ||
2023 | cmd->base.attr_mask), | ||
2024 | NULL); | ||
2025 | } | ||
2026 | 2012 | ||
2027 | release_qp: | 2013 | release_qp: |
2028 | uobj_put_obj_read(qp); | 2014 | uobj_put_obj_read(qp); |
2029 | |||
2030 | out: | 2015 | out: |
2031 | kfree(attr); | 2016 | kfree(attr); |
2032 | 2017 | ||
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c index c973a83c898b..fb98ed67d5bc 100644 --- a/drivers/infiniband/core/verbs.c +++ b/drivers/infiniband/core/verbs.c | |||
@@ -452,6 +452,19 @@ int ib_get_gids_from_rdma_hdr(const union rdma_network_hdr *hdr, | |||
452 | } | 452 | } |
453 | EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr); | 453 | EXPORT_SYMBOL(ib_get_gids_from_rdma_hdr); |
454 | 454 | ||
455 | /* | ||
456 | * This function creates ah from the incoming packet. | ||
457 | * Incoming packet has dgid of the receiver node on which this code is | ||
458 | * getting executed and, sgid contains the GID of the sender. | ||
459 | * | ||
460 | * When resolving mac address of destination, the arrived dgid is used | ||
461 | * as sgid and, sgid is used as dgid because sgid contains destinations | ||
462 | * GID whom to respond to. | ||
463 | * | ||
464 | * This is why when calling rdma_addr_find_l2_eth_by_grh() function, the | ||
465 | * position of arguments dgid and sgid do not match the order of the | ||
466 | * parameters. | ||
467 | */ | ||
455 | int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, | 468 | int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, |
456 | const struct ib_wc *wc, const struct ib_grh *grh, | 469 | const struct ib_wc *wc, const struct ib_grh *grh, |
457 | struct rdma_ah_attr *ah_attr) | 470 | struct rdma_ah_attr *ah_attr) |
@@ -507,11 +520,6 @@ int ib_init_ah_from_wc(struct ib_device *device, u8 port_num, | |||
507 | } | 520 | } |
508 | 521 | ||
509 | resolved_dev = dev_get_by_index(&init_net, if_index); | 522 | resolved_dev = dev_get_by_index(&init_net, if_index); |
510 | if (resolved_dev->flags & IFF_LOOPBACK) { | ||
511 | dev_put(resolved_dev); | ||
512 | resolved_dev = idev; | ||
513 | dev_hold(resolved_dev); | ||
514 | } | ||
515 | rcu_read_lock(); | 523 | rcu_read_lock(); |
516 | if (resolved_dev != idev && !rdma_is_upper_dev_rcu(idev, | 524 | if (resolved_dev != idev && !rdma_is_upper_dev_rcu(idev, |
517 | resolved_dev)) | 525 | resolved_dev)) |
@@ -887,6 +895,7 @@ static const struct { | |||
887 | } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = { | 895 | } qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = { |
888 | [IB_QPS_RESET] = { | 896 | [IB_QPS_RESET] = { |
889 | [IB_QPS_RESET] = { .valid = 1 }, | 897 | [IB_QPS_RESET] = { .valid = 1 }, |
898 | [IB_QPS_ERR] = { .valid = 1 }, | ||
890 | [IB_QPS_INIT] = { | 899 | [IB_QPS_INIT] = { |
891 | .valid = 1, | 900 | .valid = 1, |
892 | .req_param = { | 901 | .req_param = { |
@@ -1268,20 +1277,36 @@ out: | |||
1268 | } | 1277 | } |
1269 | EXPORT_SYMBOL(ib_resolve_eth_dmac); | 1278 | EXPORT_SYMBOL(ib_resolve_eth_dmac); |
1270 | 1279 | ||
1271 | int ib_modify_qp(struct ib_qp *qp, | 1280 | /** |
1272 | struct ib_qp_attr *qp_attr, | 1281 | * ib_modify_qp_with_udata - Modifies the attributes for the specified QP. |
1273 | int qp_attr_mask) | 1282 | * @qp: The QP to modify. |
1283 | * @attr: On input, specifies the QP attributes to modify. On output, | ||
1284 | * the current values of selected QP attributes are returned. | ||
1285 | * @attr_mask: A bit-mask used to specify which attributes of the QP | ||
1286 | * are being modified. | ||
1287 | * @udata: pointer to user's input output buffer information | ||
1288 | * are being modified. | ||
1289 | * It returns 0 on success and returns appropriate error code on error. | ||
1290 | */ | ||
1291 | int ib_modify_qp_with_udata(struct ib_qp *qp, struct ib_qp_attr *attr, | ||
1292 | int attr_mask, struct ib_udata *udata) | ||
1274 | { | 1293 | { |
1294 | int ret; | ||
1275 | 1295 | ||
1276 | if (qp_attr_mask & IB_QP_AV) { | 1296 | if (attr_mask & IB_QP_AV) { |
1277 | int ret; | 1297 | ret = ib_resolve_eth_dmac(qp->device, &attr->ah_attr); |
1278 | |||
1279 | ret = ib_resolve_eth_dmac(qp->device, &qp_attr->ah_attr); | ||
1280 | if (ret) | 1298 | if (ret) |
1281 | return ret; | 1299 | return ret; |
1282 | } | 1300 | } |
1301 | return ib_security_modify_qp(qp, attr, attr_mask, udata); | ||
1302 | } | ||
1303 | EXPORT_SYMBOL(ib_modify_qp_with_udata); | ||
1283 | 1304 | ||
1284 | return ib_security_modify_qp(qp->real_qp, qp_attr, qp_attr_mask, NULL); | 1305 | int ib_modify_qp(struct ib_qp *qp, |
1306 | struct ib_qp_attr *qp_attr, | ||
1307 | int qp_attr_mask) | ||
1308 | { | ||
1309 | return ib_modify_qp_with_udata(qp, qp_attr, qp_attr_mask, NULL); | ||
1285 | } | 1310 | } |
1286 | EXPORT_SYMBOL(ib_modify_qp); | 1311 | EXPORT_SYMBOL(ib_modify_qp); |
1287 | 1312 | ||
diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c index 2ba00b89df6a..94b54850ec75 100644 --- a/drivers/infiniband/hw/hfi1/chip.c +++ b/drivers/infiniband/hw/hfi1/chip.c | |||
@@ -12847,7 +12847,12 @@ static void remap_intr(struct hfi1_devdata *dd, int isrc, int msix_intr) | |||
12847 | /* clear from the handled mask of the general interrupt */ | 12847 | /* clear from the handled mask of the general interrupt */ |
12848 | m = isrc / 64; | 12848 | m = isrc / 64; |
12849 | n = isrc % 64; | 12849 | n = isrc % 64; |
12850 | dd->gi_mask[m] &= ~((u64)1 << n); | 12850 | if (likely(m < CCE_NUM_INT_CSRS)) { |
12851 | dd->gi_mask[m] &= ~((u64)1 << n); | ||
12852 | } else { | ||
12853 | dd_dev_err(dd, "remap interrupt err\n"); | ||
12854 | return; | ||
12855 | } | ||
12851 | 12856 | ||
12852 | /* direct the chip source to the given MSI-X interrupt */ | 12857 | /* direct the chip source to the given MSI-X interrupt */ |
12853 | m = isrc / 8; | 12858 | m = isrc / 8; |
diff --git a/drivers/infiniband/hw/hfi1/qp.c b/drivers/infiniband/hw/hfi1/qp.c index 650305cc0373..1a7af9f60c13 100644 --- a/drivers/infiniband/hw/hfi1/qp.c +++ b/drivers/infiniband/hw/hfi1/qp.c | |||
@@ -647,18 +647,17 @@ void qp_iter_print(struct seq_file *s, struct qp_iter *iter) | |||
647 | qp->pid); | 647 | qp->pid); |
648 | } | 648 | } |
649 | 649 | ||
650 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, | 650 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp) |
651 | gfp_t gfp) | ||
652 | { | 651 | { |
653 | struct hfi1_qp_priv *priv; | 652 | struct hfi1_qp_priv *priv; |
654 | 653 | ||
655 | priv = kzalloc_node(sizeof(*priv), gfp, rdi->dparms.node); | 654 | priv = kzalloc_node(sizeof(*priv), GFP_KERNEL, rdi->dparms.node); |
656 | if (!priv) | 655 | if (!priv) |
657 | return ERR_PTR(-ENOMEM); | 656 | return ERR_PTR(-ENOMEM); |
658 | 657 | ||
659 | priv->owner = qp; | 658 | priv->owner = qp; |
660 | 659 | ||
661 | priv->s_ahg = kzalloc_node(sizeof(*priv->s_ahg), gfp, | 660 | priv->s_ahg = kzalloc_node(sizeof(*priv->s_ahg), GFP_KERNEL, |
662 | rdi->dparms.node); | 661 | rdi->dparms.node); |
663 | if (!priv->s_ahg) { | 662 | if (!priv->s_ahg) { |
664 | kfree(priv); | 663 | kfree(priv); |
diff --git a/drivers/infiniband/hw/hfi1/qp.h b/drivers/infiniband/hw/hfi1/qp.h index 1eb9cd7b8c19..6fe542b6a927 100644 --- a/drivers/infiniband/hw/hfi1/qp.h +++ b/drivers/infiniband/hw/hfi1/qp.h | |||
@@ -123,8 +123,7 @@ void hfi1_migrate_qp(struct rvt_qp *qp); | |||
123 | /* | 123 | /* |
124 | * Functions provided by hfi1 driver for rdmavt to use | 124 | * Functions provided by hfi1 driver for rdmavt to use |
125 | */ | 125 | */ |
126 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, | 126 | void *qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
127 | gfp_t gfp); | ||
128 | void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); | 127 | void qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
129 | unsigned free_all_qps(struct rvt_dev_info *rdi); | 128 | unsigned free_all_qps(struct rvt_dev_info *rdi); |
130 | void notify_qp_reset(struct rvt_qp *qp); | 129 | void notify_qp_reset(struct rvt_qp *qp); |
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c index 37d5d29597a4..23fad6d96944 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v1.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v1.c | |||
@@ -228,14 +228,14 @@ int hns_roce_v1_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
228 | switch (wr->opcode) { | 228 | switch (wr->opcode) { |
229 | case IB_WR_RDMA_READ: | 229 | case IB_WR_RDMA_READ: |
230 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_READ; | 230 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_READ; |
231 | set_raddr_seg(wqe, atomic_wr(wr)->remote_addr, | 231 | set_raddr_seg(wqe, rdma_wr(wr)->remote_addr, |
232 | atomic_wr(wr)->rkey); | 232 | rdma_wr(wr)->rkey); |
233 | break; | 233 | break; |
234 | case IB_WR_RDMA_WRITE: | 234 | case IB_WR_RDMA_WRITE: |
235 | case IB_WR_RDMA_WRITE_WITH_IMM: | 235 | case IB_WR_RDMA_WRITE_WITH_IMM: |
236 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_WRITE; | 236 | ps_opcode = HNS_ROCE_WQE_OPCODE_RDMA_WRITE; |
237 | set_raddr_seg(wqe, atomic_wr(wr)->remote_addr, | 237 | set_raddr_seg(wqe, rdma_wr(wr)->remote_addr, |
238 | atomic_wr(wr)->rkey); | 238 | rdma_wr(wr)->rkey); |
239 | break; | 239 | break; |
240 | case IB_WR_SEND: | 240 | case IB_WR_SEND: |
241 | case IB_WR_SEND_WITH_INV: | 241 | case IB_WR_SEND_WITH_INV: |
@@ -661,9 +661,11 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
661 | union ib_gid dgid; | 661 | union ib_gid dgid; |
662 | u64 subnet_prefix; | 662 | u64 subnet_prefix; |
663 | int attr_mask = 0; | 663 | int attr_mask = 0; |
664 | int i; | 664 | int i, j; |
665 | int ret; | 665 | int ret; |
666 | u8 queue_en[HNS_ROCE_V1_RESV_QP] = { 0 }; | ||
666 | u8 phy_port; | 667 | u8 phy_port; |
668 | u8 port = 0; | ||
667 | u8 sl; | 669 | u8 sl; |
668 | 670 | ||
669 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; | 671 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; |
@@ -709,11 +711,27 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
709 | attr.rnr_retry = 7; | 711 | attr.rnr_retry = 7; |
710 | attr.timeout = 0x12; | 712 | attr.timeout = 0x12; |
711 | attr.path_mtu = IB_MTU_256; | 713 | attr.path_mtu = IB_MTU_256; |
714 | attr.ah_attr.type = RDMA_AH_ATTR_TYPE_ROCE; | ||
712 | rdma_ah_set_grh(&attr.ah_attr, NULL, 0, 0, 1, 0); | 715 | rdma_ah_set_grh(&attr.ah_attr, NULL, 0, 0, 1, 0); |
713 | rdma_ah_set_static_rate(&attr.ah_attr, 3); | 716 | rdma_ah_set_static_rate(&attr.ah_attr, 3); |
714 | 717 | ||
715 | subnet_prefix = cpu_to_be64(0xfe80000000000000LL); | 718 | subnet_prefix = cpu_to_be64(0xfe80000000000000LL); |
716 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { | 719 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { |
720 | phy_port = (i >= HNS_ROCE_MAX_PORTS) ? (i - 2) : | ||
721 | (i % HNS_ROCE_MAX_PORTS); | ||
722 | sl = i / HNS_ROCE_MAX_PORTS; | ||
723 | |||
724 | for (j = 0; j < caps->num_ports; j++) { | ||
725 | if (hr_dev->iboe.phy_port[j] == phy_port) { | ||
726 | queue_en[i] = 1; | ||
727 | port = j; | ||
728 | break; | ||
729 | } | ||
730 | } | ||
731 | |||
732 | if (!queue_en[i]) | ||
733 | continue; | ||
734 | |||
717 | free_mr->mr_free_qp[i] = hns_roce_v1_create_lp_qp(hr_dev, pd); | 735 | free_mr->mr_free_qp[i] = hns_roce_v1_create_lp_qp(hr_dev, pd); |
718 | if (IS_ERR(free_mr->mr_free_qp[i])) { | 736 | if (IS_ERR(free_mr->mr_free_qp[i])) { |
719 | dev_err(dev, "Create loop qp failed!\n"); | 737 | dev_err(dev, "Create loop qp failed!\n"); |
@@ -721,15 +739,7 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
721 | } | 739 | } |
722 | hr_qp = free_mr->mr_free_qp[i]; | 740 | hr_qp = free_mr->mr_free_qp[i]; |
723 | 741 | ||
724 | sl = i / caps->num_ports; | 742 | hr_qp->port = port; |
725 | |||
726 | if (caps->num_ports == HNS_ROCE_MAX_PORTS) | ||
727 | phy_port = (i >= HNS_ROCE_MAX_PORTS) ? (i - 2) : | ||
728 | (i % caps->num_ports); | ||
729 | else | ||
730 | phy_port = i % caps->num_ports; | ||
731 | |||
732 | hr_qp->port = phy_port + 1; | ||
733 | hr_qp->phy_port = phy_port; | 743 | hr_qp->phy_port = phy_port; |
734 | hr_qp->ibqp.qp_type = IB_QPT_RC; | 744 | hr_qp->ibqp.qp_type = IB_QPT_RC; |
735 | hr_qp->ibqp.device = &hr_dev->ib_dev; | 745 | hr_qp->ibqp.device = &hr_dev->ib_dev; |
@@ -739,23 +749,22 @@ static int hns_roce_v1_rsv_lp_qp(struct hns_roce_dev *hr_dev) | |||
739 | hr_qp->ibqp.recv_cq = cq; | 749 | hr_qp->ibqp.recv_cq = cq; |
740 | hr_qp->ibqp.send_cq = cq; | 750 | hr_qp->ibqp.send_cq = cq; |
741 | 751 | ||
742 | rdma_ah_set_port_num(&attr.ah_attr, phy_port + 1); | 752 | rdma_ah_set_port_num(&attr.ah_attr, port + 1); |
743 | rdma_ah_set_sl(&attr.ah_attr, phy_port + 1); | 753 | rdma_ah_set_sl(&attr.ah_attr, sl); |
744 | attr.port_num = phy_port + 1; | 754 | attr.port_num = port + 1; |
745 | 755 | ||
746 | attr.dest_qp_num = hr_qp->qpn; | 756 | attr.dest_qp_num = hr_qp->qpn; |
747 | memcpy(rdma_ah_retrieve_dmac(&attr.ah_attr), | 757 | memcpy(rdma_ah_retrieve_dmac(&attr.ah_attr), |
748 | hr_dev->dev_addr[phy_port], | 758 | hr_dev->dev_addr[port], |
749 | MAC_ADDR_OCTET_NUM); | 759 | MAC_ADDR_OCTET_NUM); |
750 | 760 | ||
751 | memcpy(&dgid.raw, &subnet_prefix, sizeof(u64)); | 761 | memcpy(&dgid.raw, &subnet_prefix, sizeof(u64)); |
752 | memcpy(&dgid.raw[8], hr_dev->dev_addr[phy_port], 3); | 762 | memcpy(&dgid.raw[8], hr_dev->dev_addr[port], 3); |
753 | memcpy(&dgid.raw[13], hr_dev->dev_addr[phy_port] + 3, 3); | 763 | memcpy(&dgid.raw[13], hr_dev->dev_addr[port] + 3, 3); |
754 | dgid.raw[11] = 0xff; | 764 | dgid.raw[11] = 0xff; |
755 | dgid.raw[12] = 0xfe; | 765 | dgid.raw[12] = 0xfe; |
756 | dgid.raw[8] ^= 2; | 766 | dgid.raw[8] ^= 2; |
757 | rdma_ah_set_dgid_raw(&attr.ah_attr, dgid.raw); | 767 | rdma_ah_set_dgid_raw(&attr.ah_attr, dgid.raw); |
758 | attr_mask |= IB_QP_PORT; | ||
759 | 768 | ||
760 | ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, &attr, attr_mask, | 769 | ret = hr_dev->hw->modify_qp(&hr_qp->ibqp, &attr, attr_mask, |
761 | IB_QPS_RESET, IB_QPS_INIT); | 770 | IB_QPS_RESET, IB_QPS_INIT); |
@@ -812,6 +821,9 @@ static void hns_roce_v1_release_lp_qp(struct hns_roce_dev *hr_dev) | |||
812 | 821 | ||
813 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { | 822 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { |
814 | hr_qp = free_mr->mr_free_qp[i]; | 823 | hr_qp = free_mr->mr_free_qp[i]; |
824 | if (!hr_qp) | ||
825 | continue; | ||
826 | |||
815 | ret = hns_roce_v1_destroy_qp(&hr_qp->ibqp); | 827 | ret = hns_roce_v1_destroy_qp(&hr_qp->ibqp); |
816 | if (ret) | 828 | if (ret) |
817 | dev_err(dev, "Destroy qp %d for mr free failed(%d)!\n", | 829 | dev_err(dev, "Destroy qp %d for mr free failed(%d)!\n", |
@@ -963,7 +975,7 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
963 | msecs_to_jiffies(HNS_ROCE_V1_FREE_MR_TIMEOUT_MSECS) + jiffies; | 975 | msecs_to_jiffies(HNS_ROCE_V1_FREE_MR_TIMEOUT_MSECS) + jiffies; |
964 | int i; | 976 | int i; |
965 | int ret; | 977 | int ret; |
966 | int ne; | 978 | int ne = 0; |
967 | 979 | ||
968 | mr_work = container_of(work, struct hns_roce_mr_free_work, work); | 980 | mr_work = container_of(work, struct hns_roce_mr_free_work, work); |
969 | hr_mr = (struct hns_roce_mr *)mr_work->mr; | 981 | hr_mr = (struct hns_roce_mr *)mr_work->mr; |
@@ -976,6 +988,10 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
976 | 988 | ||
977 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { | 989 | for (i = 0; i < HNS_ROCE_V1_RESV_QP; i++) { |
978 | hr_qp = free_mr->mr_free_qp[i]; | 990 | hr_qp = free_mr->mr_free_qp[i]; |
991 | if (!hr_qp) | ||
992 | continue; | ||
993 | ne++; | ||
994 | |||
979 | ret = hns_roce_v1_send_lp_wqe(hr_qp); | 995 | ret = hns_roce_v1_send_lp_wqe(hr_qp); |
980 | if (ret) { | 996 | if (ret) { |
981 | dev_err(dev, | 997 | dev_err(dev, |
@@ -985,7 +1001,6 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
985 | } | 1001 | } |
986 | } | 1002 | } |
987 | 1003 | ||
988 | ne = HNS_ROCE_V1_RESV_QP; | ||
989 | do { | 1004 | do { |
990 | ret = hns_roce_v1_poll_cq(&mr_free_cq->ib_cq, ne, wc); | 1005 | ret = hns_roce_v1_poll_cq(&mr_free_cq->ib_cq, ne, wc); |
991 | if (ret < 0) { | 1006 | if (ret < 0) { |
@@ -995,7 +1010,8 @@ static void hns_roce_v1_mr_free_work_fn(struct work_struct *work) | |||
995 | goto free_work; | 1010 | goto free_work; |
996 | } | 1011 | } |
997 | ne -= ret; | 1012 | ne -= ret; |
998 | msleep(HNS_ROCE_V1_FREE_MR_WAIT_VALUE); | 1013 | usleep_range(HNS_ROCE_V1_FREE_MR_WAIT_VALUE * 1000, |
1014 | (1 + HNS_ROCE_V1_FREE_MR_WAIT_VALUE) * 1000); | ||
999 | } while (ne && time_before_eq(jiffies, end)); | 1015 | } while (ne && time_before_eq(jiffies, end)); |
1000 | 1016 | ||
1001 | if (ne != 0) | 1017 | if (ne != 0) |
@@ -2181,7 +2197,7 @@ static int hns_roce_v1_poll_one(struct hns_roce_cq *hr_cq, | |||
2181 | } | 2197 | } |
2182 | wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; | 2198 | wc->wr_id = wq->wrid[wq->tail & (wq->wqe_cnt - 1)]; |
2183 | ++wq->tail; | 2199 | ++wq->tail; |
2184 | } else { | 2200 | } else { |
2185 | /* RQ conrespond to CQE */ | 2201 | /* RQ conrespond to CQE */ |
2186 | wc->byte_len = le32_to_cpu(cqe->byte_cnt); | 2202 | wc->byte_len = le32_to_cpu(cqe->byte_cnt); |
2187 | opcode = roce_get_field(cqe->cqe_byte_4, | 2203 | opcode = roce_get_field(cqe->cqe_byte_4, |
@@ -3533,10 +3549,12 @@ static int check_qp_db_process_status(struct hns_roce_dev *hr_dev, | |||
3533 | old_cnt = roce_get_field(old_send, | 3549 | old_cnt = roce_get_field(old_send, |
3534 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, | 3550 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, |
3535 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S); | 3551 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S); |
3536 | if (cur_cnt - old_cnt > SDB_ST_CMP_VAL) | 3552 | if (cur_cnt - old_cnt > |
3553 | SDB_ST_CMP_VAL) { | ||
3537 | success_flags = 1; | 3554 | success_flags = 1; |
3538 | else { | 3555 | } else { |
3539 | send_ptr = roce_get_field(old_send, | 3556 | send_ptr = |
3557 | roce_get_field(old_send, | ||
3540 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, | 3558 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_M, |
3541 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S) + | 3559 | ROCEE_SDB_SEND_PTR_SDB_SEND_PTR_S) + |
3542 | roce_get_field(sdb_retry_cnt, | 3560 | roce_get_field(sdb_retry_cnt, |
@@ -3641,6 +3659,7 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3641 | struct hns_roce_dev *hr_dev; | 3659 | struct hns_roce_dev *hr_dev; |
3642 | struct hns_roce_qp *hr_qp; | 3660 | struct hns_roce_qp *hr_qp; |
3643 | struct device *dev; | 3661 | struct device *dev; |
3662 | unsigned long qpn; | ||
3644 | int ret; | 3663 | int ret; |
3645 | 3664 | ||
3646 | qp_work_entry = container_of(work, struct hns_roce_qp_work, work); | 3665 | qp_work_entry = container_of(work, struct hns_roce_qp_work, work); |
@@ -3648,8 +3667,9 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3648 | dev = &hr_dev->pdev->dev; | 3667 | dev = &hr_dev->pdev->dev; |
3649 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; | 3668 | priv = (struct hns_roce_v1_priv *)hr_dev->hw->priv; |
3650 | hr_qp = qp_work_entry->qp; | 3669 | hr_qp = qp_work_entry->qp; |
3670 | qpn = hr_qp->qpn; | ||
3651 | 3671 | ||
3652 | dev_dbg(dev, "Schedule destroy QP(0x%lx) work.\n", hr_qp->qpn); | 3672 | dev_dbg(dev, "Schedule destroy QP(0x%lx) work.\n", qpn); |
3653 | 3673 | ||
3654 | qp_work_entry->sche_cnt++; | 3674 | qp_work_entry->sche_cnt++; |
3655 | 3675 | ||
@@ -3660,7 +3680,7 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3660 | &qp_work_entry->db_wait_stage); | 3680 | &qp_work_entry->db_wait_stage); |
3661 | if (ret) { | 3681 | if (ret) { |
3662 | dev_err(dev, "Check QP(0x%lx) db process status failed!\n", | 3682 | dev_err(dev, "Check QP(0x%lx) db process status failed!\n", |
3663 | hr_qp->qpn); | 3683 | qpn); |
3664 | return; | 3684 | return; |
3665 | } | 3685 | } |
3666 | 3686 | ||
@@ -3674,7 +3694,7 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3674 | ret = hns_roce_v1_modify_qp(&hr_qp->ibqp, NULL, 0, hr_qp->state, | 3694 | ret = hns_roce_v1_modify_qp(&hr_qp->ibqp, NULL, 0, hr_qp->state, |
3675 | IB_QPS_RESET); | 3695 | IB_QPS_RESET); |
3676 | if (ret) { | 3696 | if (ret) { |
3677 | dev_err(dev, "Modify QP(0x%lx) to RST failed!\n", hr_qp->qpn); | 3697 | dev_err(dev, "Modify QP(0x%lx) to RST failed!\n", qpn); |
3678 | return; | 3698 | return; |
3679 | } | 3699 | } |
3680 | 3700 | ||
@@ -3683,14 +3703,14 @@ static void hns_roce_v1_destroy_qp_work_fn(struct work_struct *work) | |||
3683 | 3703 | ||
3684 | if (hr_qp->ibqp.qp_type == IB_QPT_RC) { | 3704 | if (hr_qp->ibqp.qp_type == IB_QPT_RC) { |
3685 | /* RC QP, release QPN */ | 3705 | /* RC QP, release QPN */ |
3686 | hns_roce_release_range_qp(hr_dev, hr_qp->qpn, 1); | 3706 | hns_roce_release_range_qp(hr_dev, qpn, 1); |
3687 | kfree(hr_qp); | 3707 | kfree(hr_qp); |
3688 | } else | 3708 | } else |
3689 | kfree(hr_to_hr_sqp(hr_qp)); | 3709 | kfree(hr_to_hr_sqp(hr_qp)); |
3690 | 3710 | ||
3691 | kfree(qp_work_entry); | 3711 | kfree(qp_work_entry); |
3692 | 3712 | ||
3693 | dev_dbg(dev, "Accomplished destroy QP(0x%lx) work.\n", hr_qp->qpn); | 3713 | dev_dbg(dev, "Accomplished destroy QP(0x%lx) work.\n", qpn); |
3694 | } | 3714 | } |
3695 | 3715 | ||
3696 | int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) | 3716 | int hns_roce_v1_destroy_qp(struct ib_qp *ibqp) |
diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index c3b41f95e70a..d9777b662eba 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c | |||
@@ -125,8 +125,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port, | |||
125 | return -ENODEV; | 125 | return -ENODEV; |
126 | } | 126 | } |
127 | 127 | ||
128 | spin_lock_bh(&hr_dev->iboe.lock); | ||
129 | |||
130 | switch (event) { | 128 | switch (event) { |
131 | case NETDEV_UP: | 129 | case NETDEV_UP: |
132 | case NETDEV_CHANGE: | 130 | case NETDEV_CHANGE: |
@@ -144,7 +142,6 @@ static int handle_en_event(struct hns_roce_dev *hr_dev, u8 port, | |||
144 | break; | 142 | break; |
145 | } | 143 | } |
146 | 144 | ||
147 | spin_unlock_bh(&hr_dev->iboe.lock); | ||
148 | return 0; | 145 | return 0; |
149 | } | 146 | } |
150 | 147 | ||
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c index 4f5a143fc0a7..ff931c580557 100644 --- a/drivers/infiniband/hw/mlx4/cq.c +++ b/drivers/infiniband/hw/mlx4/cq.c | |||
@@ -102,7 +102,7 @@ static int mlx4_ib_alloc_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf * | |||
102 | int err; | 102 | int err; |
103 | 103 | ||
104 | err = mlx4_buf_alloc(dev->dev, nent * dev->dev->caps.cqe_size, | 104 | err = mlx4_buf_alloc(dev->dev, nent * dev->dev->caps.cqe_size, |
105 | PAGE_SIZE * 2, &buf->buf, GFP_KERNEL); | 105 | PAGE_SIZE * 2, &buf->buf); |
106 | 106 | ||
107 | if (err) | 107 | if (err) |
108 | goto out; | 108 | goto out; |
@@ -113,7 +113,7 @@ static int mlx4_ib_alloc_cq_buf(struct mlx4_ib_dev *dev, struct mlx4_ib_cq_buf * | |||
113 | if (err) | 113 | if (err) |
114 | goto err_buf; | 114 | goto err_buf; |
115 | 115 | ||
116 | err = mlx4_buf_write_mtt(dev->dev, &buf->mtt, &buf->buf, GFP_KERNEL); | 116 | err = mlx4_buf_write_mtt(dev->dev, &buf->mtt, &buf->buf); |
117 | if (err) | 117 | if (err) |
118 | goto err_mtt; | 118 | goto err_mtt; |
119 | 119 | ||
@@ -219,7 +219,7 @@ struct ib_cq *mlx4_ib_create_cq(struct ib_device *ibdev, | |||
219 | 219 | ||
220 | uar = &to_mucontext(context)->uar; | 220 | uar = &to_mucontext(context)->uar; |
221 | } else { | 221 | } else { |
222 | err = mlx4_db_alloc(dev->dev, &cq->db, 1, GFP_KERNEL); | 222 | err = mlx4_db_alloc(dev->dev, &cq->db, 1); |
223 | if (err) | 223 | if (err) |
224 | goto err_cq; | 224 | goto err_cq; |
225 | 225 | ||
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 75b2f7d4cd95..d1b43cbbfea7 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
@@ -1155,7 +1155,7 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext) | |||
1155 | * call to mlx4_ib_vma_close. | 1155 | * call to mlx4_ib_vma_close. |
1156 | */ | 1156 | */ |
1157 | put_task_struct(owning_process); | 1157 | put_task_struct(owning_process); |
1158 | msleep(1); | 1158 | usleep_range(1000, 2000); |
1159 | owning_process = get_pid_task(ibcontext->tgid, | 1159 | owning_process = get_pid_task(ibcontext->tgid, |
1160 | PIDTYPE_PID); | 1160 | PIDTYPE_PID); |
1161 | if (!owning_process || | 1161 | if (!owning_process || |
diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c index 3405e947dc1e..b73f89700ef9 100644 --- a/drivers/infiniband/hw/mlx4/mcg.c +++ b/drivers/infiniband/hw/mlx4/mcg.c | |||
@@ -1091,7 +1091,7 @@ static void _mlx4_ib_mcg_port_cleanup(struct mlx4_ib_demux_ctx *ctx, int destroy | |||
1091 | if (!count) | 1091 | if (!count) |
1092 | break; | 1092 | break; |
1093 | 1093 | ||
1094 | msleep(1); | 1094 | usleep_range(1000, 2000); |
1095 | } while (time_after(end, jiffies)); | 1095 | } while (time_after(end, jiffies)); |
1096 | 1096 | ||
1097 | flush_workqueue(ctx->mcg_wq); | 1097 | flush_workqueue(ctx->mcg_wq); |
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h index c2b9cbf4da05..9db82e67e959 100644 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h | |||
@@ -185,7 +185,6 @@ enum mlx4_ib_qp_flags { | |||
185 | MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO, | 185 | MLX4_IB_QP_LSO = IB_QP_CREATE_IPOIB_UD_LSO, |
186 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, | 186 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK, |
187 | MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP, | 187 | MLX4_IB_QP_NETIF = IB_QP_CREATE_NETIF_QP, |
188 | MLX4_IB_QP_CREATE_USE_GFP_NOIO = IB_QP_CREATE_USE_GFP_NOIO, | ||
189 | 188 | ||
190 | /* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */ | 189 | /* Mellanox specific flags start from IB_QP_CREATE_RESERVED_START */ |
191 | MLX4_IB_ROCE_V2_GSI_QP = MLX4_IB_QP_CREATE_ROCE_V2_GSI, | 190 | MLX4_IB_ROCE_V2_GSI_QP = MLX4_IB_QP_CREATE_ROCE_V2_GSI, |
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 996e9058e515..75c0e6c5dd56 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
@@ -634,8 +634,8 @@ static void mlx4_ib_free_qp_counter(struct mlx4_ib_dev *dev, | |||
634 | 634 | ||
635 | static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | 635 | static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, |
636 | struct ib_qp_init_attr *init_attr, | 636 | struct ib_qp_init_attr *init_attr, |
637 | struct ib_udata *udata, int sqpn, struct mlx4_ib_qp **caller_qp, | 637 | struct ib_udata *udata, int sqpn, |
638 | gfp_t gfp) | 638 | struct mlx4_ib_qp **caller_qp) |
639 | { | 639 | { |
640 | int qpn; | 640 | int qpn; |
641 | int err; | 641 | int err; |
@@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
691 | if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI || | 691 | if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI || |
692 | (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER | | 692 | (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER | |
693 | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) { | 693 | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) { |
694 | sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp); | 694 | sqp = kzalloc(sizeof(struct mlx4_ib_sqp), GFP_KERNEL); |
695 | if (!sqp) | 695 | if (!sqp) |
696 | return -ENOMEM; | 696 | return -ENOMEM; |
697 | qp = &sqp->qp; | 697 | qp = &sqp->qp; |
698 | qp->pri.vid = 0xFFFF; | 698 | qp->pri.vid = 0xFFFF; |
699 | qp->alt.vid = 0xFFFF; | 699 | qp->alt.vid = 0xFFFF; |
700 | } else { | 700 | } else { |
701 | qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp); | 701 | qp = kzalloc(sizeof(struct mlx4_ib_qp), GFP_KERNEL); |
702 | if (!qp) | 702 | if (!qp) |
703 | return -ENOMEM; | 703 | return -ENOMEM; |
704 | qp->pri.vid = 0xFFFF; | 704 | qp->pri.vid = 0xFFFF; |
@@ -780,7 +780,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
780 | goto err; | 780 | goto err; |
781 | 781 | ||
782 | if (qp_has_rq(init_attr)) { | 782 | if (qp_has_rq(init_attr)) { |
783 | err = mlx4_db_alloc(dev->dev, &qp->db, 0, gfp); | 783 | err = mlx4_db_alloc(dev->dev, &qp->db, 0); |
784 | if (err) | 784 | if (err) |
785 | goto err; | 785 | goto err; |
786 | 786 | ||
@@ -788,7 +788,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
788 | } | 788 | } |
789 | 789 | ||
790 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, qp->buf_size, | 790 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, qp->buf_size, |
791 | &qp->buf, gfp)) { | 791 | &qp->buf)) { |
792 | memcpy(&init_attr->cap, &backup_cap, | 792 | memcpy(&init_attr->cap, &backup_cap, |
793 | sizeof(backup_cap)); | 793 | sizeof(backup_cap)); |
794 | err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, | 794 | err = set_kernel_sq_size(dev, &init_attr->cap, qp_type, |
@@ -797,7 +797,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
797 | goto err_db; | 797 | goto err_db; |
798 | 798 | ||
799 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, | 799 | if (mlx4_buf_alloc(dev->dev, qp->buf_size, |
800 | PAGE_SIZE * 2, &qp->buf, gfp)) { | 800 | PAGE_SIZE * 2, &qp->buf)) { |
801 | err = -ENOMEM; | 801 | err = -ENOMEM; |
802 | goto err_db; | 802 | goto err_db; |
803 | } | 803 | } |
@@ -808,20 +808,20 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
808 | if (err) | 808 | if (err) |
809 | goto err_buf; | 809 | goto err_buf; |
810 | 810 | ||
811 | err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf, gfp); | 811 | err = mlx4_buf_write_mtt(dev->dev, &qp->mtt, &qp->buf); |
812 | if (err) | 812 | if (err) |
813 | goto err_mtt; | 813 | goto err_mtt; |
814 | 814 | ||
815 | qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(u64), | 815 | qp->sq.wrid = kmalloc_array(qp->sq.wqe_cnt, sizeof(u64), |
816 | gfp | __GFP_NOWARN); | 816 | GFP_KERNEL | __GFP_NOWARN); |
817 | if (!qp->sq.wrid) | 817 | if (!qp->sq.wrid) |
818 | qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64), | 818 | qp->sq.wrid = __vmalloc(qp->sq.wqe_cnt * sizeof(u64), |
819 | gfp, PAGE_KERNEL); | 819 | GFP_KERNEL, PAGE_KERNEL); |
820 | qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, sizeof(u64), | 820 | qp->rq.wrid = kmalloc_array(qp->rq.wqe_cnt, sizeof(u64), |
821 | gfp | __GFP_NOWARN); | 821 | GFP_KERNEL | __GFP_NOWARN); |
822 | if (!qp->rq.wrid) | 822 | if (!qp->rq.wrid) |
823 | qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64), | 823 | qp->rq.wrid = __vmalloc(qp->rq.wqe_cnt * sizeof(u64), |
824 | gfp, PAGE_KERNEL); | 824 | GFP_KERNEL, PAGE_KERNEL); |
825 | if (!qp->sq.wrid || !qp->rq.wrid) { | 825 | if (!qp->sq.wrid || !qp->rq.wrid) { |
826 | err = -ENOMEM; | 826 | err = -ENOMEM; |
827 | goto err_wrid; | 827 | goto err_wrid; |
@@ -859,7 +859,7 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, | |||
859 | if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) | 859 | if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK) |
860 | qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; | 860 | qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; |
861 | 861 | ||
862 | err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp, gfp); | 862 | err = mlx4_qp_alloc(dev->dev, qpn, &qp->mqp); |
863 | if (err) | 863 | if (err) |
864 | goto err_qpn; | 864 | goto err_qpn; |
865 | 865 | ||
@@ -1127,10 +1127,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1127 | int err; | 1127 | int err; |
1128 | int sup_u_create_flags = MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; | 1128 | int sup_u_create_flags = MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK; |
1129 | u16 xrcdn = 0; | 1129 | u16 xrcdn = 0; |
1130 | gfp_t gfp; | ||
1131 | 1130 | ||
1132 | gfp = (init_attr->create_flags & MLX4_IB_QP_CREATE_USE_GFP_NOIO) ? | ||
1133 | GFP_NOIO : GFP_KERNEL; | ||
1134 | /* | 1131 | /* |
1135 | * We only support LSO, vendor flag1, and multicast loopback blocking, | 1132 | * We only support LSO, vendor flag1, and multicast loopback blocking, |
1136 | * and only for kernel UD QPs. | 1133 | * and only for kernel UD QPs. |
@@ -1140,8 +1137,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1140 | MLX4_IB_SRIOV_TUNNEL_QP | | 1137 | MLX4_IB_SRIOV_TUNNEL_QP | |
1141 | MLX4_IB_SRIOV_SQP | | 1138 | MLX4_IB_SRIOV_SQP | |
1142 | MLX4_IB_QP_NETIF | | 1139 | MLX4_IB_QP_NETIF | |
1143 | MLX4_IB_QP_CREATE_ROCE_V2_GSI | | 1140 | MLX4_IB_QP_CREATE_ROCE_V2_GSI)) |
1144 | MLX4_IB_QP_CREATE_USE_GFP_NOIO)) | ||
1145 | return ERR_PTR(-EINVAL); | 1141 | return ERR_PTR(-EINVAL); |
1146 | 1142 | ||
1147 | if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) { | 1143 | if (init_attr->create_flags & IB_QP_CREATE_NETIF_QP) { |
@@ -1154,7 +1150,6 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1154 | return ERR_PTR(-EINVAL); | 1150 | return ERR_PTR(-EINVAL); |
1155 | 1151 | ||
1156 | if ((init_attr->create_flags & ~(MLX4_IB_SRIOV_SQP | | 1152 | if ((init_attr->create_flags & ~(MLX4_IB_SRIOV_SQP | |
1157 | MLX4_IB_QP_CREATE_USE_GFP_NOIO | | ||
1158 | MLX4_IB_QP_CREATE_ROCE_V2_GSI | | 1153 | MLX4_IB_QP_CREATE_ROCE_V2_GSI | |
1159 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK) && | 1154 | MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK) && |
1160 | init_attr->qp_type != IB_QPT_UD) || | 1155 | init_attr->qp_type != IB_QPT_UD) || |
@@ -1179,7 +1174,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1179 | case IB_QPT_RC: | 1174 | case IB_QPT_RC: |
1180 | case IB_QPT_UC: | 1175 | case IB_QPT_UC: |
1181 | case IB_QPT_RAW_PACKET: | 1176 | case IB_QPT_RAW_PACKET: |
1182 | qp = kzalloc(sizeof *qp, gfp); | 1177 | qp = kzalloc(sizeof(*qp), GFP_KERNEL); |
1183 | if (!qp) | 1178 | if (!qp) |
1184 | return ERR_PTR(-ENOMEM); | 1179 | return ERR_PTR(-ENOMEM); |
1185 | qp->pri.vid = 0xFFFF; | 1180 | qp->pri.vid = 0xFFFF; |
@@ -1188,7 +1183,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1188 | case IB_QPT_UD: | 1183 | case IB_QPT_UD: |
1189 | { | 1184 | { |
1190 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, | 1185 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, |
1191 | udata, 0, &qp, gfp); | 1186 | udata, 0, &qp); |
1192 | if (err) { | 1187 | if (err) { |
1193 | kfree(qp); | 1188 | kfree(qp); |
1194 | return ERR_PTR(err); | 1189 | return ERR_PTR(err); |
@@ -1217,8 +1212,7 @@ static struct ib_qp *_mlx4_ib_create_qp(struct ib_pd *pd, | |||
1217 | } | 1212 | } |
1218 | 1213 | ||
1219 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, udata, | 1214 | err = create_qp_common(to_mdev(pd->device), pd, init_attr, udata, |
1220 | sqpn, | 1215 | sqpn, &qp); |
1221 | &qp, gfp); | ||
1222 | if (err) | 1216 | if (err) |
1223 | return ERR_PTR(err); | 1217 | return ERR_PTR(err); |
1224 | 1218 | ||
diff --git a/drivers/infiniband/hw/mlx4/srq.c b/drivers/infiniband/hw/mlx4/srq.c index e32dd58937a8..0facaf5f6d23 100644 --- a/drivers/infiniband/hw/mlx4/srq.c +++ b/drivers/infiniband/hw/mlx4/srq.c | |||
@@ -135,14 +135,14 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, | |||
135 | if (err) | 135 | if (err) |
136 | goto err_mtt; | 136 | goto err_mtt; |
137 | } else { | 137 | } else { |
138 | err = mlx4_db_alloc(dev->dev, &srq->db, 0, GFP_KERNEL); | 138 | err = mlx4_db_alloc(dev->dev, &srq->db, 0); |
139 | if (err) | 139 | if (err) |
140 | goto err_srq; | 140 | goto err_srq; |
141 | 141 | ||
142 | *srq->db.db = 0; | 142 | *srq->db.db = 0; |
143 | 143 | ||
144 | if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2, &srq->buf, | 144 | if (mlx4_buf_alloc(dev->dev, buf_size, PAGE_SIZE * 2, |
145 | GFP_KERNEL)) { | 145 | &srq->buf)) { |
146 | err = -ENOMEM; | 146 | err = -ENOMEM; |
147 | goto err_db; | 147 | goto err_db; |
148 | } | 148 | } |
@@ -167,7 +167,7 @@ struct ib_srq *mlx4_ib_create_srq(struct ib_pd *pd, | |||
167 | if (err) | 167 | if (err) |
168 | goto err_buf; | 168 | goto err_buf; |
169 | 169 | ||
170 | err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf, GFP_KERNEL); | 170 | err = mlx4_buf_write_mtt(dev->dev, &srq->mtt, &srq->buf); |
171 | if (err) | 171 | if (err) |
172 | goto err_mtt; | 172 | goto err_mtt; |
173 | 173 | ||
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 763bb5b36144..8ab2f1360a45 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c | |||
@@ -582,6 +582,15 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c) | |||
582 | } | 582 | } |
583 | } | 583 | } |
584 | 584 | ||
585 | static void mlx5_mr_cache_debugfs_cleanup(struct mlx5_ib_dev *dev) | ||
586 | { | ||
587 | if (!mlx5_debugfs_root) | ||
588 | return; | ||
589 | |||
590 | debugfs_remove_recursive(dev->cache.root); | ||
591 | dev->cache.root = NULL; | ||
592 | } | ||
593 | |||
585 | static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) | 594 | static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) |
586 | { | 595 | { |
587 | struct mlx5_mr_cache *cache = &dev->cache; | 596 | struct mlx5_mr_cache *cache = &dev->cache; |
@@ -600,38 +609,34 @@ static int mlx5_mr_cache_debugfs_init(struct mlx5_ib_dev *dev) | |||
600 | sprintf(ent->name, "%d", ent->order); | 609 | sprintf(ent->name, "%d", ent->order); |
601 | ent->dir = debugfs_create_dir(ent->name, cache->root); | 610 | ent->dir = debugfs_create_dir(ent->name, cache->root); |
602 | if (!ent->dir) | 611 | if (!ent->dir) |
603 | return -ENOMEM; | 612 | goto err; |
604 | 613 | ||
605 | ent->fsize = debugfs_create_file("size", 0600, ent->dir, ent, | 614 | ent->fsize = debugfs_create_file("size", 0600, ent->dir, ent, |
606 | &size_fops); | 615 | &size_fops); |
607 | if (!ent->fsize) | 616 | if (!ent->fsize) |
608 | return -ENOMEM; | 617 | goto err; |
609 | 618 | ||
610 | ent->flimit = debugfs_create_file("limit", 0600, ent->dir, ent, | 619 | ent->flimit = debugfs_create_file("limit", 0600, ent->dir, ent, |
611 | &limit_fops); | 620 | &limit_fops); |
612 | if (!ent->flimit) | 621 | if (!ent->flimit) |
613 | return -ENOMEM; | 622 | goto err; |
614 | 623 | ||
615 | ent->fcur = debugfs_create_u32("cur", 0400, ent->dir, | 624 | ent->fcur = debugfs_create_u32("cur", 0400, ent->dir, |
616 | &ent->cur); | 625 | &ent->cur); |
617 | if (!ent->fcur) | 626 | if (!ent->fcur) |
618 | return -ENOMEM; | 627 | goto err; |
619 | 628 | ||
620 | ent->fmiss = debugfs_create_u32("miss", 0600, ent->dir, | 629 | ent->fmiss = debugfs_create_u32("miss", 0600, ent->dir, |
621 | &ent->miss); | 630 | &ent->miss); |
622 | if (!ent->fmiss) | 631 | if (!ent->fmiss) |
623 | return -ENOMEM; | 632 | goto err; |
624 | } | 633 | } |
625 | 634 | ||
626 | return 0; | 635 | return 0; |
627 | } | 636 | err: |
628 | 637 | mlx5_mr_cache_debugfs_cleanup(dev); | |
629 | static void mlx5_mr_cache_debugfs_cleanup(struct mlx5_ib_dev *dev) | ||
630 | { | ||
631 | if (!mlx5_debugfs_root) | ||
632 | return; | ||
633 | 638 | ||
634 | debugfs_remove_recursive(dev->cache.root); | 639 | return -ENOMEM; |
635 | } | 640 | } |
636 | 641 | ||
637 | static void delay_time_func(unsigned long ctx) | 642 | static void delay_time_func(unsigned long ctx) |
@@ -692,6 +697,11 @@ int mlx5_mr_cache_init(struct mlx5_ib_dev *dev) | |||
692 | if (err) | 697 | if (err) |
693 | mlx5_ib_warn(dev, "cache debugfs failure\n"); | 698 | mlx5_ib_warn(dev, "cache debugfs failure\n"); |
694 | 699 | ||
700 | /* | ||
701 | * We don't want to fail driver if debugfs failed to initialize, | ||
702 | * so we are not forwarding error to the user. | ||
703 | */ | ||
704 | |||
695 | return 0; | 705 | return 0; |
696 | } | 706 | } |
697 | 707 | ||
@@ -1779,7 +1789,7 @@ mlx5_ib_sg_to_klms(struct mlx5_ib_mr *mr, | |||
1779 | mr->ndescs = sg_nents; | 1789 | mr->ndescs = sg_nents; |
1780 | 1790 | ||
1781 | for_each_sg(sgl, sg, sg_nents, i) { | 1791 | for_each_sg(sgl, sg, sg_nents, i) { |
1782 | if (unlikely(i > mr->max_descs)) | 1792 | if (unlikely(i >= mr->max_descs)) |
1783 | break; | 1793 | break; |
1784 | klms[i].va = cpu_to_be64(sg_dma_address(sg) + sg_offset); | 1794 | klms[i].va = cpu_to_be64(sg_dma_address(sg) + sg_offset); |
1785 | klms[i].bcount = cpu_to_be32(sg_dma_len(sg) - sg_offset); | 1795 | klms[i].bcount = cpu_to_be32(sg_dma_len(sg) - sg_offset); |
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c index 8f9d8b4ad583..b0adf65e4bdb 100644 --- a/drivers/infiniband/hw/nes/nes_hw.c +++ b/drivers/infiniband/hw/nes/nes_hw.c | |||
@@ -551,7 +551,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { | |||
551 | if ((0x0F000100 == (pcs_control_status0 & 0x0F000100)) | 551 | if ((0x0F000100 == (pcs_control_status0 & 0x0F000100)) |
552 | || (0x0F000100 == (pcs_control_status1 & 0x0F000100))) | 552 | || (0x0F000100 == (pcs_control_status1 & 0x0F000100))) |
553 | int_cnt++; | 553 | int_cnt++; |
554 | msleep(1); | 554 | usleep_range(1000, 2000); |
555 | } | 555 | } |
556 | if (int_cnt > 1) { | 556 | if (int_cnt > 1) { |
557 | spin_lock_irqsave(&nesadapter->phy_lock, flags); | 557 | spin_lock_irqsave(&nesadapter->phy_lock, flags); |
@@ -592,7 +592,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) { | |||
592 | break; | 592 | break; |
593 | } | 593 | } |
594 | } | 594 | } |
595 | msleep(1); | 595 | usleep_range(1000, 2000); |
596 | } | 596 | } |
597 | } | 597 | } |
598 | } | 598 | } |
diff --git a/drivers/infiniband/hw/qib/qib_qp.c b/drivers/infiniband/hw/qib/qib_qp.c index 5984981e7dd4..a343e3b5d4cb 100644 --- a/drivers/infiniband/hw/qib/qib_qp.c +++ b/drivers/infiniband/hw/qib/qib_qp.c | |||
@@ -104,10 +104,9 @@ const struct rvt_operation_params qib_post_parms[RVT_OPERATION_MAX] = { | |||
104 | 104 | ||
105 | }; | 105 | }; |
106 | 106 | ||
107 | static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map, | 107 | static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map) |
108 | gfp_t gfp) | ||
109 | { | 108 | { |
110 | unsigned long page = get_zeroed_page(gfp); | 109 | unsigned long page = get_zeroed_page(GFP_KERNEL); |
111 | 110 | ||
112 | /* | 111 | /* |
113 | * Free the page if someone raced with us installing it. | 112 | * Free the page if someone raced with us installing it. |
@@ -126,7 +125,7 @@ static void get_map_page(struct rvt_qpn_table *qpt, struct rvt_qpn_map *map, | |||
126 | * zero/one for QP type IB_QPT_SMI/IB_QPT_GSI. | 125 | * zero/one for QP type IB_QPT_SMI/IB_QPT_GSI. |
127 | */ | 126 | */ |
128 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 127 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
129 | enum ib_qp_type type, u8 port, gfp_t gfp) | 128 | enum ib_qp_type type, u8 port) |
130 | { | 129 | { |
131 | u32 i, offset, max_scan, qpn; | 130 | u32 i, offset, max_scan, qpn; |
132 | struct rvt_qpn_map *map; | 131 | struct rvt_qpn_map *map; |
@@ -160,7 +159,7 @@ int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | |||
160 | max_scan = qpt->nmaps - !offset; | 159 | max_scan = qpt->nmaps - !offset; |
161 | for (i = 0;;) { | 160 | for (i = 0;;) { |
162 | if (unlikely(!map->page)) { | 161 | if (unlikely(!map->page)) { |
163 | get_map_page(qpt, map, gfp); | 162 | get_map_page(qpt, map); |
164 | if (unlikely(!map->page)) | 163 | if (unlikely(!map->page)) |
165 | break; | 164 | break; |
166 | } | 165 | } |
@@ -317,16 +316,16 @@ u32 qib_mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu) | |||
317 | return ib_mtu_enum_to_int(pmtu); | 316 | return ib_mtu_enum_to_int(pmtu); |
318 | } | 317 | } |
319 | 318 | ||
320 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp) | 319 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp) |
321 | { | 320 | { |
322 | struct qib_qp_priv *priv; | 321 | struct qib_qp_priv *priv; |
323 | 322 | ||
324 | priv = kzalloc(sizeof(*priv), gfp); | 323 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
325 | if (!priv) | 324 | if (!priv) |
326 | return ERR_PTR(-ENOMEM); | 325 | return ERR_PTR(-ENOMEM); |
327 | priv->owner = qp; | 326 | priv->owner = qp; |
328 | 327 | ||
329 | priv->s_hdr = kzalloc(sizeof(*priv->s_hdr), gfp); | 328 | priv->s_hdr = kzalloc(sizeof(*priv->s_hdr), GFP_KERNEL); |
330 | if (!priv->s_hdr) { | 329 | if (!priv->s_hdr) { |
331 | kfree(priv); | 330 | kfree(priv); |
332 | return ERR_PTR(-ENOMEM); | 331 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/infiniband/hw/qib/qib_verbs.h b/drivers/infiniband/hw/qib/qib_verbs.h index da0db5485ddc..a52fc67b40d7 100644 --- a/drivers/infiniband/hw/qib/qib_verbs.h +++ b/drivers/infiniband/hw/qib/qib_verbs.h | |||
@@ -274,11 +274,11 @@ int qib_get_counters(struct qib_pportdata *ppd, | |||
274 | * Functions provided by qib driver for rdmavt to use | 274 | * Functions provided by qib driver for rdmavt to use |
275 | */ | 275 | */ |
276 | unsigned qib_free_all_qps(struct rvt_dev_info *rdi); | 276 | unsigned qib_free_all_qps(struct rvt_dev_info *rdi); |
277 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp, gfp_t gfp); | 277 | void *qib_qp_priv_alloc(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
278 | void qib_qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); | 278 | void qib_qp_priv_free(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
279 | void qib_notify_qp_reset(struct rvt_qp *qp); | 279 | void qib_notify_qp_reset(struct rvt_qp *qp); |
280 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 280 | int qib_alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
281 | enum ib_qp_type type, u8 port, gfp_t gfp); | 281 | enum ib_qp_type type, u8 port); |
282 | void qib_restart_rc(struct rvt_qp *qp, u32 psn, int wait); | 282 | void qib_restart_rc(struct rvt_qp *qp, u32 psn, int wait); |
283 | #ifdef CONFIG_DEBUG_FS | 283 | #ifdef CONFIG_DEBUG_FS |
284 | 284 | ||
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c index 727e81cc2c8f..459865439a0b 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c | |||
@@ -118,10 +118,9 @@ const int ib_rvt_state_ops[IB_QPS_ERR + 1] = { | |||
118 | EXPORT_SYMBOL(ib_rvt_state_ops); | 118 | EXPORT_SYMBOL(ib_rvt_state_ops); |
119 | 119 | ||
120 | static void get_map_page(struct rvt_qpn_table *qpt, | 120 | static void get_map_page(struct rvt_qpn_table *qpt, |
121 | struct rvt_qpn_map *map, | 121 | struct rvt_qpn_map *map) |
122 | gfp_t gfp) | ||
123 | { | 122 | { |
124 | unsigned long page = get_zeroed_page(gfp); | 123 | unsigned long page = get_zeroed_page(GFP_KERNEL); |
125 | 124 | ||
126 | /* | 125 | /* |
127 | * Free the page if someone raced with us installing it. | 126 | * Free the page if someone raced with us installing it. |
@@ -173,7 +172,7 @@ static int init_qpn_table(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt) | |||
173 | rdi->dparms.qpn_res_start, rdi->dparms.qpn_res_end); | 172 | rdi->dparms.qpn_res_start, rdi->dparms.qpn_res_end); |
174 | for (i = rdi->dparms.qpn_res_start; i <= rdi->dparms.qpn_res_end; i++) { | 173 | for (i = rdi->dparms.qpn_res_start; i <= rdi->dparms.qpn_res_end; i++) { |
175 | if (!map->page) { | 174 | if (!map->page) { |
176 | get_map_page(qpt, map, GFP_KERNEL); | 175 | get_map_page(qpt, map); |
177 | if (!map->page) { | 176 | if (!map->page) { |
178 | ret = -ENOMEM; | 177 | ret = -ENOMEM; |
179 | break; | 178 | break; |
@@ -342,14 +341,14 @@ static inline unsigned mk_qpn(struct rvt_qpn_table *qpt, | |||
342 | * Return: The queue pair number | 341 | * Return: The queue pair number |
343 | */ | 342 | */ |
344 | static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 343 | static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
345 | enum ib_qp_type type, u8 port_num, gfp_t gfp) | 344 | enum ib_qp_type type, u8 port_num) |
346 | { | 345 | { |
347 | u32 i, offset, max_scan, qpn; | 346 | u32 i, offset, max_scan, qpn; |
348 | struct rvt_qpn_map *map; | 347 | struct rvt_qpn_map *map; |
349 | u32 ret; | 348 | u32 ret; |
350 | 349 | ||
351 | if (rdi->driver_f.alloc_qpn) | 350 | if (rdi->driver_f.alloc_qpn) |
352 | return rdi->driver_f.alloc_qpn(rdi, qpt, type, port_num, gfp); | 351 | return rdi->driver_f.alloc_qpn(rdi, qpt, type, port_num); |
353 | 352 | ||
354 | if (type == IB_QPT_SMI || type == IB_QPT_GSI) { | 353 | if (type == IB_QPT_SMI || type == IB_QPT_GSI) { |
355 | unsigned n; | 354 | unsigned n; |
@@ -374,7 +373,7 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | |||
374 | max_scan = qpt->nmaps - !offset; | 373 | max_scan = qpt->nmaps - !offset; |
375 | for (i = 0;;) { | 374 | for (i = 0;;) { |
376 | if (unlikely(!map->page)) { | 375 | if (unlikely(!map->page)) { |
377 | get_map_page(qpt, map, gfp); | 376 | get_map_page(qpt, map); |
378 | if (unlikely(!map->page)) | 377 | if (unlikely(!map->page)) |
379 | break; | 378 | break; |
380 | } | 379 | } |
@@ -672,7 +671,6 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
672 | struct ib_qp *ret = ERR_PTR(-ENOMEM); | 671 | struct ib_qp *ret = ERR_PTR(-ENOMEM); |
673 | struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device); | 672 | struct rvt_dev_info *rdi = ib_to_rvt(ibpd->device); |
674 | void *priv = NULL; | 673 | void *priv = NULL; |
675 | gfp_t gfp; | ||
676 | size_t sqsize; | 674 | size_t sqsize; |
677 | 675 | ||
678 | if (!rdi) | 676 | if (!rdi) |
@@ -680,18 +678,9 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
680 | 678 | ||
681 | if (init_attr->cap.max_send_sge > rdi->dparms.props.max_sge || | 679 | if (init_attr->cap.max_send_sge > rdi->dparms.props.max_sge || |
682 | init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr || | 680 | init_attr->cap.max_send_wr > rdi->dparms.props.max_qp_wr || |
683 | init_attr->create_flags & ~(IB_QP_CREATE_USE_GFP_NOIO)) | 681 | init_attr->create_flags) |
684 | return ERR_PTR(-EINVAL); | 682 | return ERR_PTR(-EINVAL); |
685 | 683 | ||
686 | /* GFP_NOIO is applicable to RC QP's only */ | ||
687 | |||
688 | if (init_attr->create_flags & IB_QP_CREATE_USE_GFP_NOIO && | ||
689 | init_attr->qp_type != IB_QPT_RC) | ||
690 | return ERR_PTR(-EINVAL); | ||
691 | |||
692 | gfp = init_attr->create_flags & IB_QP_CREATE_USE_GFP_NOIO ? | ||
693 | GFP_NOIO : GFP_KERNEL; | ||
694 | |||
695 | /* Check receive queue parameters if no SRQ is specified. */ | 684 | /* Check receive queue parameters if no SRQ is specified. */ |
696 | if (!init_attr->srq) { | 685 | if (!init_attr->srq) { |
697 | if (init_attr->cap.max_recv_sge > rdi->dparms.props.max_sge || | 686 | if (init_attr->cap.max_recv_sge > rdi->dparms.props.max_sge || |
@@ -719,14 +708,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
719 | sz = sizeof(struct rvt_sge) * | 708 | sz = sizeof(struct rvt_sge) * |
720 | init_attr->cap.max_send_sge + | 709 | init_attr->cap.max_send_sge + |
721 | sizeof(struct rvt_swqe); | 710 | sizeof(struct rvt_swqe); |
722 | if (gfp == GFP_NOIO) | 711 | swq = vzalloc_node(sqsize * sz, rdi->dparms.node); |
723 | swq = __vmalloc( | ||
724 | sqsize * sz, | ||
725 | gfp | __GFP_ZERO, PAGE_KERNEL); | ||
726 | else | ||
727 | swq = vzalloc_node( | ||
728 | sqsize * sz, | ||
729 | rdi->dparms.node); | ||
730 | if (!swq) | 712 | if (!swq) |
731 | return ERR_PTR(-ENOMEM); | 713 | return ERR_PTR(-ENOMEM); |
732 | 714 | ||
@@ -741,7 +723,8 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
741 | } else if (init_attr->cap.max_recv_sge > 1) | 723 | } else if (init_attr->cap.max_recv_sge > 1) |
742 | sg_list_sz = sizeof(*qp->r_sg_list) * | 724 | sg_list_sz = sizeof(*qp->r_sg_list) * |
743 | (init_attr->cap.max_recv_sge - 1); | 725 | (init_attr->cap.max_recv_sge - 1); |
744 | qp = kzalloc_node(sz + sg_list_sz, gfp, rdi->dparms.node); | 726 | qp = kzalloc_node(sz + sg_list_sz, GFP_KERNEL, |
727 | rdi->dparms.node); | ||
745 | if (!qp) | 728 | if (!qp) |
746 | goto bail_swq; | 729 | goto bail_swq; |
747 | 730 | ||
@@ -751,7 +734,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
751 | kzalloc_node( | 734 | kzalloc_node( |
752 | sizeof(*qp->s_ack_queue) * | 735 | sizeof(*qp->s_ack_queue) * |
753 | rvt_max_atomic(rdi), | 736 | rvt_max_atomic(rdi), |
754 | gfp, | 737 | GFP_KERNEL, |
755 | rdi->dparms.node); | 738 | rdi->dparms.node); |
756 | if (!qp->s_ack_queue) | 739 | if (!qp->s_ack_queue) |
757 | goto bail_qp; | 740 | goto bail_qp; |
@@ -766,7 +749,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
766 | * Driver needs to set up it's private QP structure and do any | 749 | * Driver needs to set up it's private QP structure and do any |
767 | * initialization that is needed. | 750 | * initialization that is needed. |
768 | */ | 751 | */ |
769 | priv = rdi->driver_f.qp_priv_alloc(rdi, qp, gfp); | 752 | priv = rdi->driver_f.qp_priv_alloc(rdi, qp); |
770 | if (IS_ERR(priv)) { | 753 | if (IS_ERR(priv)) { |
771 | ret = priv; | 754 | ret = priv; |
772 | goto bail_qp; | 755 | goto bail_qp; |
@@ -786,11 +769,6 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
786 | qp->r_rq.wq = vmalloc_user( | 769 | qp->r_rq.wq = vmalloc_user( |
787 | sizeof(struct rvt_rwq) + | 770 | sizeof(struct rvt_rwq) + |
788 | qp->r_rq.size * sz); | 771 | qp->r_rq.size * sz); |
789 | else if (gfp == GFP_NOIO) | ||
790 | qp->r_rq.wq = __vmalloc( | ||
791 | sizeof(struct rvt_rwq) + | ||
792 | qp->r_rq.size * sz, | ||
793 | gfp | __GFP_ZERO, PAGE_KERNEL); | ||
794 | else | 772 | else |
795 | qp->r_rq.wq = vzalloc_node( | 773 | qp->r_rq.wq = vzalloc_node( |
796 | sizeof(struct rvt_rwq) + | 774 | sizeof(struct rvt_rwq) + |
@@ -824,7 +802,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
824 | 802 | ||
825 | err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table, | 803 | err = alloc_qpn(rdi, &rdi->qp_dev->qpn_table, |
826 | init_attr->qp_type, | 804 | init_attr->qp_type, |
827 | init_attr->port_num, gfp); | 805 | init_attr->port_num); |
828 | if (err < 0) { | 806 | if (err < 0) { |
829 | ret = ERR_PTR(err); | 807 | ret = ERR_PTR(err); |
830 | goto bail_rq_wq; | 808 | goto bail_rq_wq; |
diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c index c3a140ed4df2..08f3f90d2912 100644 --- a/drivers/infiniband/sw/rxe/rxe_net.c +++ b/drivers/infiniband/sw/rxe/rxe_net.c | |||
@@ -441,6 +441,8 @@ static void rxe_skb_tx_dtor(struct sk_buff *skb) | |||
441 | if (unlikely(qp->need_req_skb && | 441 | if (unlikely(qp->need_req_skb && |
442 | skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) | 442 | skb_out < RXE_INFLIGHT_SKBS_PER_QP_LOW)) |
443 | rxe_run_task(&qp->req.task, 1); | 443 | rxe_run_task(&qp->req.task, 1); |
444 | |||
445 | rxe_drop_ref(qp); | ||
444 | } | 446 | } |
445 | 447 | ||
446 | int rxe_send(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct sk_buff *skb) | 448 | int rxe_send(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct sk_buff *skb) |
@@ -473,6 +475,7 @@ int rxe_send(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, struct sk_buff *skb) | |||
473 | return -EAGAIN; | 475 | return -EAGAIN; |
474 | } | 476 | } |
475 | 477 | ||
478 | rxe_add_ref(pkt->qp); | ||
476 | atomic_inc(&pkt->qp->skb_out); | 479 | atomic_inc(&pkt->qp->skb_out); |
477 | kfree_skb(skb); | 480 | kfree_skb(skb); |
478 | 481 | ||
diff --git a/drivers/infiniband/sw/rxe/rxe_verbs.c b/drivers/infiniband/sw/rxe/rxe_verbs.c index 073e66783f1d..07511718d98d 100644 --- a/drivers/infiniband/sw/rxe/rxe_verbs.c +++ b/drivers/infiniband/sw/rxe/rxe_verbs.c | |||
@@ -1240,6 +1240,8 @@ int rxe_register_device(struct rxe_dev *rxe) | |||
1240 | addrconf_addr_eui48((unsigned char *)&dev->node_guid, | 1240 | addrconf_addr_eui48((unsigned char *)&dev->node_guid, |
1241 | rxe->ndev->dev_addr); | 1241 | rxe->ndev->dev_addr); |
1242 | dev->dev.dma_ops = &dma_virt_ops; | 1242 | dev->dev.dma_ops = &dma_virt_ops; |
1243 | dma_coerce_mask_and_coherent(&dev->dev, | ||
1244 | dma_get_required_mask(dev->dev.parent)); | ||
1243 | 1245 | ||
1244 | dev->uverbs_abi_ver = RXE_UVERBS_ABI_VERSION; | 1246 | dev->uverbs_abi_ver = RXE_UVERBS_ABI_VERSION; |
1245 | dev->uverbs_cmd_mask = BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT) | 1247 | dev->uverbs_cmd_mask = BIT_ULL(IB_USER_VERBS_CMD_GET_CONTEXT) |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 7cbcfdac6529..f87d104837dc 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/vmalloc.h> | 39 | #include <linux/vmalloc.h> |
40 | #include <linux/moduleparam.h> | 40 | #include <linux/moduleparam.h> |
41 | #include <linux/sched/signal.h> | 41 | #include <linux/sched/signal.h> |
42 | #include <linux/sched/mm.h> | ||
42 | 43 | ||
43 | #include "ipoib.h" | 44 | #include "ipoib.h" |
44 | 45 | ||
@@ -954,7 +955,7 @@ void ipoib_cm_dev_stop(struct net_device *dev) | |||
954 | break; | 955 | break; |
955 | } | 956 | } |
956 | spin_unlock_irq(&priv->lock); | 957 | spin_unlock_irq(&priv->lock); |
957 | msleep(1); | 958 | usleep_range(1000, 2000); |
958 | ipoib_drain_cq(dev); | 959 | ipoib_drain_cq(dev); |
959 | spin_lock_irq(&priv->lock); | 960 | spin_lock_irq(&priv->lock); |
960 | } | 961 | } |
@@ -1047,9 +1048,8 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_ | |||
1047 | .sq_sig_type = IB_SIGNAL_ALL_WR, | 1048 | .sq_sig_type = IB_SIGNAL_ALL_WR, |
1048 | .qp_type = IB_QPT_RC, | 1049 | .qp_type = IB_QPT_RC, |
1049 | .qp_context = tx, | 1050 | .qp_context = tx, |
1050 | .create_flags = IB_QP_CREATE_USE_GFP_NOIO | 1051 | .create_flags = 0 |
1051 | }; | 1052 | }; |
1052 | |||
1053 | struct ib_qp *tx_qp; | 1053 | struct ib_qp *tx_qp; |
1054 | 1054 | ||
1055 | if (dev->features & NETIF_F_SG) | 1055 | if (dev->features & NETIF_F_SG) |
@@ -1057,10 +1057,6 @@ static struct ib_qp *ipoib_cm_create_tx_qp(struct net_device *dev, struct ipoib_ | |||
1057 | min_t(u32, priv->ca->attrs.max_sge, MAX_SKB_FRAGS + 1); | 1057 | min_t(u32, priv->ca->attrs.max_sge, MAX_SKB_FRAGS + 1); |
1058 | 1058 | ||
1059 | tx_qp = ib_create_qp(priv->pd, &attr); | 1059 | tx_qp = ib_create_qp(priv->pd, &attr); |
1060 | if (PTR_ERR(tx_qp) == -EINVAL) { | ||
1061 | attr.create_flags &= ~IB_QP_CREATE_USE_GFP_NOIO; | ||
1062 | tx_qp = ib_create_qp(priv->pd, &attr); | ||
1063 | } | ||
1064 | tx->max_send_sge = attr.cap.max_send_sge; | 1060 | tx->max_send_sge = attr.cap.max_send_sge; |
1065 | return tx_qp; | 1061 | return tx_qp; |
1066 | } | 1062 | } |
@@ -1131,10 +1127,11 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | |||
1131 | struct sa_path_rec *pathrec) | 1127 | struct sa_path_rec *pathrec) |
1132 | { | 1128 | { |
1133 | struct ipoib_dev_priv *priv = ipoib_priv(p->dev); | 1129 | struct ipoib_dev_priv *priv = ipoib_priv(p->dev); |
1130 | unsigned int noio_flag; | ||
1134 | int ret; | 1131 | int ret; |
1135 | 1132 | ||
1136 | p->tx_ring = __vmalloc(ipoib_sendq_size * sizeof *p->tx_ring, | 1133 | noio_flag = memalloc_noio_save(); |
1137 | GFP_NOIO, PAGE_KERNEL); | 1134 | p->tx_ring = vzalloc(ipoib_sendq_size * sizeof(*p->tx_ring)); |
1138 | if (!p->tx_ring) { | 1135 | if (!p->tx_ring) { |
1139 | ret = -ENOMEM; | 1136 | ret = -ENOMEM; |
1140 | goto err_tx; | 1137 | goto err_tx; |
@@ -1142,9 +1139,10 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | |||
1142 | memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); | 1139 | memset(p->tx_ring, 0, ipoib_sendq_size * sizeof *p->tx_ring); |
1143 | 1140 | ||
1144 | p->qp = ipoib_cm_create_tx_qp(p->dev, p); | 1141 | p->qp = ipoib_cm_create_tx_qp(p->dev, p); |
1142 | memalloc_noio_restore(noio_flag); | ||
1145 | if (IS_ERR(p->qp)) { | 1143 | if (IS_ERR(p->qp)) { |
1146 | ret = PTR_ERR(p->qp); | 1144 | ret = PTR_ERR(p->qp); |
1147 | ipoib_warn(priv, "failed to allocate tx qp: %d\n", ret); | 1145 | ipoib_warn(priv, "failed to create tx qp: %d\n", ret); |
1148 | goto err_qp; | 1146 | goto err_qp; |
1149 | } | 1147 | } |
1150 | 1148 | ||
@@ -1206,7 +1204,7 @@ static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p) | |||
1206 | goto timeout; | 1204 | goto timeout; |
1207 | } | 1205 | } |
1208 | 1206 | ||
1209 | msleep(1); | 1207 | usleep_range(1000, 2000); |
1210 | } | 1208 | } |
1211 | } | 1209 | } |
1212 | 1210 | ||
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c index efe7402f4885..57a9655e844d 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c | |||
@@ -770,7 +770,7 @@ int ipoib_ib_dev_stop_default(struct net_device *dev) | |||
770 | 770 | ||
771 | ipoib_drain_cq(dev); | 771 | ipoib_drain_cq(dev); |
772 | 772 | ||
773 | msleep(1); | 773 | usleep_range(1000, 2000); |
774 | } | 774 | } |
775 | 775 | ||
776 | ipoib_dbg(priv, "All sends and receives done.\n"); | 776 | ipoib_dbg(priv, "All sends and receives done.\n"); |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 6e86eeee370e..70dacaf9044e 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -233,6 +233,7 @@ static netdev_features_t ipoib_fix_features(struct net_device *dev, netdev_featu | |||
233 | static int ipoib_change_mtu(struct net_device *dev, int new_mtu) | 233 | static int ipoib_change_mtu(struct net_device *dev, int new_mtu) |
234 | { | 234 | { |
235 | struct ipoib_dev_priv *priv = ipoib_priv(dev); | 235 | struct ipoib_dev_priv *priv = ipoib_priv(dev); |
236 | int ret = 0; | ||
236 | 237 | ||
237 | /* dev->mtu > 2K ==> connected mode */ | 238 | /* dev->mtu > 2K ==> connected mode */ |
238 | if (ipoib_cm_admin_enabled(dev)) { | 239 | if (ipoib_cm_admin_enabled(dev)) { |
@@ -256,9 +257,34 @@ static int ipoib_change_mtu(struct net_device *dev, int new_mtu) | |||
256 | ipoib_dbg(priv, "MTU must be smaller than the underlying " | 257 | ipoib_dbg(priv, "MTU must be smaller than the underlying " |
257 | "link layer MTU - 4 (%u)\n", priv->mcast_mtu); | 258 | "link layer MTU - 4 (%u)\n", priv->mcast_mtu); |
258 | 259 | ||
259 | dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); | 260 | new_mtu = min(priv->mcast_mtu, priv->admin_mtu); |
260 | 261 | ||
261 | return 0; | 262 | if (priv->rn_ops->ndo_change_mtu) { |
263 | bool carrier_status = netif_carrier_ok(dev); | ||
264 | |||
265 | netif_carrier_off(dev); | ||
266 | |||
267 | /* notify lower level on the real mtu */ | ||
268 | ret = priv->rn_ops->ndo_change_mtu(dev, new_mtu); | ||
269 | |||
270 | if (carrier_status) | ||
271 | netif_carrier_on(dev); | ||
272 | } else { | ||
273 | dev->mtu = new_mtu; | ||
274 | } | ||
275 | |||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | static void ipoib_get_stats(struct net_device *dev, | ||
280 | struct rtnl_link_stats64 *stats) | ||
281 | { | ||
282 | struct ipoib_dev_priv *priv = ipoib_priv(dev); | ||
283 | |||
284 | if (priv->rn_ops->ndo_get_stats64) | ||
285 | priv->rn_ops->ndo_get_stats64(dev, stats); | ||
286 | else | ||
287 | netdev_stats_to_stats64(stats, &dev->stats); | ||
262 | } | 288 | } |
263 | 289 | ||
264 | /* Called with an RCU read lock taken */ | 290 | /* Called with an RCU read lock taken */ |
@@ -1808,6 +1834,7 @@ static const struct net_device_ops ipoib_netdev_ops_pf = { | |||
1808 | .ndo_get_vf_stats = ipoib_get_vf_stats, | 1834 | .ndo_get_vf_stats = ipoib_get_vf_stats, |
1809 | .ndo_set_vf_guid = ipoib_set_vf_guid, | 1835 | .ndo_set_vf_guid = ipoib_set_vf_guid, |
1810 | .ndo_set_mac_address = ipoib_set_mac, | 1836 | .ndo_set_mac_address = ipoib_set_mac, |
1837 | .ndo_get_stats64 = ipoib_get_stats, | ||
1811 | }; | 1838 | }; |
1812 | 1839 | ||
1813 | static const struct net_device_ops ipoib_netdev_ops_vf = { | 1840 | static const struct net_device_ops ipoib_netdev_ops_vf = { |
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c index 5a887efb4bdf..37b33d708c2d 100644 --- a/drivers/infiniband/ulp/iser/iscsi_iser.c +++ b/drivers/infiniband/ulp/iser/iscsi_iser.c | |||
@@ -83,6 +83,7 @@ static struct scsi_host_template iscsi_iser_sht; | |||
83 | static struct iscsi_transport iscsi_iser_transport; | 83 | static struct iscsi_transport iscsi_iser_transport; |
84 | static struct scsi_transport_template *iscsi_iser_scsi_transport; | 84 | static struct scsi_transport_template *iscsi_iser_scsi_transport; |
85 | static struct workqueue_struct *release_wq; | 85 | static struct workqueue_struct *release_wq; |
86 | static DEFINE_MUTEX(unbind_iser_conn_mutex); | ||
86 | struct iser_global ig; | 87 | struct iser_global ig; |
87 | 88 | ||
88 | int iser_debug_level = 0; | 89 | int iser_debug_level = 0; |
@@ -550,12 +551,14 @@ iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag) | |||
550 | */ | 551 | */ |
551 | if (iser_conn) { | 552 | if (iser_conn) { |
552 | mutex_lock(&iser_conn->state_mutex); | 553 | mutex_lock(&iser_conn->state_mutex); |
554 | mutex_lock(&unbind_iser_conn_mutex); | ||
553 | iser_conn_terminate(iser_conn); | 555 | iser_conn_terminate(iser_conn); |
554 | iscsi_conn_stop(cls_conn, flag); | 556 | iscsi_conn_stop(cls_conn, flag); |
555 | 557 | ||
556 | /* unbind */ | 558 | /* unbind */ |
557 | iser_conn->iscsi_conn = NULL; | 559 | iser_conn->iscsi_conn = NULL; |
558 | conn->dd_data = NULL; | 560 | conn->dd_data = NULL; |
561 | mutex_unlock(&unbind_iser_conn_mutex); | ||
559 | 562 | ||
560 | complete(&iser_conn->stop_completion); | 563 | complete(&iser_conn->stop_completion); |
561 | mutex_unlock(&iser_conn->state_mutex); | 564 | mutex_unlock(&iser_conn->state_mutex); |
@@ -977,13 +980,21 @@ static int iscsi_iser_slave_alloc(struct scsi_device *sdev) | |||
977 | struct iser_conn *iser_conn; | 980 | struct iser_conn *iser_conn; |
978 | struct ib_device *ib_dev; | 981 | struct ib_device *ib_dev; |
979 | 982 | ||
983 | mutex_lock(&unbind_iser_conn_mutex); | ||
984 | |||
980 | session = starget_to_session(scsi_target(sdev))->dd_data; | 985 | session = starget_to_session(scsi_target(sdev))->dd_data; |
981 | iser_conn = session->leadconn->dd_data; | 986 | iser_conn = session->leadconn->dd_data; |
987 | if (!iser_conn) { | ||
988 | mutex_unlock(&unbind_iser_conn_mutex); | ||
989 | return -ENOTCONN; | ||
990 | } | ||
982 | ib_dev = iser_conn->ib_conn.device->ib_device; | 991 | ib_dev = iser_conn->ib_conn.device->ib_device; |
983 | 992 | ||
984 | if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)) | 993 | if (!(ib_dev->attrs.device_cap_flags & IB_DEVICE_SG_GAPS_REG)) |
985 | blk_queue_virt_boundary(sdev->request_queue, ~MASK_4K); | 994 | blk_queue_virt_boundary(sdev->request_queue, ~MASK_4K); |
986 | 995 | ||
996 | mutex_unlock(&unbind_iser_conn_mutex); | ||
997 | |||
987 | return 0; | 998 | return 0; |
988 | } | 999 | } |
989 | 1000 | ||
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c index c538a38c91ce..26a004e97ae0 100644 --- a/drivers/infiniband/ulp/iser/iser_verbs.c +++ b/drivers/infiniband/ulp/iser/iser_verbs.c | |||
@@ -708,8 +708,14 @@ iser_calc_scsi_params(struct iser_conn *iser_conn, | |||
708 | unsigned short sg_tablesize, sup_sg_tablesize; | 708 | unsigned short sg_tablesize, sup_sg_tablesize; |
709 | 709 | ||
710 | sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K); | 710 | sg_tablesize = DIV_ROUND_UP(max_sectors * 512, SIZE_4K); |
711 | sup_sg_tablesize = min_t(unsigned, ISCSI_ISER_MAX_SG_TABLESIZE, | 711 | if (device->ib_device->attrs.device_cap_flags & |
712 | device->ib_device->attrs.max_fast_reg_page_list_len); | 712 | IB_DEVICE_MEM_MGT_EXTENSIONS) |
713 | sup_sg_tablesize = | ||
714 | min_t( | ||
715 | uint, ISCSI_ISER_MAX_SG_TABLESIZE, | ||
716 | device->ib_device->attrs.max_fast_reg_page_list_len); | ||
717 | else | ||
718 | sup_sg_tablesize = ISCSI_ISER_MAX_SG_TABLESIZE; | ||
713 | 719 | ||
714 | iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize); | 720 | iser_conn->scsi_sg_tablesize = min(sg_tablesize, sup_sg_tablesize); |
715 | } | 721 | } |
diff --git a/drivers/irqchip/irq-digicolor.c b/drivers/irqchip/irq-digicolor.c index dad85e74c37c..3aae015469a5 100644 --- a/drivers/irqchip/irq-digicolor.c +++ b/drivers/irqchip/irq-digicolor.c | |||
@@ -71,7 +71,7 @@ static void __init digicolor_set_gc(void __iomem *reg_base, unsigned irq_base, | |||
71 | static int __init digicolor_of_init(struct device_node *node, | 71 | static int __init digicolor_of_init(struct device_node *node, |
72 | struct device_node *parent) | 72 | struct device_node *parent) |
73 | { | 73 | { |
74 | static void __iomem *reg_base; | 74 | void __iomem *reg_base; |
75 | unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; | 75 | unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN; |
76 | struct regmap *ucregs; | 76 | struct regmap *ucregs; |
77 | int ret; | 77 | int ret; |
diff --git a/drivers/irqchip/irq-gic-realview.c b/drivers/irqchip/irq-gic-realview.c index 54c296401525..18d58d2b4ffe 100644 --- a/drivers/irqchip/irq-gic-realview.c +++ b/drivers/irqchip/irq-gic-realview.c | |||
@@ -43,7 +43,7 @@ static const struct of_device_id syscon_pldset_of_match[] = { | |||
43 | static int __init | 43 | static int __init |
44 | realview_gic_of_init(struct device_node *node, struct device_node *parent) | 44 | realview_gic_of_init(struct device_node *node, struct device_node *parent) |
45 | { | 45 | { |
46 | static struct regmap *map; | 46 | struct regmap *map; |
47 | struct device_node *np; | 47 | struct device_node *np; |
48 | const struct of_device_id *gic_id; | 48 | const struct of_device_id *gic_id; |
49 | u32 pld1_ctrl; | 49 | u32 pld1_ctrl; |
diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c index 0a8ed1c05518..14461cbfab2f 100644 --- a/drivers/irqchip/irq-mips-cpu.c +++ b/drivers/irqchip/irq-mips-cpu.c | |||
@@ -154,7 +154,7 @@ asmlinkage void __weak plat_irq_dispatch(void) | |||
154 | static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq, | 154 | static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq, |
155 | irq_hw_number_t hw) | 155 | irq_hw_number_t hw) |
156 | { | 156 | { |
157 | static struct irq_chip *chip; | 157 | struct irq_chip *chip; |
158 | 158 | ||
159 | if (hw < 2 && cpu_has_mipsmt) { | 159 | if (hw < 2 && cpu_has_mipsmt) { |
160 | /* Software interrupts are used for MT/CMT IPI */ | 160 | /* Software interrupts are used for MT/CMT IPI */ |
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 832ebf4062f7..6ab1d3afec02 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
@@ -950,7 +950,6 @@ static void __init __gic_init(unsigned long gic_base_addr, | |||
950 | &gic_irq_domain_ops, NULL); | 950 | &gic_irq_domain_ops, NULL); |
951 | if (!gic_irq_domain) | 951 | if (!gic_irq_domain) |
952 | panic("Failed to add GIC IRQ domain"); | 952 | panic("Failed to add GIC IRQ domain"); |
953 | gic_irq_domain->name = "mips-gic-irq"; | ||
954 | 953 | ||
955 | gic_ipi_domain = irq_domain_add_hierarchy(gic_irq_domain, | 954 | gic_ipi_domain = irq_domain_add_hierarchy(gic_irq_domain, |
956 | IRQ_DOMAIN_FLAG_IPI_PER_CPU, | 955 | IRQ_DOMAIN_FLAG_IPI_PER_CPU, |
@@ -959,7 +958,6 @@ static void __init __gic_init(unsigned long gic_base_addr, | |||
959 | if (!gic_ipi_domain) | 958 | if (!gic_ipi_domain) |
960 | panic("Failed to add GIC IPI domain"); | 959 | panic("Failed to add GIC IPI domain"); |
961 | 960 | ||
962 | gic_ipi_domain->name = "mips-gic-ipi"; | ||
963 | irq_domain_update_bus_token(gic_ipi_domain, DOMAIN_BUS_IPI); | 961 | irq_domain_update_bus_token(gic_ipi_domain, DOMAIN_BUS_IPI); |
964 | 962 | ||
965 | if (node && | 963 | if (node && |
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c index 060d357f107f..6f423bc49d0d 100644 --- a/drivers/isdn/divert/isdn_divert.c +++ b/drivers/isdn/divert/isdn_divert.c | |||
@@ -485,18 +485,19 @@ static int isdn_divert_icall(isdn_ctrl *ic) | |||
485 | cs->deflect_dest[0] = '\0'; | 485 | cs->deflect_dest[0] = '\0'; |
486 | retval = 4; /* only proceed */ | 486 | retval = 4; /* only proceed */ |
487 | } | 487 | } |
488 | sprintf(cs->info, "%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n", | 488 | snprintf(cs->info, sizeof(cs->info), |
489 | cs->akt_state, | 489 | "%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n", |
490 | cs->divert_id, | 490 | cs->akt_state, |
491 | divert_if.drv_to_name(cs->ics.driver), | 491 | cs->divert_id, |
492 | (ic->command == ISDN_STAT_ICALLW) ? "1" : "0", | 492 | divert_if.drv_to_name(cs->ics.driver), |
493 | cs->ics.parm.setup.phone, | 493 | (ic->command == ISDN_STAT_ICALLW) ? "1" : "0", |
494 | cs->ics.parm.setup.eazmsn, | 494 | cs->ics.parm.setup.phone, |
495 | cs->ics.parm.setup.si1, | 495 | cs->ics.parm.setup.eazmsn, |
496 | cs->ics.parm.setup.si2, | 496 | cs->ics.parm.setup.si1, |
497 | cs->ics.parm.setup.screen, | 497 | cs->ics.parm.setup.si2, |
498 | dv->rule.waittime, | 498 | cs->ics.parm.setup.screen, |
499 | cs->deflect_dest); | 499 | dv->rule.waittime, |
500 | cs->deflect_dest); | ||
500 | if ((dv->rule.action == DEFLECT_REPORT) || | 501 | if ((dv->rule.action == DEFLECT_REPORT) || |
501 | (dv->rule.action == DEFLECT_REJECT)) { | 502 | (dv->rule.action == DEFLECT_REJECT)) { |
502 | put_info_buffer(cs->info); | 503 | put_info_buffer(cs->info); |
diff --git a/drivers/isdn/hardware/avm/c4.c b/drivers/isdn/hardware/avm/c4.c index 40c7e2cf423b..034cabac699d 100644 --- a/drivers/isdn/hardware/avm/c4.c +++ b/drivers/isdn/hardware/avm/c4.c | |||
@@ -42,7 +42,7 @@ static char *revision = "$Revision: 1.1.2.2 $"; | |||
42 | 42 | ||
43 | static bool suppress_pollack; | 43 | static bool suppress_pollack; |
44 | 44 | ||
45 | static struct pci_device_id c4_pci_tbl[] = { | 45 | static const struct pci_device_id c4_pci_tbl[] = { |
46 | { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C4, 0, 0, (unsigned long)4 }, | 46 | { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C4, 0, 0, (unsigned long)4 }, |
47 | { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C2, 0, 0, (unsigned long)2 }, | 47 | { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_21285, PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_C2, 0, 0, (unsigned long)2 }, |
48 | { } /* Terminating entry */ | 48 | { } /* Terminating entry */ |
diff --git a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c index 8b7ad4f1ab01..b2023e08dcd2 100644 --- a/drivers/isdn/hardware/eicon/divasmain.c +++ b/drivers/isdn/hardware/eicon/divasmain.c | |||
@@ -110,7 +110,7 @@ typedef struct _diva_os_thread_dpc { | |||
110 | /* | 110 | /* |
111 | This table should be sorted by PCI device ID | 111 | This table should be sorted by PCI device ID |
112 | */ | 112 | */ |
113 | static struct pci_device_id divas_pci_tbl[] = { | 113 | static const struct pci_device_id divas_pci_tbl[] = { |
114 | /* Diva Server BRI-2M PCI 0xE010 */ | 114 | /* Diva Server BRI-2M PCI 0xE010 */ |
115 | { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRA), | 115 | { PCI_VDEVICE(EICON, PCI_DEVICE_ID_EICON_MAESTRA), |
116 | CARDTYPE_MAESTRA_PCI }, | 116 | CARDTYPE_MAESTRA_PCI }, |
diff --git a/drivers/isdn/hardware/mISDN/avmfritz.c b/drivers/isdn/hardware/mISDN/avmfritz.c index e3fa1cd64470..dce6632daae1 100644 --- a/drivers/isdn/hardware/mISDN/avmfritz.c +++ b/drivers/isdn/hardware/mISDN/avmfritz.c | |||
@@ -1142,7 +1142,7 @@ fritz_remove_pci(struct pci_dev *pdev) | |||
1142 | pr_info("%s: drvdata already removed\n", __func__); | 1142 | pr_info("%s: drvdata already removed\n", __func__); |
1143 | } | 1143 | } |
1144 | 1144 | ||
1145 | static struct pci_device_id fcpci_ids[] = { | 1145 | static const struct pci_device_id fcpci_ids[] = { |
1146 | { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID, | 1146 | { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, PCI_ANY_ID, PCI_ANY_ID, |
1147 | 0, 0, (unsigned long) "Fritz!Card PCI"}, | 1147 | 0, 0, (unsigned long) "Fritz!Card PCI"}, |
1148 | { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1_V2, PCI_ANY_ID, PCI_ANY_ID, | 1148 | { PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1_V2, PCI_ANY_ID, PCI_ANY_ID, |
diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c index aea0c9616ea5..3cf07b8ced1c 100644 --- a/drivers/isdn/hardware/mISDN/hfcmulti.c +++ b/drivers/isdn/hardware/mISDN/hfcmulti.c | |||
@@ -5348,7 +5348,7 @@ static const struct hm_map hfcm_map[] = { | |||
5348 | 5348 | ||
5349 | #undef H | 5349 | #undef H |
5350 | #define H(x) ((unsigned long)&hfcm_map[x]) | 5350 | #define H(x) ((unsigned long)&hfcm_map[x]) |
5351 | static struct pci_device_id hfmultipci_ids[] = { | 5351 | static const struct pci_device_id hfmultipci_ids[] = { |
5352 | 5352 | ||
5353 | /* Cards with HFC-4S Chip */ | 5353 | /* Cards with HFC-4S Chip */ |
5354 | { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, | 5354 | { PCI_VENDOR_ID_CCD, PCI_DEVICE_ID_CCD_HFC4S, PCI_VENDOR_ID_CCD, |
diff --git a/drivers/isdn/hardware/mISDN/hfcpci.c b/drivers/isdn/hardware/mISDN/hfcpci.c index 5dc246d71c16..d2e401a8090e 100644 --- a/drivers/isdn/hardware/mISDN/hfcpci.c +++ b/drivers/isdn/hardware/mISDN/hfcpci.c | |||
@@ -2161,7 +2161,7 @@ static const struct _hfc_map hfc_map[] = | |||
2161 | {}, | 2161 | {}, |
2162 | }; | 2162 | }; |
2163 | 2163 | ||
2164 | static struct pci_device_id hfc_ids[] = | 2164 | static const struct pci_device_id hfc_ids[] = |
2165 | { | 2165 | { |
2166 | { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_2BD0), | 2166 | { PCI_VDEVICE(CCD, PCI_DEVICE_ID_CCD_2BD0), |
2167 | (unsigned long) &hfc_map[0] }, | 2167 | (unsigned long) &hfc_map[0] }, |
diff --git a/drivers/isdn/hardware/mISDN/netjet.c b/drivers/isdn/hardware/mISDN/netjet.c index afde4edef9ae..6a6d848bd18e 100644 --- a/drivers/isdn/hardware/mISDN/netjet.c +++ b/drivers/isdn/hardware/mISDN/netjet.c | |||
@@ -1137,7 +1137,7 @@ static void nj_remove(struct pci_dev *pdev) | |||
1137 | /* We cannot select cards with PCI_SUB... IDs, since here are cards with | 1137 | /* We cannot select cards with PCI_SUB... IDs, since here are cards with |
1138 | * SUB IDs set to PCI_ANY_ID, so we need to match all and reject | 1138 | * SUB IDs set to PCI_ANY_ID, so we need to match all and reject |
1139 | * known other cards which not work with this driver - see probe function */ | 1139 | * known other cards which not work with this driver - see probe function */ |
1140 | static struct pci_device_id nj_pci_ids[] = { | 1140 | static const struct pci_device_id nj_pci_ids[] = { |
1141 | { PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, | 1141 | { PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, |
1142 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 1142 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
1143 | { } | 1143 | { } |
diff --git a/drivers/isdn/hardware/mISDN/w6692.c b/drivers/isdn/hardware/mISDN/w6692.c index 3052c836b89f..d80072fef434 100644 --- a/drivers/isdn/hardware/mISDN/w6692.c +++ b/drivers/isdn/hardware/mISDN/w6692.c | |||
@@ -1398,7 +1398,7 @@ w6692_remove_pci(struct pci_dev *pdev) | |||
1398 | pr_notice("%s: drvdata already removed\n", __func__); | 1398 | pr_notice("%s: drvdata already removed\n", __func__); |
1399 | } | 1399 | } |
1400 | 1400 | ||
1401 | static struct pci_device_id w6692_ids[] = { | 1401 | static const struct pci_device_id w6692_ids[] = { |
1402 | { PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, | 1402 | { PCI_VENDOR_ID_DYNALINK, PCI_DEVICE_ID_DYNALINK_IS64PH, |
1403 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, (ulong)&w6692_map[0]}, | 1403 | PCI_ANY_ID, PCI_ANY_ID, 0, 0, (ulong)&w6692_map[0]}, |
1404 | { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, | 1404 | { PCI_VENDOR_ID_WINBOND2, PCI_DEVICE_ID_WINBOND2_6692, |
diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index c7d68675b028..7108bdb8742e 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c | |||
@@ -1909,7 +1909,7 @@ static void EChannel_proc_rcv(struct hisax_d_if *d_if) | |||
1909 | #ifdef CONFIG_PCI | 1909 | #ifdef CONFIG_PCI |
1910 | #include <linux/pci.h> | 1910 | #include <linux/pci.h> |
1911 | 1911 | ||
1912 | static struct pci_device_id hisax_pci_tbl[] __used = { | 1912 | static const struct pci_device_id hisax_pci_tbl[] __used = { |
1913 | #ifdef CONFIG_HISAX_FRITZPCI | 1913 | #ifdef CONFIG_HISAX_FRITZPCI |
1914 | {PCI_VDEVICE(AVM, PCI_DEVICE_ID_AVM_A1) }, | 1914 | {PCI_VDEVICE(AVM, PCI_DEVICE_ID_AVM_A1) }, |
1915 | #endif | 1915 | #endif |
diff --git a/drivers/isdn/hisax/hfc4s8s_l1.c b/drivers/isdn/hisax/hfc4s8s_l1.c index 90f051ce0259..9090cc1e1f29 100644 --- a/drivers/isdn/hisax/hfc4s8s_l1.c +++ b/drivers/isdn/hisax/hfc4s8s_l1.c | |||
@@ -86,7 +86,7 @@ typedef struct { | |||
86 | char *device_name; | 86 | char *device_name; |
87 | } hfc4s8s_param; | 87 | } hfc4s8s_param; |
88 | 88 | ||
89 | static struct pci_device_id hfc4s8s_ids[] = { | 89 | static const struct pci_device_id hfc4s8s_ids[] = { |
90 | {.vendor = PCI_VENDOR_ID_CCD, | 90 | {.vendor = PCI_VENDOR_ID_CCD, |
91 | .device = PCI_DEVICE_ID_4S, | 91 | .device = PCI_DEVICE_ID_4S, |
92 | .subvendor = 0x1397, | 92 | .subvendor = 0x1397, |
diff --git a/drivers/isdn/hisax/hisax_fcpcipnp.c b/drivers/isdn/hisax/hisax_fcpcipnp.c index 5a9f39ed1d5d..e4f7573ba9bf 100644 --- a/drivers/isdn/hisax/hisax_fcpcipnp.c +++ b/drivers/isdn/hisax/hisax_fcpcipnp.c | |||
@@ -52,7 +52,7 @@ module_param(debug, int, 0); | |||
52 | MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>"); | 52 | MODULE_AUTHOR("Kai Germaschewski <kai.germaschewski@gmx.de>/Karsten Keil <kkeil@suse.de>"); |
53 | MODULE_DESCRIPTION("AVM Fritz!PCI/PnP ISDN driver"); | 53 | MODULE_DESCRIPTION("AVM Fritz!PCI/PnP ISDN driver"); |
54 | 54 | ||
55 | static struct pci_device_id fcpci_ids[] = { | 55 | static const struct pci_device_id fcpci_ids[] = { |
56 | { .vendor = PCI_VENDOR_ID_AVM, | 56 | { .vendor = PCI_VENDOR_ID_AVM, |
57 | .device = PCI_DEVICE_ID_AVM_A1, | 57 | .device = PCI_DEVICE_ID_AVM_A1, |
58 | .subvendor = PCI_ANY_ID, | 58 | .subvendor = PCI_ANY_ID, |
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index f4eace5ea184..40f3cd7eab0f 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -156,7 +156,8 @@ static int read_sb_page(struct mddev *mddev, loff_t offset, | |||
156 | 156 | ||
157 | rdev_for_each(rdev, mddev) { | 157 | rdev_for_each(rdev, mddev) { |
158 | if (! test_bit(In_sync, &rdev->flags) | 158 | if (! test_bit(In_sync, &rdev->flags) |
159 | || test_bit(Faulty, &rdev->flags)) | 159 | || test_bit(Faulty, &rdev->flags) |
160 | || test_bit(Bitmap_sync, &rdev->flags)) | ||
160 | continue; | 161 | continue; |
161 | 162 | ||
162 | target = offset + index * (PAGE_SIZE/512); | 163 | target = offset + index * (PAGE_SIZE/512); |
diff --git a/drivers/md/md.h b/drivers/md/md.h index 991f0fe2dcc6..b50eb4ac1b82 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h | |||
@@ -134,7 +134,9 @@ enum flag_bits { | |||
134 | Faulty, /* device is known to have a fault */ | 134 | Faulty, /* device is known to have a fault */ |
135 | In_sync, /* device is in_sync with rest of array */ | 135 | In_sync, /* device is in_sync with rest of array */ |
136 | Bitmap_sync, /* ..actually, not quite In_sync. Need a | 136 | Bitmap_sync, /* ..actually, not quite In_sync. Need a |
137 | * bitmap-based recovery to get fully in sync | 137 | * bitmap-based recovery to get fully in sync. |
138 | * The bit is only meaningful before device | ||
139 | * has been passed to pers->hot_add_disk. | ||
138 | */ | 140 | */ |
139 | WriteMostly, /* Avoid reading if at all possible */ | 141 | WriteMostly, /* Avoid reading if at all possible */ |
140 | AutoDetected, /* added by auto-detect */ | 142 | AutoDetected, /* added by auto-detect */ |
diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c index 77cce3573aa8..44ad5baf3206 100644 --- a/drivers/md/raid5-ppl.c +++ b/drivers/md/raid5-ppl.c | |||
@@ -1150,7 +1150,7 @@ int ppl_init_log(struct r5conf *conf) | |||
1150 | goto err; | 1150 | goto err; |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | ppl_conf->bs = bioset_create(conf->raid_disks, 0, 0); | 1153 | ppl_conf->bs = bioset_create(conf->raid_disks, 0, BIOSET_NEED_BVECS); |
1154 | if (!ppl_conf->bs) { | 1154 | if (!ppl_conf->bs) { |
1155 | ret = -ENOMEM; | 1155 | ret = -ENOMEM; |
1156 | goto err; | 1156 | goto err; |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 2ceb338b094b..aeeb8d6854e2 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -7951,12 +7951,10 @@ static void end_reshape(struct r5conf *conf) | |||
7951 | { | 7951 | { |
7952 | 7952 | ||
7953 | if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { | 7953 | if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) { |
7954 | struct md_rdev *rdev; | ||
7955 | 7954 | ||
7956 | spin_lock_irq(&conf->device_lock); | 7955 | spin_lock_irq(&conf->device_lock); |
7957 | conf->previous_raid_disks = conf->raid_disks; | 7956 | conf->previous_raid_disks = conf->raid_disks; |
7958 | rdev_for_each(rdev, conf->mddev) | 7957 | md_finish_reshape(conf->mddev); |
7959 | rdev->data_offset = rdev->new_data_offset; | ||
7960 | smp_wmb(); | 7958 | smp_wmb(); |
7961 | conf->reshape_progress = MaxSector; | 7959 | conf->reshape_progress = MaxSector; |
7962 | conf->mddev->reshape_position = MaxSector; | 7960 | conf->mddev->reshape_position = MaxSector; |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 14ff622190a5..181839d6fbea 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4596,7 +4596,7 @@ static int bond_check_params(struct bond_params *params) | |||
4596 | } | 4596 | } |
4597 | ad_user_port_key = valptr->value; | 4597 | ad_user_port_key = valptr->value; |
4598 | 4598 | ||
4599 | if (bond_mode == BOND_MODE_TLB) { | 4599 | if ((bond_mode == BOND_MODE_TLB) || (bond_mode == BOND_MODE_ALB)) { |
4600 | bond_opt_initstr(&newval, "default"); | 4600 | bond_opt_initstr(&newval, "default"); |
4601 | valptr = bond_opt_parse(bond_opt_get(BOND_OPT_TLB_DYNAMIC_LB), | 4601 | valptr = bond_opt_parse(bond_opt_get(BOND_OPT_TLB_DYNAMIC_LB), |
4602 | &newval); | 4602 | &newval); |
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index e68d368e20ac..7f36d3e3c98b 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c | |||
@@ -1665,6 +1665,7 @@ static const struct b53_chip_data b53_switch_chips[] = { | |||
1665 | .dev_name = "BCM53125", | 1665 | .dev_name = "BCM53125", |
1666 | .vlans = 4096, | 1666 | .vlans = 4096, |
1667 | .enabled_ports = 0xff, | 1667 | .enabled_ports = 0xff, |
1668 | .arl_entries = 4, | ||
1668 | .cpu_port = B53_CPU_PORT, | 1669 | .cpu_port = B53_CPU_PORT, |
1669 | .vta_regs = B53_VTA_REGS, | 1670 | .vta_regs = B53_VTA_REGS, |
1670 | .duplex_reg = B53_DUPLEX_STAT_GE, | 1671 | .duplex_reg = B53_DUPLEX_STAT_GE, |
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index 53b088166c28..5bcdd33101b0 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c | |||
@@ -3178,6 +3178,7 @@ static const struct mv88e6xxx_ops mv88e6390x_ops = { | |||
3178 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, | 3178 | .port_set_jumbo_size = mv88e6165_port_set_jumbo_size, |
3179 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, | 3179 | .port_egress_rate_limiting = mv88e6097_port_egress_rate_limiting, |
3180 | .port_pause_limit = mv88e6390_port_pause_limit, | 3180 | .port_pause_limit = mv88e6390_port_pause_limit, |
3181 | .port_set_cmode = mv88e6390x_port_set_cmode, | ||
3181 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, | 3182 | .port_disable_learn_limit = mv88e6xxx_port_disable_learn_limit, |
3182 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, | 3183 | .port_disable_pri_override = mv88e6xxx_port_disable_pri_override, |
3183 | .stats_snapshot = mv88e6390_g1_stats_snapshot, | 3184 | .stats_snapshot = mv88e6390_g1_stats_snapshot, |
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index d3906f6b01bd..86058a9f3417 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c | |||
@@ -1785,16 +1785,18 @@ static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata) | |||
1785 | 1785 | ||
1786 | xgene_enet_gpiod_get(pdata); | 1786 | xgene_enet_gpiod_get(pdata); |
1787 | 1787 | ||
1788 | pdata->clk = devm_clk_get(&pdev->dev, NULL); | 1788 | if (pdata->phy_mode != PHY_INTERFACE_MODE_SGMII) { |
1789 | if (IS_ERR(pdata->clk)) { | 1789 | pdata->clk = devm_clk_get(&pdev->dev, NULL); |
1790 | /* Abort if the clock is defined but couldn't be retrived. | 1790 | if (IS_ERR(pdata->clk)) { |
1791 | * Always abort if the clock is missing on DT system as | 1791 | /* Abort if the clock is defined but couldn't be |
1792 | * the driver can't cope with this case. | 1792 | * retrived. Always abort if the clock is missing on |
1793 | */ | 1793 | * DT system as the driver can't cope with this case. |
1794 | if (PTR_ERR(pdata->clk) != -ENOENT || dev->of_node) | 1794 | */ |
1795 | return PTR_ERR(pdata->clk); | 1795 | if (PTR_ERR(pdata->clk) != -ENOENT || dev->of_node) |
1796 | /* Firmware may have set up the clock already. */ | 1796 | return PTR_ERR(pdata->clk); |
1797 | dev_info(dev, "clocks have been setup already\n"); | 1797 | /* Firmware may have set up the clock already. */ |
1798 | dev_info(dev, "clocks have been setup already\n"); | ||
1799 | } | ||
1798 | } | 1800 | } |
1799 | 1801 | ||
1800 | if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) | 1802 | if (pdata->phy_mode != PHY_INTERFACE_MODE_XGMII) |
diff --git a/drivers/net/ethernet/broadcom/bgmac-platform.c b/drivers/net/ethernet/broadcom/bgmac-platform.c index 73aca97a96bc..d937083db9a4 100644 --- a/drivers/net/ethernet/broadcom/bgmac-platform.c +++ b/drivers/net/ethernet/broadcom/bgmac-platform.c | |||
@@ -50,11 +50,14 @@ static u32 platform_bgmac_idm_read(struct bgmac *bgmac, u16 offset) | |||
50 | 50 | ||
51 | static void platform_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value) | 51 | static void platform_bgmac_idm_write(struct bgmac *bgmac, u16 offset, u32 value) |
52 | { | 52 | { |
53 | return writel(value, bgmac->plat.idm_base + offset); | 53 | writel(value, bgmac->plat.idm_base + offset); |
54 | } | 54 | } |
55 | 55 | ||
56 | static bool platform_bgmac_clk_enabled(struct bgmac *bgmac) | 56 | static bool platform_bgmac_clk_enabled(struct bgmac *bgmac) |
57 | { | 57 | { |
58 | if (!bgmac->plat.idm_base) | ||
59 | return true; | ||
60 | |||
58 | if ((bgmac_idm_read(bgmac, BCMA_IOCTL) & BGMAC_CLK_EN) != BGMAC_CLK_EN) | 61 | if ((bgmac_idm_read(bgmac, BCMA_IOCTL) & BGMAC_CLK_EN) != BGMAC_CLK_EN) |
59 | return false; | 62 | return false; |
60 | if (bgmac_idm_read(bgmac, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET) | 63 | if (bgmac_idm_read(bgmac, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET) |
@@ -66,6 +69,9 @@ static void platform_bgmac_clk_enable(struct bgmac *bgmac, u32 flags) | |||
66 | { | 69 | { |
67 | u32 val; | 70 | u32 val; |
68 | 71 | ||
72 | if (!bgmac->plat.idm_base) | ||
73 | return; | ||
74 | |||
69 | /* The Reset Control register only contains a single bit to show if the | 75 | /* The Reset Control register only contains a single bit to show if the |
70 | * controller is currently in reset. Do a sanity check here, just in | 76 | * controller is currently in reset. Do a sanity check here, just in |
71 | * case the bootloader happened to leave the device in reset. | 77 | * case the bootloader happened to leave the device in reset. |
@@ -180,6 +186,7 @@ static int bgmac_probe(struct platform_device *pdev) | |||
180 | bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4; | 186 | bgmac->feature_flags |= BGMAC_FEAT_CMDCFG_SR_REV4; |
181 | bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP; | 187 | bgmac->feature_flags |= BGMAC_FEAT_TX_MASK_SETUP; |
182 | bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP; | 188 | bgmac->feature_flags |= BGMAC_FEAT_RX_MASK_SETUP; |
189 | bgmac->feature_flags |= BGMAC_FEAT_IDM_MASK; | ||
183 | 190 | ||
184 | bgmac->dev = &pdev->dev; | 191 | bgmac->dev = &pdev->dev; |
185 | bgmac->dma_dev = &pdev->dev; | 192 | bgmac->dma_dev = &pdev->dev; |
@@ -207,15 +214,13 @@ static int bgmac_probe(struct platform_device *pdev) | |||
207 | return PTR_ERR(bgmac->plat.base); | 214 | return PTR_ERR(bgmac->plat.base); |
208 | 215 | ||
209 | regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base"); | 216 | regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "idm_base"); |
210 | if (!regs) { | 217 | if (regs) { |
211 | dev_err(&pdev->dev, "Unable to obtain idm resource\n"); | 218 | bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs); |
212 | return -EINVAL; | 219 | if (IS_ERR(bgmac->plat.idm_base)) |
220 | return PTR_ERR(bgmac->plat.idm_base); | ||
221 | bgmac->feature_flags &= ~BGMAC_FEAT_IDM_MASK; | ||
213 | } | 222 | } |
214 | 223 | ||
215 | bgmac->plat.idm_base = devm_ioremap_resource(&pdev->dev, regs); | ||
216 | if (IS_ERR(bgmac->plat.idm_base)) | ||
217 | return PTR_ERR(bgmac->plat.idm_base); | ||
218 | |||
219 | regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base"); | 224 | regs = platform_get_resource_byname(pdev, IORESOURCE_MEM, "nicpm_base"); |
220 | if (regs) { | 225 | if (regs) { |
221 | bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev, | 226 | bgmac->plat.nicpm_base = devm_ioremap_resource(&pdev->dev, |
diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c index ba4d2e145bb9..48d672b204a4 100644 --- a/drivers/net/ethernet/broadcom/bgmac.c +++ b/drivers/net/ethernet/broadcom/bgmac.c | |||
@@ -622,9 +622,11 @@ static int bgmac_dma_alloc(struct bgmac *bgmac) | |||
622 | BUILD_BUG_ON(BGMAC_MAX_TX_RINGS > ARRAY_SIZE(ring_base)); | 622 | BUILD_BUG_ON(BGMAC_MAX_TX_RINGS > ARRAY_SIZE(ring_base)); |
623 | BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base)); | 623 | BUILD_BUG_ON(BGMAC_MAX_RX_RINGS > ARRAY_SIZE(ring_base)); |
624 | 624 | ||
625 | if (!(bgmac_idm_read(bgmac, BCMA_IOST) & BCMA_IOST_DMA64)) { | 625 | if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) { |
626 | dev_err(bgmac->dev, "Core does not report 64-bit DMA\n"); | 626 | if (!(bgmac_idm_read(bgmac, BCMA_IOST) & BCMA_IOST_DMA64)) { |
627 | return -ENOTSUPP; | 627 | dev_err(bgmac->dev, "Core does not report 64-bit DMA\n"); |
628 | return -ENOTSUPP; | ||
629 | } | ||
628 | } | 630 | } |
629 | 631 | ||
630 | for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { | 632 | for (i = 0; i < BGMAC_MAX_TX_RINGS; i++) { |
@@ -855,9 +857,11 @@ static void bgmac_mac_speed(struct bgmac *bgmac) | |||
855 | static void bgmac_miiconfig(struct bgmac *bgmac) | 857 | static void bgmac_miiconfig(struct bgmac *bgmac) |
856 | { | 858 | { |
857 | if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) { | 859 | if (bgmac->feature_flags & BGMAC_FEAT_FORCE_SPEED_2500) { |
858 | bgmac_idm_write(bgmac, BCMA_IOCTL, | 860 | if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) { |
859 | bgmac_idm_read(bgmac, BCMA_IOCTL) | 0x40 | | 861 | bgmac_idm_write(bgmac, BCMA_IOCTL, |
860 | BGMAC_BCMA_IOCTL_SW_CLKEN); | 862 | bgmac_idm_read(bgmac, BCMA_IOCTL) | |
863 | 0x40 | BGMAC_BCMA_IOCTL_SW_CLKEN); | ||
864 | } | ||
861 | bgmac->mac_speed = SPEED_2500; | 865 | bgmac->mac_speed = SPEED_2500; |
862 | bgmac->mac_duplex = DUPLEX_FULL; | 866 | bgmac->mac_duplex = DUPLEX_FULL; |
863 | bgmac_mac_speed(bgmac); | 867 | bgmac_mac_speed(bgmac); |
@@ -874,11 +878,36 @@ static void bgmac_miiconfig(struct bgmac *bgmac) | |||
874 | } | 878 | } |
875 | } | 879 | } |
876 | 880 | ||
881 | static void bgmac_chip_reset_idm_config(struct bgmac *bgmac) | ||
882 | { | ||
883 | u32 iost; | ||
884 | |||
885 | iost = bgmac_idm_read(bgmac, BCMA_IOST); | ||
886 | if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED) | ||
887 | iost &= ~BGMAC_BCMA_IOST_ATTACHED; | ||
888 | |||
889 | /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */ | ||
890 | if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) { | ||
891 | u32 flags = 0; | ||
892 | |||
893 | if (iost & BGMAC_BCMA_IOST_ATTACHED) { | ||
894 | flags = BGMAC_BCMA_IOCTL_SW_CLKEN; | ||
895 | if (!bgmac->has_robosw) | ||
896 | flags |= BGMAC_BCMA_IOCTL_SW_RESET; | ||
897 | } | ||
898 | bgmac_clk_enable(bgmac, flags); | ||
899 | } | ||
900 | |||
901 | if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw) | ||
902 | bgmac_idm_write(bgmac, BCMA_IOCTL, | ||
903 | bgmac_idm_read(bgmac, BCMA_IOCTL) & | ||
904 | ~BGMAC_BCMA_IOCTL_SW_RESET); | ||
905 | } | ||
906 | |||
877 | /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */ | 907 | /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/chipreset */ |
878 | static void bgmac_chip_reset(struct bgmac *bgmac) | 908 | static void bgmac_chip_reset(struct bgmac *bgmac) |
879 | { | 909 | { |
880 | u32 cmdcfg_sr; | 910 | u32 cmdcfg_sr; |
881 | u32 iost; | ||
882 | int i; | 911 | int i; |
883 | 912 | ||
884 | if (bgmac_clk_enabled(bgmac)) { | 913 | if (bgmac_clk_enabled(bgmac)) { |
@@ -899,20 +928,8 @@ static void bgmac_chip_reset(struct bgmac *bgmac) | |||
899 | /* TODO: Clear software multicast filter list */ | 928 | /* TODO: Clear software multicast filter list */ |
900 | } | 929 | } |
901 | 930 | ||
902 | iost = bgmac_idm_read(bgmac, BCMA_IOST); | 931 | if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) |
903 | if (bgmac->feature_flags & BGMAC_FEAT_IOST_ATTACHED) | 932 | bgmac_chip_reset_idm_config(bgmac); |
904 | iost &= ~BGMAC_BCMA_IOST_ATTACHED; | ||
905 | |||
906 | /* 3GMAC: for BCM4707 & BCM47094, only do core reset at bgmac_probe() */ | ||
907 | if (!(bgmac->feature_flags & BGMAC_FEAT_NO_RESET)) { | ||
908 | u32 flags = 0; | ||
909 | if (iost & BGMAC_BCMA_IOST_ATTACHED) { | ||
910 | flags = BGMAC_BCMA_IOCTL_SW_CLKEN; | ||
911 | if (!bgmac->has_robosw) | ||
912 | flags |= BGMAC_BCMA_IOCTL_SW_RESET; | ||
913 | } | ||
914 | bgmac_clk_enable(bgmac, flags); | ||
915 | } | ||
916 | 933 | ||
917 | /* Request Misc PLL for corerev > 2 */ | 934 | /* Request Misc PLL for corerev > 2 */ |
918 | if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) { | 935 | if (bgmac->feature_flags & BGMAC_FEAT_MISC_PLL_REQ) { |
@@ -970,11 +987,6 @@ static void bgmac_chip_reset(struct bgmac *bgmac) | |||
970 | BGMAC_CHIPCTL_7_IF_TYPE_RGMII); | 987 | BGMAC_CHIPCTL_7_IF_TYPE_RGMII); |
971 | } | 988 | } |
972 | 989 | ||
973 | if (iost & BGMAC_BCMA_IOST_ATTACHED && !bgmac->has_robosw) | ||
974 | bgmac_idm_write(bgmac, BCMA_IOCTL, | ||
975 | bgmac_idm_read(bgmac, BCMA_IOCTL) & | ||
976 | ~BGMAC_BCMA_IOCTL_SW_RESET); | ||
977 | |||
978 | /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_reset | 990 | /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_reset |
979 | * Specs don't say about using BGMAC_CMDCFG_SR, but in this routine | 991 | * Specs don't say about using BGMAC_CMDCFG_SR, but in this routine |
980 | * BGMAC_CMDCFG is read _after_ putting chip in a reset. So it has to | 992 | * BGMAC_CMDCFG is read _after_ putting chip in a reset. So it has to |
@@ -1497,8 +1509,10 @@ int bgmac_enet_probe(struct bgmac *bgmac) | |||
1497 | bgmac_clk_enable(bgmac, 0); | 1509 | bgmac_clk_enable(bgmac, 0); |
1498 | 1510 | ||
1499 | /* This seems to be fixing IRQ by assigning OOB #6 to the core */ | 1511 | /* This seems to be fixing IRQ by assigning OOB #6 to the core */ |
1500 | if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6) | 1512 | if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) { |
1501 | bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86); | 1513 | if (bgmac->feature_flags & BGMAC_FEAT_IRQ_ID_OOB_6) |
1514 | bgmac_idm_write(bgmac, BCMA_OOB_SEL_OUT_A30, 0x86); | ||
1515 | } | ||
1502 | 1516 | ||
1503 | bgmac_chip_reset(bgmac); | 1517 | bgmac_chip_reset(bgmac); |
1504 | 1518 | ||
diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h index c1818766c501..443d57b10264 100644 --- a/drivers/net/ethernet/broadcom/bgmac.h +++ b/drivers/net/ethernet/broadcom/bgmac.h | |||
@@ -425,6 +425,7 @@ | |||
425 | #define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17) | 425 | #define BGMAC_FEAT_CC4_IF_SW_TYPE BIT(17) |
426 | #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18) | 426 | #define BGMAC_FEAT_CC4_IF_SW_TYPE_RGMII BIT(18) |
427 | #define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19) | 427 | #define BGMAC_FEAT_CC7_IF_TYPE_RGMII BIT(19) |
428 | #define BGMAC_FEAT_IDM_MASK BIT(20) | ||
428 | 429 | ||
429 | struct bgmac_slot_info { | 430 | struct bgmac_slot_info { |
430 | union { | 431 | union { |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 43423744fdfa..1e33abde4a3e 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | |||
@@ -2886,7 +2886,7 @@ static int bnx2x_test_nvram_tbl(struct bnx2x *bp, | |||
2886 | 2886 | ||
2887 | static int bnx2x_test_nvram(struct bnx2x *bp) | 2887 | static int bnx2x_test_nvram(struct bnx2x *bp) |
2888 | { | 2888 | { |
2889 | const struct crc_pair nvram_tbl[] = { | 2889 | static const struct crc_pair nvram_tbl[] = { |
2890 | { 0, 0x14 }, /* bootstrap */ | 2890 | { 0, 0x14 }, /* bootstrap */ |
2891 | { 0x14, 0xec }, /* dir */ | 2891 | { 0x14, 0xec }, /* dir */ |
2892 | { 0x100, 0x350 }, /* manuf_info */ | 2892 | { 0x100, 0x350 }, /* manuf_info */ |
@@ -2895,7 +2895,7 @@ static int bnx2x_test_nvram(struct bnx2x *bp) | |||
2895 | { 0x708, 0x70 }, /* manuf_key_info */ | 2895 | { 0x708, 0x70 }, /* manuf_key_info */ |
2896 | { 0, 0 } | 2896 | { 0, 0 } |
2897 | }; | 2897 | }; |
2898 | const struct crc_pair nvram_tbl2[] = { | 2898 | static const struct crc_pair nvram_tbl2[] = { |
2899 | { 0x7e8, 0x350 }, /* manuf_info2 */ | 2899 | { 0x7e8, 0x350 }, /* manuf_info2 */ |
2900 | { 0xb38, 0xf0 }, /* feature_info */ | 2900 | { 0xb38, 0xf0 }, /* feature_info */ |
2901 | { 0, 0 } | 2901 | { 0, 0 } |
@@ -3162,7 +3162,8 @@ static void bnx2x_get_strings(struct net_device *dev, u32 stringset, u8 *buf) | |||
3162 | if (is_multi(bp)) { | 3162 | if (is_multi(bp)) { |
3163 | for_each_eth_queue(bp, i) { | 3163 | for_each_eth_queue(bp, i) { |
3164 | memset(queue_name, 0, sizeof(queue_name)); | 3164 | memset(queue_name, 0, sizeof(queue_name)); |
3165 | sprintf(queue_name, "%d", i); | 3165 | snprintf(queue_name, sizeof(queue_name), |
3166 | "%d", i); | ||
3166 | for (j = 0; j < BNX2X_NUM_Q_STATS; j++) | 3167 | for (j = 0; j < BNX2X_NUM_Q_STATS; j++) |
3167 | snprintf(buf + (k + j)*ETH_GSTRING_LEN, | 3168 | snprintf(buf + (k + j)*ETH_GSTRING_LEN, |
3168 | ETH_GSTRING_LEN, | 3169 | ETH_GSTRING_LEN, |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index daca1c9d254b..7b0b399aaedd 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
@@ -1202,12 +1202,21 @@ static struct enet_cb *bcmgenet_get_txcb(struct bcmgenet_priv *priv, | |||
1202 | return tx_cb_ptr; | 1202 | return tx_cb_ptr; |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | /* Simple helper to free a control block's resources */ | 1205 | static struct enet_cb *bcmgenet_put_txcb(struct bcmgenet_priv *priv, |
1206 | static void bcmgenet_free_cb(struct enet_cb *cb) | 1206 | struct bcmgenet_tx_ring *ring) |
1207 | { | 1207 | { |
1208 | dev_kfree_skb_any(cb->skb); | 1208 | struct enet_cb *tx_cb_ptr; |
1209 | cb->skb = NULL; | 1209 | |
1210 | dma_unmap_addr_set(cb, dma_addr, 0); | 1210 | tx_cb_ptr = ring->cbs; |
1211 | tx_cb_ptr += ring->write_ptr - ring->cb_ptr; | ||
1212 | |||
1213 | /* Rewinding local write pointer */ | ||
1214 | if (ring->write_ptr == ring->cb_ptr) | ||
1215 | ring->write_ptr = ring->end_ptr; | ||
1216 | else | ||
1217 | ring->write_ptr--; | ||
1218 | |||
1219 | return tx_cb_ptr; | ||
1211 | } | 1220 | } |
1212 | 1221 | ||
1213 | static inline void bcmgenet_rx_ring16_int_disable(struct bcmgenet_rx_ring *ring) | 1222 | static inline void bcmgenet_rx_ring16_int_disable(struct bcmgenet_rx_ring *ring) |
@@ -1260,18 +1269,72 @@ static inline void bcmgenet_tx_ring_int_disable(struct bcmgenet_tx_ring *ring) | |||
1260 | INTRL2_CPU_MASK_SET); | 1269 | INTRL2_CPU_MASK_SET); |
1261 | } | 1270 | } |
1262 | 1271 | ||
1272 | /* Simple helper to free a transmit control block's resources | ||
1273 | * Returns an skb when the last transmit control block associated with the | ||
1274 | * skb is freed. The skb should be freed by the caller if necessary. | ||
1275 | */ | ||
1276 | static struct sk_buff *bcmgenet_free_tx_cb(struct device *dev, | ||
1277 | struct enet_cb *cb) | ||
1278 | { | ||
1279 | struct sk_buff *skb; | ||
1280 | |||
1281 | skb = cb->skb; | ||
1282 | |||
1283 | if (skb) { | ||
1284 | cb->skb = NULL; | ||
1285 | if (cb == GENET_CB(skb)->first_cb) | ||
1286 | dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr), | ||
1287 | dma_unmap_len(cb, dma_len), | ||
1288 | DMA_TO_DEVICE); | ||
1289 | else | ||
1290 | dma_unmap_page(dev, dma_unmap_addr(cb, dma_addr), | ||
1291 | dma_unmap_len(cb, dma_len), | ||
1292 | DMA_TO_DEVICE); | ||
1293 | dma_unmap_addr_set(cb, dma_addr, 0); | ||
1294 | |||
1295 | if (cb == GENET_CB(skb)->last_cb) | ||
1296 | return skb; | ||
1297 | |||
1298 | } else if (dma_unmap_addr(cb, dma_addr)) { | ||
1299 | dma_unmap_page(dev, | ||
1300 | dma_unmap_addr(cb, dma_addr), | ||
1301 | dma_unmap_len(cb, dma_len), | ||
1302 | DMA_TO_DEVICE); | ||
1303 | dma_unmap_addr_set(cb, dma_addr, 0); | ||
1304 | } | ||
1305 | |||
1306 | return 0; | ||
1307 | } | ||
1308 | |||
1309 | /* Simple helper to free a receive control block's resources */ | ||
1310 | static struct sk_buff *bcmgenet_free_rx_cb(struct device *dev, | ||
1311 | struct enet_cb *cb) | ||
1312 | { | ||
1313 | struct sk_buff *skb; | ||
1314 | |||
1315 | skb = cb->skb; | ||
1316 | cb->skb = NULL; | ||
1317 | |||
1318 | if (dma_unmap_addr(cb, dma_addr)) { | ||
1319 | dma_unmap_single(dev, dma_unmap_addr(cb, dma_addr), | ||
1320 | dma_unmap_len(cb, dma_len), DMA_FROM_DEVICE); | ||
1321 | dma_unmap_addr_set(cb, dma_addr, 0); | ||
1322 | } | ||
1323 | |||
1324 | return skb; | ||
1325 | } | ||
1326 | |||
1263 | /* Unlocked version of the reclaim routine */ | 1327 | /* Unlocked version of the reclaim routine */ |
1264 | static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, | 1328 | static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, |
1265 | struct bcmgenet_tx_ring *ring) | 1329 | struct bcmgenet_tx_ring *ring) |
1266 | { | 1330 | { |
1267 | struct bcmgenet_priv *priv = netdev_priv(dev); | 1331 | struct bcmgenet_priv *priv = netdev_priv(dev); |
1268 | struct device *kdev = &priv->pdev->dev; | 1332 | unsigned int txbds_processed = 0; |
1269 | struct enet_cb *tx_cb_ptr; | ||
1270 | unsigned int pkts_compl = 0; | ||
1271 | unsigned int bytes_compl = 0; | 1333 | unsigned int bytes_compl = 0; |
1272 | unsigned int c_index; | 1334 | unsigned int pkts_compl = 0; |
1273 | unsigned int txbds_ready; | 1335 | unsigned int txbds_ready; |
1274 | unsigned int txbds_processed = 0; | 1336 | unsigned int c_index; |
1337 | struct sk_buff *skb; | ||
1275 | 1338 | ||
1276 | /* Clear status before servicing to reduce spurious interrupts */ | 1339 | /* Clear status before servicing to reduce spurious interrupts */ |
1277 | if (ring->index == DESC_INDEX) | 1340 | if (ring->index == DESC_INDEX) |
@@ -1292,21 +1355,12 @@ static unsigned int __bcmgenet_tx_reclaim(struct net_device *dev, | |||
1292 | 1355 | ||
1293 | /* Reclaim transmitted buffers */ | 1356 | /* Reclaim transmitted buffers */ |
1294 | while (txbds_processed < txbds_ready) { | 1357 | while (txbds_processed < txbds_ready) { |
1295 | tx_cb_ptr = &priv->tx_cbs[ring->clean_ptr]; | 1358 | skb = bcmgenet_free_tx_cb(&priv->pdev->dev, |
1296 | if (tx_cb_ptr->skb) { | 1359 | &priv->tx_cbs[ring->clean_ptr]); |
1360 | if (skb) { | ||
1297 | pkts_compl++; | 1361 | pkts_compl++; |
1298 | bytes_compl += GENET_CB(tx_cb_ptr->skb)->bytes_sent; | 1362 | bytes_compl += GENET_CB(skb)->bytes_sent; |
1299 | dma_unmap_single(kdev, | 1363 | dev_kfree_skb_any(skb); |
1300 | dma_unmap_addr(tx_cb_ptr, dma_addr), | ||
1301 | dma_unmap_len(tx_cb_ptr, dma_len), | ||
1302 | DMA_TO_DEVICE); | ||
1303 | bcmgenet_free_cb(tx_cb_ptr); | ||
1304 | } else if (dma_unmap_addr(tx_cb_ptr, dma_addr)) { | ||
1305 | dma_unmap_page(kdev, | ||
1306 | dma_unmap_addr(tx_cb_ptr, dma_addr), | ||
1307 | dma_unmap_len(tx_cb_ptr, dma_len), | ||
1308 | DMA_TO_DEVICE); | ||
1309 | dma_unmap_addr_set(tx_cb_ptr, dma_addr, 0); | ||
1310 | } | 1364 | } |
1311 | 1365 | ||
1312 | txbds_processed++; | 1366 | txbds_processed++; |
@@ -1380,95 +1434,6 @@ static void bcmgenet_tx_reclaim_all(struct net_device *dev) | |||
1380 | bcmgenet_tx_reclaim(dev, &priv->tx_rings[DESC_INDEX]); | 1434 | bcmgenet_tx_reclaim(dev, &priv->tx_rings[DESC_INDEX]); |
1381 | } | 1435 | } |
1382 | 1436 | ||
1383 | /* Transmits a single SKB (either head of a fragment or a single SKB) | ||
1384 | * caller must hold priv->lock | ||
1385 | */ | ||
1386 | static int bcmgenet_xmit_single(struct net_device *dev, | ||
1387 | struct sk_buff *skb, | ||
1388 | u16 dma_desc_flags, | ||
1389 | struct bcmgenet_tx_ring *ring) | ||
1390 | { | ||
1391 | struct bcmgenet_priv *priv = netdev_priv(dev); | ||
1392 | struct device *kdev = &priv->pdev->dev; | ||
1393 | struct enet_cb *tx_cb_ptr; | ||
1394 | unsigned int skb_len; | ||
1395 | dma_addr_t mapping; | ||
1396 | u32 length_status; | ||
1397 | int ret; | ||
1398 | |||
1399 | tx_cb_ptr = bcmgenet_get_txcb(priv, ring); | ||
1400 | |||
1401 | if (unlikely(!tx_cb_ptr)) | ||
1402 | BUG(); | ||
1403 | |||
1404 | tx_cb_ptr->skb = skb; | ||
1405 | |||
1406 | skb_len = skb_headlen(skb); | ||
1407 | |||
1408 | mapping = dma_map_single(kdev, skb->data, skb_len, DMA_TO_DEVICE); | ||
1409 | ret = dma_mapping_error(kdev, mapping); | ||
1410 | if (ret) { | ||
1411 | priv->mib.tx_dma_failed++; | ||
1412 | netif_err(priv, tx_err, dev, "Tx DMA map failed\n"); | ||
1413 | dev_kfree_skb(skb); | ||
1414 | return ret; | ||
1415 | } | ||
1416 | |||
1417 | dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping); | ||
1418 | dma_unmap_len_set(tx_cb_ptr, dma_len, skb_len); | ||
1419 | length_status = (skb_len << DMA_BUFLENGTH_SHIFT) | dma_desc_flags | | ||
1420 | (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT) | | ||
1421 | DMA_TX_APPEND_CRC; | ||
1422 | |||
1423 | if (skb->ip_summed == CHECKSUM_PARTIAL) | ||
1424 | length_status |= DMA_TX_DO_CSUM; | ||
1425 | |||
1426 | dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, length_status); | ||
1427 | |||
1428 | return 0; | ||
1429 | } | ||
1430 | |||
1431 | /* Transmit a SKB fragment */ | ||
1432 | static int bcmgenet_xmit_frag(struct net_device *dev, | ||
1433 | skb_frag_t *frag, | ||
1434 | u16 dma_desc_flags, | ||
1435 | struct bcmgenet_tx_ring *ring) | ||
1436 | { | ||
1437 | struct bcmgenet_priv *priv = netdev_priv(dev); | ||
1438 | struct device *kdev = &priv->pdev->dev; | ||
1439 | struct enet_cb *tx_cb_ptr; | ||
1440 | unsigned int frag_size; | ||
1441 | dma_addr_t mapping; | ||
1442 | int ret; | ||
1443 | |||
1444 | tx_cb_ptr = bcmgenet_get_txcb(priv, ring); | ||
1445 | |||
1446 | if (unlikely(!tx_cb_ptr)) | ||
1447 | BUG(); | ||
1448 | |||
1449 | tx_cb_ptr->skb = NULL; | ||
1450 | |||
1451 | frag_size = skb_frag_size(frag); | ||
1452 | |||
1453 | mapping = skb_frag_dma_map(kdev, frag, 0, frag_size, DMA_TO_DEVICE); | ||
1454 | ret = dma_mapping_error(kdev, mapping); | ||
1455 | if (ret) { | ||
1456 | priv->mib.tx_dma_failed++; | ||
1457 | netif_err(priv, tx_err, dev, "%s: Tx DMA map failed\n", | ||
1458 | __func__); | ||
1459 | return ret; | ||
1460 | } | ||
1461 | |||
1462 | dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping); | ||
1463 | dma_unmap_len_set(tx_cb_ptr, dma_len, frag_size); | ||
1464 | |||
1465 | dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, | ||
1466 | (frag_size << DMA_BUFLENGTH_SHIFT) | dma_desc_flags | | ||
1467 | (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT)); | ||
1468 | |||
1469 | return 0; | ||
1470 | } | ||
1471 | |||
1472 | /* Reallocate the SKB to put enough headroom in front of it and insert | 1437 | /* Reallocate the SKB to put enough headroom in front of it and insert |
1473 | * the transmit checksum offsets in the descriptors | 1438 | * the transmit checksum offsets in the descriptors |
1474 | */ | 1439 | */ |
@@ -1535,11 +1500,16 @@ static struct sk_buff *bcmgenet_put_tx_csum(struct net_device *dev, | |||
1535 | static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev) | 1500 | static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev) |
1536 | { | 1501 | { |
1537 | struct bcmgenet_priv *priv = netdev_priv(dev); | 1502 | struct bcmgenet_priv *priv = netdev_priv(dev); |
1503 | struct device *kdev = &priv->pdev->dev; | ||
1538 | struct bcmgenet_tx_ring *ring = NULL; | 1504 | struct bcmgenet_tx_ring *ring = NULL; |
1505 | struct enet_cb *tx_cb_ptr; | ||
1539 | struct netdev_queue *txq; | 1506 | struct netdev_queue *txq; |
1540 | unsigned long flags = 0; | 1507 | unsigned long flags = 0; |
1541 | int nr_frags, index; | 1508 | int nr_frags, index; |
1542 | u16 dma_desc_flags; | 1509 | dma_addr_t mapping; |
1510 | unsigned int size; | ||
1511 | skb_frag_t *frag; | ||
1512 | u32 len_stat; | ||
1543 | int ret; | 1513 | int ret; |
1544 | int i; | 1514 | int i; |
1545 | 1515 | ||
@@ -1592,29 +1562,53 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1592 | } | 1562 | } |
1593 | } | 1563 | } |
1594 | 1564 | ||
1595 | dma_desc_flags = DMA_SOP; | 1565 | for (i = 0; i <= nr_frags; i++) { |
1596 | if (nr_frags == 0) | 1566 | tx_cb_ptr = bcmgenet_get_txcb(priv, ring); |
1597 | dma_desc_flags |= DMA_EOP; | ||
1598 | 1567 | ||
1599 | /* Transmit single SKB or head of fragment list */ | 1568 | if (unlikely(!tx_cb_ptr)) |
1600 | ret = bcmgenet_xmit_single(dev, skb, dma_desc_flags, ring); | 1569 | BUG(); |
1601 | if (ret) { | 1570 | |
1602 | ret = NETDEV_TX_OK; | 1571 | if (!i) { |
1603 | goto out; | 1572 | /* Transmit single SKB or head of fragment list */ |
1604 | } | 1573 | GENET_CB(skb)->first_cb = tx_cb_ptr; |
1574 | size = skb_headlen(skb); | ||
1575 | mapping = dma_map_single(kdev, skb->data, size, | ||
1576 | DMA_TO_DEVICE); | ||
1577 | } else { | ||
1578 | /* xmit fragment */ | ||
1579 | frag = &skb_shinfo(skb)->frags[i - 1]; | ||
1580 | size = skb_frag_size(frag); | ||
1581 | mapping = skb_frag_dma_map(kdev, frag, 0, size, | ||
1582 | DMA_TO_DEVICE); | ||
1583 | } | ||
1605 | 1584 | ||
1606 | /* xmit fragment */ | 1585 | ret = dma_mapping_error(kdev, mapping); |
1607 | for (i = 0; i < nr_frags; i++) { | ||
1608 | ret = bcmgenet_xmit_frag(dev, | ||
1609 | &skb_shinfo(skb)->frags[i], | ||
1610 | (i == nr_frags - 1) ? DMA_EOP : 0, | ||
1611 | ring); | ||
1612 | if (ret) { | 1586 | if (ret) { |
1587 | priv->mib.tx_dma_failed++; | ||
1588 | netif_err(priv, tx_err, dev, "Tx DMA map failed\n"); | ||
1613 | ret = NETDEV_TX_OK; | 1589 | ret = NETDEV_TX_OK; |
1614 | goto out; | 1590 | goto out_unmap_frags; |
1591 | } | ||
1592 | dma_unmap_addr_set(tx_cb_ptr, dma_addr, mapping); | ||
1593 | dma_unmap_len_set(tx_cb_ptr, dma_len, size); | ||
1594 | |||
1595 | tx_cb_ptr->skb = skb; | ||
1596 | |||
1597 | len_stat = (size << DMA_BUFLENGTH_SHIFT) | | ||
1598 | (priv->hw_params->qtag_mask << DMA_TX_QTAG_SHIFT); | ||
1599 | |||
1600 | if (!i) { | ||
1601 | len_stat |= DMA_TX_APPEND_CRC | DMA_SOP; | ||
1602 | if (skb->ip_summed == CHECKSUM_PARTIAL) | ||
1603 | len_stat |= DMA_TX_DO_CSUM; | ||
1615 | } | 1604 | } |
1605 | if (i == nr_frags) | ||
1606 | len_stat |= DMA_EOP; | ||
1607 | |||
1608 | dmadesc_set(priv, tx_cb_ptr->bd_addr, mapping, len_stat); | ||
1616 | } | 1609 | } |
1617 | 1610 | ||
1611 | GENET_CB(skb)->last_cb = tx_cb_ptr; | ||
1618 | skb_tx_timestamp(skb); | 1612 | skb_tx_timestamp(skb); |
1619 | 1613 | ||
1620 | /* Decrement total BD count and advance our write pointer */ | 1614 | /* Decrement total BD count and advance our write pointer */ |
@@ -1635,6 +1629,19 @@ out: | |||
1635 | spin_unlock_irqrestore(&ring->lock, flags); | 1629 | spin_unlock_irqrestore(&ring->lock, flags); |
1636 | 1630 | ||
1637 | return ret; | 1631 | return ret; |
1632 | |||
1633 | out_unmap_frags: | ||
1634 | /* Back up for failed control block mapping */ | ||
1635 | bcmgenet_put_txcb(priv, ring); | ||
1636 | |||
1637 | /* Unmap successfully mapped control blocks */ | ||
1638 | while (i-- > 0) { | ||
1639 | tx_cb_ptr = bcmgenet_put_txcb(priv, ring); | ||
1640 | bcmgenet_free_tx_cb(kdev, tx_cb_ptr); | ||
1641 | } | ||
1642 | |||
1643 | dev_kfree_skb(skb); | ||
1644 | goto out; | ||
1638 | } | 1645 | } |
1639 | 1646 | ||
1640 | static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv, | 1647 | static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv, |
@@ -1666,14 +1673,12 @@ static struct sk_buff *bcmgenet_rx_refill(struct bcmgenet_priv *priv, | |||
1666 | } | 1673 | } |
1667 | 1674 | ||
1668 | /* Grab the current Rx skb from the ring and DMA-unmap it */ | 1675 | /* Grab the current Rx skb from the ring and DMA-unmap it */ |
1669 | rx_skb = cb->skb; | 1676 | rx_skb = bcmgenet_free_rx_cb(kdev, cb); |
1670 | if (likely(rx_skb)) | ||
1671 | dma_unmap_single(kdev, dma_unmap_addr(cb, dma_addr), | ||
1672 | priv->rx_buf_len, DMA_FROM_DEVICE); | ||
1673 | 1677 | ||
1674 | /* Put the new Rx skb on the ring */ | 1678 | /* Put the new Rx skb on the ring */ |
1675 | cb->skb = skb; | 1679 | cb->skb = skb; |
1676 | dma_unmap_addr_set(cb, dma_addr, mapping); | 1680 | dma_unmap_addr_set(cb, dma_addr, mapping); |
1681 | dma_unmap_len_set(cb, dma_len, priv->rx_buf_len); | ||
1677 | dmadesc_set_addr(priv, cb->bd_addr, mapping); | 1682 | dmadesc_set_addr(priv, cb->bd_addr, mapping); |
1678 | 1683 | ||
1679 | /* Return the current Rx skb to caller */ | 1684 | /* Return the current Rx skb to caller */ |
@@ -1880,22 +1885,16 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv, | |||
1880 | 1885 | ||
1881 | static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) | 1886 | static void bcmgenet_free_rx_buffers(struct bcmgenet_priv *priv) |
1882 | { | 1887 | { |
1883 | struct device *kdev = &priv->pdev->dev; | 1888 | struct sk_buff *skb; |
1884 | struct enet_cb *cb; | 1889 | struct enet_cb *cb; |
1885 | int i; | 1890 | int i; |
1886 | 1891 | ||
1887 | for (i = 0; i < priv->num_rx_bds; i++) { | 1892 | for (i = 0; i < priv->num_rx_bds; i++) { |
1888 | cb = &priv->rx_cbs[i]; | 1893 | cb = &priv->rx_cbs[i]; |
1889 | 1894 | ||
1890 | if (dma_unmap_addr(cb, dma_addr)) { | 1895 | skb = bcmgenet_free_rx_cb(&priv->pdev->dev, cb); |
1891 | dma_unmap_single(kdev, | 1896 | if (skb) |
1892 | dma_unmap_addr(cb, dma_addr), | 1897 | dev_kfree_skb_any(skb); |
1893 | priv->rx_buf_len, DMA_FROM_DEVICE); | ||
1894 | dma_unmap_addr_set(cb, dma_addr, 0); | ||
1895 | } | ||
1896 | |||
1897 | if (cb->skb) | ||
1898 | bcmgenet_free_cb(cb); | ||
1899 | } | 1898 | } |
1900 | } | 1899 | } |
1901 | 1900 | ||
@@ -2479,8 +2478,10 @@ static int bcmgenet_dma_teardown(struct bcmgenet_priv *priv) | |||
2479 | 2478 | ||
2480 | static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) | 2479 | static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) |
2481 | { | 2480 | { |
2482 | int i; | ||
2483 | struct netdev_queue *txq; | 2481 | struct netdev_queue *txq; |
2482 | struct sk_buff *skb; | ||
2483 | struct enet_cb *cb; | ||
2484 | int i; | ||
2484 | 2485 | ||
2485 | bcmgenet_fini_rx_napi(priv); | 2486 | bcmgenet_fini_rx_napi(priv); |
2486 | bcmgenet_fini_tx_napi(priv); | 2487 | bcmgenet_fini_tx_napi(priv); |
@@ -2489,10 +2490,10 @@ static void bcmgenet_fini_dma(struct bcmgenet_priv *priv) | |||
2489 | bcmgenet_dma_teardown(priv); | 2490 | bcmgenet_dma_teardown(priv); |
2490 | 2491 | ||
2491 | for (i = 0; i < priv->num_tx_bds; i++) { | 2492 | for (i = 0; i < priv->num_tx_bds; i++) { |
2492 | if (priv->tx_cbs[i].skb != NULL) { | 2493 | cb = priv->tx_cbs + i; |
2493 | dev_kfree_skb(priv->tx_cbs[i].skb); | 2494 | skb = bcmgenet_free_tx_cb(&priv->pdev->dev, cb); |
2494 | priv->tx_cbs[i].skb = NULL; | 2495 | if (skb) |
2495 | } | 2496 | dev_kfree_skb(skb); |
2496 | } | 2497 | } |
2497 | 2498 | ||
2498 | for (i = 0; i < priv->hw_params->tx_queues; i++) { | 2499 | for (i = 0; i < priv->hw_params->tx_queues; i++) { |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h index efd07020b89f..b9344de669f8 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h | |||
@@ -544,6 +544,8 @@ struct bcmgenet_hw_params { | |||
544 | }; | 544 | }; |
545 | 545 | ||
546 | struct bcmgenet_skb_cb { | 546 | struct bcmgenet_skb_cb { |
547 | struct enet_cb *first_cb; /* First control block of SKB */ | ||
548 | struct enet_cb *last_cb; /* Last control block of SKB */ | ||
547 | unsigned int bytes_sent; /* bytes on the wire (no TSB) */ | 549 | unsigned int bytes_sent; /* bytes on the wire (no TSB) */ |
548 | }; | 550 | }; |
549 | 551 | ||
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c index 28ecda3d3404..ebd353bc78ff 100644 --- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c +++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | |||
@@ -335,7 +335,7 @@ lio_ethtool_get_channels(struct net_device *dev, | |||
335 | 335 | ||
336 | static int lio_get_eeprom_len(struct net_device *netdev) | 336 | static int lio_get_eeprom_len(struct net_device *netdev) |
337 | { | 337 | { |
338 | u8 buf[128]; | 338 | u8 buf[192]; |
339 | struct lio *lio = GET_LIO(netdev); | 339 | struct lio *lio = GET_LIO(netdev); |
340 | struct octeon_device *oct_dev = lio->oct_dev; | 340 | struct octeon_device *oct_dev = lio->oct_dev; |
341 | struct octeon_board_info *board_info; | 341 | struct octeon_board_info *board_info; |
diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index a0ca68ce3fbb..79112563a25a 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c | |||
@@ -1008,7 +1008,7 @@ static void bgx_print_qlm_mode(struct bgx *bgx, u8 lmacid) | |||
1008 | { | 1008 | { |
1009 | struct device *dev = &bgx->pdev->dev; | 1009 | struct device *dev = &bgx->pdev->dev; |
1010 | struct lmac *lmac; | 1010 | struct lmac *lmac; |
1011 | char str[20]; | 1011 | char str[27]; |
1012 | 1012 | ||
1013 | if (!bgx->is_dlm && lmacid) | 1013 | if (!bgx->is_dlm && lmacid) |
1014 | return; | 1014 | return; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c index 50517cfd9671..9f9d6cae39d5 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ptp.c | |||
@@ -441,7 +441,8 @@ void cxgb4_ptp_init(struct adapter *adapter) | |||
441 | 441 | ||
442 | adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info, | 442 | adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info, |
443 | &adapter->pdev->dev); | 443 | &adapter->pdev->dev); |
444 | if (!adapter->ptp_clock) { | 444 | if (IS_ERR_OR_NULL(adapter->ptp_clock)) { |
445 | adapter->ptp_clock = NULL; | ||
445 | dev_err(adapter->pdev_dev, | 446 | dev_err(adapter->pdev_dev, |
446 | "PTP %s Clock registration has failed\n", __func__); | 447 | "PTP %s Clock registration has failed\n", __func__); |
447 | return; | 448 | return; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h index 99987d8e437e..aa28299aef5f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h +++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h | |||
@@ -174,6 +174,8 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN | |||
174 | CH_PCI_ID_TABLE_FENTRY(0x50a0), /* Custom T540-CR */ | 174 | CH_PCI_ID_TABLE_FENTRY(0x50a0), /* Custom T540-CR */ |
175 | CH_PCI_ID_TABLE_FENTRY(0x50a1), /* Custom T540-CR */ | 175 | CH_PCI_ID_TABLE_FENTRY(0x50a1), /* Custom T540-CR */ |
176 | CH_PCI_ID_TABLE_FENTRY(0x50a2), /* Custom T540-KR4 */ | 176 | CH_PCI_ID_TABLE_FENTRY(0x50a2), /* Custom T540-KR4 */ |
177 | CH_PCI_ID_TABLE_FENTRY(0x50a3), /* Custom T580-KR4 */ | ||
178 | CH_PCI_ID_TABLE_FENTRY(0x50a4), /* Custom 2x T540-CR */ | ||
177 | 179 | ||
178 | /* T6 adapters: | 180 | /* T6 adapters: |
179 | */ | 181 | */ |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c index ff864a187d5a..a37166ee577b 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c | |||
@@ -776,8 +776,9 @@ void hns_ae_update_led_status(struct hnae_handle *handle) | |||
776 | 776 | ||
777 | assert(handle); | 777 | assert(handle); |
778 | mac_cb = hns_get_mac_cb(handle); | 778 | mac_cb = hns_get_mac_cb(handle); |
779 | if (!mac_cb->cpld_ctrl) | 779 | if (mac_cb->media_type != HNAE_MEDIA_TYPE_FIBER) |
780 | return; | 780 | return; |
781 | |||
781 | hns_set_led_opt(mac_cb); | 782 | hns_set_led_opt(mac_cb); |
782 | } | 783 | } |
783 | 784 | ||
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c index 7a8addda726e..408b63faf9a8 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c | |||
@@ -53,6 +53,34 @@ static u32 dsaf_read_sub(struct dsaf_device *dsaf_dev, u32 reg) | |||
53 | return ret; | 53 | return ret; |
54 | } | 54 | } |
55 | 55 | ||
56 | static void hns_dsaf_acpi_ledctrl_by_port(struct hns_mac_cb *mac_cb, u8 op_type, | ||
57 | u32 link, u32 port, u32 act) | ||
58 | { | ||
59 | union acpi_object *obj; | ||
60 | union acpi_object obj_args[3], argv4; | ||
61 | |||
62 | obj_args[0].integer.type = ACPI_TYPE_INTEGER; | ||
63 | obj_args[0].integer.value = link; | ||
64 | obj_args[1].integer.type = ACPI_TYPE_INTEGER; | ||
65 | obj_args[1].integer.value = port; | ||
66 | obj_args[2].integer.type = ACPI_TYPE_INTEGER; | ||
67 | obj_args[2].integer.value = act; | ||
68 | |||
69 | argv4.type = ACPI_TYPE_PACKAGE; | ||
70 | argv4.package.count = 3; | ||
71 | argv4.package.elements = obj_args; | ||
72 | |||
73 | obj = acpi_evaluate_dsm(ACPI_HANDLE(mac_cb->dev), | ||
74 | &hns_dsaf_acpi_dsm_guid, 0, op_type, &argv4); | ||
75 | if (!obj) { | ||
76 | dev_warn(mac_cb->dev, "ledctrl fail, link:%d port:%d act:%d!\n", | ||
77 | link, port, act); | ||
78 | return; | ||
79 | } | ||
80 | |||
81 | ACPI_FREE(obj); | ||
82 | } | ||
83 | |||
56 | static void hns_cpld_set_led(struct hns_mac_cb *mac_cb, int link_status, | 84 | static void hns_cpld_set_led(struct hns_mac_cb *mac_cb, int link_status, |
57 | u16 speed, int data) | 85 | u16 speed, int data) |
58 | { | 86 | { |
@@ -93,6 +121,18 @@ static void hns_cpld_set_led(struct hns_mac_cb *mac_cb, int link_status, | |||
93 | } | 121 | } |
94 | } | 122 | } |
95 | 123 | ||
124 | static void hns_cpld_set_led_acpi(struct hns_mac_cb *mac_cb, int link_status, | ||
125 | u16 speed, int data) | ||
126 | { | ||
127 | if (!mac_cb) { | ||
128 | pr_err("cpld_led_set mac_cb is null!\n"); | ||
129 | return; | ||
130 | } | ||
131 | |||
132 | hns_dsaf_acpi_ledctrl_by_port(mac_cb, HNS_OP_LED_SET_FUNC, | ||
133 | link_status, mac_cb->mac_id, data); | ||
134 | } | ||
135 | |||
96 | static void cpld_led_reset(struct hns_mac_cb *mac_cb) | 136 | static void cpld_led_reset(struct hns_mac_cb *mac_cb) |
97 | { | 137 | { |
98 | if (!mac_cb || !mac_cb->cpld_ctrl) | 138 | if (!mac_cb || !mac_cb->cpld_ctrl) |
@@ -103,6 +143,20 @@ static void cpld_led_reset(struct hns_mac_cb *mac_cb) | |||
103 | mac_cb->cpld_led_value = CPLD_LED_DEFAULT_VALUE; | 143 | mac_cb->cpld_led_value = CPLD_LED_DEFAULT_VALUE; |
104 | } | 144 | } |
105 | 145 | ||
146 | static void cpld_led_reset_acpi(struct hns_mac_cb *mac_cb) | ||
147 | { | ||
148 | if (!mac_cb) { | ||
149 | pr_err("cpld_led_reset mac_cb is null!\n"); | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | if (mac_cb->media_type != HNAE_MEDIA_TYPE_FIBER) | ||
154 | return; | ||
155 | |||
156 | hns_dsaf_acpi_ledctrl_by_port(mac_cb, HNS_OP_LED_SET_FUNC, | ||
157 | 0, mac_cb->mac_id, 0); | ||
158 | } | ||
159 | |||
106 | static int cpld_set_led_id(struct hns_mac_cb *mac_cb, | 160 | static int cpld_set_led_id(struct hns_mac_cb *mac_cb, |
107 | enum hnae_led_state status) | 161 | enum hnae_led_state status) |
108 | { | 162 | { |
@@ -604,8 +658,8 @@ struct dsaf_misc_op *hns_misc_op_get(struct dsaf_device *dsaf_dev) | |||
604 | 658 | ||
605 | misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback; | 659 | misc_op->cfg_serdes_loopback = hns_mac_config_sds_loopback; |
606 | } else if (is_acpi_node(dsaf_dev->dev->fwnode)) { | 660 | } else if (is_acpi_node(dsaf_dev->dev->fwnode)) { |
607 | misc_op->cpld_set_led = hns_cpld_set_led; | 661 | misc_op->cpld_set_led = hns_cpld_set_led_acpi; |
608 | misc_op->cpld_reset_led = cpld_led_reset; | 662 | misc_op->cpld_reset_led = cpld_led_reset_acpi; |
609 | misc_op->cpld_set_led_id = cpld_set_led_id; | 663 | misc_op->cpld_set_led_id = cpld_set_led_id; |
610 | 664 | ||
611 | misc_op->dsaf_reset = hns_dsaf_rst_acpi; | 665 | misc_op->dsaf_reset = hns_dsaf_rst_acpi; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c index 249a4584401a..b651c1210555 100644 --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c | |||
@@ -283,7 +283,7 @@ int mlx4_zone_add_one(struct mlx4_zone_allocator *zone_alloc, | |||
283 | } | 283 | } |
284 | 284 | ||
285 | /* Should be called under a lock */ | 285 | /* Should be called under a lock */ |
286 | static int __mlx4_zone_remove_one_entry(struct mlx4_zone_entry *entry) | 286 | static void __mlx4_zone_remove_one_entry(struct mlx4_zone_entry *entry) |
287 | { | 287 | { |
288 | struct mlx4_zone_allocator *zone_alloc = entry->allocator; | 288 | struct mlx4_zone_allocator *zone_alloc = entry->allocator; |
289 | 289 | ||
@@ -315,8 +315,6 @@ static int __mlx4_zone_remove_one_entry(struct mlx4_zone_entry *entry) | |||
315 | } | 315 | } |
316 | zone_alloc->mask = mask; | 316 | zone_alloc->mask = mask; |
317 | } | 317 | } |
318 | |||
319 | return 0; | ||
320 | } | 318 | } |
321 | 319 | ||
322 | void mlx4_zone_allocator_destroy(struct mlx4_zone_allocator *zone_alloc) | 320 | void mlx4_zone_allocator_destroy(struct mlx4_zone_allocator *zone_alloc) |
@@ -457,7 +455,7 @@ struct mlx4_bitmap *mlx4_zone_get_bitmap(struct mlx4_zone_allocator *zones, u32 | |||
457 | int mlx4_zone_remove_one(struct mlx4_zone_allocator *zones, u32 uid) | 455 | int mlx4_zone_remove_one(struct mlx4_zone_allocator *zones, u32 uid) |
458 | { | 456 | { |
459 | struct mlx4_zone_entry *zone; | 457 | struct mlx4_zone_entry *zone; |
460 | int res; | 458 | int res = 0; |
461 | 459 | ||
462 | spin_lock(&zones->lock); | 460 | spin_lock(&zones->lock); |
463 | 461 | ||
@@ -468,7 +466,7 @@ int mlx4_zone_remove_one(struct mlx4_zone_allocator *zones, u32 uid) | |||
468 | goto out; | 466 | goto out; |
469 | } | 467 | } |
470 | 468 | ||
471 | res = __mlx4_zone_remove_one_entry(zone); | 469 | __mlx4_zone_remove_one_entry(zone); |
472 | 470 | ||
473 | out: | 471 | out: |
474 | spin_unlock(&zones->lock); | 472 | spin_unlock(&zones->lock); |
@@ -578,7 +576,7 @@ out: | |||
578 | } | 576 | } |
579 | 577 | ||
580 | static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, | 578 | static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, |
581 | struct mlx4_buf *buf, gfp_t gfp) | 579 | struct mlx4_buf *buf) |
582 | { | 580 | { |
583 | dma_addr_t t; | 581 | dma_addr_t t; |
584 | 582 | ||
@@ -587,7 +585,7 @@ static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, | |||
587 | buf->page_shift = get_order(size) + PAGE_SHIFT; | 585 | buf->page_shift = get_order(size) + PAGE_SHIFT; |
588 | buf->direct.buf = | 586 | buf->direct.buf = |
589 | dma_zalloc_coherent(&dev->persist->pdev->dev, | 587 | dma_zalloc_coherent(&dev->persist->pdev->dev, |
590 | size, &t, gfp); | 588 | size, &t, GFP_KERNEL); |
591 | if (!buf->direct.buf) | 589 | if (!buf->direct.buf) |
592 | return -ENOMEM; | 590 | return -ENOMEM; |
593 | 591 | ||
@@ -607,10 +605,10 @@ static int mlx4_buf_direct_alloc(struct mlx4_dev *dev, int size, | |||
607 | * multiple pages, so we don't require too much contiguous memory. | 605 | * multiple pages, so we don't require too much contiguous memory. |
608 | */ | 606 | */ |
609 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | 607 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, |
610 | struct mlx4_buf *buf, gfp_t gfp) | 608 | struct mlx4_buf *buf) |
611 | { | 609 | { |
612 | if (size <= max_direct) { | 610 | if (size <= max_direct) { |
613 | return mlx4_buf_direct_alloc(dev, size, buf, gfp); | 611 | return mlx4_buf_direct_alloc(dev, size, buf); |
614 | } else { | 612 | } else { |
615 | dma_addr_t t; | 613 | dma_addr_t t; |
616 | int i; | 614 | int i; |
@@ -620,14 +618,14 @@ int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | |||
620 | buf->npages = buf->nbufs; | 618 | buf->npages = buf->nbufs; |
621 | buf->page_shift = PAGE_SHIFT; | 619 | buf->page_shift = PAGE_SHIFT; |
622 | buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list), | 620 | buf->page_list = kcalloc(buf->nbufs, sizeof(*buf->page_list), |
623 | gfp); | 621 | GFP_KERNEL); |
624 | if (!buf->page_list) | 622 | if (!buf->page_list) |
625 | return -ENOMEM; | 623 | return -ENOMEM; |
626 | 624 | ||
627 | for (i = 0; i < buf->nbufs; ++i) { | 625 | for (i = 0; i < buf->nbufs; ++i) { |
628 | buf->page_list[i].buf = | 626 | buf->page_list[i].buf = |
629 | dma_zalloc_coherent(&dev->persist->pdev->dev, | 627 | dma_zalloc_coherent(&dev->persist->pdev->dev, |
630 | PAGE_SIZE, &t, gfp); | 628 | PAGE_SIZE, &t, GFP_KERNEL); |
631 | if (!buf->page_list[i].buf) | 629 | if (!buf->page_list[i].buf) |
632 | goto err_free; | 630 | goto err_free; |
633 | 631 | ||
@@ -663,12 +661,11 @@ void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf) | |||
663 | } | 661 | } |
664 | EXPORT_SYMBOL_GPL(mlx4_buf_free); | 662 | EXPORT_SYMBOL_GPL(mlx4_buf_free); |
665 | 663 | ||
666 | static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device, | 664 | static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device) |
667 | gfp_t gfp) | ||
668 | { | 665 | { |
669 | struct mlx4_db_pgdir *pgdir; | 666 | struct mlx4_db_pgdir *pgdir; |
670 | 667 | ||
671 | pgdir = kzalloc(sizeof *pgdir, gfp); | 668 | pgdir = kzalloc(sizeof(*pgdir), GFP_KERNEL); |
672 | if (!pgdir) | 669 | if (!pgdir) |
673 | return NULL; | 670 | return NULL; |
674 | 671 | ||
@@ -676,7 +673,7 @@ static struct mlx4_db_pgdir *mlx4_alloc_db_pgdir(struct device *dma_device, | |||
676 | pgdir->bits[0] = pgdir->order0; | 673 | pgdir->bits[0] = pgdir->order0; |
677 | pgdir->bits[1] = pgdir->order1; | 674 | pgdir->bits[1] = pgdir->order1; |
678 | pgdir->db_page = dma_alloc_coherent(dma_device, PAGE_SIZE, | 675 | pgdir->db_page = dma_alloc_coherent(dma_device, PAGE_SIZE, |
679 | &pgdir->db_dma, gfp); | 676 | &pgdir->db_dma, GFP_KERNEL); |
680 | if (!pgdir->db_page) { | 677 | if (!pgdir->db_page) { |
681 | kfree(pgdir); | 678 | kfree(pgdir); |
682 | return NULL; | 679 | return NULL; |
@@ -716,7 +713,7 @@ found: | |||
716 | return 0; | 713 | return 0; |
717 | } | 714 | } |
718 | 715 | ||
719 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, gfp_t gfp) | 716 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order) |
720 | { | 717 | { |
721 | struct mlx4_priv *priv = mlx4_priv(dev); | 718 | struct mlx4_priv *priv = mlx4_priv(dev); |
722 | struct mlx4_db_pgdir *pgdir; | 719 | struct mlx4_db_pgdir *pgdir; |
@@ -728,7 +725,7 @@ int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, gfp_t gfp | |||
728 | if (!mlx4_alloc_db_from_pgdir(pgdir, db, order)) | 725 | if (!mlx4_alloc_db_from_pgdir(pgdir, db, order)) |
729 | goto out; | 726 | goto out; |
730 | 727 | ||
731 | pgdir = mlx4_alloc_db_pgdir(&dev->persist->pdev->dev, gfp); | 728 | pgdir = mlx4_alloc_db_pgdir(&dev->persist->pdev->dev); |
732 | if (!pgdir) { | 729 | if (!pgdir) { |
733 | ret = -ENOMEM; | 730 | ret = -ENOMEM; |
734 | goto out; | 731 | goto out; |
@@ -780,13 +777,13 @@ int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | |||
780 | { | 777 | { |
781 | int err; | 778 | int err; |
782 | 779 | ||
783 | err = mlx4_db_alloc(dev, &wqres->db, 1, GFP_KERNEL); | 780 | err = mlx4_db_alloc(dev, &wqres->db, 1); |
784 | if (err) | 781 | if (err) |
785 | return err; | 782 | return err; |
786 | 783 | ||
787 | *wqres->db.db = 0; | 784 | *wqres->db.db = 0; |
788 | 785 | ||
789 | err = mlx4_buf_direct_alloc(dev, size, &wqres->buf, GFP_KERNEL); | 786 | err = mlx4_buf_direct_alloc(dev, size, &wqres->buf); |
790 | if (err) | 787 | if (err) |
791 | goto err_db; | 788 | goto err_db; |
792 | 789 | ||
@@ -795,7 +792,7 @@ int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | |||
795 | if (err) | 792 | if (err) |
796 | goto err_buf; | 793 | goto err_buf; |
797 | 794 | ||
798 | err = mlx4_buf_write_mtt(dev, &wqres->mtt, &wqres->buf, GFP_KERNEL); | 795 | err = mlx4_buf_write_mtt(dev, &wqres->mtt, &wqres->buf); |
799 | if (err) | 796 | if (err) |
800 | goto err_mtt; | 797 | goto err_mtt; |
801 | 798 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c index fa6d2354a0e9..c56a511b918e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/cq.c | |||
@@ -224,11 +224,11 @@ int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn) | |||
224 | if (*cqn == -1) | 224 | if (*cqn == -1) |
225 | return -ENOMEM; | 225 | return -ENOMEM; |
226 | 226 | ||
227 | err = mlx4_table_get(dev, &cq_table->table, *cqn, GFP_KERNEL); | 227 | err = mlx4_table_get(dev, &cq_table->table, *cqn); |
228 | if (err) | 228 | if (err) |
229 | goto err_out; | 229 | goto err_out; |
230 | 230 | ||
231 | err = mlx4_table_get(dev, &cq_table->cmpt_table, *cqn, GFP_KERNEL); | 231 | err = mlx4_table_get(dev, &cq_table->cmpt_table, *cqn); |
232 | if (err) | 232 | if (err) |
233 | goto err_put; | 233 | goto err_put; |
234 | return 0; | 234 | return 0; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index e5fb89505a13..436f7689a032 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c | |||
@@ -1042,7 +1042,7 @@ static int mlx4_en_config_rss_qp(struct mlx4_en_priv *priv, int qpn, | |||
1042 | if (!context) | 1042 | if (!context) |
1043 | return -ENOMEM; | 1043 | return -ENOMEM; |
1044 | 1044 | ||
1045 | err = mlx4_qp_alloc(mdev->dev, qpn, qp, GFP_KERNEL); | 1045 | err = mlx4_qp_alloc(mdev->dev, qpn, qp); |
1046 | if (err) { | 1046 | if (err) { |
1047 | en_err(priv, "Failed to allocate qp #%x\n", qpn); | 1047 | en_err(priv, "Failed to allocate qp #%x\n", qpn); |
1048 | goto out; | 1048 | goto out; |
@@ -1086,7 +1086,7 @@ int mlx4_en_create_drop_qp(struct mlx4_en_priv *priv) | |||
1086 | en_err(priv, "Failed reserving drop qpn\n"); | 1086 | en_err(priv, "Failed reserving drop qpn\n"); |
1087 | return err; | 1087 | return err; |
1088 | } | 1088 | } |
1089 | err = mlx4_qp_alloc(priv->mdev->dev, qpn, &priv->drop_qp, GFP_KERNEL); | 1089 | err = mlx4_qp_alloc(priv->mdev->dev, qpn, &priv->drop_qp); |
1090 | if (err) { | 1090 | if (err) { |
1091 | en_err(priv, "Failed allocating drop qp\n"); | 1091 | en_err(priv, "Failed allocating drop qp\n"); |
1092 | mlx4_qp_release_range(priv->mdev->dev, qpn, 1); | 1092 | mlx4_qp_release_range(priv->mdev->dev, qpn, 1); |
@@ -1158,8 +1158,7 @@ int mlx4_en_config_rss_steer(struct mlx4_en_priv *priv) | |||
1158 | } | 1158 | } |
1159 | 1159 | ||
1160 | /* Configure RSS indirection qp */ | 1160 | /* Configure RSS indirection qp */ |
1161 | err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, rss_map->indir_qp, | 1161 | err = mlx4_qp_alloc(mdev->dev, priv->base_qpn, rss_map->indir_qp); |
1162 | GFP_KERNEL); | ||
1163 | if (err) { | 1162 | if (err) { |
1164 | en_err(priv, "Failed to allocate RSS indirection QP\n"); | 1163 | en_err(priv, "Failed to allocate RSS indirection QP\n"); |
1165 | goto rss_err; | 1164 | goto rss_err; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 4f3a9b27ce4a..73faa3d77921 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
@@ -111,7 +111,7 @@ int mlx4_en_create_tx_ring(struct mlx4_en_priv *priv, | |||
111 | goto err_hwq_res; | 111 | goto err_hwq_res; |
112 | } | 112 | } |
113 | 113 | ||
114 | err = mlx4_qp_alloc(mdev->dev, ring->qpn, &ring->sp_qp, GFP_KERNEL); | 114 | err = mlx4_qp_alloc(mdev->dev, ring->qpn, &ring->sp_qp); |
115 | if (err) { | 115 | if (err) { |
116 | en_err(priv, "Failed allocating qp %d\n", ring->qpn); | 116 | en_err(priv, "Failed allocating qp %d\n", ring->qpn); |
117 | goto err_reserve; | 117 | goto err_reserve; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c index e1f9e7cebf8f..5a7816e7c7b4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.c +++ b/drivers/net/ethernet/mellanox/mlx4/icm.c | |||
@@ -251,8 +251,7 @@ int mlx4_UNMAP_ICM_AUX(struct mlx4_dev *dev) | |||
251 | MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); | 251 | MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE); |
252 | } | 252 | } |
253 | 253 | ||
254 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj, | 254 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj) |
255 | gfp_t gfp) | ||
256 | { | 255 | { |
257 | u32 i = (obj & (table->num_obj - 1)) / | 256 | u32 i = (obj & (table->num_obj - 1)) / |
258 | (MLX4_TABLE_CHUNK_SIZE / table->obj_size); | 257 | (MLX4_TABLE_CHUNK_SIZE / table->obj_size); |
@@ -266,7 +265,7 @@ int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj, | |||
266 | } | 265 | } |
267 | 266 | ||
268 | table->icm[i] = mlx4_alloc_icm(dev, MLX4_TABLE_CHUNK_SIZE >> PAGE_SHIFT, | 267 | table->icm[i] = mlx4_alloc_icm(dev, MLX4_TABLE_CHUNK_SIZE >> PAGE_SHIFT, |
269 | (table->lowmem ? gfp : GFP_HIGHUSER) | | 268 | (table->lowmem ? GFP_KERNEL : GFP_HIGHUSER) | |
270 | __GFP_NOWARN, table->coherent); | 269 | __GFP_NOWARN, table->coherent); |
271 | if (!table->icm[i]) { | 270 | if (!table->icm[i]) { |
272 | ret = -ENOMEM; | 271 | ret = -ENOMEM; |
@@ -363,7 +362,7 @@ int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, | |||
363 | u32 i; | 362 | u32 i; |
364 | 363 | ||
365 | for (i = start; i <= end; i += inc) { | 364 | for (i = start; i <= end; i += inc) { |
366 | err = mlx4_table_get(dev, table, i, GFP_KERNEL); | 365 | err = mlx4_table_get(dev, table, i); |
367 | if (err) | 366 | if (err) |
368 | goto fail; | 367 | goto fail; |
369 | } | 368 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.h b/drivers/net/ethernet/mellanox/mlx4/icm.h index 0c7364550150..dee67fa39107 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.h +++ b/drivers/net/ethernet/mellanox/mlx4/icm.h | |||
@@ -71,8 +71,7 @@ struct mlx4_icm *mlx4_alloc_icm(struct mlx4_dev *dev, int npages, | |||
71 | gfp_t gfp_mask, int coherent); | 71 | gfp_t gfp_mask, int coherent); |
72 | void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent); | 72 | void mlx4_free_icm(struct mlx4_dev *dev, struct mlx4_icm *icm, int coherent); |
73 | 73 | ||
74 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj, | 74 | int mlx4_table_get(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj); |
75 | gfp_t gfp); | ||
76 | void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj); | 75 | void mlx4_table_put(struct mlx4_dev *dev, struct mlx4_icm_table *table, u32 obj); |
77 | int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, | 76 | int mlx4_table_get_range(struct mlx4_dev *dev, struct mlx4_icm_table *table, |
78 | u32 start, u32 end); | 77 | u32 start, u32 end); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h index 30616cd0140d..706d7f21ac5c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h | |||
@@ -969,7 +969,7 @@ void mlx4_cleanup_cq_table(struct mlx4_dev *dev); | |||
969 | void mlx4_cleanup_qp_table(struct mlx4_dev *dev); | 969 | void mlx4_cleanup_qp_table(struct mlx4_dev *dev); |
970 | void mlx4_cleanup_srq_table(struct mlx4_dev *dev); | 970 | void mlx4_cleanup_srq_table(struct mlx4_dev *dev); |
971 | void mlx4_cleanup_mcg_table(struct mlx4_dev *dev); | 971 | void mlx4_cleanup_mcg_table(struct mlx4_dev *dev); |
972 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp); | 972 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn); |
973 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn); | 973 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn); |
974 | int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn); | 974 | int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn); |
975 | void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn); | 975 | void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn); |
@@ -977,7 +977,7 @@ int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn); | |||
977 | void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn); | 977 | void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn); |
978 | int __mlx4_mpt_reserve(struct mlx4_dev *dev); | 978 | int __mlx4_mpt_reserve(struct mlx4_dev *dev); |
979 | void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index); | 979 | void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index); |
980 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp); | 980 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index); |
981 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index); | 981 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index); |
982 | u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order); | 982 | u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order); |
983 | void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order); | 983 | void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c index ce852ca22a96..24282cd017d3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c | |||
@@ -479,14 +479,14 @@ static void mlx4_mpt_release(struct mlx4_dev *dev, u32 index) | |||
479 | __mlx4_mpt_release(dev, index); | 479 | __mlx4_mpt_release(dev, index); |
480 | } | 480 | } |
481 | 481 | ||
482 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp) | 482 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index) |
483 | { | 483 | { |
484 | struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table; | 484 | struct mlx4_mr_table *mr_table = &mlx4_priv(dev)->mr_table; |
485 | 485 | ||
486 | return mlx4_table_get(dev, &mr_table->dmpt_table, index, gfp); | 486 | return mlx4_table_get(dev, &mr_table->dmpt_table, index); |
487 | } | 487 | } |
488 | 488 | ||
489 | static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp) | 489 | static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index) |
490 | { | 490 | { |
491 | u64 param = 0; | 491 | u64 param = 0; |
492 | 492 | ||
@@ -497,7 +497,7 @@ static int mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp) | |||
497 | MLX4_CMD_TIME_CLASS_A, | 497 | MLX4_CMD_TIME_CLASS_A, |
498 | MLX4_CMD_WRAPPED); | 498 | MLX4_CMD_WRAPPED); |
499 | } | 499 | } |
500 | return __mlx4_mpt_alloc_icm(dev, index, gfp); | 500 | return __mlx4_mpt_alloc_icm(dev, index); |
501 | } | 501 | } |
502 | 502 | ||
503 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index) | 503 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index) |
@@ -629,7 +629,7 @@ int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) | |||
629 | struct mlx4_mpt_entry *mpt_entry; | 629 | struct mlx4_mpt_entry *mpt_entry; |
630 | int err; | 630 | int err; |
631 | 631 | ||
632 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mr->key), GFP_KERNEL); | 632 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mr->key)); |
633 | if (err) | 633 | if (err) |
634 | return err; | 634 | return err; |
635 | 635 | ||
@@ -787,14 +787,13 @@ int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | |||
787 | EXPORT_SYMBOL_GPL(mlx4_write_mtt); | 787 | EXPORT_SYMBOL_GPL(mlx4_write_mtt); |
788 | 788 | ||
789 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | 789 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
790 | struct mlx4_buf *buf, gfp_t gfp) | 790 | struct mlx4_buf *buf) |
791 | { | 791 | { |
792 | u64 *page_list; | 792 | u64 *page_list; |
793 | int err; | 793 | int err; |
794 | int i; | 794 | int i; |
795 | 795 | ||
796 | page_list = kmalloc(buf->npages * sizeof *page_list, | 796 | page_list = kcalloc(buf->npages, sizeof(*page_list), GFP_KERNEL); |
797 | gfp); | ||
798 | if (!page_list) | 797 | if (!page_list) |
799 | return -ENOMEM; | 798 | return -ENOMEM; |
800 | 799 | ||
@@ -841,7 +840,7 @@ int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw) | |||
841 | struct mlx4_mpt_entry *mpt_entry; | 840 | struct mlx4_mpt_entry *mpt_entry; |
842 | int err; | 841 | int err; |
843 | 842 | ||
844 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mw->key), GFP_KERNEL); | 843 | err = mlx4_mpt_alloc_icm(dev, key_to_hw_index(mw->key)); |
845 | if (err) | 844 | if (err) |
846 | return err; | 845 | return err; |
847 | 846 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c index 5a310d313e94..26747212526b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/qp.c +++ b/drivers/net/ethernet/mellanox/mlx4/qp.c | |||
@@ -301,29 +301,29 @@ void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt) | |||
301 | } | 301 | } |
302 | EXPORT_SYMBOL_GPL(mlx4_qp_release_range); | 302 | EXPORT_SYMBOL_GPL(mlx4_qp_release_range); |
303 | 303 | ||
304 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp) | 304 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn) |
305 | { | 305 | { |
306 | struct mlx4_priv *priv = mlx4_priv(dev); | 306 | struct mlx4_priv *priv = mlx4_priv(dev); |
307 | struct mlx4_qp_table *qp_table = &priv->qp_table; | 307 | struct mlx4_qp_table *qp_table = &priv->qp_table; |
308 | int err; | 308 | int err; |
309 | 309 | ||
310 | err = mlx4_table_get(dev, &qp_table->qp_table, qpn, gfp); | 310 | err = mlx4_table_get(dev, &qp_table->qp_table, qpn); |
311 | if (err) | 311 | if (err) |
312 | goto err_out; | 312 | goto err_out; |
313 | 313 | ||
314 | err = mlx4_table_get(dev, &qp_table->auxc_table, qpn, gfp); | 314 | err = mlx4_table_get(dev, &qp_table->auxc_table, qpn); |
315 | if (err) | 315 | if (err) |
316 | goto err_put_qp; | 316 | goto err_put_qp; |
317 | 317 | ||
318 | err = mlx4_table_get(dev, &qp_table->altc_table, qpn, gfp); | 318 | err = mlx4_table_get(dev, &qp_table->altc_table, qpn); |
319 | if (err) | 319 | if (err) |
320 | goto err_put_auxc; | 320 | goto err_put_auxc; |
321 | 321 | ||
322 | err = mlx4_table_get(dev, &qp_table->rdmarc_table, qpn, gfp); | 322 | err = mlx4_table_get(dev, &qp_table->rdmarc_table, qpn); |
323 | if (err) | 323 | if (err) |
324 | goto err_put_altc; | 324 | goto err_put_altc; |
325 | 325 | ||
326 | err = mlx4_table_get(dev, &qp_table->cmpt_table, qpn, gfp); | 326 | err = mlx4_table_get(dev, &qp_table->cmpt_table, qpn); |
327 | if (err) | 327 | if (err) |
328 | goto err_put_rdmarc; | 328 | goto err_put_rdmarc; |
329 | 329 | ||
@@ -345,7 +345,7 @@ err_out: | |||
345 | return err; | 345 | return err; |
346 | } | 346 | } |
347 | 347 | ||
348 | static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp) | 348 | static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn) |
349 | { | 349 | { |
350 | u64 param = 0; | 350 | u64 param = 0; |
351 | 351 | ||
@@ -355,7 +355,7 @@ static int mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp) | |||
355 | MLX4_CMD_ALLOC_RES, MLX4_CMD_TIME_CLASS_A, | 355 | MLX4_CMD_ALLOC_RES, MLX4_CMD_TIME_CLASS_A, |
356 | MLX4_CMD_WRAPPED); | 356 | MLX4_CMD_WRAPPED); |
357 | } | 357 | } |
358 | return __mlx4_qp_alloc_icm(dev, qpn, gfp); | 358 | return __mlx4_qp_alloc_icm(dev, qpn); |
359 | } | 359 | } |
360 | 360 | ||
361 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn) | 361 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn) |
@@ -397,7 +397,7 @@ struct mlx4_qp *mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn) | |||
397 | return qp; | 397 | return qp; |
398 | } | 398 | } |
399 | 399 | ||
400 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, gfp_t gfp) | 400 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp) |
401 | { | 401 | { |
402 | struct mlx4_priv *priv = mlx4_priv(dev); | 402 | struct mlx4_priv *priv = mlx4_priv(dev); |
403 | struct mlx4_qp_table *qp_table = &priv->qp_table; | 403 | struct mlx4_qp_table *qp_table = &priv->qp_table; |
@@ -408,7 +408,7 @@ int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, gfp_t gfp) | |||
408 | 408 | ||
409 | qp->qpn = qpn; | 409 | qp->qpn = qpn; |
410 | 410 | ||
411 | err = mlx4_qp_alloc_icm(dev, qpn, gfp); | 411 | err = mlx4_qp_alloc_icm(dev, qpn); |
412 | if (err) | 412 | if (err) |
413 | return err; | 413 | return err; |
414 | 414 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 812783865205..215e21c3dc8a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
@@ -1822,7 +1822,7 @@ static int qp_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, | |||
1822 | return err; | 1822 | return err; |
1823 | 1823 | ||
1824 | if (!fw_reserved(dev, qpn)) { | 1824 | if (!fw_reserved(dev, qpn)) { |
1825 | err = __mlx4_qp_alloc_icm(dev, qpn, GFP_KERNEL); | 1825 | err = __mlx4_qp_alloc_icm(dev, qpn); |
1826 | if (err) { | 1826 | if (err) { |
1827 | res_abort_move(dev, slave, RES_QP, qpn); | 1827 | res_abort_move(dev, slave, RES_QP, qpn); |
1828 | return err; | 1828 | return err; |
@@ -1909,7 +1909,7 @@ static int mpt_alloc_res(struct mlx4_dev *dev, int slave, int op, int cmd, | |||
1909 | if (err) | 1909 | if (err) |
1910 | return err; | 1910 | return err; |
1911 | 1911 | ||
1912 | err = __mlx4_mpt_alloc_icm(dev, mpt->key, GFP_KERNEL); | 1912 | err = __mlx4_mpt_alloc_icm(dev, mpt->key); |
1913 | if (err) { | 1913 | if (err) { |
1914 | res_abort_move(dev, slave, RES_MPT, id); | 1914 | res_abort_move(dev, slave, RES_MPT, id); |
1915 | return err; | 1915 | return err; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c index f44d089e2ca6..bedf52126824 100644 --- a/drivers/net/ethernet/mellanox/mlx4/srq.c +++ b/drivers/net/ethernet/mellanox/mlx4/srq.c | |||
@@ -100,11 +100,11 @@ int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn) | |||
100 | if (*srqn == -1) | 100 | if (*srqn == -1) |
101 | return -ENOMEM; | 101 | return -ENOMEM; |
102 | 102 | ||
103 | err = mlx4_table_get(dev, &srq_table->table, *srqn, GFP_KERNEL); | 103 | err = mlx4_table_get(dev, &srq_table->table, *srqn); |
104 | if (err) | 104 | if (err) |
105 | goto err_out; | 105 | goto err_out; |
106 | 106 | ||
107 | err = mlx4_table_get(dev, &srq_table->cmpt_table, *srqn, GFP_KERNEL); | 107 | err = mlx4_table_get(dev, &srq_table->cmpt_table, *srqn); |
108 | if (err) | 108 | if (err) |
109 | goto err_put; | 109 | goto err_put; |
110 | return 0; | 110 | return 0; |
diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c index 746d94e28470..60850bfa3d32 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac.c | |||
@@ -766,11 +766,13 @@ static void emac_shutdown(struct platform_device *pdev) | |||
766 | struct emac_adapter *adpt = netdev_priv(netdev); | 766 | struct emac_adapter *adpt = netdev_priv(netdev); |
767 | struct emac_sgmii *sgmii = &adpt->phy; | 767 | struct emac_sgmii *sgmii = &adpt->phy; |
768 | 768 | ||
769 | /* Closing the SGMII turns off its interrupts */ | 769 | if (netdev->flags & IFF_UP) { |
770 | sgmii->close(adpt); | 770 | /* Closing the SGMII turns off its interrupts */ |
771 | sgmii->close(adpt); | ||
771 | 772 | ||
772 | /* Resetting the MAC turns off all DMA and its interrupts */ | 773 | /* Resetting the MAC turns off all DMA and its interrupts */ |
773 | emac_mac_reset(adpt); | 774 | emac_mac_reset(adpt); |
775 | } | ||
774 | } | 776 | } |
775 | 777 | ||
776 | static struct platform_driver emac_platform_driver = { | 778 | static struct platform_driver emac_platform_driver = { |
diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c index b607936e1b3e..9c0488e0f08e 100644 --- a/drivers/net/ethernet/sgi/ioc3-eth.c +++ b/drivers/net/ethernet/sgi/ioc3-eth.c | |||
@@ -90,17 +90,13 @@ struct ioc3_private { | |||
90 | spinlock_t ioc3_lock; | 90 | spinlock_t ioc3_lock; |
91 | struct mii_if_info mii; | 91 | struct mii_if_info mii; |
92 | 92 | ||
93 | struct net_device *dev; | ||
93 | struct pci_dev *pdev; | 94 | struct pci_dev *pdev; |
94 | 95 | ||
95 | /* Members used by autonegotiation */ | 96 | /* Members used by autonegotiation */ |
96 | struct timer_list ioc3_timer; | 97 | struct timer_list ioc3_timer; |
97 | }; | 98 | }; |
98 | 99 | ||
99 | static inline struct net_device *priv_netdev(struct ioc3_private *dev) | ||
100 | { | ||
101 | return (void *)dev - ((sizeof(struct net_device) + 31) & ~31); | ||
102 | } | ||
103 | |||
104 | static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 100 | static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
105 | static void ioc3_set_multicast_list(struct net_device *dev); | 101 | static void ioc3_set_multicast_list(struct net_device *dev); |
106 | static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev); | 102 | static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev); |
@@ -427,7 +423,7 @@ static void ioc3_get_eaddr_nic(struct ioc3_private *ip) | |||
427 | nic[i] = nic_read_byte(ioc3); | 423 | nic[i] = nic_read_byte(ioc3); |
428 | 424 | ||
429 | for (i = 2; i < 8; i++) | 425 | for (i = 2; i < 8; i++) |
430 | priv_netdev(ip)->dev_addr[i - 2] = nic[i]; | 426 | ip->dev->dev_addr[i - 2] = nic[i]; |
431 | } | 427 | } |
432 | 428 | ||
433 | /* | 429 | /* |
@@ -439,7 +435,7 @@ static void ioc3_get_eaddr(struct ioc3_private *ip) | |||
439 | { | 435 | { |
440 | ioc3_get_eaddr_nic(ip); | 436 | ioc3_get_eaddr_nic(ip); |
441 | 437 | ||
442 | printk("Ethernet address is %pM.\n", priv_netdev(ip)->dev_addr); | 438 | printk("Ethernet address is %pM.\n", ip->dev->dev_addr); |
443 | } | 439 | } |
444 | 440 | ||
445 | static void __ioc3_set_mac_address(struct net_device *dev) | 441 | static void __ioc3_set_mac_address(struct net_device *dev) |
@@ -790,13 +786,12 @@ static void ioc3_timer(unsigned long data) | |||
790 | */ | 786 | */ |
791 | static int ioc3_mii_init(struct ioc3_private *ip) | 787 | static int ioc3_mii_init(struct ioc3_private *ip) |
792 | { | 788 | { |
793 | struct net_device *dev = priv_netdev(ip); | ||
794 | int i, found = 0, res = 0; | 789 | int i, found = 0, res = 0; |
795 | int ioc3_phy_workaround = 1; | 790 | int ioc3_phy_workaround = 1; |
796 | u16 word; | 791 | u16 word; |
797 | 792 | ||
798 | for (i = 0; i < 32; i++) { | 793 | for (i = 0; i < 32; i++) { |
799 | word = ioc3_mdio_read(dev, i, MII_PHYSID1); | 794 | word = ioc3_mdio_read(ip->dev, i, MII_PHYSID1); |
800 | 795 | ||
801 | if (word != 0xffff && word != 0x0000) { | 796 | if (word != 0xffff && word != 0x0000) { |
802 | found = 1; | 797 | found = 1; |
@@ -1276,6 +1271,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1276 | SET_NETDEV_DEV(dev, &pdev->dev); | 1271 | SET_NETDEV_DEV(dev, &pdev->dev); |
1277 | 1272 | ||
1278 | ip = netdev_priv(dev); | 1273 | ip = netdev_priv(dev); |
1274 | ip->dev = dev; | ||
1279 | 1275 | ||
1280 | dev->irq = pdev->irq; | 1276 | dev->irq = pdev->irq; |
1281 | 1277 | ||
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index f233bf8b4ebb..c4407e8e39a3 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c | |||
@@ -117,7 +117,7 @@ static void dwmac4_tx_queue_routing(struct mac_device_info *hw, | |||
117 | void __iomem *ioaddr = hw->pcsr; | 117 | void __iomem *ioaddr = hw->pcsr; |
118 | u32 value; | 118 | u32 value; |
119 | 119 | ||
120 | const struct stmmac_rx_routing route_possibilities[] = { | 120 | static const struct stmmac_rx_routing route_possibilities[] = { |
121 | { GMAC_RXQCTRL_AVCPQ_MASK, GMAC_RXQCTRL_AVCPQ_SHIFT }, | 121 | { GMAC_RXQCTRL_AVCPQ_MASK, GMAC_RXQCTRL_AVCPQ_SHIFT }, |
122 | { GMAC_RXQCTRL_PTPQ_MASK, GMAC_RXQCTRL_PTPQ_SHIFT }, | 122 | { GMAC_RXQCTRL_PTPQ_MASK, GMAC_RXQCTRL_PTPQ_SHIFT }, |
123 | { GMAC_RXQCTRL_DCBCPQ_MASK, GMAC_RXQCTRL_DCBCPQ_SHIFT }, | 123 | { GMAC_RXQCTRL_DCBCPQ_MASK, GMAC_RXQCTRL_DCBCPQ_SHIFT }, |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 1853f7ff6657..1763e48c84e2 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
@@ -4120,8 +4120,15 @@ int stmmac_dvr_probe(struct device *device, | |||
4120 | if ((phyaddr >= 0) && (phyaddr <= 31)) | 4120 | if ((phyaddr >= 0) && (phyaddr <= 31)) |
4121 | priv->plat->phy_addr = phyaddr; | 4121 | priv->plat->phy_addr = phyaddr; |
4122 | 4122 | ||
4123 | if (priv->plat->stmmac_rst) | 4123 | if (priv->plat->stmmac_rst) { |
4124 | ret = reset_control_assert(priv->plat->stmmac_rst); | ||
4124 | reset_control_deassert(priv->plat->stmmac_rst); | 4125 | reset_control_deassert(priv->plat->stmmac_rst); |
4126 | /* Some reset controllers have only reset callback instead of | ||
4127 | * assert + deassert callbacks pair. | ||
4128 | */ | ||
4129 | if (ret == -ENOTSUPP) | ||
4130 | reset_control_reset(priv->plat->stmmac_rst); | ||
4131 | } | ||
4125 | 4132 | ||
4126 | /* Init MAC and get the capabilities */ | 4133 | /* Init MAC and get the capabilities */ |
4127 | ret = stmmac_hw_init(priv); | 4134 | ret = stmmac_hw_init(priv); |
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c index 46cb7f8955a2..4bb04aaf9650 100644 --- a/drivers/net/ethernet/sun/niu.c +++ b/drivers/net/ethernet/sun/niu.c | |||
@@ -9532,7 +9532,7 @@ static struct niu_parent *niu_get_parent(struct niu *np, | |||
9532 | p = niu_new_parent(np, id, ptype); | 9532 | p = niu_new_parent(np, id, ptype); |
9533 | 9533 | ||
9534 | if (p) { | 9534 | if (p) { |
9535 | char port_name[6]; | 9535 | char port_name[8]; |
9536 | int err; | 9536 | int err; |
9537 | 9537 | ||
9538 | sprintf(port_name, "port%d", port); | 9538 | sprintf(port_name, "port%d", port); |
@@ -9553,7 +9553,7 @@ static void niu_put_parent(struct niu *np) | |||
9553 | { | 9553 | { |
9554 | struct niu_parent *p = np->parent; | 9554 | struct niu_parent *p = np->parent; |
9555 | u8 port = np->port; | 9555 | u8 port = np->port; |
9556 | char port_name[6]; | 9556 | char port_name[8]; |
9557 | 9557 | ||
9558 | BUG_ON(!p || p->ports[port] != np); | 9558 | BUG_ON(!p || p->ports[port] != np); |
9559 | 9559 | ||
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c index 711fbbbc4b1f..163d8d16bc24 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c | |||
@@ -654,6 +654,8 @@ static int bdx_ioctl_priv(struct net_device *ndev, struct ifreq *ifr, int cmd) | |||
654 | RET(-EFAULT); | 654 | RET(-EFAULT); |
655 | } | 655 | } |
656 | DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); | 656 | DBG("%d 0x%x 0x%x\n", data[0], data[1], data[2]); |
657 | } else { | ||
658 | return -EOPNOTSUPP; | ||
657 | } | 659 | } |
658 | 660 | ||
659 | if (!capable(CAP_SYS_RAWIO)) | 661 | if (!capable(CAP_SYS_RAWIO)) |
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1850e348f555..badd0a8caeb9 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -3089,6 +3089,31 @@ static int cpsw_probe(struct platform_device *pdev) | |||
3089 | cpsw->quirk_irq = true; | 3089 | cpsw->quirk_irq = true; |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | ||
3093 | |||
3094 | ndev->netdev_ops = &cpsw_netdev_ops; | ||
3095 | ndev->ethtool_ops = &cpsw_ethtool_ops; | ||
3096 | netif_napi_add(ndev, &cpsw->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT); | ||
3097 | netif_tx_napi_add(ndev, &cpsw->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT); | ||
3098 | cpsw_split_res(ndev); | ||
3099 | |||
3100 | /* register the network device */ | ||
3101 | SET_NETDEV_DEV(ndev, &pdev->dev); | ||
3102 | ret = register_netdev(ndev); | ||
3103 | if (ret) { | ||
3104 | dev_err(priv->dev, "error registering net device\n"); | ||
3105 | ret = -ENODEV; | ||
3106 | goto clean_ale_ret; | ||
3107 | } | ||
3108 | |||
3109 | if (cpsw->data.dual_emac) { | ||
3110 | ret = cpsw_probe_dual_emac(priv); | ||
3111 | if (ret) { | ||
3112 | cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); | ||
3113 | goto clean_unregister_netdev_ret; | ||
3114 | } | ||
3115 | } | ||
3116 | |||
3092 | /* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and | 3117 | /* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and |
3093 | * MISC IRQs which are always kept disabled with this driver so | 3118 | * MISC IRQs which are always kept disabled with this driver so |
3094 | * we will not request them. | 3119 | * we will not request them. |
@@ -3127,33 +3152,9 @@ static int cpsw_probe(struct platform_device *pdev) | |||
3127 | goto clean_ale_ret; | 3152 | goto clean_ale_ret; |
3128 | } | 3153 | } |
3129 | 3154 | ||
3130 | ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; | ||
3131 | |||
3132 | ndev->netdev_ops = &cpsw_netdev_ops; | ||
3133 | ndev->ethtool_ops = &cpsw_ethtool_ops; | ||
3134 | netif_napi_add(ndev, &cpsw->napi_rx, cpsw_rx_poll, CPSW_POLL_WEIGHT); | ||
3135 | netif_tx_napi_add(ndev, &cpsw->napi_tx, cpsw_tx_poll, CPSW_POLL_WEIGHT); | ||
3136 | cpsw_split_res(ndev); | ||
3137 | |||
3138 | /* register the network device */ | ||
3139 | SET_NETDEV_DEV(ndev, &pdev->dev); | ||
3140 | ret = register_netdev(ndev); | ||
3141 | if (ret) { | ||
3142 | dev_err(priv->dev, "error registering net device\n"); | ||
3143 | ret = -ENODEV; | ||
3144 | goto clean_ale_ret; | ||
3145 | } | ||
3146 | |||
3147 | cpsw_notice(priv, probe, | 3155 | cpsw_notice(priv, probe, |
3148 | "initialized device (regs %pa, irq %d, pool size %d)\n", | 3156 | "initialized device (regs %pa, irq %d, pool size %d)\n", |
3149 | &ss_res->start, ndev->irq, dma_params.descs_pool_size); | 3157 | &ss_res->start, ndev->irq, dma_params.descs_pool_size); |
3150 | if (cpsw->data.dual_emac) { | ||
3151 | ret = cpsw_probe_dual_emac(priv); | ||
3152 | if (ret) { | ||
3153 | cpsw_err(priv, probe, "error probe slave 2 emac interface\n"); | ||
3154 | goto clean_unregister_netdev_ret; | ||
3155 | } | ||
3156 | } | ||
3157 | 3158 | ||
3158 | pm_runtime_put(&pdev->dev); | 3159 | pm_runtime_put(&pdev->dev); |
3159 | 3160 | ||
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c index 00755b6a42cf..c608e1dfaf09 100644 --- a/drivers/net/phy/mdio-mux.c +++ b/drivers/net/phy/mdio-mux.c | |||
@@ -135,8 +135,8 @@ int mdio_mux_init(struct device *dev, | |||
135 | for_each_available_child_of_node(dev->of_node, child_bus_node) { | 135 | for_each_available_child_of_node(dev->of_node, child_bus_node) { |
136 | int v; | 136 | int v; |
137 | 137 | ||
138 | v = of_mdio_parse_addr(dev, child_bus_node); | 138 | r = of_property_read_u32(child_bus_node, "reg", &v); |
139 | if (v < 0) { | 139 | if (r) { |
140 | dev_err(dev, | 140 | dev_err(dev, |
141 | "Error: Failed to find reg for child %s\n", | 141 | "Error: Failed to find reg for child %s\n", |
142 | of_node_full_name(child_bus_node)); | 142 | of_node_full_name(child_bus_node)); |
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 13028833bee3..bd4303944e44 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c | |||
@@ -120,6 +120,7 @@ struct ppp { | |||
120 | int n_channels; /* how many channels are attached 54 */ | 120 | int n_channels; /* how many channels are attached 54 */ |
121 | spinlock_t rlock; /* lock for receive side 58 */ | 121 | spinlock_t rlock; /* lock for receive side 58 */ |
122 | spinlock_t wlock; /* lock for transmit side 5c */ | 122 | spinlock_t wlock; /* lock for transmit side 5c */ |
123 | int *xmit_recursion __percpu; /* xmit recursion detect */ | ||
123 | int mru; /* max receive unit 60 */ | 124 | int mru; /* max receive unit 60 */ |
124 | unsigned int flags; /* control bits 64 */ | 125 | unsigned int flags; /* control bits 64 */ |
125 | unsigned int xstate; /* transmit state bits 68 */ | 126 | unsigned int xstate; /* transmit state bits 68 */ |
@@ -1025,6 +1026,7 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev, | |||
1025 | struct ppp *ppp = netdev_priv(dev); | 1026 | struct ppp *ppp = netdev_priv(dev); |
1026 | int indx; | 1027 | int indx; |
1027 | int err; | 1028 | int err; |
1029 | int cpu; | ||
1028 | 1030 | ||
1029 | ppp->dev = dev; | 1031 | ppp->dev = dev; |
1030 | ppp->ppp_net = src_net; | 1032 | ppp->ppp_net = src_net; |
@@ -1039,6 +1041,15 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev, | |||
1039 | INIT_LIST_HEAD(&ppp->channels); | 1041 | INIT_LIST_HEAD(&ppp->channels); |
1040 | spin_lock_init(&ppp->rlock); | 1042 | spin_lock_init(&ppp->rlock); |
1041 | spin_lock_init(&ppp->wlock); | 1043 | spin_lock_init(&ppp->wlock); |
1044 | |||
1045 | ppp->xmit_recursion = alloc_percpu(int); | ||
1046 | if (!ppp->xmit_recursion) { | ||
1047 | err = -ENOMEM; | ||
1048 | goto err1; | ||
1049 | } | ||
1050 | for_each_possible_cpu(cpu) | ||
1051 | (*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0; | ||
1052 | |||
1042 | #ifdef CONFIG_PPP_MULTILINK | 1053 | #ifdef CONFIG_PPP_MULTILINK |
1043 | ppp->minseq = -1; | 1054 | ppp->minseq = -1; |
1044 | skb_queue_head_init(&ppp->mrq); | 1055 | skb_queue_head_init(&ppp->mrq); |
@@ -1050,11 +1061,15 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev, | |||
1050 | 1061 | ||
1051 | err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set); | 1062 | err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set); |
1052 | if (err < 0) | 1063 | if (err < 0) |
1053 | return err; | 1064 | goto err2; |
1054 | 1065 | ||
1055 | conf->file->private_data = &ppp->file; | 1066 | conf->file->private_data = &ppp->file; |
1056 | 1067 | ||
1057 | return 0; | 1068 | return 0; |
1069 | err2: | ||
1070 | free_percpu(ppp->xmit_recursion); | ||
1071 | err1: | ||
1072 | return err; | ||
1058 | } | 1073 | } |
1059 | 1074 | ||
1060 | static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = { | 1075 | static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = { |
@@ -1400,18 +1415,16 @@ static void __ppp_xmit_process(struct ppp *ppp) | |||
1400 | ppp_xmit_unlock(ppp); | 1415 | ppp_xmit_unlock(ppp); |
1401 | } | 1416 | } |
1402 | 1417 | ||
1403 | static DEFINE_PER_CPU(int, ppp_xmit_recursion); | ||
1404 | |||
1405 | static void ppp_xmit_process(struct ppp *ppp) | 1418 | static void ppp_xmit_process(struct ppp *ppp) |
1406 | { | 1419 | { |
1407 | local_bh_disable(); | 1420 | local_bh_disable(); |
1408 | 1421 | ||
1409 | if (unlikely(__this_cpu_read(ppp_xmit_recursion))) | 1422 | if (unlikely(*this_cpu_ptr(ppp->xmit_recursion))) |
1410 | goto err; | 1423 | goto err; |
1411 | 1424 | ||
1412 | __this_cpu_inc(ppp_xmit_recursion); | 1425 | (*this_cpu_ptr(ppp->xmit_recursion))++; |
1413 | __ppp_xmit_process(ppp); | 1426 | __ppp_xmit_process(ppp); |
1414 | __this_cpu_dec(ppp_xmit_recursion); | 1427 | (*this_cpu_ptr(ppp->xmit_recursion))--; |
1415 | 1428 | ||
1416 | local_bh_enable(); | 1429 | local_bh_enable(); |
1417 | 1430 | ||
@@ -1905,7 +1918,7 @@ static void __ppp_channel_push(struct channel *pch) | |||
1905 | read_lock(&pch->upl); | 1918 | read_lock(&pch->upl); |
1906 | ppp = pch->ppp; | 1919 | ppp = pch->ppp; |
1907 | if (ppp) | 1920 | if (ppp) |
1908 | __ppp_xmit_process(ppp); | 1921 | ppp_xmit_process(ppp); |
1909 | read_unlock(&pch->upl); | 1922 | read_unlock(&pch->upl); |
1910 | } | 1923 | } |
1911 | } | 1924 | } |
@@ -1914,9 +1927,7 @@ static void ppp_channel_push(struct channel *pch) | |||
1914 | { | 1927 | { |
1915 | local_bh_disable(); | 1928 | local_bh_disable(); |
1916 | 1929 | ||
1917 | __this_cpu_inc(ppp_xmit_recursion); | ||
1918 | __ppp_channel_push(pch); | 1930 | __ppp_channel_push(pch); |
1919 | __this_cpu_dec(ppp_xmit_recursion); | ||
1920 | 1931 | ||
1921 | local_bh_enable(); | 1932 | local_bh_enable(); |
1922 | } | 1933 | } |
@@ -3057,6 +3068,7 @@ static void ppp_destroy_interface(struct ppp *ppp) | |||
3057 | #endif /* CONFIG_PPP_FILTER */ | 3068 | #endif /* CONFIG_PPP_FILTER */ |
3058 | 3069 | ||
3059 | kfree_skb(ppp->xmit_pending); | 3070 | kfree_skb(ppp->xmit_pending); |
3071 | free_percpu(ppp->xmit_recursion); | ||
3060 | 3072 | ||
3061 | free_netdev(ppp->dev); | 3073 | free_netdev(ppp->dev); |
3062 | } | 3074 | } |
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c index d103a1d4fb36..8f572b9f3625 100644 --- a/drivers/net/usb/cdc_ncm.c +++ b/drivers/net/usb/cdc_ncm.c | |||
@@ -768,8 +768,10 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ | |||
768 | u8 *buf; | 768 | u8 *buf; |
769 | int len; | 769 | int len; |
770 | int temp; | 770 | int temp; |
771 | int err; | ||
771 | u8 iface_no; | 772 | u8 iface_no; |
772 | struct usb_cdc_parsed_header hdr; | 773 | struct usb_cdc_parsed_header hdr; |
774 | u16 curr_ntb_format; | ||
773 | 775 | ||
774 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | 776 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
775 | if (!ctx) | 777 | if (!ctx) |
@@ -874,6 +876,32 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ | |||
874 | goto error2; | 876 | goto error2; |
875 | } | 877 | } |
876 | 878 | ||
879 | /* | ||
880 | * Some Huawei devices have been observed to come out of reset in NDP32 mode. | ||
881 | * Let's check if this is the case, and set the device to NDP16 mode again if | ||
882 | * needed. | ||
883 | */ | ||
884 | if (ctx->drvflags & CDC_NCM_FLAG_RESET_NTB16) { | ||
885 | err = usbnet_read_cmd(dev, USB_CDC_GET_NTB_FORMAT, | ||
886 | USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, | ||
887 | 0, iface_no, &curr_ntb_format, 2); | ||
888 | if (err < 0) { | ||
889 | goto error2; | ||
890 | } | ||
891 | |||
892 | if (curr_ntb_format == USB_CDC_NCM_NTB32_FORMAT) { | ||
893 | dev_info(&intf->dev, "resetting NTB format to 16-bit"); | ||
894 | err = usbnet_write_cmd(dev, USB_CDC_SET_NTB_FORMAT, | ||
895 | USB_TYPE_CLASS | USB_DIR_OUT | ||
896 | | USB_RECIP_INTERFACE, | ||
897 | USB_CDC_NCM_NTB16_FORMAT, | ||
898 | iface_no, NULL, 0); | ||
899 | |||
900 | if (err < 0) | ||
901 | goto error2; | ||
902 | } | ||
903 | } | ||
904 | |||
877 | cdc_ncm_find_endpoints(dev, ctx->data); | 905 | cdc_ncm_find_endpoints(dev, ctx->data); |
878 | cdc_ncm_find_endpoints(dev, ctx->control); | 906 | cdc_ncm_find_endpoints(dev, ctx->control); |
879 | if (!dev->in || !dev->out || !dev->status) { | 907 | if (!dev->in || !dev->out || !dev->status) { |
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c index 2680a65cd5e4..63f28908afda 100644 --- a/drivers/net/usb/huawei_cdc_ncm.c +++ b/drivers/net/usb/huawei_cdc_ncm.c | |||
@@ -80,6 +80,12 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev, | |||
80 | * be at the end of the frame. | 80 | * be at the end of the frame. |
81 | */ | 81 | */ |
82 | drvflags |= CDC_NCM_FLAG_NDP_TO_END; | 82 | drvflags |= CDC_NCM_FLAG_NDP_TO_END; |
83 | |||
84 | /* Additionally, it has been reported that some Huawei E3372H devices, with | ||
85 | * firmware version 21.318.01.00.541, come out of reset in NTB32 format mode, hence | ||
86 | * needing to be set to the NTB16 one again. | ||
87 | */ | ||
88 | drvflags |= CDC_NCM_FLAG_RESET_NTB16; | ||
83 | ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags); | 89 | ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags); |
84 | if (ret) | 90 | if (ret) |
85 | goto err; | 91 | goto err; |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 2dfca96a63b6..340c13484e5c 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
@@ -898,6 +898,7 @@ static const struct ethtool_ops smsc95xx_ethtool_ops = { | |||
898 | .set_wol = smsc95xx_ethtool_set_wol, | 898 | .set_wol = smsc95xx_ethtool_set_wol, |
899 | .get_link_ksettings = smsc95xx_get_link_ksettings, | 899 | .get_link_ksettings = smsc95xx_get_link_ksettings, |
900 | .set_link_ksettings = smsc95xx_set_link_ksettings, | 900 | .set_link_ksettings = smsc95xx_set_link_ksettings, |
901 | .get_ts_info = ethtool_op_get_ts_info, | ||
901 | }; | 902 | }; |
902 | 903 | ||
903 | static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) | 904 | static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) |
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index ba1c9f93592b..9c51b8be0038 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h | |||
@@ -311,7 +311,7 @@ struct vmxnet3_intr { | |||
311 | u8 num_intrs; /* # of intr vectors */ | 311 | u8 num_intrs; /* # of intr vectors */ |
312 | u8 event_intr_idx; /* idx of the intr vector for event */ | 312 | u8 event_intr_idx; /* idx of the intr vector for event */ |
313 | u8 mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */ | 313 | u8 mod_levels[VMXNET3_LINUX_MAX_MSIX_VECT]; /* moderation level */ |
314 | char event_msi_vector_name[IFNAMSIZ+11]; | 314 | char event_msi_vector_name[IFNAMSIZ+17]; |
315 | #ifdef CONFIG_PCI_MSI | 315 | #ifdef CONFIG_PCI_MSI |
316 | struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT]; | 316 | struct msix_entry msix_entries[VMXNET3_LINUX_MAX_MSIX_VECT]; |
317 | #endif | 317 | #endif |
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c index 6e2e760d98b1..0b75def39c6c 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c | |||
@@ -5704,7 +5704,7 @@ static void rt2800_init_freq_calibration(struct rt2x00_dev *rt2x00dev) | |||
5704 | 5704 | ||
5705 | static void rt2800_init_bbp_5592_glrt(struct rt2x00_dev *rt2x00dev) | 5705 | static void rt2800_init_bbp_5592_glrt(struct rt2x00_dev *rt2x00dev) |
5706 | { | 5706 | { |
5707 | const u8 glrt_table[] = { | 5707 | static const u8 glrt_table[] = { |
5708 | 0xE0, 0x1F, 0X38, 0x32, 0x08, 0x28, 0x19, 0x0A, 0xFF, 0x00, /* 128 ~ 137 */ | 5708 | 0xE0, 0x1F, 0X38, 0x32, 0x08, 0x28, 0x19, 0x0A, 0xFF, 0x00, /* 128 ~ 137 */ |
5709 | 0x16, 0x10, 0x10, 0x0B, 0x36, 0x2C, 0x26, 0x24, 0x42, 0x36, /* 138 ~ 147 */ | 5709 | 0x16, 0x10, 0x10, 0x0B, 0x36, 0x2C, 0x26, 0x24, 0x42, 0x36, /* 138 ~ 147 */ |
5710 | 0x30, 0x2D, 0x4C, 0x46, 0x3D, 0x40, 0x3E, 0x42, 0x3D, 0x40, /* 148 ~ 157 */ | 5710 | 0x30, 0x2D, 0x4C, 0x46, 0x3D, 0x40, 0x3E, 0x42, 0x3D, 0x40, /* 148 ~ 157 */ |
diff --git a/drivers/nvdimm/core.c b/drivers/nvdimm/core.c index 7cd99b1f8596..75bc08c6838c 100644 --- a/drivers/nvdimm/core.c +++ b/drivers/nvdimm/core.c | |||
@@ -421,14 +421,15 @@ static void set_badblock(struct badblocks *bb, sector_t s, int num) | |||
421 | static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len) | 421 | static void __add_badblock_range(struct badblocks *bb, u64 ns_offset, u64 len) |
422 | { | 422 | { |
423 | const unsigned int sector_size = 512; | 423 | const unsigned int sector_size = 512; |
424 | sector_t start_sector; | 424 | sector_t start_sector, end_sector; |
425 | u64 num_sectors; | 425 | u64 num_sectors; |
426 | u32 rem; | 426 | u32 rem; |
427 | 427 | ||
428 | start_sector = div_u64(ns_offset, sector_size); | 428 | start_sector = div_u64(ns_offset, sector_size); |
429 | num_sectors = div_u64_rem(len, sector_size, &rem); | 429 | end_sector = div_u64_rem(ns_offset + len, sector_size, &rem); |
430 | if (rem) | 430 | if (rem) |
431 | num_sectors++; | 431 | end_sector++; |
432 | num_sectors = end_sector - start_sector; | ||
432 | 433 | ||
433 | if (unlikely(num_sectors > (u64)INT_MAX)) { | 434 | if (unlikely(num_sectors > (u64)INT_MAX)) { |
434 | u64 remaining = num_sectors; | 435 | u64 remaining = num_sectors; |
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c index 077f62e208aa..6a4367cc9caa 100644 --- a/drivers/scsi/cxlflash/main.c +++ b/drivers/scsi/cxlflash/main.c | |||
@@ -3401,9 +3401,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, | |||
3401 | if (is_write) { | 3401 | if (is_write) { |
3402 | req_flags |= SISL_REQ_FLAGS_HOST_WRITE; | 3402 | req_flags |= SISL_REQ_FLAGS_HOST_WRITE; |
3403 | 3403 | ||
3404 | rc = copy_from_user(kbuf, ubuf, ulen); | 3404 | if (copy_from_user(kbuf, ubuf, ulen)) { |
3405 | if (unlikely(rc)) | 3405 | rc = -EFAULT; |
3406 | goto out; | 3406 | goto out; |
3407 | } | ||
3407 | } | 3408 | } |
3408 | } | 3409 | } |
3409 | 3410 | ||
@@ -3431,8 +3432,10 @@ static int cxlflash_afu_debug(struct cxlflash_cfg *cfg, | |||
3431 | goto out; | 3432 | goto out; |
3432 | } | 3433 | } |
3433 | 3434 | ||
3434 | if (ulen && !is_write) | 3435 | if (ulen && !is_write) { |
3435 | rc = copy_to_user(ubuf, kbuf, ulen); | 3436 | if (copy_to_user(ubuf, kbuf, ulen)) |
3437 | rc = -EFAULT; | ||
3438 | } | ||
3436 | out: | 3439 | out: |
3437 | kfree(buf); | 3440 | kfree(buf); |
3438 | dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); | 3441 | dev_dbg(dev, "%s: returning rc=%d\n", __func__, rc); |
diff --git a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c index 551d103c27f1..2bfea7082e3a 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | |||
@@ -1693,7 +1693,7 @@ static int prep_ssp_v2_hw(struct hisi_hba *hisi_hba, | |||
1693 | 1693 | ||
1694 | static int parse_trans_tx_err_code_v2_hw(u32 err_msk) | 1694 | static int parse_trans_tx_err_code_v2_hw(u32 err_msk) |
1695 | { | 1695 | { |
1696 | const u8 trans_tx_err_code_prio[] = { | 1696 | static const u8 trans_tx_err_code_prio[] = { |
1697 | TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, | 1697 | TRANS_TX_OPEN_FAIL_WITH_IT_NEXUS_LOSS, |
1698 | TRANS_TX_ERR_PHY_NOT_ENABLE, | 1698 | TRANS_TX_ERR_PHY_NOT_ENABLE, |
1699 | TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, | 1699 | TRANS_TX_OPEN_CNX_ERR_WRONG_DESTINATION, |
@@ -1738,7 +1738,7 @@ static int parse_trans_tx_err_code_v2_hw(u32 err_msk) | |||
1738 | 1738 | ||
1739 | static int parse_trans_rx_err_code_v2_hw(u32 err_msk) | 1739 | static int parse_trans_rx_err_code_v2_hw(u32 err_msk) |
1740 | { | 1740 | { |
1741 | const u8 trans_rx_err_code_prio[] = { | 1741 | static const u8 trans_rx_err_code_prio[] = { |
1742 | TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, | 1742 | TRANS_RX_ERR_WITH_RXFRAME_CRC_ERR, |
1743 | TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, | 1743 | TRANS_RX_ERR_WITH_RXFIS_8B10B_DISP_ERR, |
1744 | TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, | 1744 | TRANS_RX_ERR_WITH_RXFRAME_HAVE_ERRPRM, |
@@ -1784,7 +1784,7 @@ static int parse_trans_rx_err_code_v2_hw(u32 err_msk) | |||
1784 | 1784 | ||
1785 | static int parse_dma_tx_err_code_v2_hw(u32 err_msk) | 1785 | static int parse_dma_tx_err_code_v2_hw(u32 err_msk) |
1786 | { | 1786 | { |
1787 | const u8 dma_tx_err_code_prio[] = { | 1787 | static const u8 dma_tx_err_code_prio[] = { |
1788 | DMA_TX_UNEXP_XFER_ERR, | 1788 | DMA_TX_UNEXP_XFER_ERR, |
1789 | DMA_TX_UNEXP_RETRANS_ERR, | 1789 | DMA_TX_UNEXP_RETRANS_ERR, |
1790 | DMA_TX_XFER_LEN_OVERFLOW, | 1790 | DMA_TX_XFER_LEN_OVERFLOW, |
@@ -1810,7 +1810,7 @@ static int parse_dma_tx_err_code_v2_hw(u32 err_msk) | |||
1810 | 1810 | ||
1811 | static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) | 1811 | static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) |
1812 | { | 1812 | { |
1813 | const u8 sipc_rx_err_code_prio[] = { | 1813 | static const u8 sipc_rx_err_code_prio[] = { |
1814 | SIPC_RX_FIS_STATUS_ERR_BIT_VLD, | 1814 | SIPC_RX_FIS_STATUS_ERR_BIT_VLD, |
1815 | SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, | 1815 | SIPC_RX_PIO_WRSETUP_STATUS_DRQ_ERR, |
1816 | SIPC_RX_FIS_STATUS_BSY_BIT_ERR, | 1816 | SIPC_RX_FIS_STATUS_BSY_BIT_ERR, |
@@ -1836,7 +1836,7 @@ static int parse_sipc_rx_err_code_v2_hw(u32 err_msk) | |||
1836 | 1836 | ||
1837 | static int parse_dma_rx_err_code_v2_hw(u32 err_msk) | 1837 | static int parse_dma_rx_err_code_v2_hw(u32 err_msk) |
1838 | { | 1838 | { |
1839 | const u8 dma_rx_err_code_prio[] = { | 1839 | static const u8 dma_rx_err_code_prio[] = { |
1840 | DMA_RX_UNKNOWN_FRM_ERR, | 1840 | DMA_RX_UNKNOWN_FRM_ERR, |
1841 | DMA_RX_DATA_LEN_OVERFLOW, | 1841 | DMA_RX_DATA_LEN_OVERFLOW, |
1842 | DMA_RX_DATA_LEN_UNDERFLOW, | 1842 | DMA_RX_DATA_LEN_UNDERFLOW, |
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index 47f66e949745..ed197bc8e801 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -213,7 +213,7 @@ static void sci_task_request_build_ssp_task_iu(struct isci_request *ireq) | |||
213 | * @task_context: | 213 | * @task_context: |
214 | * | 214 | * |
215 | */ | 215 | */ |
216 | static void scu_ssp_reqeust_construct_task_context( | 216 | static void scu_ssp_request_construct_task_context( |
217 | struct isci_request *ireq, | 217 | struct isci_request *ireq, |
218 | struct scu_task_context *task_context) | 218 | struct scu_task_context *task_context) |
219 | { | 219 | { |
@@ -425,7 +425,7 @@ static void scu_ssp_io_request_construct_task_context(struct isci_request *ireq, | |||
425 | u8 prot_type = scsi_get_prot_type(scmd); | 425 | u8 prot_type = scsi_get_prot_type(scmd); |
426 | u8 prot_op = scsi_get_prot_op(scmd); | 426 | u8 prot_op = scsi_get_prot_op(scmd); |
427 | 427 | ||
428 | scu_ssp_reqeust_construct_task_context(ireq, task_context); | 428 | scu_ssp_request_construct_task_context(ireq, task_context); |
429 | 429 | ||
430 | task_context->ssp_command_iu_length = | 430 | task_context->ssp_command_iu_length = |
431 | sizeof(struct ssp_cmd_iu) / sizeof(u32); | 431 | sizeof(struct ssp_cmd_iu) / sizeof(u32); |
@@ -472,7 +472,7 @@ static void scu_ssp_task_request_construct_task_context(struct isci_request *ire | |||
472 | { | 472 | { |
473 | struct scu_task_context *task_context = ireq->tc; | 473 | struct scu_task_context *task_context = ireq->tc; |
474 | 474 | ||
475 | scu_ssp_reqeust_construct_task_context(ireq, task_context); | 475 | scu_ssp_request_construct_task_context(ireq, task_context); |
476 | 476 | ||
477 | task_context->control_frame = 1; | 477 | task_context->control_frame = 1; |
478 | task_context->priority = SCU_TASK_PRIORITY_HIGH; | 478 | task_context->priority = SCU_TASK_PRIORITY_HIGH; |
@@ -495,7 +495,7 @@ static void scu_ssp_task_request_construct_task_context(struct isci_request *ire | |||
495 | * the command buffer is complete. none Revisit task context construction to | 495 | * the command buffer is complete. none Revisit task context construction to |
496 | * determine what is common for SSP/SMP/STP task context structures. | 496 | * determine what is common for SSP/SMP/STP task context structures. |
497 | */ | 497 | */ |
498 | static void scu_sata_reqeust_construct_task_context( | 498 | static void scu_sata_request_construct_task_context( |
499 | struct isci_request *ireq, | 499 | struct isci_request *ireq, |
500 | struct scu_task_context *task_context) | 500 | struct scu_task_context *task_context) |
501 | { | 501 | { |
@@ -562,7 +562,7 @@ static void scu_stp_raw_request_construct_task_context(struct isci_request *ireq | |||
562 | { | 562 | { |
563 | struct scu_task_context *task_context = ireq->tc; | 563 | struct scu_task_context *task_context = ireq->tc; |
564 | 564 | ||
565 | scu_sata_reqeust_construct_task_context(ireq, task_context); | 565 | scu_sata_request_construct_task_context(ireq, task_context); |
566 | 566 | ||
567 | task_context->control_frame = 0; | 567 | task_context->control_frame = 0; |
568 | task_context->priority = SCU_TASK_PRIORITY_NORMAL; | 568 | task_context->priority = SCU_TASK_PRIORITY_NORMAL; |
@@ -613,7 +613,7 @@ static void sci_stp_optimized_request_construct(struct isci_request *ireq, | |||
613 | struct scu_task_context *task_context = ireq->tc; | 613 | struct scu_task_context *task_context = ireq->tc; |
614 | 614 | ||
615 | /* Build the STP task context structure */ | 615 | /* Build the STP task context structure */ |
616 | scu_sata_reqeust_construct_task_context(ireq, task_context); | 616 | scu_sata_request_construct_task_context(ireq, task_context); |
617 | 617 | ||
618 | /* Copy over the SGL elements */ | 618 | /* Copy over the SGL elements */ |
619 | sci_request_build_sgl(ireq); | 619 | sci_request_build_sgl(ireq); |
@@ -1401,7 +1401,7 @@ static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_re | |||
1401 | * @data_buffer: The buffer of data to be copied. | 1401 | * @data_buffer: The buffer of data to be copied. |
1402 | * @length: The length of the data transfer. | 1402 | * @length: The length of the data transfer. |
1403 | * | 1403 | * |
1404 | * Copy the data from the buffer for the length specified to the IO reqeust SGL | 1404 | * Copy the data from the buffer for the length specified to the IO request SGL |
1405 | * specified data region. enum sci_status | 1405 | * specified data region. enum sci_status |
1406 | */ | 1406 | */ |
1407 | static enum sci_status | 1407 | static enum sci_status |
diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index fd501f8dbb11..8660f923ace0 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c | |||
@@ -573,7 +573,7 @@ static void fc_disc_gpn_ft_resp(struct fc_seq *sp, struct fc_frame *fp, | |||
573 | event = DISC_EV_FAILED; | 573 | event = DISC_EV_FAILED; |
574 | } | 574 | } |
575 | if (error) | 575 | if (error) |
576 | fc_disc_error(disc, fp); | 576 | fc_disc_error(disc, ERR_PTR(error)); |
577 | else if (event != DISC_EV_NONE) | 577 | else if (event != DISC_EV_NONE) |
578 | fc_disc_done(disc, event); | 578 | fc_disc_done(disc, event); |
579 | fc_frame_free(fp); | 579 | fc_frame_free(fp); |
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c index b58bba4604e8..7786c97e033f 100644 --- a/drivers/scsi/qedf/qedf_main.c +++ b/drivers/scsi/qedf/qedf_main.c | |||
@@ -1227,7 +1227,7 @@ static void qedf_rport_event_handler(struct fc_lport *lport, | |||
1227 | 1227 | ||
1228 | if (rdata->spp_type != FC_TYPE_FCP) { | 1228 | if (rdata->spp_type != FC_TYPE_FCP) { |
1229 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, | 1229 | QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_DISC, |
1230 | "Not offlading since since spp type isn't FCP\n"); | 1230 | "Not offloading since spp type isn't FCP\n"); |
1231 | break; | 1231 | break; |
1232 | } | 1232 | } |
1233 | if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) { | 1233 | if (!(rdata->ids.roles & FC_RPORT_ROLE_FCP_TARGET)) { |
diff --git a/drivers/scsi/qedi/qedi.h b/drivers/scsi/qedi/qedi.h index 32632c9b2276..91d2f51c351b 100644 --- a/drivers/scsi/qedi/qedi.h +++ b/drivers/scsi/qedi/qedi.h | |||
@@ -23,11 +23,17 @@ | |||
23 | #include <linux/qed/qed_iscsi_if.h> | 23 | #include <linux/qed/qed_iscsi_if.h> |
24 | #include <linux/qed/qed_ll2_if.h> | 24 | #include <linux/qed/qed_ll2_if.h> |
25 | #include "qedi_version.h" | 25 | #include "qedi_version.h" |
26 | #include "qedi_nvm_iscsi_cfg.h" | ||
26 | 27 | ||
27 | #define QEDI_MODULE_NAME "qedi" | 28 | #define QEDI_MODULE_NAME "qedi" |
28 | 29 | ||
29 | struct qedi_endpoint; | 30 | struct qedi_endpoint; |
30 | 31 | ||
32 | #ifndef GET_FIELD2 | ||
33 | #define GET_FIELD2(value, name) \ | ||
34 | (((value) & (name ## _MASK)) >> (name ## _OFFSET)) | ||
35 | #endif | ||
36 | |||
31 | /* | 37 | /* |
32 | * PCI function probe defines | 38 | * PCI function probe defines |
33 | */ | 39 | */ |
@@ -66,6 +72,11 @@ struct qedi_endpoint; | |||
66 | #define QEDI_HW_DMA_BOUNDARY 0xfff | 72 | #define QEDI_HW_DMA_BOUNDARY 0xfff |
67 | #define QEDI_PATH_HANDLE 0xFE0000000UL | 73 | #define QEDI_PATH_HANDLE 0xFE0000000UL |
68 | 74 | ||
75 | enum qedi_nvm_tgts { | ||
76 | QEDI_NVM_TGT_PRI, | ||
77 | QEDI_NVM_TGT_SEC, | ||
78 | }; | ||
79 | |||
69 | struct qedi_uio_ctrl { | 80 | struct qedi_uio_ctrl { |
70 | /* meta data */ | 81 | /* meta data */ |
71 | u32 uio_hsi_version; | 82 | u32 uio_hsi_version; |
@@ -283,6 +294,8 @@ struct qedi_ctx { | |||
283 | void *bdq_pbl_list; | 294 | void *bdq_pbl_list; |
284 | dma_addr_t bdq_pbl_list_dma; | 295 | dma_addr_t bdq_pbl_list_dma; |
285 | u8 bdq_pbl_list_num_entries; | 296 | u8 bdq_pbl_list_num_entries; |
297 | struct nvm_iscsi_cfg *iscsi_cfg; | ||
298 | dma_addr_t nvm_buf_dma; | ||
286 | void __iomem *bdq_primary_prod; | 299 | void __iomem *bdq_primary_prod; |
287 | void __iomem *bdq_secondary_prod; | 300 | void __iomem *bdq_secondary_prod; |
288 | u16 bdq_prod_idx; | 301 | u16 bdq_prod_idx; |
@@ -337,6 +350,10 @@ struct qedi_ctx { | |||
337 | bool use_fast_sge; | 350 | bool use_fast_sge; |
338 | 351 | ||
339 | atomic_t num_offloads; | 352 | atomic_t num_offloads; |
353 | #define SYSFS_FLAG_FW_SEL_BOOT 2 | ||
354 | #define IPV6_LEN 41 | ||
355 | #define IPV4_LEN 17 | ||
356 | struct iscsi_boot_kset *boot_kset; | ||
340 | }; | 357 | }; |
341 | 358 | ||
342 | struct qedi_work { | 359 | struct qedi_work { |
diff --git a/drivers/scsi/qedi/qedi_fw.c b/drivers/scsi/qedi/qedi_fw.c index 19254bd739d9..93d54acd4a22 100644 --- a/drivers/scsi/qedi/qedi_fw.c +++ b/drivers/scsi/qedi/qedi_fw.c | |||
@@ -1411,7 +1411,7 @@ static void qedi_tmf_work(struct work_struct *work) | |||
1411 | 1411 | ||
1412 | list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); | 1412 | list_work = kzalloc(sizeof(*list_work), GFP_ATOMIC); |
1413 | if (!list_work) { | 1413 | if (!list_work) { |
1414 | QEDI_ERR(&qedi->dbg_ctx, "Memory alloction failed\n"); | 1414 | QEDI_ERR(&qedi->dbg_ctx, "Memory allocation failed\n"); |
1415 | goto abort_ret; | 1415 | goto abort_ret; |
1416 | } | 1416 | } |
1417 | 1417 | ||
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 5f5a4ef2e529..2c3783684815 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/mm.h> | 19 | #include <linux/mm.h> |
20 | #include <linux/if_vlan.h> | 20 | #include <linux/if_vlan.h> |
21 | #include <linux/cpu.h> | 21 | #include <linux/cpu.h> |
22 | #include <linux/iscsi_boot_sysfs.h> | ||
22 | 23 | ||
23 | #include <scsi/scsi_cmnd.h> | 24 | #include <scsi/scsi_cmnd.h> |
24 | #include <scsi/scsi_device.h> | 25 | #include <scsi/scsi_device.h> |
@@ -1143,6 +1144,30 @@ exit_setup_int: | |||
1143 | return rc; | 1144 | return rc; |
1144 | } | 1145 | } |
1145 | 1146 | ||
1147 | static void qedi_free_nvm_iscsi_cfg(struct qedi_ctx *qedi) | ||
1148 | { | ||
1149 | if (qedi->iscsi_cfg) | ||
1150 | dma_free_coherent(&qedi->pdev->dev, | ||
1151 | sizeof(struct nvm_iscsi_cfg), | ||
1152 | qedi->iscsi_cfg, qedi->nvm_buf_dma); | ||
1153 | } | ||
1154 | |||
1155 | static int qedi_alloc_nvm_iscsi_cfg(struct qedi_ctx *qedi) | ||
1156 | { | ||
1157 | qedi->iscsi_cfg = dma_zalloc_coherent(&qedi->pdev->dev, | ||
1158 | sizeof(struct nvm_iscsi_cfg), | ||
1159 | &qedi->nvm_buf_dma, GFP_KERNEL); | ||
1160 | if (!qedi->iscsi_cfg) { | ||
1161 | QEDI_ERR(&qedi->dbg_ctx, "Could not allocate NVM BUF.\n"); | ||
1162 | return -ENOMEM; | ||
1163 | } | ||
1164 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | ||
1165 | "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_cfg, | ||
1166 | qedi->nvm_buf_dma); | ||
1167 | |||
1168 | return 0; | ||
1169 | } | ||
1170 | |||
1146 | static void qedi_free_bdq(struct qedi_ctx *qedi) | 1171 | static void qedi_free_bdq(struct qedi_ctx *qedi) |
1147 | { | 1172 | { |
1148 | int i; | 1173 | int i; |
@@ -1183,6 +1208,7 @@ static void qedi_free_global_queues(struct qedi_ctx *qedi) | |||
1183 | kfree(gl[i]); | 1208 | kfree(gl[i]); |
1184 | } | 1209 | } |
1185 | qedi_free_bdq(qedi); | 1210 | qedi_free_bdq(qedi); |
1211 | qedi_free_nvm_iscsi_cfg(qedi); | ||
1186 | } | 1212 | } |
1187 | 1213 | ||
1188 | static int qedi_alloc_bdq(struct qedi_ctx *qedi) | 1214 | static int qedi_alloc_bdq(struct qedi_ctx *qedi) |
@@ -1309,6 +1335,11 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi) | |||
1309 | if (rc) | 1335 | if (rc) |
1310 | goto mem_alloc_failure; | 1336 | goto mem_alloc_failure; |
1311 | 1337 | ||
1338 | /* Allocate DMA coherent buffers for NVM_ISCSI_CFG */ | ||
1339 | rc = qedi_alloc_nvm_iscsi_cfg(qedi); | ||
1340 | if (rc) | ||
1341 | goto mem_alloc_failure; | ||
1342 | |||
1312 | /* Allocate a CQ and an associated PBL for each MSI-X | 1343 | /* Allocate a CQ and an associated PBL for each MSI-X |
1313 | * vector. | 1344 | * vector. |
1314 | */ | 1345 | */ |
@@ -1671,6 +1702,387 @@ void qedi_reset_host_mtu(struct qedi_ctx *qedi, u16 mtu) | |||
1671 | qedi_ops->ll2->start(qedi->cdev, ¶ms); | 1702 | qedi_ops->ll2->start(qedi->cdev, ¶ms); |
1672 | } | 1703 | } |
1673 | 1704 | ||
1705 | /** | ||
1706 | * qedi_get_nvram_block: - Scan through the iSCSI NVRAM block (while accounting | ||
1707 | * for gaps) for the matching absolute-pf-id of the QEDI device. | ||
1708 | */ | ||
1709 | static struct nvm_iscsi_block * | ||
1710 | qedi_get_nvram_block(struct qedi_ctx *qedi) | ||
1711 | { | ||
1712 | int i; | ||
1713 | u8 pf; | ||
1714 | u32 flags; | ||
1715 | struct nvm_iscsi_block *block; | ||
1716 | |||
1717 | pf = qedi->dev_info.common.abs_pf_id; | ||
1718 | block = &qedi->iscsi_cfg->block[0]; | ||
1719 | for (i = 0; i < NUM_OF_ISCSI_PF_SUPPORTED; i++, block++) { | ||
1720 | flags = ((block->id) & NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK) >> | ||
1721 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET; | ||
1722 | if (flags & (NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY | | ||
1723 | NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED) && | ||
1724 | (pf == (block->id & NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK) | ||
1725 | >> NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET)) | ||
1726 | return block; | ||
1727 | } | ||
1728 | return NULL; | ||
1729 | } | ||
1730 | |||
1731 | static ssize_t qedi_show_boot_eth_info(void *data, int type, char *buf) | ||
1732 | { | ||
1733 | struct qedi_ctx *qedi = data; | ||
1734 | struct nvm_iscsi_initiator *initiator; | ||
1735 | char *str = buf; | ||
1736 | int rc = 1; | ||
1737 | u32 ipv6_en, dhcp_en, ip_len; | ||
1738 | struct nvm_iscsi_block *block; | ||
1739 | char *fmt, *ip, *sub, *gw; | ||
1740 | |||
1741 | block = qedi_get_nvram_block(qedi); | ||
1742 | if (!block) | ||
1743 | return 0; | ||
1744 | |||
1745 | initiator = &block->initiator; | ||
1746 | ipv6_en = block->generic.ctrl_flags & | ||
1747 | NVM_ISCSI_CFG_GEN_IPV6_ENABLED; | ||
1748 | dhcp_en = block->generic.ctrl_flags & | ||
1749 | NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED; | ||
1750 | /* Static IP assignments. */ | ||
1751 | fmt = ipv6_en ? "%pI6\n" : "%pI4\n"; | ||
1752 | ip = ipv6_en ? initiator->ipv6.addr.byte : initiator->ipv4.addr.byte; | ||
1753 | ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; | ||
1754 | sub = ipv6_en ? initiator->ipv6.subnet_mask.byte : | ||
1755 | initiator->ipv4.subnet_mask.byte; | ||
1756 | gw = ipv6_en ? initiator->ipv6.gateway.byte : | ||
1757 | initiator->ipv4.gateway.byte; | ||
1758 | /* DHCP IP adjustments. */ | ||
1759 | fmt = dhcp_en ? "%s\n" : fmt; | ||
1760 | if (dhcp_en) { | ||
1761 | ip = ipv6_en ? "0::0" : "0.0.0.0"; | ||
1762 | sub = ip; | ||
1763 | gw = ip; | ||
1764 | ip_len = ipv6_en ? 5 : 8; | ||
1765 | } | ||
1766 | |||
1767 | switch (type) { | ||
1768 | case ISCSI_BOOT_ETH_IP_ADDR: | ||
1769 | rc = snprintf(str, ip_len, fmt, ip); | ||
1770 | break; | ||
1771 | case ISCSI_BOOT_ETH_SUBNET_MASK: | ||
1772 | rc = snprintf(str, ip_len, fmt, sub); | ||
1773 | break; | ||
1774 | case ISCSI_BOOT_ETH_GATEWAY: | ||
1775 | rc = snprintf(str, ip_len, fmt, gw); | ||
1776 | break; | ||
1777 | case ISCSI_BOOT_ETH_FLAGS: | ||
1778 | rc = snprintf(str, 3, "%hhd\n", | ||
1779 | SYSFS_FLAG_FW_SEL_BOOT); | ||
1780 | break; | ||
1781 | case ISCSI_BOOT_ETH_INDEX: | ||
1782 | rc = snprintf(str, 3, "0\n"); | ||
1783 | break; | ||
1784 | case ISCSI_BOOT_ETH_MAC: | ||
1785 | rc = sysfs_format_mac(str, qedi->mac, ETH_ALEN); | ||
1786 | break; | ||
1787 | case ISCSI_BOOT_ETH_VLAN: | ||
1788 | rc = snprintf(str, 12, "%d\n", | ||
1789 | GET_FIELD2(initiator->generic_cont0, | ||
1790 | NVM_ISCSI_CFG_INITIATOR_VLAN)); | ||
1791 | break; | ||
1792 | case ISCSI_BOOT_ETH_ORIGIN: | ||
1793 | if (dhcp_en) | ||
1794 | rc = snprintf(str, 3, "3\n"); | ||
1795 | break; | ||
1796 | default: | ||
1797 | rc = 0; | ||
1798 | break; | ||
1799 | } | ||
1800 | |||
1801 | return rc; | ||
1802 | } | ||
1803 | |||
1804 | static umode_t qedi_eth_get_attr_visibility(void *data, int type) | ||
1805 | { | ||
1806 | int rc = 1; | ||
1807 | |||
1808 | switch (type) { | ||
1809 | case ISCSI_BOOT_ETH_FLAGS: | ||
1810 | case ISCSI_BOOT_ETH_MAC: | ||
1811 | case ISCSI_BOOT_ETH_INDEX: | ||
1812 | case ISCSI_BOOT_ETH_IP_ADDR: | ||
1813 | case ISCSI_BOOT_ETH_SUBNET_MASK: | ||
1814 | case ISCSI_BOOT_ETH_GATEWAY: | ||
1815 | case ISCSI_BOOT_ETH_ORIGIN: | ||
1816 | case ISCSI_BOOT_ETH_VLAN: | ||
1817 | rc = 0444; | ||
1818 | break; | ||
1819 | default: | ||
1820 | rc = 0; | ||
1821 | break; | ||
1822 | } | ||
1823 | return rc; | ||
1824 | } | ||
1825 | |||
1826 | static ssize_t qedi_show_boot_ini_info(void *data, int type, char *buf) | ||
1827 | { | ||
1828 | struct qedi_ctx *qedi = data; | ||
1829 | struct nvm_iscsi_initiator *initiator; | ||
1830 | char *str = buf; | ||
1831 | int rc; | ||
1832 | struct nvm_iscsi_block *block; | ||
1833 | |||
1834 | block = qedi_get_nvram_block(qedi); | ||
1835 | if (!block) | ||
1836 | return 0; | ||
1837 | |||
1838 | initiator = &block->initiator; | ||
1839 | |||
1840 | switch (type) { | ||
1841 | case ISCSI_BOOT_INI_INITIATOR_NAME: | ||
1842 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | ||
1843 | initiator->initiator_name.byte); | ||
1844 | break; | ||
1845 | default: | ||
1846 | rc = 0; | ||
1847 | break; | ||
1848 | } | ||
1849 | return rc; | ||
1850 | } | ||
1851 | |||
1852 | static umode_t qedi_ini_get_attr_visibility(void *data, int type) | ||
1853 | { | ||
1854 | int rc; | ||
1855 | |||
1856 | switch (type) { | ||
1857 | case ISCSI_BOOT_INI_INITIATOR_NAME: | ||
1858 | rc = 0444; | ||
1859 | break; | ||
1860 | default: | ||
1861 | rc = 0; | ||
1862 | break; | ||
1863 | } | ||
1864 | return rc; | ||
1865 | } | ||
1866 | |||
1867 | static ssize_t | ||
1868 | qedi_show_boot_tgt_info(struct qedi_ctx *qedi, int type, | ||
1869 | char *buf, enum qedi_nvm_tgts idx) | ||
1870 | { | ||
1871 | char *str = buf; | ||
1872 | int rc = 1; | ||
1873 | u32 ctrl_flags, ipv6_en, chap_en, mchap_en, ip_len; | ||
1874 | struct nvm_iscsi_block *block; | ||
1875 | char *chap_name, *chap_secret; | ||
1876 | char *mchap_name, *mchap_secret; | ||
1877 | |||
1878 | block = qedi_get_nvram_block(qedi); | ||
1879 | if (!block) | ||
1880 | goto exit_show_tgt_info; | ||
1881 | |||
1882 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, | ||
1883 | "Port:%d, tgt_idx:%d\n", | ||
1884 | GET_FIELD2(block->id, NVM_ISCSI_CFG_BLK_MAPPED_PF_ID), idx); | ||
1885 | |||
1886 | ctrl_flags = block->target[idx].ctrl_flags & | ||
1887 | NVM_ISCSI_CFG_TARGET_ENABLED; | ||
1888 | |||
1889 | if (!ctrl_flags) { | ||
1890 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_EVT, | ||
1891 | "Target disabled\n"); | ||
1892 | goto exit_show_tgt_info; | ||
1893 | } | ||
1894 | |||
1895 | ipv6_en = block->generic.ctrl_flags & | ||
1896 | NVM_ISCSI_CFG_GEN_IPV6_ENABLED; | ||
1897 | ip_len = ipv6_en ? IPV6_LEN : IPV4_LEN; | ||
1898 | chap_en = block->generic.ctrl_flags & | ||
1899 | NVM_ISCSI_CFG_GEN_CHAP_ENABLED; | ||
1900 | chap_name = chap_en ? block->initiator.chap_name.byte : NULL; | ||
1901 | chap_secret = chap_en ? block->initiator.chap_password.byte : NULL; | ||
1902 | |||
1903 | mchap_en = block->generic.ctrl_flags & | ||
1904 | NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED; | ||
1905 | mchap_name = mchap_en ? block->target[idx].chap_name.byte : NULL; | ||
1906 | mchap_secret = mchap_en ? block->target[idx].chap_password.byte : NULL; | ||
1907 | |||
1908 | switch (type) { | ||
1909 | case ISCSI_BOOT_TGT_NAME: | ||
1910 | rc = snprintf(str, NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN, "%s\n", | ||
1911 | block->target[idx].target_name.byte); | ||
1912 | break; | ||
1913 | case ISCSI_BOOT_TGT_IP_ADDR: | ||
1914 | if (ipv6_en) | ||
1915 | rc = snprintf(str, ip_len, "%pI6\n", | ||
1916 | block->target[idx].ipv6_addr.byte); | ||
1917 | else | ||
1918 | rc = snprintf(str, ip_len, "%pI4\n", | ||
1919 | block->target[idx].ipv4_addr.byte); | ||
1920 | break; | ||
1921 | case ISCSI_BOOT_TGT_PORT: | ||
1922 | rc = snprintf(str, 12, "%d\n", | ||
1923 | GET_FIELD2(block->target[idx].generic_cont0, | ||
1924 | NVM_ISCSI_CFG_TARGET_TCP_PORT)); | ||
1925 | break; | ||
1926 | case ISCSI_BOOT_TGT_LUN: | ||
1927 | rc = snprintf(str, 22, "%.*d\n", | ||
1928 | block->target[idx].lun.value[1], | ||
1929 | block->target[idx].lun.value[0]); | ||
1930 | break; | ||
1931 | case ISCSI_BOOT_TGT_CHAP_NAME: | ||
1932 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | ||
1933 | chap_name); | ||
1934 | break; | ||
1935 | case ISCSI_BOOT_TGT_CHAP_SECRET: | ||
1936 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | ||
1937 | chap_secret); | ||
1938 | break; | ||
1939 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | ||
1940 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN, "%s\n", | ||
1941 | mchap_name); | ||
1942 | break; | ||
1943 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | ||
1944 | rc = snprintf(str, NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN, "%s\n", | ||
1945 | mchap_secret); | ||
1946 | break; | ||
1947 | case ISCSI_BOOT_TGT_FLAGS: | ||
1948 | rc = snprintf(str, 3, "%hhd\n", SYSFS_FLAG_FW_SEL_BOOT); | ||
1949 | break; | ||
1950 | case ISCSI_BOOT_TGT_NIC_ASSOC: | ||
1951 | rc = snprintf(str, 3, "0\n"); | ||
1952 | break; | ||
1953 | default: | ||
1954 | rc = 0; | ||
1955 | break; | ||
1956 | } | ||
1957 | |||
1958 | exit_show_tgt_info: | ||
1959 | return rc; | ||
1960 | } | ||
1961 | |||
1962 | static ssize_t qedi_show_boot_tgt_pri_info(void *data, int type, char *buf) | ||
1963 | { | ||
1964 | struct qedi_ctx *qedi = data; | ||
1965 | |||
1966 | return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_PRI); | ||
1967 | } | ||
1968 | |||
1969 | static ssize_t qedi_show_boot_tgt_sec_info(void *data, int type, char *buf) | ||
1970 | { | ||
1971 | struct qedi_ctx *qedi = data; | ||
1972 | |||
1973 | return qedi_show_boot_tgt_info(qedi, type, buf, QEDI_NVM_TGT_SEC); | ||
1974 | } | ||
1975 | |||
1976 | static umode_t qedi_tgt_get_attr_visibility(void *data, int type) | ||
1977 | { | ||
1978 | int rc; | ||
1979 | |||
1980 | switch (type) { | ||
1981 | case ISCSI_BOOT_TGT_NAME: | ||
1982 | case ISCSI_BOOT_TGT_IP_ADDR: | ||
1983 | case ISCSI_BOOT_TGT_PORT: | ||
1984 | case ISCSI_BOOT_TGT_LUN: | ||
1985 | case ISCSI_BOOT_TGT_CHAP_NAME: | ||
1986 | case ISCSI_BOOT_TGT_CHAP_SECRET: | ||
1987 | case ISCSI_BOOT_TGT_REV_CHAP_NAME: | ||
1988 | case ISCSI_BOOT_TGT_REV_CHAP_SECRET: | ||
1989 | case ISCSI_BOOT_TGT_NIC_ASSOC: | ||
1990 | case ISCSI_BOOT_TGT_FLAGS: | ||
1991 | rc = 0444; | ||
1992 | break; | ||
1993 | default: | ||
1994 | rc = 0; | ||
1995 | break; | ||
1996 | } | ||
1997 | return rc; | ||
1998 | } | ||
1999 | |||
2000 | static void qedi_boot_release(void *data) | ||
2001 | { | ||
2002 | struct qedi_ctx *qedi = data; | ||
2003 | |||
2004 | scsi_host_put(qedi->shost); | ||
2005 | } | ||
2006 | |||
2007 | static int qedi_get_boot_info(struct qedi_ctx *qedi) | ||
2008 | { | ||
2009 | int ret = 1; | ||
2010 | u16 len; | ||
2011 | |||
2012 | len = sizeof(struct nvm_iscsi_cfg); | ||
2013 | |||
2014 | QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO, | ||
2015 | "Get NVM iSCSI CFG image\n"); | ||
2016 | ret = qedi_ops->common->nvm_get_image(qedi->cdev, | ||
2017 | QED_NVM_IMAGE_ISCSI_CFG, | ||
2018 | (char *)qedi->iscsi_cfg, len); | ||
2019 | if (ret) | ||
2020 | QEDI_ERR(&qedi->dbg_ctx, | ||
2021 | "Could not get NVM image. ret = %d\n", ret); | ||
2022 | |||
2023 | return ret; | ||
2024 | } | ||
2025 | |||
2026 | static int qedi_setup_boot_info(struct qedi_ctx *qedi) | ||
2027 | { | ||
2028 | struct iscsi_boot_kobj *boot_kobj; | ||
2029 | |||
2030 | if (qedi_get_boot_info(qedi)) | ||
2031 | return -EPERM; | ||
2032 | |||
2033 | qedi->boot_kset = iscsi_boot_create_host_kset(qedi->shost->host_no); | ||
2034 | if (!qedi->boot_kset) | ||
2035 | goto kset_free; | ||
2036 | |||
2037 | if (!scsi_host_get(qedi->shost)) | ||
2038 | goto kset_free; | ||
2039 | |||
2040 | boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 0, qedi, | ||
2041 | qedi_show_boot_tgt_pri_info, | ||
2042 | qedi_tgt_get_attr_visibility, | ||
2043 | qedi_boot_release); | ||
2044 | if (!boot_kobj) | ||
2045 | goto put_host; | ||
2046 | |||
2047 | if (!scsi_host_get(qedi->shost)) | ||
2048 | goto kset_free; | ||
2049 | |||
2050 | boot_kobj = iscsi_boot_create_target(qedi->boot_kset, 1, qedi, | ||
2051 | qedi_show_boot_tgt_sec_info, | ||
2052 | qedi_tgt_get_attr_visibility, | ||
2053 | qedi_boot_release); | ||
2054 | if (!boot_kobj) | ||
2055 | goto put_host; | ||
2056 | |||
2057 | if (!scsi_host_get(qedi->shost)) | ||
2058 | goto kset_free; | ||
2059 | |||
2060 | boot_kobj = iscsi_boot_create_initiator(qedi->boot_kset, 0, qedi, | ||
2061 | qedi_show_boot_ini_info, | ||
2062 | qedi_ini_get_attr_visibility, | ||
2063 | qedi_boot_release); | ||
2064 | if (!boot_kobj) | ||
2065 | goto put_host; | ||
2066 | |||
2067 | if (!scsi_host_get(qedi->shost)) | ||
2068 | goto kset_free; | ||
2069 | |||
2070 | boot_kobj = iscsi_boot_create_ethernet(qedi->boot_kset, 0, qedi, | ||
2071 | qedi_show_boot_eth_info, | ||
2072 | qedi_eth_get_attr_visibility, | ||
2073 | qedi_boot_release); | ||
2074 | if (!boot_kobj) | ||
2075 | goto put_host; | ||
2076 | |||
2077 | return 0; | ||
2078 | |||
2079 | put_host: | ||
2080 | scsi_host_put(qedi->shost); | ||
2081 | kset_free: | ||
2082 | iscsi_boot_destroy_kset(qedi->boot_kset); | ||
2083 | return -ENOMEM; | ||
2084 | } | ||
2085 | |||
1674 | static void __qedi_remove(struct pci_dev *pdev, int mode) | 2086 | static void __qedi_remove(struct pci_dev *pdev, int mode) |
1675 | { | 2087 | { |
1676 | struct qedi_ctx *qedi = pci_get_drvdata(pdev); | 2088 | struct qedi_ctx *qedi = pci_get_drvdata(pdev); |
@@ -1724,6 +2136,9 @@ static void __qedi_remove(struct pci_dev *pdev, int mode) | |||
1724 | qedi->ll2_recv_thread = NULL; | 2136 | qedi->ll2_recv_thread = NULL; |
1725 | } | 2137 | } |
1726 | qedi_ll2_free_skbs(qedi); | 2138 | qedi_ll2_free_skbs(qedi); |
2139 | |||
2140 | if (qedi->boot_kset) | ||
2141 | iscsi_boot_destroy_kset(qedi->boot_kset); | ||
1727 | } | 2142 | } |
1728 | } | 2143 | } |
1729 | 2144 | ||
@@ -1967,6 +2382,10 @@ static int __qedi_probe(struct pci_dev *pdev, int mode) | |||
1967 | /* F/w needs 1st task context memory entry for performance */ | 2382 | /* F/w needs 1st task context memory entry for performance */ |
1968 | set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); | 2383 | set_bit(QEDI_RESERVE_TASK_ID, qedi->task_idx_map); |
1969 | atomic_set(&qedi->num_offloads, 0); | 2384 | atomic_set(&qedi->num_offloads, 0); |
2385 | |||
2386 | if (qedi_setup_boot_info(qedi)) | ||
2387 | QEDI_ERR(&qedi->dbg_ctx, | ||
2388 | "No iSCSI boot target configured\n"); | ||
1970 | } | 2389 | } |
1971 | 2390 | ||
1972 | return 0; | 2391 | return 0; |
diff --git a/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h b/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h new file mode 100644 index 000000000000..df39b69b366d --- /dev/null +++ b/drivers/scsi/qedi/qedi_nvm_iscsi_cfg.h | |||
@@ -0,0 +1,210 @@ | |||
1 | /* | ||
2 | * QLogic iSCSI Offload Driver | ||
3 | * Copyright (c) 2016 Cavium Inc. | ||
4 | * | ||
5 | * This software is available under the terms of the GNU General Public License | ||
6 | * (GPL) Version 2, available from the file COPYING in the main directory of | ||
7 | * this source tree. | ||
8 | */ | ||
9 | |||
10 | #ifndef NVM_ISCSI_CFG_H | ||
11 | #define NVM_ISCSI_CFG_H | ||
12 | |||
13 | #define NUM_OF_ISCSI_TARGET_PER_PF 4 /* Defined as per the | ||
14 | * ISCSI IBFT constraint | ||
15 | */ | ||
16 | #define NUM_OF_ISCSI_PF_SUPPORTED 4 /* One PF per Port - | ||
17 | * assuming 4 port card | ||
18 | */ | ||
19 | |||
20 | #define NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN 256 | ||
21 | |||
22 | union nvm_iscsi_dhcp_vendor_id { | ||
23 | u32 value[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN / 4]; | ||
24 | u8 byte[NVM_ISCSI_CFG_DHCP_NAME_MAX_LEN]; | ||
25 | }; | ||
26 | |||
27 | #define NVM_ISCSI_IPV4_ADDR_BYTE_LEN 4 | ||
28 | union nvm_iscsi_ipv4_addr { | ||
29 | u32 addr; | ||
30 | u8 byte[NVM_ISCSI_IPV4_ADDR_BYTE_LEN]; | ||
31 | }; | ||
32 | |||
33 | #define NVM_ISCSI_IPV6_ADDR_BYTE_LEN 16 | ||
34 | union nvm_iscsi_ipv6_addr { | ||
35 | u32 addr[4]; | ||
36 | u8 byte[NVM_ISCSI_IPV6_ADDR_BYTE_LEN]; | ||
37 | }; | ||
38 | |||
39 | struct nvm_iscsi_initiator_ipv4 { | ||
40 | union nvm_iscsi_ipv4_addr addr; /* 0x0 */ | ||
41 | union nvm_iscsi_ipv4_addr subnet_mask; /* 0x4 */ | ||
42 | union nvm_iscsi_ipv4_addr gateway; /* 0x8 */ | ||
43 | union nvm_iscsi_ipv4_addr primary_dns; /* 0xC */ | ||
44 | union nvm_iscsi_ipv4_addr secondary_dns; /* 0x10 */ | ||
45 | union nvm_iscsi_ipv4_addr dhcp_addr; /* 0x14 */ | ||
46 | |||
47 | union nvm_iscsi_ipv4_addr isns_server; /* 0x18 */ | ||
48 | union nvm_iscsi_ipv4_addr slp_server; /* 0x1C */ | ||
49 | union nvm_iscsi_ipv4_addr primay_radius_server; /* 0x20 */ | ||
50 | union nvm_iscsi_ipv4_addr secondary_radius_server; /* 0x24 */ | ||
51 | |||
52 | union nvm_iscsi_ipv4_addr rsvd[4]; /* 0x28 */ | ||
53 | }; | ||
54 | |||
55 | struct nvm_iscsi_initiator_ipv6 { | ||
56 | union nvm_iscsi_ipv6_addr addr; /* 0x0 */ | ||
57 | union nvm_iscsi_ipv6_addr subnet_mask; /* 0x10 */ | ||
58 | union nvm_iscsi_ipv6_addr gateway; /* 0x20 */ | ||
59 | union nvm_iscsi_ipv6_addr primary_dns; /* 0x30 */ | ||
60 | union nvm_iscsi_ipv6_addr secondary_dns; /* 0x40 */ | ||
61 | union nvm_iscsi_ipv6_addr dhcp_addr; /* 0x50 */ | ||
62 | |||
63 | union nvm_iscsi_ipv6_addr isns_server; /* 0x60 */ | ||
64 | union nvm_iscsi_ipv6_addr slp_server; /* 0x70 */ | ||
65 | union nvm_iscsi_ipv6_addr primay_radius_server; /* 0x80 */ | ||
66 | union nvm_iscsi_ipv6_addr secondary_radius_server; /* 0x90 */ | ||
67 | |||
68 | union nvm_iscsi_ipv6_addr rsvd[3]; /* 0xA0 */ | ||
69 | |||
70 | u32 config; /* 0xD0 */ | ||
71 | #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_MASK 0x000000FF | ||
72 | #define NVM_ISCSI_CFG_INITIATOR_IPV6_SUBNET_MASK_PREFIX_OFFSET 0 | ||
73 | |||
74 | u32 rsvd_1[3]; | ||
75 | }; | ||
76 | |||
77 | #define NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN 256 | ||
78 | union nvm_iscsi_name { | ||
79 | u32 value[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN / 4]; | ||
80 | u8 byte[NVM_ISCSI_CFG_ISCSI_NAME_MAX_LEN]; | ||
81 | }; | ||
82 | |||
83 | #define NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN 256 | ||
84 | union nvm_iscsi_chap_name { | ||
85 | u32 value[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN / 4]; | ||
86 | u8 byte[NVM_ISCSI_CFG_CHAP_NAME_MAX_LEN]; | ||
87 | }; | ||
88 | |||
89 | #define NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN 16 /* md5 need per RFC1996 | ||
90 | * is 16 octets | ||
91 | */ | ||
92 | union nvm_iscsi_chap_password { | ||
93 | u32 value[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN / 4]; | ||
94 | u8 byte[NVM_ISCSI_CFG_CHAP_PWD_MAX_LEN]; | ||
95 | }; | ||
96 | |||
97 | union nvm_iscsi_lun { | ||
98 | u8 byte[8]; | ||
99 | u32 value[2]; | ||
100 | }; | ||
101 | |||
102 | struct nvm_iscsi_generic { | ||
103 | u32 ctrl_flags; /* 0x0 */ | ||
104 | #define NVM_ISCSI_CFG_GEN_CHAP_ENABLED BIT(0) | ||
105 | #define NVM_ISCSI_CFG_GEN_DHCP_TCPIP_CONFIG_ENABLED BIT(1) | ||
106 | #define NVM_ISCSI_CFG_GEN_DHCP_ISCSI_CONFIG_ENABLED BIT(2) | ||
107 | #define NVM_ISCSI_CFG_GEN_IPV6_ENABLED BIT(3) | ||
108 | #define NVM_ISCSI_CFG_GEN_IPV4_FALLBACK_ENABLED BIT(4) | ||
109 | #define NVM_ISCSI_CFG_GEN_ISNS_WORLD_LOGIN BIT(5) | ||
110 | #define NVM_ISCSI_CFG_GEN_ISNS_SELECTIVE_LOGIN BIT(6) | ||
111 | #define NVM_ISCSI_CFG_GEN_ADDR_REDIRECT_ENABLED BIT(7) | ||
112 | #define NVM_ISCSI_CFG_GEN_CHAP_MUTUAL_ENABLED BIT(8) | ||
113 | |||
114 | u32 timeout; /* 0x4 */ | ||
115 | #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_MASK 0x0000FFFF | ||
116 | #define NVM_ISCSI_CFG_GEN_DHCP_REQUEST_TIMEOUT_OFFSET 0 | ||
117 | #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_MASK 0xFFFF0000 | ||
118 | #define NVM_ISCSI_CFG_GEN_PORT_LOGIN_TIMEOUT_OFFSET 16 | ||
119 | |||
120 | union nvm_iscsi_dhcp_vendor_id dhcp_vendor_id; /* 0x8 */ | ||
121 | u32 rsvd[62]; /* 0x108 */ | ||
122 | }; | ||
123 | |||
124 | struct nvm_iscsi_initiator { | ||
125 | struct nvm_iscsi_initiator_ipv4 ipv4; /* 0x0 */ | ||
126 | struct nvm_iscsi_initiator_ipv6 ipv6; /* 0x38 */ | ||
127 | |||
128 | union nvm_iscsi_name initiator_name; /* 0x118 */ | ||
129 | union nvm_iscsi_chap_name chap_name; /* 0x218 */ | ||
130 | union nvm_iscsi_chap_password chap_password; /* 0x318 */ | ||
131 | |||
132 | u32 generic_cont0; /* 0x398 */ | ||
133 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_MASK 0x0000FFFF | ||
134 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_OFFSET 0 | ||
135 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_MASK 0x00030000 | ||
136 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_OFFSET 16 | ||
137 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4 1 | ||
138 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_6 2 | ||
139 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_4_AND_6 3 | ||
140 | |||
141 | u32 ctrl_flags; | ||
142 | #define NVM_ISCSI_CFG_INITIATOR_IP_VERSION_PRIORITY_V6 BIT(0) | ||
143 | #define NVM_ISCSI_CFG_INITIATOR_VLAN_ENABLED BIT(1) | ||
144 | |||
145 | u32 rsvd[116]; /* 0x32C */ | ||
146 | }; | ||
147 | |||
148 | struct nvm_iscsi_target { | ||
149 | u32 ctrl_flags; /* 0x0 */ | ||
150 | #define NVM_ISCSI_CFG_TARGET_ENABLED BIT(0) | ||
151 | #define NVM_ISCSI_CFG_BOOT_TIME_LOGIN_STATUS BIT(1) | ||
152 | |||
153 | u32 generic_cont0; /* 0x4 */ | ||
154 | #define NVM_ISCSI_CFG_TARGET_TCP_PORT_MASK 0x0000FFFF | ||
155 | #define NVM_ISCSI_CFG_TARGET_TCP_PORT_OFFSET 0 | ||
156 | |||
157 | u32 ip_ver; | ||
158 | #define NVM_ISCSI_CFG_IPv4 4 | ||
159 | #define NVM_ISCSI_CFG_IPv6 6 | ||
160 | |||
161 | u32 rsvd_1[7]; /* 0x24 */ | ||
162 | union nvm_iscsi_ipv4_addr ipv4_addr; /* 0x28 */ | ||
163 | union nvm_iscsi_ipv6_addr ipv6_addr; /* 0x2C */ | ||
164 | union nvm_iscsi_lun lun; /* 0x3C */ | ||
165 | |||
166 | union nvm_iscsi_name target_name; /* 0x44 */ | ||
167 | union nvm_iscsi_chap_name chap_name; /* 0x144 */ | ||
168 | union nvm_iscsi_chap_password chap_password; /* 0x244 */ | ||
169 | |||
170 | u32 rsvd_2[107]; /* 0x2C4 */ | ||
171 | }; | ||
172 | |||
173 | struct nvm_iscsi_block { | ||
174 | u32 id; /* 0x0 */ | ||
175 | #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_MASK 0x0000000F | ||
176 | #define NVM_ISCSI_CFG_BLK_MAPPED_PF_ID_OFFSET 0 | ||
177 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_MASK 0x00000FF0 | ||
178 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_OFFSET 4 | ||
179 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_IS_NOT_EMPTY BIT(0) | ||
180 | #define NVM_ISCSI_CFG_BLK_CTRL_FLAG_PF_MAPPED BIT(1) | ||
181 | |||
182 | u32 rsvd_1[5]; /* 0x4 */ | ||
183 | |||
184 | struct nvm_iscsi_generic generic; /* 0x18 */ | ||
185 | struct nvm_iscsi_initiator initiator; /* 0x218 */ | ||
186 | struct nvm_iscsi_target target[NUM_OF_ISCSI_TARGET_PER_PF]; | ||
187 | /* 0x718 */ | ||
188 | |||
189 | u32 rsvd_2[58]; /* 0x1718 */ | ||
190 | /* total size - 0x1800 - 6K block */ | ||
191 | }; | ||
192 | |||
193 | struct nvm_iscsi_cfg { | ||
194 | u32 id; /* 0x0 */ | ||
195 | #define NVM_ISCSI_CFG_BLK_VERSION_MINOR_MASK 0x000000FF | ||
196 | #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR_MASK 0x0000FF00 | ||
197 | #define NVM_ISCSI_CFG_BLK_SIGNATURE_MASK 0xFFFF0000 | ||
198 | #define NVM_ISCSI_CFG_BLK_SIGNATURE 0x49430000 /* IC - Iscsi | ||
199 | * Config | ||
200 | */ | ||
201 | |||
202 | #define NVM_ISCSI_CFG_BLK_VERSION_MAJOR 0 | ||
203 | #define NVM_ISCSI_CFG_BLK_VERSION_MINOR 10 | ||
204 | #define NVM_ISCSI_CFG_BLK_VERSION ((NVM_ISCSI_CFG_BLK_VERSION_MAJOR << 8) | \ | ||
205 | NVM_ISCSI_CFG_BLK_VERSION_MINOR) | ||
206 | |||
207 | struct nvm_iscsi_block block[NUM_OF_ISCSI_PF_SUPPORTED]; /* 0x4 */ | ||
208 | }; | ||
209 | |||
210 | #endif | ||
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index c2dc836dc484..e101cd3043b9 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
@@ -3727,7 +3727,7 @@ static struct qla_tgt_cmd *qlt_ctio_to_cmd(struct scsi_qla_host *vha, | |||
3727 | h &= QLA_CMD_HANDLE_MASK; | 3727 | h &= QLA_CMD_HANDLE_MASK; |
3728 | 3728 | ||
3729 | if (h != QLA_TGT_NULL_HANDLE) { | 3729 | if (h != QLA_TGT_NULL_HANDLE) { |
3730 | if (unlikely(h > req->num_outstanding_cmds)) { | 3730 | if (unlikely(h >= req->num_outstanding_cmds)) { |
3731 | ql_dbg(ql_dbg_tgt, vha, 0xe052, | 3731 | ql_dbg(ql_dbg_tgt, vha, 0xe052, |
3732 | "qla_target(%d): Wrong handle %x received\n", | 3732 | "qla_target(%d): Wrong handle %x received\n", |
3733 | vha->vp_idx, handle); | 3733 | vha->vp_idx, handle); |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 21225d62b0c1..1e82d4128a84 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -758,8 +758,11 @@ static bool sg_is_valid_dxfer(sg_io_hdr_t *hp) | |||
758 | if (hp->dxferp || hp->dxfer_len > 0) | 758 | if (hp->dxferp || hp->dxfer_len > 0) |
759 | return false; | 759 | return false; |
760 | return true; | 760 | return true; |
761 | case SG_DXFER_TO_DEV: | ||
762 | case SG_DXFER_FROM_DEV: | 761 | case SG_DXFER_FROM_DEV: |
762 | if (hp->dxfer_len < 0) | ||
763 | return false; | ||
764 | return true; | ||
765 | case SG_DXFER_TO_DEV: | ||
763 | case SG_DXFER_TO_FROM_DEV: | 766 | case SG_DXFER_TO_FROM_DEV: |
764 | if (!hp->dxferp || hp->dxfer_len == 0) | 767 | if (!hp->dxferp || hp->dxfer_len == 0) |
765 | return false; | 768 | return false; |
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 8b93197daefe..9be211d68b15 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
@@ -837,6 +837,7 @@ static struct scsi_host_template virtscsi_host_template_multi = { | |||
837 | .eh_abort_handler = virtscsi_abort, | 837 | .eh_abort_handler = virtscsi_abort, |
838 | .eh_device_reset_handler = virtscsi_device_reset, | 838 | .eh_device_reset_handler = virtscsi_device_reset, |
839 | .eh_timed_out = virtscsi_eh_timed_out, | 839 | .eh_timed_out = virtscsi_eh_timed_out, |
840 | .slave_alloc = virtscsi_device_alloc, | ||
840 | 841 | ||
841 | .can_queue = 1024, | 842 | .can_queue = 1024, |
842 | .dma_boundary = UINT_MAX, | 843 | .dma_boundary = UINT_MAX, |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 69ec23daa25e..a1e6860b6f46 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -574,7 +574,7 @@ static int load_flat_file(struct linux_binprm *bprm, | |||
574 | MAX_SHARED_LIBS * sizeof(unsigned long), | 574 | MAX_SHARED_LIBS * sizeof(unsigned long), |
575 | FLAT_DATA_ALIGN); | 575 | FLAT_DATA_ALIGN); |
576 | 576 | ||
577 | pr_debug("Allocated data+bss+stack (%ld bytes): %lx\n", | 577 | pr_debug("Allocated data+bss+stack (%u bytes): %lx\n", |
578 | data_len + bss_len + stack_len, datapos); | 578 | data_len + bss_len + stack_len, datapos); |
579 | 579 | ||
580 | fpos = ntohl(hdr->data_start); | 580 | fpos = ntohl(hdr->data_start); |
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index e071d23f6148..ef7240ace576 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c | |||
@@ -271,6 +271,11 @@ out: | |||
271 | if (ret < 0) | 271 | if (ret < 0) |
272 | err = ret; | 272 | err = ret; |
273 | dput(last); | 273 | dput(last); |
274 | /* last_name no longer match cache index */ | ||
275 | if (fi->readdir_cache_idx >= 0) { | ||
276 | fi->readdir_cache_idx = -1; | ||
277 | fi->dir_release_count = 0; | ||
278 | } | ||
274 | } | 279 | } |
275 | return err; | 280 | return err; |
276 | } | 281 | } |
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index 79dafa71effd..51f0aea70cb4 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -175,11 +175,8 @@ ext2_get_acl(struct inode *inode, int type) | |||
175 | return acl; | 175 | return acl; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* | 178 | static int |
179 | * inode->i_mutex: down | 179 | __ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) |
180 | */ | ||
181 | int | ||
182 | ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | ||
183 | { | 180 | { |
184 | int name_index; | 181 | int name_index; |
185 | void *value = NULL; | 182 | void *value = NULL; |
@@ -189,13 +186,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
189 | switch(type) { | 186 | switch(type) { |
190 | case ACL_TYPE_ACCESS: | 187 | case ACL_TYPE_ACCESS: |
191 | name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; | 188 | name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; |
192 | if (acl) { | ||
193 | error = posix_acl_update_mode(inode, &inode->i_mode, &acl); | ||
194 | if (error) | ||
195 | return error; | ||
196 | inode->i_ctime = current_time(inode); | ||
197 | mark_inode_dirty(inode); | ||
198 | } | ||
199 | break; | 189 | break; |
200 | 190 | ||
201 | case ACL_TYPE_DEFAULT: | 191 | case ACL_TYPE_DEFAULT: |
@@ -222,6 +212,31 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
222 | } | 212 | } |
223 | 213 | ||
224 | /* | 214 | /* |
215 | * inode->i_mutex: down | ||
216 | */ | ||
217 | int | ||
218 | ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type) | ||
219 | { | ||
220 | int error; | ||
221 | int update_mode = 0; | ||
222 | umode_t mode = inode->i_mode; | ||
223 | |||
224 | if (type == ACL_TYPE_ACCESS && acl) { | ||
225 | error = posix_acl_update_mode(inode, &mode, &acl); | ||
226 | if (error) | ||
227 | return error; | ||
228 | update_mode = 1; | ||
229 | } | ||
230 | error = __ext2_set_acl(inode, acl, type); | ||
231 | if (!error && update_mode) { | ||
232 | inode->i_mode = mode; | ||
233 | inode->i_ctime = current_time(inode); | ||
234 | mark_inode_dirty(inode); | ||
235 | } | ||
236 | return error; | ||
237 | } | ||
238 | |||
239 | /* | ||
225 | * Initialize the ACLs of a new inode. Called from ext2_new_inode. | 240 | * Initialize the ACLs of a new inode. Called from ext2_new_inode. |
226 | * | 241 | * |
227 | * dir->i_mutex: down | 242 | * dir->i_mutex: down |
@@ -238,12 +253,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir) | |||
238 | return error; | 253 | return error; |
239 | 254 | ||
240 | if (default_acl) { | 255 | if (default_acl) { |
241 | error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); | 256 | error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); |
242 | posix_acl_release(default_acl); | 257 | posix_acl_release(default_acl); |
243 | } | 258 | } |
244 | if (acl) { | 259 | if (acl) { |
245 | if (!error) | 260 | if (!error) |
246 | error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); | 261 | error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); |
247 | posix_acl_release(acl); | 262 | posix_acl_release(acl); |
248 | } | 263 | } |
249 | return error; | 264 | return error; |
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c index a140c5e3dc54..b4b8438c42ef 100644 --- a/fs/f2fs/acl.c +++ b/fs/f2fs/acl.c | |||
@@ -211,7 +211,7 @@ static int __f2fs_set_acl(struct inode *inode, int type, | |||
211 | switch (type) { | 211 | switch (type) { |
212 | case ACL_TYPE_ACCESS: | 212 | case ACL_TYPE_ACCESS: |
213 | name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; | 213 | name_index = F2FS_XATTR_INDEX_POSIX_ACL_ACCESS; |
214 | if (acl) { | 214 | if (acl && !ipage) { |
215 | error = posix_acl_update_mode(inode, &inode->i_mode, &acl); | 215 | error = posix_acl_update_mode(inode, &inode->i_mode, &acl); |
216 | if (error) | 216 | if (error) |
217 | return error; | 217 | return error; |
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 56bbf592e487..5b876f6d3f6b 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
@@ -879,6 +879,7 @@ int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type) | |||
879 | struct inode *inode; | 879 | struct inode *inode; |
880 | struct f2fs_inode_info *fi; | 880 | struct f2fs_inode_info *fi; |
881 | bool is_dir = (type == DIR_INODE); | 881 | bool is_dir = (type == DIR_INODE); |
882 | unsigned long ino = 0; | ||
882 | 883 | ||
883 | trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir, | 884 | trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir, |
884 | get_pages(sbi, is_dir ? | 885 | get_pages(sbi, is_dir ? |
@@ -901,8 +902,17 @@ retry: | |||
901 | inode = igrab(&fi->vfs_inode); | 902 | inode = igrab(&fi->vfs_inode); |
902 | spin_unlock(&sbi->inode_lock[type]); | 903 | spin_unlock(&sbi->inode_lock[type]); |
903 | if (inode) { | 904 | if (inode) { |
905 | unsigned long cur_ino = inode->i_ino; | ||
906 | |||
904 | filemap_fdatawrite(inode->i_mapping); | 907 | filemap_fdatawrite(inode->i_mapping); |
905 | iput(inode); | 908 | iput(inode); |
909 | /* We need to give cpu to another writers. */ | ||
910 | if (ino == cur_ino) { | ||
911 | congestion_wait(BLK_RW_ASYNC, HZ/50); | ||
912 | cond_resched(); | ||
913 | } else { | ||
914 | ino = cur_ino; | ||
915 | } | ||
906 | } else { | 916 | } else { |
907 | /* | 917 | /* |
908 | * We should submit bio, since it exists several | 918 | * We should submit bio, since it exists several |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a0e6d2c65a9e..2706130c261b 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
@@ -1538,7 +1538,6 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg) | |||
1538 | 1538 | ||
1539 | /* Is it quota file? Do not allow user to mess with it */ | 1539 | /* Is it quota file? Do not allow user to mess with it */ |
1540 | if (IS_NOQUOTA(inode)) { | 1540 | if (IS_NOQUOTA(inode)) { |
1541 | inode_unlock(inode); | ||
1542 | ret = -EPERM; | 1541 | ret = -EPERM; |
1543 | goto unlock_out; | 1542 | goto unlock_out; |
1544 | } | 1543 | } |
@@ -1549,9 +1548,8 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg) | |||
1549 | 1548 | ||
1550 | if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) { | 1549 | if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) { |
1551 | if (!capable(CAP_LINUX_IMMUTABLE)) { | 1550 | if (!capable(CAP_LINUX_IMMUTABLE)) { |
1552 | inode_unlock(inode); | ||
1553 | ret = -EPERM; | 1551 | ret = -EPERM; |
1554 | goto out; | 1552 | goto unlock_out; |
1555 | } | 1553 | } |
1556 | } | 1554 | } |
1557 | 1555 | ||
@@ -1564,7 +1562,6 @@ static int f2fs_ioc_setflags(struct file *filp, unsigned long arg) | |||
1564 | f2fs_mark_inode_dirty_sync(inode, false); | 1562 | f2fs_mark_inode_dirty_sync(inode, false); |
1565 | unlock_out: | 1563 | unlock_out: |
1566 | inode_unlock(inode); | 1564 | inode_unlock(inode); |
1567 | out: | ||
1568 | mnt_drop_write_file(filp); | 1565 | mnt_drop_write_file(filp); |
1569 | return ret; | 1566 | return ret; |
1570 | } | 1567 | } |
diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 9adc202fcd6f..71191d89917d 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | #include <linux/proc_fs.h> | 12 | #include <linux/proc_fs.h> |
13 | #include <linux/f2fs_fs.h> | 13 | #include <linux/f2fs_fs.h> |
14 | #include <linux/seq_file.h> | ||
14 | 15 | ||
15 | #include "f2fs.h" | 16 | #include "f2fs.h" |
16 | #include "segment.h" | 17 | #include "segment.h" |
diff --git a/fs/hfsplus/posix_acl.c b/fs/hfsplus/posix_acl.c index 9b92058a1240..6bb5d7c42888 100644 --- a/fs/hfsplus/posix_acl.c +++ b/fs/hfsplus/posix_acl.c | |||
@@ -51,8 +51,8 @@ struct posix_acl *hfsplus_get_posix_acl(struct inode *inode, int type) | |||
51 | return acl; | 51 | return acl; |
52 | } | 52 | } |
53 | 53 | ||
54 | int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, | 54 | static int __hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, |
55 | int type) | 55 | int type) |
56 | { | 56 | { |
57 | int err; | 57 | int err; |
58 | char *xattr_name; | 58 | char *xattr_name; |
@@ -64,12 +64,6 @@ int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, | |||
64 | switch (type) { | 64 | switch (type) { |
65 | case ACL_TYPE_ACCESS: | 65 | case ACL_TYPE_ACCESS: |
66 | xattr_name = XATTR_NAME_POSIX_ACL_ACCESS; | 66 | xattr_name = XATTR_NAME_POSIX_ACL_ACCESS; |
67 | if (acl) { | ||
68 | err = posix_acl_update_mode(inode, &inode->i_mode, &acl); | ||
69 | if (err) | ||
70 | return err; | ||
71 | } | ||
72 | err = 0; | ||
73 | break; | 67 | break; |
74 | 68 | ||
75 | case ACL_TYPE_DEFAULT: | 69 | case ACL_TYPE_DEFAULT: |
@@ -105,6 +99,18 @@ end_set_acl: | |||
105 | return err; | 99 | return err; |
106 | } | 100 | } |
107 | 101 | ||
102 | int hfsplus_set_posix_acl(struct inode *inode, struct posix_acl *acl, int type) | ||
103 | { | ||
104 | int err; | ||
105 | |||
106 | if (type == ACL_TYPE_ACCESS && acl) { | ||
107 | err = posix_acl_update_mode(inode, &inode->i_mode, &acl); | ||
108 | if (err) | ||
109 | return err; | ||
110 | } | ||
111 | return __hfsplus_set_posix_acl(inode, acl, type); | ||
112 | } | ||
113 | |||
108 | int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) | 114 | int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) |
109 | { | 115 | { |
110 | int err = 0; | 116 | int err = 0; |
@@ -122,15 +128,15 @@ int hfsplus_init_posix_acl(struct inode *inode, struct inode *dir) | |||
122 | return err; | 128 | return err; |
123 | 129 | ||
124 | if (default_acl) { | 130 | if (default_acl) { |
125 | err = hfsplus_set_posix_acl(inode, default_acl, | 131 | err = __hfsplus_set_posix_acl(inode, default_acl, |
126 | ACL_TYPE_DEFAULT); | 132 | ACL_TYPE_DEFAULT); |
127 | posix_acl_release(default_acl); | 133 | posix_acl_release(default_acl); |
128 | } | 134 | } |
129 | 135 | ||
130 | if (acl) { | 136 | if (acl) { |
131 | if (!err) | 137 | if (!err) |
132 | err = hfsplus_set_posix_acl(inode, acl, | 138 | err = __hfsplus_set_posix_acl(inode, acl, |
133 | ACL_TYPE_ACCESS); | 139 | ACL_TYPE_ACCESS); |
134 | posix_acl_release(acl); | 140 | posix_acl_release(acl); |
135 | } | 141 | } |
136 | return err; | 142 | return err; |
diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 8cf898a59730..217a5e7815da 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c | |||
@@ -410,7 +410,11 @@ static int parse_options(char *options, struct iso9660_options *popt) | |||
410 | if (match_int(&args[0], &option)) | 410 | if (match_int(&args[0], &option)) |
411 | return 0; | 411 | return 0; |
412 | n = option; | 412 | n = option; |
413 | if (n > 99) | 413 | /* |
414 | * Track numbers are supposed to be in range 1-99, the | ||
415 | * mount option starts indexing at 0. | ||
416 | */ | ||
417 | if (n >= 99) | ||
414 | return 0; | 418 | return 0; |
415 | popt->session = n + 1; | 419 | popt->session = n + 1; |
416 | break; | 420 | break; |
@@ -543,7 +547,7 @@ static unsigned int isofs_get_last_session(struct super_block *sb, s32 session) | |||
543 | 547 | ||
544 | vol_desc_start=0; | 548 | vol_desc_start=0; |
545 | ms_info.addr_format=CDROM_LBA; | 549 | ms_info.addr_format=CDROM_LBA; |
546 | if(session >= 0 && session <= 99) { | 550 | if (session > 0) { |
547 | struct cdrom_tocentry Te; | 551 | struct cdrom_tocentry Te; |
548 | Te.cdte_track=session; | 552 | Te.cdte_track=session; |
549 | Te.cdte_format=CDROM_LBA; | 553 | Te.cdte_format=CDROM_LBA; |
diff --git a/fs/mount.h b/fs/mount.h index de45d9e76748..6790767d1883 100644 --- a/fs/mount.h +++ b/fs/mount.h | |||
@@ -16,7 +16,7 @@ struct mnt_namespace { | |||
16 | u64 event; | 16 | u64 event; |
17 | unsigned int mounts; /* # of mounts in the namespace */ | 17 | unsigned int mounts; /* # of mounts in the namespace */ |
18 | unsigned int pending_mounts; | 18 | unsigned int pending_mounts; |
19 | }; | 19 | } __randomize_layout; |
20 | 20 | ||
21 | struct mnt_pcp { | 21 | struct mnt_pcp { |
22 | int mnt_count; | 22 | int mnt_count; |
@@ -69,7 +69,7 @@ struct mount { | |||
69 | struct hlist_head mnt_pins; | 69 | struct hlist_head mnt_pins; |
70 | struct fs_pin mnt_umount; | 70 | struct fs_pin mnt_umount; |
71 | struct dentry *mnt_ex_mountpoint; | 71 | struct dentry *mnt_ex_mountpoint; |
72 | }; | 72 | } __randomize_layout; |
73 | 73 | ||
74 | #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */ | 74 | #define MNT_NS_INTERNAL ERR_PTR(-EINVAL) /* distinct from any mnt_namespace */ |
75 | 75 | ||
diff --git a/fs/namei.c b/fs/namei.c index 88fd38d1e3e7..ddb6a7c2b3d4 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -524,7 +524,7 @@ struct nameidata { | |||
524 | struct inode *link_inode; | 524 | struct inode *link_inode; |
525 | unsigned root_seq; | 525 | unsigned root_seq; |
526 | int dfd; | 526 | int dfd; |
527 | }; | 527 | } __randomize_layout; |
528 | 528 | ||
529 | static void set_nameidata(struct nameidata *p, int dfd, struct filename *name) | 529 | static void set_nameidata(struct nameidata *p, int dfd, struct filename *name) |
530 | { | 530 | { |
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index b45083c0f9ae..49b0a9e7ff18 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -720,8 +720,8 @@ static const struct rpc_version nfs_cb_version4 = { | |||
720 | .counts = nfs4_cb_counts, | 720 | .counts = nfs4_cb_counts, |
721 | }; | 721 | }; |
722 | 722 | ||
723 | static const struct rpc_version *nfs_cb_version[] = { | 723 | static const struct rpc_version *nfs_cb_version[2] = { |
724 | &nfs_cb_version4, | 724 | [1] = &nfs_cb_version4, |
725 | }; | 725 | }; |
726 | 726 | ||
727 | static const struct rpc_program cb_program; | 727 | static const struct rpc_program cb_program; |
@@ -795,7 +795,7 @@ static int setup_callback_client(struct nfs4_client *clp, struct nfs4_cb_conn *c | |||
795 | .saddress = (struct sockaddr *) &conn->cb_saddr, | 795 | .saddress = (struct sockaddr *) &conn->cb_saddr, |
796 | .timeout = &timeparms, | 796 | .timeout = &timeparms, |
797 | .program = &cb_program, | 797 | .program = &cb_program, |
798 | .version = 0, | 798 | .version = 1, |
799 | .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), | 799 | .flags = (RPC_CLNT_CREATE_NOPING | RPC_CLNT_CREATE_QUIET), |
800 | }; | 800 | }; |
801 | struct rpc_clnt *client; | 801 | struct rpc_clnt *client; |
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 18694598bebf..aa2b89071630 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h | |||
@@ -51,7 +51,7 @@ struct proc_dir_entry { | |||
51 | spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ | 51 | spinlock_t pde_unload_lock; /* proc_fops checks and pde_users bumps */ |
52 | u8 namelen; | 52 | u8 namelen; |
53 | char name[]; | 53 | char name[]; |
54 | }; | 54 | } __randomize_layout; |
55 | 55 | ||
56 | union proc_op { | 56 | union proc_op { |
57 | int (*proc_get_link)(struct dentry *, struct path *); | 57 | int (*proc_get_link)(struct dentry *, struct path *); |
@@ -70,7 +70,7 @@ struct proc_inode { | |||
70 | struct hlist_node sysctl_inodes; | 70 | struct hlist_node sysctl_inodes; |
71 | const struct proc_ns_operations *ns_ops; | 71 | const struct proc_ns_operations *ns_ops; |
72 | struct inode vfs_inode; | 72 | struct inode vfs_inode; |
73 | }; | 73 | } __randomize_layout; |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * General functions | 76 | * General functions |
@@ -279,7 +279,7 @@ struct proc_maps_private { | |||
279 | #ifdef CONFIG_NUMA | 279 | #ifdef CONFIG_NUMA |
280 | struct mempolicy *task_mempolicy; | 280 | struct mempolicy *task_mempolicy; |
281 | #endif | 281 | #endif |
282 | }; | 282 | } __randomize_layout; |
283 | 283 | ||
284 | struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode); | 284 | struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode); |
285 | 285 | ||
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 3d2256a425ee..54415f0e3d18 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -23,7 +23,8 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
23 | struct reiserfs_transaction_handle th; | 23 | struct reiserfs_transaction_handle th; |
24 | size_t jcreate_blocks; | 24 | size_t jcreate_blocks; |
25 | int size = acl ? posix_acl_xattr_size(acl->a_count) : 0; | 25 | int size = acl ? posix_acl_xattr_size(acl->a_count) : 0; |
26 | 26 | int update_mode = 0; | |
27 | umode_t mode = inode->i_mode; | ||
27 | 28 | ||
28 | /* | 29 | /* |
29 | * Pessimism: We can't assume that anything from the xattr root up | 30 | * Pessimism: We can't assume that anything from the xattr root up |
@@ -37,7 +38,16 @@ reiserfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) | |||
37 | error = journal_begin(&th, inode->i_sb, jcreate_blocks); | 38 | error = journal_begin(&th, inode->i_sb, jcreate_blocks); |
38 | reiserfs_write_unlock(inode->i_sb); | 39 | reiserfs_write_unlock(inode->i_sb); |
39 | if (error == 0) { | 40 | if (error == 0) { |
41 | if (type == ACL_TYPE_ACCESS && acl) { | ||
42 | error = posix_acl_update_mode(inode, &mode, &acl); | ||
43 | if (error) | ||
44 | goto unlock; | ||
45 | update_mode = 1; | ||
46 | } | ||
40 | error = __reiserfs_set_acl(&th, inode, type, acl); | 47 | error = __reiserfs_set_acl(&th, inode, type, acl); |
48 | if (!error && update_mode) | ||
49 | inode->i_mode = mode; | ||
50 | unlock: | ||
41 | reiserfs_write_lock(inode->i_sb); | 51 | reiserfs_write_lock(inode->i_sb); |
42 | error2 = journal_end(&th); | 52 | error2 = journal_end(&th); |
43 | reiserfs_write_unlock(inode->i_sb); | 53 | reiserfs_write_unlock(inode->i_sb); |
@@ -241,11 +251,6 @@ __reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode, | |||
241 | switch (type) { | 251 | switch (type) { |
242 | case ACL_TYPE_ACCESS: | 252 | case ACL_TYPE_ACCESS: |
243 | name = XATTR_NAME_POSIX_ACL_ACCESS; | 253 | name = XATTR_NAME_POSIX_ACL_ACCESS; |
244 | if (acl) { | ||
245 | error = posix_acl_update_mode(inode, &inode->i_mode, &acl); | ||
246 | if (error) | ||
247 | return error; | ||
248 | } | ||
249 | break; | 254 | break; |
250 | case ACL_TYPE_DEFAULT: | 255 | case ACL_TYPE_DEFAULT: |
251 | name = XATTR_NAME_POSIX_ACL_DEFAULT; | 256 | name = XATTR_NAME_POSIX_ACL_DEFAULT; |
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 05488da3aee9..3ae9013eeaaa 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -46,7 +46,7 @@ struct linux_binprm { | |||
46 | unsigned interp_flags; | 46 | unsigned interp_flags; |
47 | unsigned interp_data; | 47 | unsigned interp_data; |
48 | unsigned long loader, exec; | 48 | unsigned long loader, exec; |
49 | }; | 49 | } __randomize_layout; |
50 | 50 | ||
51 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 | 51 | #define BINPRM_FLAGS_ENFORCE_NONDUMP_BIT 0 |
52 | #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT) | 52 | #define BINPRM_FLAGS_ENFORCE_NONDUMP (1 << BINPRM_FLAGS_ENFORCE_NONDUMP_BIT) |
@@ -81,7 +81,7 @@ struct linux_binfmt { | |||
81 | int (*load_shlib)(struct file *); | 81 | int (*load_shlib)(struct file *); |
82 | int (*core_dump)(struct coredump_params *cprm); | 82 | int (*core_dump)(struct coredump_params *cprm); |
83 | unsigned long min_coredump; /* minimal dump size */ | 83 | unsigned long min_coredump; /* minimal dump size */ |
84 | }; | 84 | } __randomize_layout; |
85 | 85 | ||
86 | extern void __register_binfmt(struct linux_binfmt *fmt, int insert); | 86 | extern void __register_binfmt(struct linux_binfmt *fmt, int insert); |
87 | 87 | ||
diff --git a/include/linux/bpf-cgroup.h b/include/linux/bpf-cgroup.h index 360c082e885c..d41d40ac3efd 100644 --- a/include/linux/bpf-cgroup.h +++ b/include/linux/bpf-cgroup.h | |||
@@ -85,7 +85,7 @@ int __cgroup_bpf_run_filter_sock_ops(struct sock *sk, | |||
85 | int __ret = 0; \ | 85 | int __ret = 0; \ |
86 | if (cgroup_bpf_enabled && (sock_ops)->sk) { \ | 86 | if (cgroup_bpf_enabled && (sock_ops)->sk) { \ |
87 | typeof(sk) __sk = sk_to_full_sk((sock_ops)->sk); \ | 87 | typeof(sk) __sk = sk_to_full_sk((sock_ops)->sk); \ |
88 | if (sk_fullsock(__sk)) \ | 88 | if (__sk && sk_fullsock(__sk)) \ |
89 | __ret = __cgroup_bpf_run_filter_sock_ops(__sk, \ | 89 | __ret = __cgroup_bpf_run_filter_sock_ops(__sk, \ |
90 | sock_ops, \ | 90 | sock_ops, \ |
91 | BPF_CGROUP_SOCK_OPS); \ | 91 | BPF_CGROUP_SOCK_OPS); \ |
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h index 621076f56251..8e5d31f6faef 100644 --- a/include/linux/bpf_verifier.h +++ b/include/linux/bpf_verifier.h | |||
@@ -43,6 +43,7 @@ struct bpf_reg_state { | |||
43 | u32 min_align; | 43 | u32 min_align; |
44 | u32 aux_off; | 44 | u32 aux_off; |
45 | u32 aux_off_align; | 45 | u32 aux_off_align; |
46 | bool value_from_signed; | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | enum bpf_stack_slot_type { | 49 | enum bpf_stack_slot_type { |
diff --git a/include/linux/cdev.h b/include/linux/cdev.h index 408bc09ce497..cb28eb21e3ca 100644 --- a/include/linux/cdev.h +++ b/include/linux/cdev.h | |||
@@ -17,7 +17,7 @@ struct cdev { | |||
17 | struct list_head list; | 17 | struct list_head list; |
18 | dev_t dev; | 18 | dev_t dev; |
19 | unsigned int count; | 19 | unsigned int count; |
20 | }; | 20 | } __randomize_layout; |
21 | 21 | ||
22 | void cdev_init(struct cdev *, const struct file_operations *); | 22 | void cdev_init(struct cdev *, const struct file_operations *); |
23 | 23 | ||
diff --git a/include/linux/ceph/ceph_features.h b/include/linux/ceph/ceph_features.h index f0f6c537b64c..040dd105c3e7 100644 --- a/include/linux/ceph/ceph_features.h +++ b/include/linux/ceph/ceph_features.h | |||
@@ -10,14 +10,14 @@ | |||
10 | #define CEPH_FEATURE_INCARNATION_2 (1ull<<57) // CEPH_FEATURE_SERVER_JEWEL | 10 | #define CEPH_FEATURE_INCARNATION_2 (1ull<<57) // CEPH_FEATURE_SERVER_JEWEL |
11 | 11 | ||
12 | #define DEFINE_CEPH_FEATURE(bit, incarnation, name) \ | 12 | #define DEFINE_CEPH_FEATURE(bit, incarnation, name) \ |
13 | const static uint64_t CEPH_FEATURE_##name = (1ULL<<bit); \ | 13 | static const uint64_t CEPH_FEATURE_##name = (1ULL<<bit); \ |
14 | const static uint64_t CEPH_FEATUREMASK_##name = \ | 14 | static const uint64_t CEPH_FEATUREMASK_##name = \ |
15 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); | 15 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); |
16 | 16 | ||
17 | /* this bit is ignored but still advertised by release *when* */ | 17 | /* this bit is ignored but still advertised by release *when* */ |
18 | #define DEFINE_CEPH_FEATURE_DEPRECATED(bit, incarnation, name, when) \ | 18 | #define DEFINE_CEPH_FEATURE_DEPRECATED(bit, incarnation, name, when) \ |
19 | const static uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \ | 19 | static const uint64_t DEPRECATED_CEPH_FEATURE_##name = (1ULL<<bit); \ |
20 | const static uint64_t DEPRECATED_CEPH_FEATUREMASK_##name = \ | 20 | static const uint64_t DEPRECATED_CEPH_FEATUREMASK_##name = \ |
21 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); | 21 | (1ULL<<bit | CEPH_FEATURE_INCARNATION_##incarnation); |
22 | 22 | ||
23 | /* | 23 | /* |
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index cd4bbe8242bd..bdb80c4aef6e 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -235,6 +235,7 @@ | |||
235 | #endif /* GCC_VERSION >= 40500 */ | 235 | #endif /* GCC_VERSION >= 40500 */ |
236 | 236 | ||
237 | #if GCC_VERSION >= 40600 | 237 | #if GCC_VERSION >= 40600 |
238 | |||
238 | /* | 239 | /* |
239 | * When used with Link Time Optimization, gcc can optimize away C functions or | 240 | * When used with Link Time Optimization, gcc can optimize away C functions or |
240 | * variables which are referenced only from assembly code. __visible tells the | 241 | * variables which are referenced only from assembly code. __visible tells the |
@@ -242,7 +243,17 @@ | |||
242 | * this. | 243 | * this. |
243 | */ | 244 | */ |
244 | #define __visible __attribute__((externally_visible)) | 245 | #define __visible __attribute__((externally_visible)) |
245 | #endif | 246 | |
247 | /* | ||
248 | * RANDSTRUCT_PLUGIN wants to use an anonymous struct, but it is only | ||
249 | * possible since GCC 4.6. To provide as much build testing coverage | ||
250 | * as possible, this is used for all GCC 4.6+ builds, and not just on | ||
251 | * RANDSTRUCT_PLUGIN builds. | ||
252 | */ | ||
253 | #define randomized_struct_fields_start struct { | ||
254 | #define randomized_struct_fields_end } __randomize_layout; | ||
255 | |||
256 | #endif /* GCC_VERSION >= 40600 */ | ||
246 | 257 | ||
247 | 258 | ||
248 | #if GCC_VERSION >= 40900 && !defined(__CHECKER__) | 259 | #if GCC_VERSION >= 40900 && !defined(__CHECKER__) |
diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 219f82f3ec1a..eca8ad75e28b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h | |||
@@ -452,6 +452,11 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s | |||
452 | # define __no_randomize_layout | 452 | # define __no_randomize_layout |
453 | #endif | 453 | #endif |
454 | 454 | ||
455 | #ifndef randomized_struct_fields_start | ||
456 | # define randomized_struct_fields_start | ||
457 | # define randomized_struct_fields_end | ||
458 | #endif | ||
459 | |||
455 | /* | 460 | /* |
456 | * Tell gcc if a function is cold. The compiler will assume any path | 461 | * Tell gcc if a function is cold. The compiler will assume any path |
457 | * directly leading to the call is unlikely. | 462 | * directly leading to the call is unlikely. |
diff --git a/include/linux/cred.h b/include/linux/cred.h index c728d515e5e2..099058e1178b 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
@@ -31,7 +31,7 @@ struct group_info { | |||
31 | atomic_t usage; | 31 | atomic_t usage; |
32 | int ngroups; | 32 | int ngroups; |
33 | kgid_t gid[0]; | 33 | kgid_t gid[0]; |
34 | }; | 34 | } __randomize_layout; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | * get_group_info - Get a reference to a group info structure | 37 | * get_group_info - Get a reference to a group info structure |
@@ -145,7 +145,7 @@ struct cred { | |||
145 | struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */ | 145 | struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */ |
146 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ | 146 | struct group_info *group_info; /* supplementary groups for euid/fsgid */ |
147 | struct rcu_head rcu; /* RCU deletion hook */ | 147 | struct rcu_head rcu; /* RCU deletion hook */ |
148 | }; | 148 | } __randomize_layout; |
149 | 149 | ||
150 | extern void __put_cred(struct cred *); | 150 | extern void __put_cred(struct cred *); |
151 | extern void exit_creds(struct task_struct *); | 151 | extern void exit_creds(struct task_struct *); |
diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 3f3ff4ccdc3f..aae1cdb76851 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h | |||
@@ -118,7 +118,7 @@ struct dentry { | |||
118 | struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */ | 118 | struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */ |
119 | struct rcu_head d_rcu; | 119 | struct rcu_head d_rcu; |
120 | } d_u; | 120 | } d_u; |
121 | }; | 121 | } __randomize_layout; |
122 | 122 | ||
123 | /* | 123 | /* |
124 | * dentry->d_lock spinlock nesting subclasses: | 124 | * dentry->d_lock spinlock nesting subclasses: |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 7b5d6816542b..6e1fd5d21248 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -296,7 +296,7 @@ struct kiocb { | |||
296 | void *private; | 296 | void *private; |
297 | int ki_flags; | 297 | int ki_flags; |
298 | enum rw_hint ki_hint; | 298 | enum rw_hint ki_hint; |
299 | }; | 299 | } __randomize_layout; |
300 | 300 | ||
301 | static inline bool is_sync_kiocb(struct kiocb *kiocb) | 301 | static inline bool is_sync_kiocb(struct kiocb *kiocb) |
302 | { | 302 | { |
@@ -404,7 +404,7 @@ struct address_space { | |||
404 | struct list_head private_list; /* ditto */ | 404 | struct list_head private_list; /* ditto */ |
405 | void *private_data; /* ditto */ | 405 | void *private_data; /* ditto */ |
406 | errseq_t wb_err; | 406 | errseq_t wb_err; |
407 | } __attribute__((aligned(sizeof(long)))); | 407 | } __attribute__((aligned(sizeof(long)))) __randomize_layout; |
408 | /* | 408 | /* |
409 | * On most architectures that alignment is already the case; but | 409 | * On most architectures that alignment is already the case; but |
410 | * must be enforced here for CRIS, to let the least significant bit | 410 | * must be enforced here for CRIS, to let the least significant bit |
@@ -447,7 +447,7 @@ struct block_device { | |||
447 | int bd_fsfreeze_count; | 447 | int bd_fsfreeze_count; |
448 | /* Mutex for freeze */ | 448 | /* Mutex for freeze */ |
449 | struct mutex bd_fsfreeze_mutex; | 449 | struct mutex bd_fsfreeze_mutex; |
450 | }; | 450 | } __randomize_layout; |
451 | 451 | ||
452 | /* | 452 | /* |
453 | * Radix-tree tags, for tagging dirty and writeback pages within the pagecache | 453 | * Radix-tree tags, for tagging dirty and writeback pages within the pagecache |
@@ -666,7 +666,7 @@ struct inode { | |||
666 | #endif | 666 | #endif |
667 | 667 | ||
668 | void *i_private; /* fs or device private pointer */ | 668 | void *i_private; /* fs or device private pointer */ |
669 | }; | 669 | } __randomize_layout; |
670 | 670 | ||
671 | static inline unsigned int i_blocksize(const struct inode *node) | 671 | static inline unsigned int i_blocksize(const struct inode *node) |
672 | { | 672 | { |
@@ -883,7 +883,8 @@ struct file { | |||
883 | #endif /* #ifdef CONFIG_EPOLL */ | 883 | #endif /* #ifdef CONFIG_EPOLL */ |
884 | struct address_space *f_mapping; | 884 | struct address_space *f_mapping; |
885 | errseq_t f_wb_err; | 885 | errseq_t f_wb_err; |
886 | } __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ | 886 | } __randomize_layout |
887 | __attribute__((aligned(4))); /* lest something weird decides that 2 is OK */ | ||
887 | 888 | ||
888 | struct file_handle { | 889 | struct file_handle { |
889 | __u32 handle_bytes; | 890 | __u32 handle_bytes; |
@@ -1020,7 +1021,7 @@ struct file_lock { | |||
1020 | int state; /* state of grant or error if -ve */ | 1021 | int state; /* state of grant or error if -ve */ |
1021 | } afs; | 1022 | } afs; |
1022 | } fl_u; | 1023 | } fl_u; |
1023 | }; | 1024 | } __randomize_layout; |
1024 | 1025 | ||
1025 | struct file_lock_context { | 1026 | struct file_lock_context { |
1026 | spinlock_t flc_lock; | 1027 | spinlock_t flc_lock; |
@@ -1412,7 +1413,7 @@ struct super_block { | |||
1412 | 1413 | ||
1413 | spinlock_t s_inode_wblist_lock; | 1414 | spinlock_t s_inode_wblist_lock; |
1414 | struct list_head s_inodes_wb; /* writeback inodes */ | 1415 | struct list_head s_inodes_wb; /* writeback inodes */ |
1415 | }; | 1416 | } __randomize_layout; |
1416 | 1417 | ||
1417 | /* Helper functions so that in most cases filesystems will | 1418 | /* Helper functions so that in most cases filesystems will |
1418 | * not need to deal directly with kuid_t and kgid_t and can | 1419 | * not need to deal directly with kuid_t and kgid_t and can |
@@ -1698,7 +1699,7 @@ struct file_operations { | |||
1698 | u64); | 1699 | u64); |
1699 | ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, | 1700 | ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, |
1700 | u64); | 1701 | u64); |
1701 | }; | 1702 | } __randomize_layout; |
1702 | 1703 | ||
1703 | struct inode_operations { | 1704 | struct inode_operations { |
1704 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); | 1705 | struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); |
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index 0efc3e62843a..7a026240cbb1 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h | |||
@@ -12,7 +12,7 @@ struct fs_struct { | |||
12 | int umask; | 12 | int umask; |
13 | int in_exec; | 13 | int in_exec; |
14 | struct path root, pwd; | 14 | struct path root, pwd; |
15 | }; | 15 | } __randomize_layout; |
16 | 16 | ||
17 | extern struct kmem_cache *fs_cachep; | 17 | extern struct kmem_cache *fs_cachep; |
18 | 18 | ||
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h index 5857390ac35a..6383115e9d2c 100644 --- a/include/linux/ftrace.h +++ b/include/linux/ftrace.h | |||
@@ -145,8 +145,8 @@ enum { | |||
145 | #ifdef CONFIG_DYNAMIC_FTRACE | 145 | #ifdef CONFIG_DYNAMIC_FTRACE |
146 | /* The hash used to know what functions callbacks trace */ | 146 | /* The hash used to know what functions callbacks trace */ |
147 | struct ftrace_ops_hash { | 147 | struct ftrace_ops_hash { |
148 | struct ftrace_hash *notrace_hash; | 148 | struct ftrace_hash __rcu *notrace_hash; |
149 | struct ftrace_hash *filter_hash; | 149 | struct ftrace_hash __rcu *filter_hash; |
150 | struct mutex regex_lock; | 150 | struct mutex regex_lock; |
151 | }; | 151 | }; |
152 | 152 | ||
@@ -168,7 +168,7 @@ static inline void ftrace_free_init_mem(void) { } | |||
168 | */ | 168 | */ |
169 | struct ftrace_ops { | 169 | struct ftrace_ops { |
170 | ftrace_func_t func; | 170 | ftrace_func_t func; |
171 | struct ftrace_ops *next; | 171 | struct ftrace_ops __rcu *next; |
172 | unsigned long flags; | 172 | unsigned long flags; |
173 | void *private; | 173 | void *private; |
174 | ftrace_func_t saved_func; | 174 | ftrace_func_t saved_func; |
diff --git a/include/linux/ipc.h b/include/linux/ipc.h index 5591f055e13f..fadd579d577d 100644 --- a/include/linux/ipc.h +++ b/include/linux/ipc.h | |||
@@ -23,6 +23,6 @@ struct kern_ipc_perm { | |||
23 | 23 | ||
24 | struct rcu_head rcu; | 24 | struct rcu_head rcu; |
25 | atomic_t refcount; | 25 | atomic_t refcount; |
26 | } ____cacheline_aligned_in_smp; | 26 | } ____cacheline_aligned_in_smp __randomize_layout; |
27 | 27 | ||
28 | #endif /* _LINUX_IPC_H */ | 28 | #endif /* _LINUX_IPC_H */ |
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h index 848e5796400e..65327ee0936b 100644 --- a/include/linux/ipc_namespace.h +++ b/include/linux/ipc_namespace.h | |||
@@ -61,7 +61,7 @@ struct ipc_namespace { | |||
61 | struct ucounts *ucounts; | 61 | struct ucounts *ucounts; |
62 | 62 | ||
63 | struct ns_common ns; | 63 | struct ns_common ns; |
64 | }; | 64 | } __randomize_layout; |
65 | 65 | ||
66 | extern struct ipc_namespace init_ipc_ns; | 66 | extern struct ipc_namespace init_ipc_ns; |
67 | extern spinlock_t mq_lock; | 67 | extern spinlock_t mq_lock; |
diff --git a/include/linux/jhash.h b/include/linux/jhash.h index 348c6f47e4cc..8037850f3104 100644 --- a/include/linux/jhash.h +++ b/include/linux/jhash.h | |||
@@ -85,19 +85,18 @@ static inline u32 jhash(const void *key, u32 length, u32 initval) | |||
85 | k += 12; | 85 | k += 12; |
86 | } | 86 | } |
87 | /* Last block: affect all 32 bits of (c) */ | 87 | /* Last block: affect all 32 bits of (c) */ |
88 | /* All the case statements fall through */ | ||
89 | switch (length) { | 88 | switch (length) { |
90 | case 12: c += (u32)k[11]<<24; | 89 | case 12: c += (u32)k[11]<<24; /* fall through */ |
91 | case 11: c += (u32)k[10]<<16; | 90 | case 11: c += (u32)k[10]<<16; /* fall through */ |
92 | case 10: c += (u32)k[9]<<8; | 91 | case 10: c += (u32)k[9]<<8; /* fall through */ |
93 | case 9: c += k[8]; | 92 | case 9: c += k[8]; /* fall through */ |
94 | case 8: b += (u32)k[7]<<24; | 93 | case 8: b += (u32)k[7]<<24; /* fall through */ |
95 | case 7: b += (u32)k[6]<<16; | 94 | case 7: b += (u32)k[6]<<16; /* fall through */ |
96 | case 6: b += (u32)k[5]<<8; | 95 | case 6: b += (u32)k[5]<<8; /* fall through */ |
97 | case 5: b += k[4]; | 96 | case 5: b += k[4]; /* fall through */ |
98 | case 4: a += (u32)k[3]<<24; | 97 | case 4: a += (u32)k[3]<<24; /* fall through */ |
99 | case 3: a += (u32)k[2]<<16; | 98 | case 3: a += (u32)k[2]<<16; /* fall through */ |
100 | case 2: a += (u32)k[1]<<8; | 99 | case 2: a += (u32)k[1]<<8; /* fall through */ |
101 | case 1: a += k[0]; | 100 | case 1: a += k[0]; |
102 | __jhash_final(a, b, c); | 101 | __jhash_final(a, b, c); |
103 | case 0: /* Nothing left to add */ | 102 | case 0: /* Nothing left to add */ |
@@ -131,10 +130,10 @@ static inline u32 jhash2(const u32 *k, u32 length, u32 initval) | |||
131 | k += 3; | 130 | k += 3; |
132 | } | 131 | } |
133 | 132 | ||
134 | /* Handle the last 3 u32's: all the case statements fall through */ | 133 | /* Handle the last 3 u32's */ |
135 | switch (length) { | 134 | switch (length) { |
136 | case 3: c += k[2]; | 135 | case 3: c += k[2]; /* fall through */ |
137 | case 2: b += k[1]; | 136 | case 2: b += k[1]; /* fall through */ |
138 | case 1: a += k[0]; | 137 | case 1: a += k[0]; |
139 | __jhash_final(a, b, c); | 138 | __jhash_final(a, b, c); |
140 | case 0: /* Nothing left to add */ | 139 | case 0: /* Nothing left to add */ |
diff --git a/include/linux/key-type.h b/include/linux/key-type.h index 8496cf64575c..9520fc3c3b9a 100644 --- a/include/linux/key-type.h +++ b/include/linux/key-type.h | |||
@@ -45,7 +45,7 @@ struct key_preparsed_payload { | |||
45 | size_t datalen; /* Raw datalen */ | 45 | size_t datalen; /* Raw datalen */ |
46 | size_t quotalen; /* Quota length for proposed payload */ | 46 | size_t quotalen; /* Quota length for proposed payload */ |
47 | time_t expiry; /* Expiry time of key */ | 47 | time_t expiry; /* Expiry time of key */ |
48 | }; | 48 | } __randomize_layout; |
49 | 49 | ||
50 | typedef int (*request_key_actor_t)(struct key_construction *key, | 50 | typedef int (*request_key_actor_t)(struct key_construction *key, |
51 | const char *op, void *aux); | 51 | const char *op, void *aux); |
@@ -158,7 +158,7 @@ struct key_type { | |||
158 | /* internal fields */ | 158 | /* internal fields */ |
159 | struct list_head link; /* link in types list */ | 159 | struct list_head link; /* link in types list */ |
160 | struct lock_class_key lock_class; /* key->sem lock class */ | 160 | struct lock_class_key lock_class; /* key->sem lock class */ |
161 | }; | 161 | } __randomize_layout; |
162 | 162 | ||
163 | extern struct key_type key_type_keyring; | 163 | extern struct key_type key_type_keyring; |
164 | 164 | ||
diff --git a/include/linux/kmod.h b/include/linux/kmod.h index c4e441e00db5..655082c88fd9 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h | |||
@@ -64,7 +64,7 @@ struct subprocess_info { | |||
64 | int (*init)(struct subprocess_info *info, struct cred *new); | 64 | int (*init)(struct subprocess_info *info, struct cred *new); |
65 | void (*cleanup)(struct subprocess_info *info); | 65 | void (*cleanup)(struct subprocess_info *info); |
66 | void *data; | 66 | void *data; |
67 | }; | 67 | } __randomize_layout; |
68 | 68 | ||
69 | extern int | 69 | extern int |
70 | call_usermodehelper(const char *path, char **argv, char **envp, int wait); | 70 | call_usermodehelper(const char *path, char **argv, char **envp, int wait); |
diff --git a/include/linux/kobject.h b/include/linux/kobject.h index eeab34b0f589..4d800c79475a 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h | |||
@@ -172,7 +172,7 @@ struct kset { | |||
172 | spinlock_t list_lock; | 172 | spinlock_t list_lock; |
173 | struct kobject kobj; | 173 | struct kobject kobj; |
174 | const struct kset_uevent_ops *uevent_ops; | 174 | const struct kset_uevent_ops *uevent_ops; |
175 | }; | 175 | } __randomize_layout; |
176 | 176 | ||
177 | extern void kset_init(struct kset *kset); | 177 | extern void kset_init(struct kset *kset); |
178 | extern int __must_check kset_register(struct kset *kset); | 178 | extern int __must_check kset_register(struct kset *kset); |
diff --git a/include/linux/llist.h b/include/linux/llist.h index d11738110a7a..1957635e6d5f 100644 --- a/include/linux/llist.h +++ b/include/linux/llist.h | |||
@@ -93,6 +93,23 @@ static inline void init_llist_head(struct llist_head *list) | |||
93 | container_of(ptr, type, member) | 93 | container_of(ptr, type, member) |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * member_address_is_nonnull - check whether the member address is not NULL | ||
97 | * @ptr: the object pointer (struct type * that contains the llist_node) | ||
98 | * @member: the name of the llist_node within the struct. | ||
99 | * | ||
100 | * This macro is conceptually the same as | ||
101 | * &ptr->member != NULL | ||
102 | * but it works around the fact that compilers can decide that taking a member | ||
103 | * address is never a NULL pointer. | ||
104 | * | ||
105 | * Real objects that start at a high address and have a member at NULL are | ||
106 | * unlikely to exist, but such pointers may be returned e.g. by the | ||
107 | * container_of() macro. | ||
108 | */ | ||
109 | #define member_address_is_nonnull(ptr, member) \ | ||
110 | ((uintptr_t)(ptr) + offsetof(typeof(*(ptr)), member) != 0) | ||
111 | |||
112 | /** | ||
96 | * llist_for_each - iterate over some deleted entries of a lock-less list | 113 | * llist_for_each - iterate over some deleted entries of a lock-less list |
97 | * @pos: the &struct llist_node to use as a loop cursor | 114 | * @pos: the &struct llist_node to use as a loop cursor |
98 | * @node: the first entry of deleted list entries | 115 | * @node: the first entry of deleted list entries |
@@ -145,7 +162,7 @@ static inline void init_llist_head(struct llist_head *list) | |||
145 | */ | 162 | */ |
146 | #define llist_for_each_entry(pos, node, member) \ | 163 | #define llist_for_each_entry(pos, node, member) \ |
147 | for ((pos) = llist_entry((node), typeof(*(pos)), member); \ | 164 | for ((pos) = llist_entry((node), typeof(*(pos)), member); \ |
148 | &(pos)->member != NULL; \ | 165 | member_address_is_nonnull(pos, member); \ |
149 | (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member)) | 166 | (pos) = llist_entry((pos)->member.next, typeof(*(pos)), member)) |
150 | 167 | ||
151 | /** | 168 | /** |
@@ -167,7 +184,7 @@ static inline void init_llist_head(struct llist_head *list) | |||
167 | */ | 184 | */ |
168 | #define llist_for_each_entry_safe(pos, n, node, member) \ | 185 | #define llist_for_each_entry_safe(pos, n, node, member) \ |
169 | for (pos = llist_entry((node), typeof(*pos), member); \ | 186 | for (pos = llist_entry((node), typeof(*pos), member); \ |
170 | &pos->member != NULL && \ | 187 | member_address_is_nonnull(pos, member) && \ |
171 | (n = llist_entry(pos->member.next, typeof(*n), member), true); \ | 188 | (n = llist_entry(pos->member.next, typeof(*n), member), true); \ |
172 | pos = n) | 189 | pos = n) |
173 | 190 | ||
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h index 7a86925ba8f3..3a90febadbe2 100644 --- a/include/linux/lsm_hooks.h +++ b/include/linux/lsm_hooks.h | |||
@@ -1912,7 +1912,7 @@ struct security_hook_heads { | |||
1912 | struct list_head audit_rule_match; | 1912 | struct list_head audit_rule_match; |
1913 | struct list_head audit_rule_free; | 1913 | struct list_head audit_rule_free; |
1914 | #endif /* CONFIG_AUDIT */ | 1914 | #endif /* CONFIG_AUDIT */ |
1915 | }; | 1915 | } __randomize_layout; |
1916 | 1916 | ||
1917 | /* | 1917 | /* |
1918 | * Security module hook list structure. | 1918 | * Security module hook list structure. |
@@ -1923,7 +1923,7 @@ struct security_hook_list { | |||
1923 | struct list_head *head; | 1923 | struct list_head *head; |
1924 | union security_list_options hook; | 1924 | union security_list_options hook; |
1925 | char *lsm; | 1925 | char *lsm; |
1926 | }; | 1926 | } __randomize_layout; |
1927 | 1927 | ||
1928 | /* | 1928 | /* |
1929 | * Initializing a security_hook_list structure takes | 1929 | * Initializing a security_hook_list structure takes |
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index d5bed0875d30..aad5d81dfb44 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
@@ -1068,7 +1068,7 @@ static inline int mlx4_is_eth(struct mlx4_dev *dev, int port) | |||
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, | 1070 | int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct, |
1071 | struct mlx4_buf *buf, gfp_t gfp); | 1071 | struct mlx4_buf *buf); |
1072 | void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); | 1072 | void mlx4_buf_free(struct mlx4_dev *dev, int size, struct mlx4_buf *buf); |
1073 | static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset) | 1073 | static inline void *mlx4_buf_offset(struct mlx4_buf *buf, int offset) |
1074 | { | 1074 | { |
@@ -1105,10 +1105,9 @@ int mlx4_mw_enable(struct mlx4_dev *dev, struct mlx4_mw *mw); | |||
1105 | int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | 1105 | int mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
1106 | int start_index, int npages, u64 *page_list); | 1106 | int start_index, int npages, u64 *page_list); |
1107 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, | 1107 | int mlx4_buf_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
1108 | struct mlx4_buf *buf, gfp_t gfp); | 1108 | struct mlx4_buf *buf); |
1109 | 1109 | ||
1110 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order, | 1110 | int mlx4_db_alloc(struct mlx4_dev *dev, struct mlx4_db *db, int order); |
1111 | gfp_t gfp); | ||
1112 | void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); | 1111 | void mlx4_db_free(struct mlx4_dev *dev, struct mlx4_db *db); |
1113 | 1112 | ||
1114 | int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, | 1113 | int mlx4_alloc_hwq_res(struct mlx4_dev *dev, struct mlx4_hwq_resources *wqres, |
@@ -1124,8 +1123,7 @@ int mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, | |||
1124 | int *base, u8 flags); | 1123 | int *base, u8 flags); |
1125 | void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); | 1124 | void mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); |
1126 | 1125 | ||
1127 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, | 1126 | int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp); |
1128 | gfp_t gfp); | ||
1129 | void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp); | 1127 | void mlx4_qp_free(struct mlx4_dev *dev, struct mlx4_qp *qp); |
1130 | 1128 | ||
1131 | int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn, | 1129 | int mlx4_srq_alloc(struct mlx4_dev *dev, u32 pdn, u32 cqn, u16 xrcdn, |
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 45cdb27791a3..ff151814a02d 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h | |||
@@ -342,7 +342,7 @@ struct vm_area_struct { | |||
342 | struct mempolicy *vm_policy; /* NUMA policy for the VMA */ | 342 | struct mempolicy *vm_policy; /* NUMA policy for the VMA */ |
343 | #endif | 343 | #endif |
344 | struct vm_userfaultfd_ctx vm_userfaultfd_ctx; | 344 | struct vm_userfaultfd_ctx vm_userfaultfd_ctx; |
345 | }; | 345 | } __randomize_layout; |
346 | 346 | ||
347 | struct core_thread { | 347 | struct core_thread { |
348 | struct task_struct *task; | 348 | struct task_struct *task; |
@@ -500,7 +500,7 @@ struct mm_struct { | |||
500 | atomic_long_t hugetlb_usage; | 500 | atomic_long_t hugetlb_usage; |
501 | #endif | 501 | #endif |
502 | struct work_struct async_put_work; | 502 | struct work_struct async_put_work; |
503 | }; | 503 | } __randomize_layout; |
504 | 504 | ||
505 | extern struct mm_struct init_mm; | 505 | extern struct mm_struct init_mm; |
506 | 506 | ||
diff --git a/include/linux/module.h b/include/linux/module.h index 8eb9a1e693e5..e7bdd549e527 100644 --- a/include/linux/module.h +++ b/include/linux/module.h | |||
@@ -45,7 +45,7 @@ struct module_kobject { | |||
45 | struct kobject *drivers_dir; | 45 | struct kobject *drivers_dir; |
46 | struct module_param_attrs *mp; | 46 | struct module_param_attrs *mp; |
47 | struct completion *kobj_completion; | 47 | struct completion *kobj_completion; |
48 | }; | 48 | } __randomize_layout; |
49 | 49 | ||
50 | struct module_attribute { | 50 | struct module_attribute { |
51 | struct attribute attr; | 51 | struct attribute attr; |
@@ -475,7 +475,7 @@ struct module { | |||
475 | ctor_fn_t *ctors; | 475 | ctor_fn_t *ctors; |
476 | unsigned int num_ctors; | 476 | unsigned int num_ctors; |
477 | #endif | 477 | #endif |
478 | } ____cacheline_aligned; | 478 | } ____cacheline_aligned __randomize_layout; |
479 | #ifndef MODULE_ARCH_INIT | 479 | #ifndef MODULE_ARCH_INIT |
480 | #define MODULE_ARCH_INIT {} | 480 | #define MODULE_ARCH_INIT {} |
481 | #endif | 481 | #endif |
diff --git a/include/linux/mount.h b/include/linux/mount.h index 8e0352af06b7..1ce85e6fd95f 100644 --- a/include/linux/mount.h +++ b/include/linux/mount.h | |||
@@ -67,7 +67,7 @@ struct vfsmount { | |||
67 | struct dentry *mnt_root; /* root of the mounted tree */ | 67 | struct dentry *mnt_root; /* root of the mounted tree */ |
68 | struct super_block *mnt_sb; /* pointer to superblock */ | 68 | struct super_block *mnt_sb; /* pointer to superblock */ |
69 | int mnt_flags; | 69 | int mnt_flags; |
70 | }; | 70 | } __randomize_layout; |
71 | 71 | ||
72 | struct file; /* forward dec */ | 72 | struct file; /* forward dec */ |
73 | struct path; | 73 | struct path; |
diff --git a/include/linux/msg.h b/include/linux/msg.h index f3f302f9c197..a001305f5a79 100644 --- a/include/linux/msg.h +++ b/include/linux/msg.h | |||
@@ -29,7 +29,7 @@ struct msg_queue { | |||
29 | struct list_head q_messages; | 29 | struct list_head q_messages; |
30 | struct list_head q_receivers; | 30 | struct list_head q_receivers; |
31 | struct list_head q_senders; | 31 | struct list_head q_senders; |
32 | }; | 32 | } __randomize_layout; |
33 | 33 | ||
34 | /* Helper routines for sys_msgsnd and sys_msgrcv */ | 34 | /* Helper routines for sys_msgsnd and sys_msgrcv */ |
35 | extern long do_msgsnd(int msqid, long mtype, void __user *mtext, | 35 | extern long do_msgsnd(int msqid, long mtype, void __user *mtext, |
diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h index a4b97be30b28..22f081065d49 100644 --- a/include/linux/netfilter.h +++ b/include/linux/netfilter.h | |||
@@ -61,8 +61,6 @@ typedef unsigned int nf_hookfn(void *priv, | |||
61 | struct sk_buff *skb, | 61 | struct sk_buff *skb, |
62 | const struct nf_hook_state *state); | 62 | const struct nf_hook_state *state); |
63 | struct nf_hook_ops { | 63 | struct nf_hook_ops { |
64 | struct list_head list; | ||
65 | |||
66 | /* User fills in from here down. */ | 64 | /* User fills in from here down. */ |
67 | nf_hookfn *hook; | 65 | nf_hookfn *hook; |
68 | struct net_device *dev; | 66 | struct net_device *dev; |
@@ -160,13 +158,6 @@ int nf_register_net_hooks(struct net *net, const struct nf_hook_ops *reg, | |||
160 | void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg, | 158 | void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg, |
161 | unsigned int n); | 159 | unsigned int n); |
162 | 160 | ||
163 | int nf_register_hook(struct nf_hook_ops *reg); | ||
164 | void nf_unregister_hook(struct nf_hook_ops *reg); | ||
165 | int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n); | ||
166 | void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n); | ||
167 | int _nf_register_hooks(struct nf_hook_ops *reg, unsigned int n); | ||
168 | void _nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n); | ||
169 | |||
170 | /* Functions to register get/setsockopt ranges (non-inclusive). You | 161 | /* Functions to register get/setsockopt ranges (non-inclusive). You |
171 | need to check permissions yourself! */ | 162 | need to check permissions yourself! */ |
172 | int nf_register_sockopt(struct nf_sockopt_ops *reg); | 163 | int nf_register_sockopt(struct nf_sockopt_ops *reg); |
diff --git a/include/linux/path.h b/include/linux/path.h index d1372186f431..cde895cc4af4 100644 --- a/include/linux/path.h +++ b/include/linux/path.h | |||
@@ -7,7 +7,7 @@ struct vfsmount; | |||
7 | struct path { | 7 | struct path { |
8 | struct vfsmount *mnt; | 8 | struct vfsmount *mnt; |
9 | struct dentry *dentry; | 9 | struct dentry *dentry; |
10 | }; | 10 | } __randomize_layout; |
11 | 11 | ||
12 | extern void path_get(const struct path *); | 12 | extern void path_get(const struct path *); |
13 | extern void path_put(const struct path *); | 13 | extern void path_put(const struct path *); |
diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h index c2a989dee876..b09136f88cf4 100644 --- a/include/linux/pid_namespace.h +++ b/include/linux/pid_namespace.h | |||
@@ -52,7 +52,7 @@ struct pid_namespace { | |||
52 | int hide_pid; | 52 | int hide_pid; |
53 | int reboot; /* group exit code if this pidns was rebooted */ | 53 | int reboot; /* group exit code if this pidns was rebooted */ |
54 | struct ns_common ns; | 54 | struct ns_common ns; |
55 | }; | 55 | } __randomize_layout; |
56 | 56 | ||
57 | extern struct pid_namespace init_pid_ns; | 57 | extern struct pid_namespace init_pid_ns; |
58 | 58 | ||
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h index 58ab28d81fc2..06844b54dfc1 100644 --- a/include/linux/proc_ns.h +++ b/include/linux/proc_ns.h | |||
@@ -21,7 +21,7 @@ struct proc_ns_operations { | |||
21 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); | 21 | int (*install)(struct nsproxy *nsproxy, struct ns_common *ns); |
22 | struct user_namespace *(*owner)(struct ns_common *ns); | 22 | struct user_namespace *(*owner)(struct ns_common *ns); |
23 | struct ns_common *(*get_parent)(struct ns_common *ns); | 23 | struct ns_common *(*get_parent)(struct ns_common *ns); |
24 | }; | 24 | } __randomize_layout; |
25 | 25 | ||
26 | extern const struct proc_ns_operations netns_operations; | 26 | extern const struct proc_ns_operations netns_operations; |
27 | extern const struct proc_ns_operations utsns_operations; | 27 | extern const struct proc_ns_operations utsns_operations; |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 2ba9ec93423f..8337e2db0bb2 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -426,7 +426,7 @@ struct sched_rt_entity { | |||
426 | /* rq "owned" by this entity/group: */ | 426 | /* rq "owned" by this entity/group: */ |
427 | struct rt_rq *my_q; | 427 | struct rt_rq *my_q; |
428 | #endif | 428 | #endif |
429 | }; | 429 | } __randomize_layout; |
430 | 430 | ||
431 | struct sched_dl_entity { | 431 | struct sched_dl_entity { |
432 | struct rb_node rb_node; | 432 | struct rb_node rb_node; |
@@ -526,6 +526,13 @@ struct task_struct { | |||
526 | #endif | 526 | #endif |
527 | /* -1 unrunnable, 0 runnable, >0 stopped: */ | 527 | /* -1 unrunnable, 0 runnable, >0 stopped: */ |
528 | volatile long state; | 528 | volatile long state; |
529 | |||
530 | /* | ||
531 | * This begins the randomizable portion of task_struct. Only | ||
532 | * scheduling-critical items should be added above here. | ||
533 | */ | ||
534 | randomized_struct_fields_start | ||
535 | |||
529 | void *stack; | 536 | void *stack; |
530 | atomic_t usage; | 537 | atomic_t usage; |
531 | /* Per task flags (PF_*), defined further below: */ | 538 | /* Per task flags (PF_*), defined further below: */ |
@@ -1079,6 +1086,13 @@ struct task_struct { | |||
1079 | /* Used by LSM modules for access restriction: */ | 1086 | /* Used by LSM modules for access restriction: */ |
1080 | void *security; | 1087 | void *security; |
1081 | #endif | 1088 | #endif |
1089 | |||
1090 | /* | ||
1091 | * New fields for task_struct should be added above here, so that | ||
1092 | * they are included in the randomized portion of task_struct. | ||
1093 | */ | ||
1094 | randomized_struct_fields_end | ||
1095 | |||
1082 | /* CPU-specific state of this task: */ | 1096 | /* CPU-specific state of this task: */ |
1083 | struct thread_struct thread; | 1097 | struct thread_struct thread; |
1084 | 1098 | ||
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index c06d63b3a583..2a0dd40b15db 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h | |||
@@ -222,7 +222,7 @@ struct signal_struct { | |||
222 | struct mutex cred_guard_mutex; /* guard against foreign influences on | 222 | struct mutex cred_guard_mutex; /* guard against foreign influences on |
223 | * credential calculations | 223 | * credential calculations |
224 | * (notably. ptrace) */ | 224 | * (notably. ptrace) */ |
225 | }; | 225 | } __randomize_layout; |
226 | 226 | ||
227 | /* | 227 | /* |
228 | * Bits in flags field of signal_struct. | 228 | * Bits in flags field of signal_struct. |
diff --git a/include/linux/sem.h b/include/linux/sem.h index be5cf2ea14ad..de2deb8676bd 100644 --- a/include/linux/sem.h +++ b/include/linux/sem.h | |||
@@ -41,7 +41,7 @@ struct sem_array { | |||
41 | unsigned int use_global_lock;/* >0: global lock required */ | 41 | unsigned int use_global_lock;/* >0: global lock required */ |
42 | 42 | ||
43 | struct sem sems[]; | 43 | struct sem sems[]; |
44 | }; | 44 | } __randomize_layout; |
45 | 45 | ||
46 | #ifdef CONFIG_SYSVIPC | 46 | #ifdef CONFIG_SYSVIPC |
47 | 47 | ||
diff --git a/include/linux/shm.h b/include/linux/shm.h index 04e881829625..0fb7061ec54c 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h | |||
@@ -22,7 +22,7 @@ struct shmid_kernel /* private to the kernel */ | |||
22 | /* The task created the shm object. NULL if the task is dead. */ | 22 | /* The task created the shm object. NULL if the task is dead. */ |
23 | struct task_struct *shm_creator; | 23 | struct task_struct *shm_creator; |
24 | struct list_head shm_clist; /* list by creator */ | 24 | struct list_head shm_clist; /* list by creator */ |
25 | }; | 25 | } __randomize_layout; |
26 | 26 | ||
27 | /* shm_mode upper byte flags */ | 27 | /* shm_mode upper byte flags */ |
28 | #define SHM_DEST 01000 /* segment will be destroyed on last detach */ | 28 | #define SHM_DEST 01000 /* segment will be destroyed on last detach */ |
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 3a89b9ff4cdc..1d4dba490fb6 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h | |||
@@ -120,7 +120,7 @@ struct ctl_table | |||
120 | struct ctl_table_poll *poll; | 120 | struct ctl_table_poll *poll; |
121 | void *extra1; | 121 | void *extra1; |
122 | void *extra2; | 122 | void *extra2; |
123 | }; | 123 | } __randomize_layout; |
124 | 124 | ||
125 | struct ctl_node { | 125 | struct ctl_node { |
126 | struct rb_node node; | 126 | struct rb_node node; |
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index f73cedfa2e0b..536c80ff7ad9 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h | |||
@@ -338,7 +338,7 @@ enum { | |||
338 | struct trace_event_file { | 338 | struct trace_event_file { |
339 | struct list_head list; | 339 | struct list_head list; |
340 | struct trace_event_call *event_call; | 340 | struct trace_event_call *event_call; |
341 | struct event_filter *filter; | 341 | struct event_filter __rcu *filter; |
342 | struct dentry *dir; | 342 | struct dentry *dir; |
343 | struct trace_array *tr; | 343 | struct trace_array *tr; |
344 | struct trace_subsystem_dir *system; | 344 | struct trace_subsystem_dir *system; |
diff --git a/include/linux/tty.h b/include/linux/tty.h index 69464c0d8068..79c30daf46a9 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h | |||
@@ -332,7 +332,7 @@ struct tty_struct { | |||
332 | /* If the tty has a pending do_SAK, queue it here - akpm */ | 332 | /* If the tty has a pending do_SAK, queue it here - akpm */ |
333 | struct work_struct SAK_work; | 333 | struct work_struct SAK_work; |
334 | struct tty_port *port; | 334 | struct tty_port *port; |
335 | }; | 335 | } __randomize_layout; |
336 | 336 | ||
337 | /* Each of a tty's open files has private_data pointing to tty_file_private */ | 337 | /* Each of a tty's open files has private_data pointing to tty_file_private */ |
338 | struct tty_file_private { | 338 | struct tty_file_private { |
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index b742b5e47cc2..00b2213f6a35 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
@@ -291,7 +291,7 @@ struct tty_operations { | |||
291 | void (*poll_put_char)(struct tty_driver *driver, int line, char ch); | 291 | void (*poll_put_char)(struct tty_driver *driver, int line, char ch); |
292 | #endif | 292 | #endif |
293 | const struct file_operations *proc_fops; | 293 | const struct file_operations *proc_fops; |
294 | }; | 294 | } __randomize_layout; |
295 | 295 | ||
296 | struct tty_driver { | 296 | struct tty_driver { |
297 | int magic; /* magic number for this structure */ | 297 | int magic; /* magic number for this structure */ |
@@ -325,7 +325,7 @@ struct tty_driver { | |||
325 | 325 | ||
326 | const struct tty_operations *ops; | 326 | const struct tty_operations *ops; |
327 | struct list_head tty_drivers; | 327 | struct list_head tty_drivers; |
328 | }; | 328 | } __randomize_layout; |
329 | 329 | ||
330 | extern struct list_head tty_drivers; | 330 | extern struct list_head tty_drivers; |
331 | 331 | ||
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h index 021f7a88f52c..1a59699cf82a 100644 --- a/include/linux/usb/cdc_ncm.h +++ b/include/linux/usb/cdc_ncm.h | |||
@@ -83,6 +83,7 @@ | |||
83 | /* Driver flags */ | 83 | /* Driver flags */ |
84 | #define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */ | 84 | #define CDC_NCM_FLAG_NDP_TO_END 0x02 /* NDP is placed at end of frame */ |
85 | #define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE 0x04 /* Avoid altsetting toggle during init */ | 85 | #define CDC_MBIM_FLAG_AVOID_ALTSETTING_TOGGLE 0x04 /* Avoid altsetting toggle during init */ |
86 | #define CDC_NCM_FLAG_RESET_NTB16 0x08 /* set NDP16 one more time after altsetting switch */ | ||
86 | 87 | ||
87 | #define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ | 88 | #define cdc_ncm_comm_intf_is_mbim(x) ((x)->desc.bInterfaceSubClass == USB_CDC_SUBCLASS_MBIM && \ |
88 | (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE) | 89 | (x)->desc.bInterfaceProtocol == USB_CDC_PROTO_NONE) |
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h index 32354b4b4b2b..b3575ce29148 100644 --- a/include/linux/user_namespace.h +++ b/include/linux/user_namespace.h | |||
@@ -66,7 +66,7 @@ struct user_namespace { | |||
66 | #endif | 66 | #endif |
67 | struct ucounts *ucounts; | 67 | struct ucounts *ucounts; |
68 | int ucount_max[UCOUNT_COUNTS]; | 68 | int ucount_max[UCOUNT_COUNTS]; |
69 | }; | 69 | } __randomize_layout; |
70 | 70 | ||
71 | struct ucounts { | 71 | struct ucounts { |
72 | struct hlist_node node; | 72 | struct hlist_node node; |
diff --git a/include/linux/utsname.h b/include/linux/utsname.h index 60f0bb83b313..da826ed059cf 100644 --- a/include/linux/utsname.h +++ b/include/linux/utsname.h | |||
@@ -26,7 +26,7 @@ struct uts_namespace { | |||
26 | struct user_namespace *user_ns; | 26 | struct user_namespace *user_ns; |
27 | struct ucounts *ucounts; | 27 | struct ucounts *ucounts; |
28 | struct ns_common ns; | 28 | struct ns_common ns; |
29 | }; | 29 | } __randomize_layout; |
30 | extern struct uts_namespace init_uts_ns; | 30 | extern struct uts_namespace init_uts_ns; |
31 | 31 | ||
32 | #ifdef CONFIG_UTS_NS | 32 | #ifdef CONFIG_UTS_NS |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 678e4d6fa317..53b1a2cca421 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -37,7 +37,7 @@ struct unix_skb_parms { | |||
37 | u32 secid; /* Security ID */ | 37 | u32 secid; /* Security ID */ |
38 | #endif | 38 | #endif |
39 | u32 consumed; | 39 | u32 consumed; |
40 | }; | 40 | } __randomize_layout; |
41 | 41 | ||
42 | #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) | 42 | #define UNIXCB(skb) (*(struct unix_skb_parms *)&((skb)->cb)) |
43 | 43 | ||
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index afc39e3a3f7c..9816df225af3 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -156,7 +156,7 @@ struct neighbour { | |||
156 | struct rcu_head rcu; | 156 | struct rcu_head rcu; |
157 | struct net_device *dev; | 157 | struct net_device *dev; |
158 | u8 primary_key[0]; | 158 | u8 primary_key[0]; |
159 | }; | 159 | } __randomize_layout; |
160 | 160 | ||
161 | struct neigh_ops { | 161 | struct neigh_ops { |
162 | int family; | 162 | int family; |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 31a2b51bef2c..1c401bd4c2e0 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -148,7 +148,7 @@ struct net { | |||
148 | #endif | 148 | #endif |
149 | struct sock *diag_nlsk; | 149 | struct sock *diag_nlsk; |
150 | atomic_t fnhe_genid; | 150 | atomic_t fnhe_genid; |
151 | }; | 151 | } __randomize_layout; |
152 | 152 | ||
153 | #include <linux/seq_file_net.h> | 153 | #include <linux/seq_file_net.h> |
154 | 154 | ||
diff --git a/include/net/netlink.h b/include/net/netlink.h index 01709172b3d3..ef8e6c3a80a6 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -98,8 +98,8 @@ | |||
98 | * nla_put_u8(skb, type, value) add u8 attribute to skb | 98 | * nla_put_u8(skb, type, value) add u8 attribute to skb |
99 | * nla_put_u16(skb, type, value) add u16 attribute to skb | 99 | * nla_put_u16(skb, type, value) add u16 attribute to skb |
100 | * nla_put_u32(skb, type, value) add u32 attribute to skb | 100 | * nla_put_u32(skb, type, value) add u32 attribute to skb |
101 | * nla_put_u64_64bits(skb, type, | 101 | * nla_put_u64_64bit(skb, type, |
102 | * value, padattr) add u64 attribute to skb | 102 | * value, padattr) add u64 attribute to skb |
103 | * nla_put_s8(skb, type, value) add s8 attribute to skb | 103 | * nla_put_s8(skb, type, value) add s8 attribute to skb |
104 | * nla_put_s16(skb, type, value) add s16 attribute to skb | 104 | * nla_put_s16(skb, type, value) add s16 attribute to skb |
105 | * nla_put_s32(skb, type, value) add s32 attribute to skb | 105 | * nla_put_s32(skb, type, value) add s32 attribute to skb |
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index a9519a06a23b..980807d7506f 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -469,6 +469,8 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) | |||
469 | 469 | ||
470 | #define _sctp_walk_params(pos, chunk, end, member)\ | 470 | #define _sctp_walk_params(pos, chunk, end, member)\ |
471 | for (pos.v = chunk->member;\ | 471 | for (pos.v = chunk->member;\ |
472 | (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <\ | ||
473 | (void *)chunk + end) &&\ | ||
472 | pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ | 474 | pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ |
473 | ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\ | 475 | ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\ |
474 | pos.v += SCTP_PAD4(ntohs(pos.p->length))) | 476 | pos.v += SCTP_PAD4(ntohs(pos.p->length))) |
@@ -479,6 +481,8 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length)) | |||
479 | #define _sctp_walk_errors(err, chunk_hdr, end)\ | 481 | #define _sctp_walk_errors(err, chunk_hdr, end)\ |
480 | for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ | 482 | for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ |
481 | sizeof(struct sctp_chunkhdr));\ | 483 | sizeof(struct sctp_chunkhdr));\ |
484 | ((void *)err + offsetof(sctp_errhdr_t, length) + sizeof(err->length) <\ | ||
485 | (void *)chunk_hdr + end) &&\ | ||
482 | (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ | 486 | (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ |
483 | ntohs(err->length) >= sizeof(sctp_errhdr_t); \ | 487 | ntohs(err->length) >= sizeof(sctp_errhdr_t); \ |
484 | err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length)))) | 488 | err = (sctp_errhdr_t *)((void *)err + SCTP_PAD4(ntohs(err->length)))) |
diff --git a/include/net/sock.h b/include/net/sock.h index f69c8c2782df..7c0632c7e870 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -1128,7 +1128,7 @@ struct proto { | |||
1128 | atomic_t socks; | 1128 | atomic_t socks; |
1129 | #endif | 1129 | #endif |
1130 | int (*diag_destroy)(struct sock *sk, int err); | 1130 | int (*diag_destroy)(struct sock *sk, int err); |
1131 | }; | 1131 | } __randomize_layout; |
1132 | 1132 | ||
1133 | int proto_register(struct proto *prot, int alloc_slab); | 1133 | int proto_register(struct proto *prot, int alloc_slab); |
1134 | void proto_unregister(struct proto *prot); | 1134 | void proto_unregister(struct proto *prot); |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 356953d3dbd1..b5732432bb29 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -1056,7 +1056,7 @@ enum ib_qp_create_flags { | |||
1056 | IB_QP_CREATE_MANAGED_RECV = 1 << 4, | 1056 | IB_QP_CREATE_MANAGED_RECV = 1 << 4, |
1057 | IB_QP_CREATE_NETIF_QP = 1 << 5, | 1057 | IB_QP_CREATE_NETIF_QP = 1 << 5, |
1058 | IB_QP_CREATE_SIGNATURE_EN = 1 << 6, | 1058 | IB_QP_CREATE_SIGNATURE_EN = 1 << 6, |
1059 | IB_QP_CREATE_USE_GFP_NOIO = 1 << 7, | 1059 | /* FREE = 1 << 7, */ |
1060 | IB_QP_CREATE_SCATTER_FCS = 1 << 8, | 1060 | IB_QP_CREATE_SCATTER_FCS = 1 << 8, |
1061 | IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9, | 1061 | IB_QP_CREATE_CVLAN_STRIPPING = 1 << 9, |
1062 | /* reserve bits 26-31 for low level drivers' internal use */ | 1062 | /* reserve bits 26-31 for low level drivers' internal use */ |
@@ -2948,6 +2948,22 @@ struct ib_qp *ib_create_qp(struct ib_pd *pd, | |||
2948 | struct ib_qp_init_attr *qp_init_attr); | 2948 | struct ib_qp_init_attr *qp_init_attr); |
2949 | 2949 | ||
2950 | /** | 2950 | /** |
2951 | * ib_modify_qp_with_udata - Modifies the attributes for the specified QP. | ||
2952 | * @qp: The QP to modify. | ||
2953 | * @attr: On input, specifies the QP attributes to modify. On output, | ||
2954 | * the current values of selected QP attributes are returned. | ||
2955 | * @attr_mask: A bit-mask used to specify which attributes of the QP | ||
2956 | * are being modified. | ||
2957 | * @udata: pointer to user's input output buffer information | ||
2958 | * are being modified. | ||
2959 | * It returns 0 on success and returns appropriate error code on error. | ||
2960 | */ | ||
2961 | int ib_modify_qp_with_udata(struct ib_qp *qp, | ||
2962 | struct ib_qp_attr *attr, | ||
2963 | int attr_mask, | ||
2964 | struct ib_udata *udata); | ||
2965 | |||
2966 | /** | ||
2951 | * ib_modify_qp - Modifies the attributes for the specified QP and then | 2967 | * ib_modify_qp - Modifies the attributes for the specified QP and then |
2952 | * transitions the QP to the given state. | 2968 | * transitions the QP to the given state. |
2953 | * @qp: The QP to modify. | 2969 | * @qp: The QP to modify. |
diff --git a/include/rdma/rdma_vt.h b/include/rdma/rdma_vt.h index 4878aaf7bdff..55af69271053 100644 --- a/include/rdma/rdma_vt.h +++ b/include/rdma/rdma_vt.h | |||
@@ -229,8 +229,7 @@ struct rvt_driver_provided { | |||
229 | * ERR_PTR(err). The driver is free to return NULL or a valid | 229 | * ERR_PTR(err). The driver is free to return NULL or a valid |
230 | * pointer. | 230 | * pointer. |
231 | */ | 231 | */ |
232 | void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp, | 232 | void * (*qp_priv_alloc)(struct rvt_dev_info *rdi, struct rvt_qp *qp); |
233 | gfp_t gfp); | ||
234 | 233 | ||
235 | /* | 234 | /* |
236 | * Free the driver's private qp structure. | 235 | * Free the driver's private qp structure. |
@@ -319,7 +318,7 @@ struct rvt_driver_provided { | |||
319 | 318 | ||
320 | /* Let the driver pick the next queue pair number*/ | 319 | /* Let the driver pick the next queue pair number*/ |
321 | int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, | 320 | int (*alloc_qpn)(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, |
322 | enum ib_qp_type type, u8 port_num, gfp_t gfp); | 321 | enum ib_qp_type type, u8 port_num); |
323 | 322 | ||
324 | /* Determine if its safe or allowed to modify the qp */ | 323 | /* Determine if its safe or allowed to modify the qp */ |
325 | int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr, | 324 | int (*check_modify_qp)(struct rvt_qp *qp, struct ib_qp_attr *attr, |
diff --git a/kernel/audit.c b/kernel/audit.c index 833267bbd80b..6dd556931739 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
@@ -641,6 +641,7 @@ static int auditd_send_unicast_skb(struct sk_buff *skb) | |||
641 | ac = rcu_dereference(auditd_conn); | 641 | ac = rcu_dereference(auditd_conn); |
642 | if (!ac) { | 642 | if (!ac) { |
643 | rcu_read_unlock(); | 643 | rcu_read_unlock(); |
644 | kfree_skb(skb); | ||
644 | rc = -ECONNREFUSED; | 645 | rc = -ECONNREFUSED; |
645 | goto err; | 646 | goto err; |
646 | } | 647 | } |
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 6a86723c5b64..af9e84a4944e 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
@@ -504,6 +504,7 @@ static void reset_reg_range_values(struct bpf_reg_state *regs, u32 regno) | |||
504 | { | 504 | { |
505 | regs[regno].min_value = BPF_REGISTER_MIN_RANGE; | 505 | regs[regno].min_value = BPF_REGISTER_MIN_RANGE; |
506 | regs[regno].max_value = BPF_REGISTER_MAX_RANGE; | 506 | regs[regno].max_value = BPF_REGISTER_MAX_RANGE; |
507 | regs[regno].value_from_signed = false; | ||
507 | regs[regno].min_align = 0; | 508 | regs[regno].min_align = 0; |
508 | } | 509 | } |
509 | 510 | ||
@@ -777,12 +778,13 @@ static int check_ctx_access(struct bpf_verifier_env *env, int insn_idx, int off, | |||
777 | return -EACCES; | 778 | return -EACCES; |
778 | } | 779 | } |
779 | 780 | ||
780 | static bool is_pointer_value(struct bpf_verifier_env *env, int regno) | 781 | static bool __is_pointer_value(bool allow_ptr_leaks, |
782 | const struct bpf_reg_state *reg) | ||
781 | { | 783 | { |
782 | if (env->allow_ptr_leaks) | 784 | if (allow_ptr_leaks) |
783 | return false; | 785 | return false; |
784 | 786 | ||
785 | switch (env->cur_state.regs[regno].type) { | 787 | switch (reg->type) { |
786 | case UNKNOWN_VALUE: | 788 | case UNKNOWN_VALUE: |
787 | case CONST_IMM: | 789 | case CONST_IMM: |
788 | return false; | 790 | return false; |
@@ -791,6 +793,11 @@ static bool is_pointer_value(struct bpf_verifier_env *env, int regno) | |||
791 | } | 793 | } |
792 | } | 794 | } |
793 | 795 | ||
796 | static bool is_pointer_value(struct bpf_verifier_env *env, int regno) | ||
797 | { | ||
798 | return __is_pointer_value(env->allow_ptr_leaks, &env->cur_state.regs[regno]); | ||
799 | } | ||
800 | |||
794 | static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg, | 801 | static int check_pkt_ptr_alignment(const struct bpf_reg_state *reg, |
795 | int off, int size, bool strict) | 802 | int off, int size, bool strict) |
796 | { | 803 | { |
@@ -1832,10 +1839,24 @@ static void adjust_reg_min_max_vals(struct bpf_verifier_env *env, | |||
1832 | dst_align = dst_reg->min_align; | 1839 | dst_align = dst_reg->min_align; |
1833 | 1840 | ||
1834 | /* We don't know anything about what was done to this register, mark it | 1841 | /* We don't know anything about what was done to this register, mark it |
1835 | * as unknown. | 1842 | * as unknown. Also, if both derived bounds came from signed/unsigned |
1843 | * mixed compares and one side is unbounded, we cannot really do anything | ||
1844 | * with them as boundaries cannot be trusted. Thus, arithmetic of two | ||
1845 | * regs of such kind will get invalidated bounds on the dst side. | ||
1836 | */ | 1846 | */ |
1837 | if (min_val == BPF_REGISTER_MIN_RANGE && | 1847 | if ((min_val == BPF_REGISTER_MIN_RANGE && |
1838 | max_val == BPF_REGISTER_MAX_RANGE) { | 1848 | max_val == BPF_REGISTER_MAX_RANGE) || |
1849 | (BPF_SRC(insn->code) == BPF_X && | ||
1850 | ((min_val != BPF_REGISTER_MIN_RANGE && | ||
1851 | max_val == BPF_REGISTER_MAX_RANGE) || | ||
1852 | (min_val == BPF_REGISTER_MIN_RANGE && | ||
1853 | max_val != BPF_REGISTER_MAX_RANGE) || | ||
1854 | (dst_reg->min_value != BPF_REGISTER_MIN_RANGE && | ||
1855 | dst_reg->max_value == BPF_REGISTER_MAX_RANGE) || | ||
1856 | (dst_reg->min_value == BPF_REGISTER_MIN_RANGE && | ||
1857 | dst_reg->max_value != BPF_REGISTER_MAX_RANGE)) && | ||
1858 | regs[insn->dst_reg].value_from_signed != | ||
1859 | regs[insn->src_reg].value_from_signed)) { | ||
1839 | reset_reg_range_values(regs, insn->dst_reg); | 1860 | reset_reg_range_values(regs, insn->dst_reg); |
1840 | return; | 1861 | return; |
1841 | } | 1862 | } |
@@ -2023,6 +2044,7 @@ static int check_alu_op(struct bpf_verifier_env *env, struct bpf_insn *insn) | |||
2023 | regs[insn->dst_reg].max_value = insn->imm; | 2044 | regs[insn->dst_reg].max_value = insn->imm; |
2024 | regs[insn->dst_reg].min_value = insn->imm; | 2045 | regs[insn->dst_reg].min_value = insn->imm; |
2025 | regs[insn->dst_reg].min_align = calc_align(insn->imm); | 2046 | regs[insn->dst_reg].min_align = calc_align(insn->imm); |
2047 | regs[insn->dst_reg].value_from_signed = false; | ||
2026 | } | 2048 | } |
2027 | 2049 | ||
2028 | } else if (opcode > BPF_END) { | 2050 | } else if (opcode > BPF_END) { |
@@ -2198,40 +2220,63 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg, | |||
2198 | struct bpf_reg_state *false_reg, u64 val, | 2220 | struct bpf_reg_state *false_reg, u64 val, |
2199 | u8 opcode) | 2221 | u8 opcode) |
2200 | { | 2222 | { |
2223 | bool value_from_signed = true; | ||
2224 | bool is_range = true; | ||
2225 | |||
2201 | switch (opcode) { | 2226 | switch (opcode) { |
2202 | case BPF_JEQ: | 2227 | case BPF_JEQ: |
2203 | /* If this is false then we know nothing Jon Snow, but if it is | 2228 | /* If this is false then we know nothing Jon Snow, but if it is |
2204 | * true then we know for sure. | 2229 | * true then we know for sure. |
2205 | */ | 2230 | */ |
2206 | true_reg->max_value = true_reg->min_value = val; | 2231 | true_reg->max_value = true_reg->min_value = val; |
2232 | is_range = false; | ||
2207 | break; | 2233 | break; |
2208 | case BPF_JNE: | 2234 | case BPF_JNE: |
2209 | /* If this is true we know nothing Jon Snow, but if it is false | 2235 | /* If this is true we know nothing Jon Snow, but if it is false |
2210 | * we know the value for sure; | 2236 | * we know the value for sure; |
2211 | */ | 2237 | */ |
2212 | false_reg->max_value = false_reg->min_value = val; | 2238 | false_reg->max_value = false_reg->min_value = val; |
2239 | is_range = false; | ||
2213 | break; | 2240 | break; |
2214 | case BPF_JGT: | 2241 | case BPF_JGT: |
2215 | /* Unsigned comparison, the minimum value is 0. */ | 2242 | value_from_signed = false; |
2216 | false_reg->min_value = 0; | ||
2217 | /* fallthrough */ | 2243 | /* fallthrough */ |
2218 | case BPF_JSGT: | 2244 | case BPF_JSGT: |
2245 | if (true_reg->value_from_signed != value_from_signed) | ||
2246 | reset_reg_range_values(true_reg, 0); | ||
2247 | if (false_reg->value_from_signed != value_from_signed) | ||
2248 | reset_reg_range_values(false_reg, 0); | ||
2249 | if (opcode == BPF_JGT) { | ||
2250 | /* Unsigned comparison, the minimum value is 0. */ | ||
2251 | false_reg->min_value = 0; | ||
2252 | } | ||
2219 | /* If this is false then we know the maximum val is val, | 2253 | /* If this is false then we know the maximum val is val, |
2220 | * otherwise we know the min val is val+1. | 2254 | * otherwise we know the min val is val+1. |
2221 | */ | 2255 | */ |
2222 | false_reg->max_value = val; | 2256 | false_reg->max_value = val; |
2257 | false_reg->value_from_signed = value_from_signed; | ||
2223 | true_reg->min_value = val + 1; | 2258 | true_reg->min_value = val + 1; |
2259 | true_reg->value_from_signed = value_from_signed; | ||
2224 | break; | 2260 | break; |
2225 | case BPF_JGE: | 2261 | case BPF_JGE: |
2226 | /* Unsigned comparison, the minimum value is 0. */ | 2262 | value_from_signed = false; |
2227 | false_reg->min_value = 0; | ||
2228 | /* fallthrough */ | 2263 | /* fallthrough */ |
2229 | case BPF_JSGE: | 2264 | case BPF_JSGE: |
2265 | if (true_reg->value_from_signed != value_from_signed) | ||
2266 | reset_reg_range_values(true_reg, 0); | ||
2267 | if (false_reg->value_from_signed != value_from_signed) | ||
2268 | reset_reg_range_values(false_reg, 0); | ||
2269 | if (opcode == BPF_JGE) { | ||
2270 | /* Unsigned comparison, the minimum value is 0. */ | ||
2271 | false_reg->min_value = 0; | ||
2272 | } | ||
2230 | /* If this is false then we know the maximum value is val - 1, | 2273 | /* If this is false then we know the maximum value is val - 1, |
2231 | * otherwise we know the mimimum value is val. | 2274 | * otherwise we know the mimimum value is val. |
2232 | */ | 2275 | */ |
2233 | false_reg->max_value = val - 1; | 2276 | false_reg->max_value = val - 1; |
2277 | false_reg->value_from_signed = value_from_signed; | ||
2234 | true_reg->min_value = val; | 2278 | true_reg->min_value = val; |
2279 | true_reg->value_from_signed = value_from_signed; | ||
2235 | break; | 2280 | break; |
2236 | default: | 2281 | default: |
2237 | break; | 2282 | break; |
@@ -2239,6 +2284,12 @@ static void reg_set_min_max(struct bpf_reg_state *true_reg, | |||
2239 | 2284 | ||
2240 | check_reg_overflow(false_reg); | 2285 | check_reg_overflow(false_reg); |
2241 | check_reg_overflow(true_reg); | 2286 | check_reg_overflow(true_reg); |
2287 | if (is_range) { | ||
2288 | if (__is_pointer_value(false, false_reg)) | ||
2289 | reset_reg_range_values(false_reg, 0); | ||
2290 | if (__is_pointer_value(false, true_reg)) | ||
2291 | reset_reg_range_values(true_reg, 0); | ||
2292 | } | ||
2242 | } | 2293 | } |
2243 | 2294 | ||
2244 | /* Same as above, but for the case that dst_reg is a CONST_IMM reg and src_reg | 2295 | /* Same as above, but for the case that dst_reg is a CONST_IMM reg and src_reg |
@@ -2248,41 +2299,64 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg, | |||
2248 | struct bpf_reg_state *false_reg, u64 val, | 2299 | struct bpf_reg_state *false_reg, u64 val, |
2249 | u8 opcode) | 2300 | u8 opcode) |
2250 | { | 2301 | { |
2302 | bool value_from_signed = true; | ||
2303 | bool is_range = true; | ||
2304 | |||
2251 | switch (opcode) { | 2305 | switch (opcode) { |
2252 | case BPF_JEQ: | 2306 | case BPF_JEQ: |
2253 | /* If this is false then we know nothing Jon Snow, but if it is | 2307 | /* If this is false then we know nothing Jon Snow, but if it is |
2254 | * true then we know for sure. | 2308 | * true then we know for sure. |
2255 | */ | 2309 | */ |
2256 | true_reg->max_value = true_reg->min_value = val; | 2310 | true_reg->max_value = true_reg->min_value = val; |
2311 | is_range = false; | ||
2257 | break; | 2312 | break; |
2258 | case BPF_JNE: | 2313 | case BPF_JNE: |
2259 | /* If this is true we know nothing Jon Snow, but if it is false | 2314 | /* If this is true we know nothing Jon Snow, but if it is false |
2260 | * we know the value for sure; | 2315 | * we know the value for sure; |
2261 | */ | 2316 | */ |
2262 | false_reg->max_value = false_reg->min_value = val; | 2317 | false_reg->max_value = false_reg->min_value = val; |
2318 | is_range = false; | ||
2263 | break; | 2319 | break; |
2264 | case BPF_JGT: | 2320 | case BPF_JGT: |
2265 | /* Unsigned comparison, the minimum value is 0. */ | 2321 | value_from_signed = false; |
2266 | true_reg->min_value = 0; | ||
2267 | /* fallthrough */ | 2322 | /* fallthrough */ |
2268 | case BPF_JSGT: | 2323 | case BPF_JSGT: |
2324 | if (true_reg->value_from_signed != value_from_signed) | ||
2325 | reset_reg_range_values(true_reg, 0); | ||
2326 | if (false_reg->value_from_signed != value_from_signed) | ||
2327 | reset_reg_range_values(false_reg, 0); | ||
2328 | if (opcode == BPF_JGT) { | ||
2329 | /* Unsigned comparison, the minimum value is 0. */ | ||
2330 | true_reg->min_value = 0; | ||
2331 | } | ||
2269 | /* | 2332 | /* |
2270 | * If this is false, then the val is <= the register, if it is | 2333 | * If this is false, then the val is <= the register, if it is |
2271 | * true the register <= to the val. | 2334 | * true the register <= to the val. |
2272 | */ | 2335 | */ |
2273 | false_reg->min_value = val; | 2336 | false_reg->min_value = val; |
2337 | false_reg->value_from_signed = value_from_signed; | ||
2274 | true_reg->max_value = val - 1; | 2338 | true_reg->max_value = val - 1; |
2339 | true_reg->value_from_signed = value_from_signed; | ||
2275 | break; | 2340 | break; |
2276 | case BPF_JGE: | 2341 | case BPF_JGE: |
2277 | /* Unsigned comparison, the minimum value is 0. */ | 2342 | value_from_signed = false; |
2278 | true_reg->min_value = 0; | ||
2279 | /* fallthrough */ | 2343 | /* fallthrough */ |
2280 | case BPF_JSGE: | 2344 | case BPF_JSGE: |
2345 | if (true_reg->value_from_signed != value_from_signed) | ||
2346 | reset_reg_range_values(true_reg, 0); | ||
2347 | if (false_reg->value_from_signed != value_from_signed) | ||
2348 | reset_reg_range_values(false_reg, 0); | ||
2349 | if (opcode == BPF_JGE) { | ||
2350 | /* Unsigned comparison, the minimum value is 0. */ | ||
2351 | true_reg->min_value = 0; | ||
2352 | } | ||
2281 | /* If this is false then constant < register, if it is true then | 2353 | /* If this is false then constant < register, if it is true then |
2282 | * the register < constant. | 2354 | * the register < constant. |
2283 | */ | 2355 | */ |
2284 | false_reg->min_value = val + 1; | 2356 | false_reg->min_value = val + 1; |
2357 | false_reg->value_from_signed = value_from_signed; | ||
2285 | true_reg->max_value = val; | 2358 | true_reg->max_value = val; |
2359 | true_reg->value_from_signed = value_from_signed; | ||
2286 | break; | 2360 | break; |
2287 | default: | 2361 | default: |
2288 | break; | 2362 | break; |
@@ -2290,6 +2364,12 @@ static void reg_set_min_max_inv(struct bpf_reg_state *true_reg, | |||
2290 | 2364 | ||
2291 | check_reg_overflow(false_reg); | 2365 | check_reg_overflow(false_reg); |
2292 | check_reg_overflow(true_reg); | 2366 | check_reg_overflow(true_reg); |
2367 | if (is_range) { | ||
2368 | if (__is_pointer_value(false, false_reg)) | ||
2369 | reset_reg_range_values(false_reg, 0); | ||
2370 | if (__is_pointer_value(false, true_reg)) | ||
2371 | reset_reg_range_values(true_reg, 0); | ||
2372 | } | ||
2293 | } | 2373 | } |
2294 | 2374 | ||
2295 | static void mark_map_reg(struct bpf_reg_state *regs, u32 regno, u32 id, | 2375 | static void mark_map_reg(struct bpf_reg_state *regs, u32 regno, u32 id, |
diff --git a/kernel/cpu.c b/kernel/cpu.c index ab860453841d..eee033134262 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c | |||
@@ -279,7 +279,8 @@ static int bringup_wait_for_ap(unsigned int cpu) | |||
279 | 279 | ||
280 | /* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */ | 280 | /* Wait for the CPU to reach CPUHP_AP_ONLINE_IDLE */ |
281 | wait_for_completion(&st->done); | 281 | wait_for_completion(&st->done); |
282 | BUG_ON(!cpu_online(cpu)); | 282 | if (WARN_ON_ONCE((!cpu_online(cpu)))) |
283 | return -ECANCELED; | ||
283 | 284 | ||
284 | /* Unpark the stopper thread and the hotplug thread of the target cpu */ | 285 | /* Unpark the stopper thread and the hotplug thread of the target cpu */ |
285 | stop_machine_unpark(cpu); | 286 | stop_machine_unpark(cpu); |
diff --git a/kernel/events/core.c b/kernel/events/core.c index 1538df9b2b65..426c2ffba16d 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -1452,6 +1452,13 @@ static enum event_type_t get_event_type(struct perf_event *event) | |||
1452 | 1452 | ||
1453 | lockdep_assert_held(&ctx->lock); | 1453 | lockdep_assert_held(&ctx->lock); |
1454 | 1454 | ||
1455 | /* | ||
1456 | * It's 'group type', really, because if our group leader is | ||
1457 | * pinned, so are we. | ||
1458 | */ | ||
1459 | if (event->group_leader != event) | ||
1460 | event = event->group_leader; | ||
1461 | |||
1455 | event_type = event->attr.pinned ? EVENT_PINNED : EVENT_FLEXIBLE; | 1462 | event_type = event->attr.pinned ? EVENT_PINNED : EVENT_FLEXIBLE; |
1456 | if (!ctx->task) | 1463 | if (!ctx->task) |
1457 | event_type |= EVENT_CPU; | 1464 | event_type |= EVENT_CPU; |
@@ -4378,7 +4385,9 @@ EXPORT_SYMBOL_GPL(perf_event_read_value); | |||
4378 | static int __perf_read_group_add(struct perf_event *leader, | 4385 | static int __perf_read_group_add(struct perf_event *leader, |
4379 | u64 read_format, u64 *values) | 4386 | u64 read_format, u64 *values) |
4380 | { | 4387 | { |
4388 | struct perf_event_context *ctx = leader->ctx; | ||
4381 | struct perf_event *sub; | 4389 | struct perf_event *sub; |
4390 | unsigned long flags; | ||
4382 | int n = 1; /* skip @nr */ | 4391 | int n = 1; /* skip @nr */ |
4383 | int ret; | 4392 | int ret; |
4384 | 4393 | ||
@@ -4408,12 +4417,15 @@ static int __perf_read_group_add(struct perf_event *leader, | |||
4408 | if (read_format & PERF_FORMAT_ID) | 4417 | if (read_format & PERF_FORMAT_ID) |
4409 | values[n++] = primary_event_id(leader); | 4418 | values[n++] = primary_event_id(leader); |
4410 | 4419 | ||
4420 | raw_spin_lock_irqsave(&ctx->lock, flags); | ||
4421 | |||
4411 | list_for_each_entry(sub, &leader->sibling_list, group_entry) { | 4422 | list_for_each_entry(sub, &leader->sibling_list, group_entry) { |
4412 | values[n++] += perf_event_count(sub); | 4423 | values[n++] += perf_event_count(sub); |
4413 | if (read_format & PERF_FORMAT_ID) | 4424 | if (read_format & PERF_FORMAT_ID) |
4414 | values[n++] = primary_event_id(sub); | 4425 | values[n++] = primary_event_id(sub); |
4415 | } | 4426 | } |
4416 | 4427 | ||
4428 | raw_spin_unlock_irqrestore(&ctx->lock, flags); | ||
4417 | return 0; | 4429 | return 0; |
4418 | } | 4430 | } |
4419 | 4431 | ||
@@ -7321,21 +7333,6 @@ int perf_event_account_interrupt(struct perf_event *event) | |||
7321 | return __perf_event_account_interrupt(event, 1); | 7333 | return __perf_event_account_interrupt(event, 1); |
7322 | } | 7334 | } |
7323 | 7335 | ||
7324 | static bool sample_is_allowed(struct perf_event *event, struct pt_regs *regs) | ||
7325 | { | ||
7326 | /* | ||
7327 | * Due to interrupt latency (AKA "skid"), we may enter the | ||
7328 | * kernel before taking an overflow, even if the PMU is only | ||
7329 | * counting user events. | ||
7330 | * To avoid leaking information to userspace, we must always | ||
7331 | * reject kernel samples when exclude_kernel is set. | ||
7332 | */ | ||
7333 | if (event->attr.exclude_kernel && !user_mode(regs)) | ||
7334 | return false; | ||
7335 | |||
7336 | return true; | ||
7337 | } | ||
7338 | |||
7339 | /* | 7336 | /* |
7340 | * Generic event overflow handling, sampling. | 7337 | * Generic event overflow handling, sampling. |
7341 | */ | 7338 | */ |
@@ -7357,12 +7354,6 @@ static int __perf_event_overflow(struct perf_event *event, | |||
7357 | ret = __perf_event_account_interrupt(event, throttle); | 7354 | ret = __perf_event_account_interrupt(event, throttle); |
7358 | 7355 | ||
7359 | /* | 7356 | /* |
7360 | * For security, drop the skid kernel samples if necessary. | ||
7361 | */ | ||
7362 | if (!sample_is_allowed(event, regs)) | ||
7363 | return ret; | ||
7364 | |||
7365 | /* | ||
7366 | * XXX event_limit might not quite work as expected on inherited | 7357 | * XXX event_limit might not quite work as expected on inherited |
7367 | * events | 7358 | * events |
7368 | */ | 7359 | */ |
diff --git a/kernel/futex.c b/kernel/futex.c index c934689043b2..16dbe4c93895 100644 --- a/kernel/futex.c +++ b/kernel/futex.c | |||
@@ -212,7 +212,7 @@ struct futex_pi_state { | |||
212 | atomic_t refcount; | 212 | atomic_t refcount; |
213 | 213 | ||
214 | union futex_key key; | 214 | union futex_key key; |
215 | }; | 215 | } __randomize_layout; |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * struct futex_q - The hashed futex queue entry, one per waiting task | 218 | * struct futex_q - The hashed futex queue entry, one per waiting task |
@@ -246,7 +246,7 @@ struct futex_q { | |||
246 | struct rt_mutex_waiter *rt_waiter; | 246 | struct rt_mutex_waiter *rt_waiter; |
247 | union futex_key *requeue_pi_key; | 247 | union futex_key *requeue_pi_key; |
248 | u32 bitset; | 248 | u32 bitset; |
249 | }; | 249 | } __randomize_layout; |
250 | 250 | ||
251 | static const struct futex_q futex_q_init = { | 251 | static const struct futex_q futex_q_init = { |
252 | /* list gets initialized in queue_me()*/ | 252 | /* list gets initialized in queue_me()*/ |
diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c index d171bc57e1e0..a3cc37c0c85e 100644 --- a/kernel/irq/chip.c +++ b/kernel/irq/chip.c | |||
@@ -170,21 +170,11 @@ static void irq_state_clr_disabled(struct irq_desc *desc) | |||
170 | irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED); | 170 | irqd_clear(&desc->irq_data, IRQD_IRQ_DISABLED); |
171 | } | 171 | } |
172 | 172 | ||
173 | static void irq_state_set_disabled(struct irq_desc *desc) | ||
174 | { | ||
175 | irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED); | ||
176 | } | ||
177 | |||
178 | static void irq_state_clr_masked(struct irq_desc *desc) | 173 | static void irq_state_clr_masked(struct irq_desc *desc) |
179 | { | 174 | { |
180 | irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED); | 175 | irqd_clear(&desc->irq_data, IRQD_IRQ_MASKED); |
181 | } | 176 | } |
182 | 177 | ||
183 | static void irq_state_set_masked(struct irq_desc *desc) | ||
184 | { | ||
185 | irqd_set(&desc->irq_data, IRQD_IRQ_MASKED); | ||
186 | } | ||
187 | |||
188 | static void irq_state_clr_started(struct irq_desc *desc) | 178 | static void irq_state_clr_started(struct irq_desc *desc) |
189 | { | 179 | { |
190 | irqd_clear(&desc->irq_data, IRQD_IRQ_STARTED); | 180 | irqd_clear(&desc->irq_data, IRQD_IRQ_STARTED); |
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h index dbfba9933ed2..a2c48058354c 100644 --- a/kernel/irq/internals.h +++ b/kernel/irq/internals.h | |||
@@ -227,6 +227,16 @@ static inline bool irqd_has_set(struct irq_data *d, unsigned int mask) | |||
227 | return __irqd_to_state(d) & mask; | 227 | return __irqd_to_state(d) & mask; |
228 | } | 228 | } |
229 | 229 | ||
230 | static inline void irq_state_set_disabled(struct irq_desc *desc) | ||
231 | { | ||
232 | irqd_set(&desc->irq_data, IRQD_IRQ_DISABLED); | ||
233 | } | ||
234 | |||
235 | static inline void irq_state_set_masked(struct irq_desc *desc) | ||
236 | { | ||
237 | irqd_set(&desc->irq_data, IRQD_IRQ_MASKED); | ||
238 | } | ||
239 | |||
230 | #undef __irqd_to_state | 240 | #undef __irqd_to_state |
231 | 241 | ||
232 | static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc) | 242 | static inline void kstat_incr_irqs_this_cpu(struct irq_desc *desc) |
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c index 5624b2dd6b58..1d1a5b945ab4 100644 --- a/kernel/irq/manage.c +++ b/kernel/irq/manage.c | |||
@@ -1090,6 +1090,16 @@ setup_irq_thread(struct irqaction *new, unsigned int irq, bool secondary) | |||
1090 | /* | 1090 | /* |
1091 | * Internal function to register an irqaction - typically used to | 1091 | * Internal function to register an irqaction - typically used to |
1092 | * allocate special interrupts that are part of the architecture. | 1092 | * allocate special interrupts that are part of the architecture. |
1093 | * | ||
1094 | * Locking rules: | ||
1095 | * | ||
1096 | * desc->request_mutex Provides serialization against a concurrent free_irq() | ||
1097 | * chip_bus_lock Provides serialization for slow bus operations | ||
1098 | * desc->lock Provides serialization against hard interrupts | ||
1099 | * | ||
1100 | * chip_bus_lock and desc->lock are sufficient for all other management and | ||
1101 | * interrupt related functions. desc->request_mutex solely serializes | ||
1102 | * request/free_irq(). | ||
1093 | */ | 1103 | */ |
1094 | static int | 1104 | static int |
1095 | __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | 1105 | __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) |
@@ -1167,20 +1177,35 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
1167 | if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE) | 1177 | if (desc->irq_data.chip->flags & IRQCHIP_ONESHOT_SAFE) |
1168 | new->flags &= ~IRQF_ONESHOT; | 1178 | new->flags &= ~IRQF_ONESHOT; |
1169 | 1179 | ||
1180 | /* | ||
1181 | * Protects against a concurrent __free_irq() call which might wait | ||
1182 | * for synchronize_irq() to complete without holding the optional | ||
1183 | * chip bus lock and desc->lock. | ||
1184 | */ | ||
1170 | mutex_lock(&desc->request_mutex); | 1185 | mutex_lock(&desc->request_mutex); |
1186 | |||
1187 | /* | ||
1188 | * Acquire bus lock as the irq_request_resources() callback below | ||
1189 | * might rely on the serialization or the magic power management | ||
1190 | * functions which are abusing the irq_bus_lock() callback, | ||
1191 | */ | ||
1192 | chip_bus_lock(desc); | ||
1193 | |||
1194 | /* First installed action requests resources. */ | ||
1171 | if (!desc->action) { | 1195 | if (!desc->action) { |
1172 | ret = irq_request_resources(desc); | 1196 | ret = irq_request_resources(desc); |
1173 | if (ret) { | 1197 | if (ret) { |
1174 | pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", | 1198 | pr_err("Failed to request resources for %s (irq %d) on irqchip %s\n", |
1175 | new->name, irq, desc->irq_data.chip->name); | 1199 | new->name, irq, desc->irq_data.chip->name); |
1176 | goto out_mutex; | 1200 | goto out_bus_unlock; |
1177 | } | 1201 | } |
1178 | } | 1202 | } |
1179 | 1203 | ||
1180 | chip_bus_lock(desc); | ||
1181 | |||
1182 | /* | 1204 | /* |
1183 | * The following block of code has to be executed atomically | 1205 | * The following block of code has to be executed atomically |
1206 | * protected against a concurrent interrupt and any of the other | ||
1207 | * management calls which are not serialized via | ||
1208 | * desc->request_mutex or the optional bus lock. | ||
1184 | */ | 1209 | */ |
1185 | raw_spin_lock_irqsave(&desc->lock, flags); | 1210 | raw_spin_lock_irqsave(&desc->lock, flags); |
1186 | old_ptr = &desc->action; | 1211 | old_ptr = &desc->action; |
@@ -1286,10 +1311,8 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new) | |||
1286 | ret = __irq_set_trigger(desc, | 1311 | ret = __irq_set_trigger(desc, |
1287 | new->flags & IRQF_TRIGGER_MASK); | 1312 | new->flags & IRQF_TRIGGER_MASK); |
1288 | 1313 | ||
1289 | if (ret) { | 1314 | if (ret) |
1290 | irq_release_resources(desc); | ||
1291 | goto out_unlock; | 1315 | goto out_unlock; |
1292 | } | ||
1293 | } | 1316 | } |
1294 | 1317 | ||
1295 | desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | \ | 1318 | desc->istate &= ~(IRQS_AUTODETECT | IRQS_SPURIOUS_DISABLED | \ |
@@ -1385,12 +1408,10 @@ mismatch: | |||
1385 | out_unlock: | 1408 | out_unlock: |
1386 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 1409 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
1387 | 1410 | ||
1388 | chip_bus_sync_unlock(desc); | ||
1389 | |||
1390 | if (!desc->action) | 1411 | if (!desc->action) |
1391 | irq_release_resources(desc); | 1412 | irq_release_resources(desc); |
1392 | 1413 | out_bus_unlock: | |
1393 | out_mutex: | 1414 | chip_bus_sync_unlock(desc); |
1394 | mutex_unlock(&desc->request_mutex); | 1415 | mutex_unlock(&desc->request_mutex); |
1395 | 1416 | ||
1396 | out_thread: | 1417 | out_thread: |
@@ -1472,6 +1493,7 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1472 | WARN(1, "Trying to free already-free IRQ %d\n", irq); | 1493 | WARN(1, "Trying to free already-free IRQ %d\n", irq); |
1473 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 1494 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
1474 | chip_bus_sync_unlock(desc); | 1495 | chip_bus_sync_unlock(desc); |
1496 | mutex_unlock(&desc->request_mutex); | ||
1475 | return NULL; | 1497 | return NULL; |
1476 | } | 1498 | } |
1477 | 1499 | ||
@@ -1498,6 +1520,20 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1498 | #endif | 1520 | #endif |
1499 | 1521 | ||
1500 | raw_spin_unlock_irqrestore(&desc->lock, flags); | 1522 | raw_spin_unlock_irqrestore(&desc->lock, flags); |
1523 | /* | ||
1524 | * Drop bus_lock here so the changes which were done in the chip | ||
1525 | * callbacks above are synced out to the irq chips which hang | ||
1526 | * behind a slow bus (I2C, SPI) before calling synchronize_irq(). | ||
1527 | * | ||
1528 | * Aside of that the bus_lock can also be taken from the threaded | ||
1529 | * handler in irq_finalize_oneshot() which results in a deadlock | ||
1530 | * because synchronize_irq() would wait forever for the thread to | ||
1531 | * complete, which is blocked on the bus lock. | ||
1532 | * | ||
1533 | * The still held desc->request_mutex() protects against a | ||
1534 | * concurrent request_irq() of this irq so the release of resources | ||
1535 | * and timing data is properly serialized. | ||
1536 | */ | ||
1501 | chip_bus_sync_unlock(desc); | 1537 | chip_bus_sync_unlock(desc); |
1502 | 1538 | ||
1503 | unregister_handler_proc(irq, action); | 1539 | unregister_handler_proc(irq, action); |
@@ -1530,8 +1566,15 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id) | |||
1530 | } | 1566 | } |
1531 | } | 1567 | } |
1532 | 1568 | ||
1569 | /* Last action releases resources */ | ||
1533 | if (!desc->action) { | 1570 | if (!desc->action) { |
1571 | /* | ||
1572 | * Reaquire bus lock as irq_release_resources() might | ||
1573 | * require it to deallocate resources over the slow bus. | ||
1574 | */ | ||
1575 | chip_bus_lock(desc); | ||
1534 | irq_release_resources(desc); | 1576 | irq_release_resources(desc); |
1577 | chip_bus_sync_unlock(desc); | ||
1535 | irq_remove_timings(desc); | 1578 | irq_remove_timings(desc); |
1536 | } | 1579 | } |
1537 | 1580 | ||
diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c index cea1de0161f1..6bd9b58429cc 100644 --- a/kernel/irq/pm.c +++ b/kernel/irq/pm.c | |||
@@ -149,6 +149,8 @@ static void resume_irq(struct irq_desc *desc) | |||
149 | 149 | ||
150 | /* Pretend that it got disabled ! */ | 150 | /* Pretend that it got disabled ! */ |
151 | desc->depth++; | 151 | desc->depth++; |
152 | irq_state_set_disabled(desc); | ||
153 | irq_state_set_masked(desc); | ||
152 | resume: | 154 | resume: |
153 | desc->istate &= ~IRQS_SUSPENDED; | 155 | desc->istate &= ~IRQS_SUSPENDED; |
154 | __enable_irq(desc); | 156 | __enable_irq(desc); |
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c index 78069895032a..649dc9d3951a 100644 --- a/kernel/locking/rtmutex.c +++ b/kernel/locking/rtmutex.c | |||
@@ -963,7 +963,6 @@ static int task_blocks_on_rt_mutex(struct rt_mutex *lock, | |||
963 | return -EDEADLK; | 963 | return -EDEADLK; |
964 | 964 | ||
965 | raw_spin_lock(&task->pi_lock); | 965 | raw_spin_lock(&task->pi_lock); |
966 | rt_mutex_adjust_prio(task); | ||
967 | waiter->task = task; | 966 | waiter->task = task; |
968 | waiter->lock = lock; | 967 | waiter->lock = lock; |
969 | waiter->prio = task->prio; | 968 | waiter->prio = task->prio; |
diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c index 6e3ea4ac1bda..14d2dbf97c53 100644 --- a/kernel/sched/cputime.c +++ b/kernel/sched/cputime.c | |||
@@ -683,7 +683,7 @@ static u64 vtime_delta(struct vtime *vtime) | |||
683 | { | 683 | { |
684 | unsigned long long clock; | 684 | unsigned long long clock; |
685 | 685 | ||
686 | clock = sched_clock_cpu(smp_processor_id()); | 686 | clock = sched_clock(); |
687 | if (clock < vtime->starttime) | 687 | if (clock < vtime->starttime) |
688 | return 0; | 688 | return 0; |
689 | 689 | ||
@@ -814,7 +814,7 @@ void arch_vtime_task_switch(struct task_struct *prev) | |||
814 | 814 | ||
815 | write_seqcount_begin(&vtime->seqcount); | 815 | write_seqcount_begin(&vtime->seqcount); |
816 | vtime->state = VTIME_SYS; | 816 | vtime->state = VTIME_SYS; |
817 | vtime->starttime = sched_clock_cpu(smp_processor_id()); | 817 | vtime->starttime = sched_clock(); |
818 | write_seqcount_end(&vtime->seqcount); | 818 | write_seqcount_end(&vtime->seqcount); |
819 | } | 819 | } |
820 | 820 | ||
@@ -826,7 +826,7 @@ void vtime_init_idle(struct task_struct *t, int cpu) | |||
826 | local_irq_save(flags); | 826 | local_irq_save(flags); |
827 | write_seqcount_begin(&vtime->seqcount); | 827 | write_seqcount_begin(&vtime->seqcount); |
828 | vtime->state = VTIME_SYS; | 828 | vtime->state = VTIME_SYS; |
829 | vtime->starttime = sched_clock_cpu(cpu); | 829 | vtime->starttime = sched_clock(); |
830 | write_seqcount_end(&vtime->seqcount); | 830 | write_seqcount_end(&vtime->seqcount); |
831 | local_irq_restore(flags); | 831 | local_irq_restore(flags); |
832 | } | 832 | } |
diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c index a84299f44b5d..755bd3f1a1a9 100644 --- a/kernel/sched/deadline.c +++ b/kernel/sched/deadline.c | |||
@@ -1392,17 +1392,19 @@ static void enqueue_task_dl(struct rq *rq, struct task_struct *p, int flags) | |||
1392 | struct sched_dl_entity *pi_se = &p->dl; | 1392 | struct sched_dl_entity *pi_se = &p->dl; |
1393 | 1393 | ||
1394 | /* | 1394 | /* |
1395 | * Use the scheduling parameters of the top pi-waiter | 1395 | * Use the scheduling parameters of the top pi-waiter task if: |
1396 | * task if we have one and its (absolute) deadline is | 1396 | * - we have a top pi-waiter which is a SCHED_DEADLINE task AND |
1397 | * smaller than our one... OTW we keep our runtime and | 1397 | * - our dl_boosted is set (i.e. the pi-waiter's (absolute) deadline is |
1398 | * deadline. | 1398 | * smaller than our deadline OR we are a !SCHED_DEADLINE task getting |
1399 | * boosted due to a SCHED_DEADLINE pi-waiter). | ||
1400 | * Otherwise we keep our runtime and deadline. | ||
1399 | */ | 1401 | */ |
1400 | if (pi_task && p->dl.dl_boosted && dl_prio(pi_task->normal_prio)) { | 1402 | if (pi_task && dl_prio(pi_task->normal_prio) && p->dl.dl_boosted) { |
1401 | pi_se = &pi_task->dl; | 1403 | pi_se = &pi_task->dl; |
1402 | } else if (!dl_prio(p->normal_prio)) { | 1404 | } else if (!dl_prio(p->normal_prio)) { |
1403 | /* | 1405 | /* |
1404 | * Special case in which we have a !SCHED_DEADLINE task | 1406 | * Special case in which we have a !SCHED_DEADLINE task |
1405 | * that is going to be deboosted, but exceedes its | 1407 | * that is going to be deboosted, but exceeds its |
1406 | * runtime while doing so. No point in replenishing | 1408 | * runtime while doing so. No point in replenishing |
1407 | * it, as it's going to return back to its original | 1409 | * it, as it's going to return back to its original |
1408 | * scheduling class after this. | 1410 | * scheduling class after this. |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 53f6b6401cf0..02004ae91860 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
@@ -113,7 +113,7 @@ static int ftrace_disabled __read_mostly; | |||
113 | 113 | ||
114 | static DEFINE_MUTEX(ftrace_lock); | 114 | static DEFINE_MUTEX(ftrace_lock); |
115 | 115 | ||
116 | static struct ftrace_ops *ftrace_ops_list __read_mostly = &ftrace_list_end; | 116 | static struct ftrace_ops __rcu *ftrace_ops_list __read_mostly = &ftrace_list_end; |
117 | ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; | 117 | ftrace_func_t ftrace_trace_function __read_mostly = ftrace_stub; |
118 | static struct ftrace_ops global_ops; | 118 | static struct ftrace_ops global_ops; |
119 | 119 | ||
@@ -169,8 +169,11 @@ int ftrace_nr_registered_ops(void) | |||
169 | 169 | ||
170 | mutex_lock(&ftrace_lock); | 170 | mutex_lock(&ftrace_lock); |
171 | 171 | ||
172 | for (ops = ftrace_ops_list; | 172 | for (ops = rcu_dereference_protected(ftrace_ops_list, |
173 | ops != &ftrace_list_end; ops = ops->next) | 173 | lockdep_is_held(&ftrace_lock)); |
174 | ops != &ftrace_list_end; | ||
175 | ops = rcu_dereference_protected(ops->next, | ||
176 | lockdep_is_held(&ftrace_lock))) | ||
174 | cnt++; | 177 | cnt++; |
175 | 178 | ||
176 | mutex_unlock(&ftrace_lock); | 179 | mutex_unlock(&ftrace_lock); |
@@ -275,10 +278,11 @@ static void update_ftrace_function(void) | |||
275 | * If there's only one ftrace_ops registered, the ftrace_ops_list | 278 | * If there's only one ftrace_ops registered, the ftrace_ops_list |
276 | * will point to the ops we want. | 279 | * will point to the ops we want. |
277 | */ | 280 | */ |
278 | set_function_trace_op = ftrace_ops_list; | 281 | set_function_trace_op = rcu_dereference_protected(ftrace_ops_list, |
282 | lockdep_is_held(&ftrace_lock)); | ||
279 | 283 | ||
280 | /* If there's no ftrace_ops registered, just call the stub function */ | 284 | /* If there's no ftrace_ops registered, just call the stub function */ |
281 | if (ftrace_ops_list == &ftrace_list_end) { | 285 | if (set_function_trace_op == &ftrace_list_end) { |
282 | func = ftrace_stub; | 286 | func = ftrace_stub; |
283 | 287 | ||
284 | /* | 288 | /* |
@@ -286,7 +290,8 @@ static void update_ftrace_function(void) | |||
286 | * recursion safe and not dynamic and the arch supports passing ops, | 290 | * recursion safe and not dynamic and the arch supports passing ops, |
287 | * then have the mcount trampoline call the function directly. | 291 | * then have the mcount trampoline call the function directly. |
288 | */ | 292 | */ |
289 | } else if (ftrace_ops_list->next == &ftrace_list_end) { | 293 | } else if (rcu_dereference_protected(ftrace_ops_list->next, |
294 | lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) { | ||
290 | func = ftrace_ops_get_list_func(ftrace_ops_list); | 295 | func = ftrace_ops_get_list_func(ftrace_ops_list); |
291 | 296 | ||
292 | } else { | 297 | } else { |
@@ -348,9 +353,11 @@ int using_ftrace_ops_list_func(void) | |||
348 | return ftrace_trace_function == ftrace_ops_list_func; | 353 | return ftrace_trace_function == ftrace_ops_list_func; |
349 | } | 354 | } |
350 | 355 | ||
351 | static void add_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops) | 356 | static void add_ftrace_ops(struct ftrace_ops __rcu **list, |
357 | struct ftrace_ops *ops) | ||
352 | { | 358 | { |
353 | ops->next = *list; | 359 | rcu_assign_pointer(ops->next, *list); |
360 | |||
354 | /* | 361 | /* |
355 | * We are entering ops into the list but another | 362 | * We are entering ops into the list but another |
356 | * CPU might be walking that list. We need to make sure | 363 | * CPU might be walking that list. We need to make sure |
@@ -360,7 +367,8 @@ static void add_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops) | |||
360 | rcu_assign_pointer(*list, ops); | 367 | rcu_assign_pointer(*list, ops); |
361 | } | 368 | } |
362 | 369 | ||
363 | static int remove_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops) | 370 | static int remove_ftrace_ops(struct ftrace_ops __rcu **list, |
371 | struct ftrace_ops *ops) | ||
364 | { | 372 | { |
365 | struct ftrace_ops **p; | 373 | struct ftrace_ops **p; |
366 | 374 | ||
@@ -368,7 +376,10 @@ static int remove_ftrace_ops(struct ftrace_ops **list, struct ftrace_ops *ops) | |||
368 | * If we are removing the last function, then simply point | 376 | * If we are removing the last function, then simply point |
369 | * to the ftrace_stub. | 377 | * to the ftrace_stub. |
370 | */ | 378 | */ |
371 | if (*list == ops && ops->next == &ftrace_list_end) { | 379 | if (rcu_dereference_protected(*list, |
380 | lockdep_is_held(&ftrace_lock)) == ops && | ||
381 | rcu_dereference_protected(ops->next, | ||
382 | lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) { | ||
372 | *list = &ftrace_list_end; | 383 | *list = &ftrace_list_end; |
373 | return 0; | 384 | return 0; |
374 | } | 385 | } |
@@ -1569,8 +1580,8 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs) | |||
1569 | return 0; | 1580 | return 0; |
1570 | #endif | 1581 | #endif |
1571 | 1582 | ||
1572 | hash.filter_hash = rcu_dereference_raw_notrace(ops->func_hash->filter_hash); | 1583 | rcu_assign_pointer(hash.filter_hash, ops->func_hash->filter_hash); |
1573 | hash.notrace_hash = rcu_dereference_raw_notrace(ops->func_hash->notrace_hash); | 1584 | rcu_assign_pointer(hash.notrace_hash, ops->func_hash->notrace_hash); |
1574 | 1585 | ||
1575 | if (hash_contains_ip(ip, &hash)) | 1586 | if (hash_contains_ip(ip, &hash)) |
1576 | ret = 1; | 1587 | ret = 1; |
@@ -2840,7 +2851,8 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command) | |||
2840 | * If there's no more ops registered with ftrace, run a | 2851 | * If there's no more ops registered with ftrace, run a |
2841 | * sanity check to make sure all rec flags are cleared. | 2852 | * sanity check to make sure all rec flags are cleared. |
2842 | */ | 2853 | */ |
2843 | if (ftrace_ops_list == &ftrace_list_end) { | 2854 | if (rcu_dereference_protected(ftrace_ops_list, |
2855 | lockdep_is_held(&ftrace_lock)) == &ftrace_list_end) { | ||
2844 | struct ftrace_page *pg; | 2856 | struct ftrace_page *pg; |
2845 | struct dyn_ftrace *rec; | 2857 | struct dyn_ftrace *rec; |
2846 | 2858 | ||
@@ -6453,7 +6465,8 @@ ftrace_enable_sysctl(struct ctl_table *table, int write, | |||
6453 | if (ftrace_enabled) { | 6465 | if (ftrace_enabled) { |
6454 | 6466 | ||
6455 | /* we are starting ftrace again */ | 6467 | /* we are starting ftrace again */ |
6456 | if (ftrace_ops_list != &ftrace_list_end) | 6468 | if (rcu_dereference_protected(ftrace_ops_list, |
6469 | lockdep_is_held(&ftrace_lock)) != &ftrace_list_end) | ||
6457 | update_ftrace_function(); | 6470 | update_ftrace_function(); |
6458 | 6471 | ||
6459 | ftrace_startup_sysctl(); | 6472 | ftrace_startup_sysctl(); |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 4ae268e687fe..529cc50d7243 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
@@ -1136,12 +1136,12 @@ static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu) | |||
1136 | for (i = 0; i < nr_pages; i++) { | 1136 | for (i = 0; i < nr_pages; i++) { |
1137 | struct page *page; | 1137 | struct page *page; |
1138 | /* | 1138 | /* |
1139 | * __GFP_NORETRY flag makes sure that the allocation fails | 1139 | * __GFP_RETRY_MAYFAIL flag makes sure that the allocation fails |
1140 | * gracefully without invoking oom-killer and the system is | 1140 | * gracefully without invoking oom-killer and the system is not |
1141 | * not destabilized. | 1141 | * destabilized. |
1142 | */ | 1142 | */ |
1143 | bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()), | 1143 | bpage = kzalloc_node(ALIGN(sizeof(*bpage), cache_line_size()), |
1144 | GFP_KERNEL | __GFP_NORETRY, | 1144 | GFP_KERNEL | __GFP_RETRY_MAYFAIL, |
1145 | cpu_to_node(cpu)); | 1145 | cpu_to_node(cpu)); |
1146 | if (!bpage) | 1146 | if (!bpage) |
1147 | goto free_pages; | 1147 | goto free_pages; |
@@ -1149,7 +1149,7 @@ static int __rb_allocate_pages(long nr_pages, struct list_head *pages, int cpu) | |||
1149 | list_add(&bpage->list, pages); | 1149 | list_add(&bpage->list, pages); |
1150 | 1150 | ||
1151 | page = alloc_pages_node(cpu_to_node(cpu), | 1151 | page = alloc_pages_node(cpu_to_node(cpu), |
1152 | GFP_KERNEL | __GFP_NORETRY, 0); | 1152 | GFP_KERNEL | __GFP_RETRY_MAYFAIL, 0); |
1153 | if (!page) | 1153 | if (!page) |
1154 | goto free_pages; | 1154 | goto free_pages; |
1155 | bpage->page = page_address(page); | 1155 | bpage->page = page_address(page); |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 2d0ffcc49dba..42b9355033d4 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
@@ -7774,6 +7774,7 @@ static int instance_rmdir(const char *name) | |||
7774 | } | 7774 | } |
7775 | kfree(tr->topts); | 7775 | kfree(tr->topts); |
7776 | 7776 | ||
7777 | free_cpumask_var(tr->tracing_cpumask); | ||
7777 | kfree(tr->name); | 7778 | kfree(tr->name); |
7778 | kfree(tr); | 7779 | kfree(tr); |
7779 | 7780 | ||
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 6ade1c55cc3a..490ba229931d 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
@@ -1210,9 +1210,9 @@ struct ftrace_event_field { | |||
1210 | struct event_filter { | 1210 | struct event_filter { |
1211 | int n_preds; /* Number assigned */ | 1211 | int n_preds; /* Number assigned */ |
1212 | int a_preds; /* allocated */ | 1212 | int a_preds; /* allocated */ |
1213 | struct filter_pred *preds; | 1213 | struct filter_pred __rcu *preds; |
1214 | struct filter_pred *root; | 1214 | struct filter_pred __rcu *root; |
1215 | char *filter_string; | 1215 | char *filter_string; |
1216 | }; | 1216 | }; |
1217 | 1217 | ||
1218 | struct event_subsystem { | 1218 | struct event_subsystem { |
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index f0f3447e8aa4..861ae2a165f4 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -34,11 +34,11 @@ static struct lock_class_key bridge_netdev_addr_lock_key; | |||
34 | netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) | 34 | netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) |
35 | { | 35 | { |
36 | struct net_bridge *br = netdev_priv(dev); | 36 | struct net_bridge *br = netdev_priv(dev); |
37 | const unsigned char *dest = skb->data; | ||
38 | struct net_bridge_fdb_entry *dst; | 37 | struct net_bridge_fdb_entry *dst; |
39 | struct net_bridge_mdb_entry *mdst; | 38 | struct net_bridge_mdb_entry *mdst; |
40 | struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats); | 39 | struct pcpu_sw_netstats *brstats = this_cpu_ptr(br->stats); |
41 | const struct nf_br_ops *nf_ops; | 40 | const struct nf_br_ops *nf_ops; |
41 | const unsigned char *dest; | ||
42 | u16 vid = 0; | 42 | u16 vid = 0; |
43 | 43 | ||
44 | rcu_read_lock(); | 44 | rcu_read_lock(); |
@@ -61,6 +61,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
61 | if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid)) | 61 | if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid)) |
62 | goto out; | 62 | goto out; |
63 | 63 | ||
64 | dest = eth_hdr(skb)->h_dest; | ||
64 | if (is_broadcast_ether_addr(dest)) { | 65 | if (is_broadcast_ether_addr(dest)) { |
65 | br_flood(br, skb, BR_PKT_BROADCAST, false, true); | 66 | br_flood(br, skb, BR_PKT_BROADCAST, false, true); |
66 | } else if (is_multicast_ether_addr(dest)) { | 67 | } else if (is_multicast_ether_addr(dest)) { |
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c index 013f2290bfa5..7637f58c1226 100644 --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c | |||
@@ -131,11 +131,11 @@ static void br_do_proxy_arp(struct sk_buff *skb, struct net_bridge *br, | |||
131 | int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb) | 131 | int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb) |
132 | { | 132 | { |
133 | struct net_bridge_port *p = br_port_get_rcu(skb->dev); | 133 | struct net_bridge_port *p = br_port_get_rcu(skb->dev); |
134 | const unsigned char *dest = eth_hdr(skb)->h_dest; | ||
135 | enum br_pkt_type pkt_type = BR_PKT_UNICAST; | 134 | enum br_pkt_type pkt_type = BR_PKT_UNICAST; |
136 | struct net_bridge_fdb_entry *dst = NULL; | 135 | struct net_bridge_fdb_entry *dst = NULL; |
137 | struct net_bridge_mdb_entry *mdst; | 136 | struct net_bridge_mdb_entry *mdst; |
138 | bool local_rcv, mcast_hit = false; | 137 | bool local_rcv, mcast_hit = false; |
138 | const unsigned char *dest; | ||
139 | struct net_bridge *br; | 139 | struct net_bridge *br; |
140 | u16 vid = 0; | 140 | u16 vid = 0; |
141 | 141 | ||
@@ -153,6 +153,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb | |||
153 | br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false); | 153 | br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, false); |
154 | 154 | ||
155 | local_rcv = !!(br->dev->flags & IFF_PROMISC); | 155 | local_rcv = !!(br->dev->flags & IFF_PROMISC); |
156 | dest = eth_hdr(skb)->h_dest; | ||
156 | if (is_multicast_ether_addr(dest)) { | 157 | if (is_multicast_ether_addr(dest)) { |
157 | /* by definition the broadcast is also a multicast address */ | 158 | /* by definition the broadcast is also a multicast address */ |
158 | if (is_broadcast_ether_addr(dest)) { | 159 | if (is_broadcast_ether_addr(dest)) { |
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 0c31035bbfee..b7cc615d42ef 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -3203,8 +3203,10 @@ static struct ceph_msg_data *ceph_msg_data_create(enum ceph_msg_data_type type) | |||
3203 | return NULL; | 3203 | return NULL; |
3204 | 3204 | ||
3205 | data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS); | 3205 | data = kmem_cache_zalloc(ceph_msg_data_cache, GFP_NOFS); |
3206 | if (data) | 3206 | if (!data) |
3207 | data->type = type; | 3207 | return NULL; |
3208 | |||
3209 | data->type = type; | ||
3208 | INIT_LIST_HEAD(&data->links); | 3210 | INIT_LIST_HEAD(&data->links); |
3209 | 3211 | ||
3210 | return data; | 3212 | return data; |
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 86a9737d8e3f..901bb8221366 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c | |||
@@ -5310,7 +5310,10 @@ static int invalidate_authorizer(struct ceph_connection *con) | |||
5310 | 5310 | ||
5311 | static void osd_reencode_message(struct ceph_msg *msg) | 5311 | static void osd_reencode_message(struct ceph_msg *msg) |
5312 | { | 5312 | { |
5313 | encode_request_finish(msg); | 5313 | int type = le16_to_cpu(msg->hdr.type); |
5314 | |||
5315 | if (type == CEPH_MSG_OSD_OP) | ||
5316 | encode_request_finish(msg); | ||
5314 | } | 5317 | } |
5315 | 5318 | ||
5316 | static int osd_sign_message(struct ceph_msg *msg) | 5319 | static int osd_sign_message(struct ceph_msg *msg) |
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 864789c5974e..64ae9f89773a 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -338,7 +338,7 @@ static void crush_finalize(struct crush_map *c) | |||
338 | static struct crush_map *crush_decode(void *pbyval, void *end) | 338 | static struct crush_map *crush_decode(void *pbyval, void *end) |
339 | { | 339 | { |
340 | struct crush_map *c; | 340 | struct crush_map *c; |
341 | int err = -EINVAL; | 341 | int err; |
342 | int i, j; | 342 | int i, j; |
343 | void **p = &pbyval; | 343 | void **p = &pbyval; |
344 | void *start = pbyval; | 344 | void *start = pbyval; |
@@ -407,7 +407,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
407 | size = sizeof(struct crush_bucket_straw2); | 407 | size = sizeof(struct crush_bucket_straw2); |
408 | break; | 408 | break; |
409 | default: | 409 | default: |
410 | err = -EINVAL; | ||
411 | goto bad; | 410 | goto bad; |
412 | } | 411 | } |
413 | BUG_ON(size == 0); | 412 | BUG_ON(size == 0); |
@@ -439,31 +438,31 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
439 | err = crush_decode_uniform_bucket(p, end, | 438 | err = crush_decode_uniform_bucket(p, end, |
440 | (struct crush_bucket_uniform *)b); | 439 | (struct crush_bucket_uniform *)b); |
441 | if (err < 0) | 440 | if (err < 0) |
442 | goto bad; | 441 | goto fail; |
443 | break; | 442 | break; |
444 | case CRUSH_BUCKET_LIST: | 443 | case CRUSH_BUCKET_LIST: |
445 | err = crush_decode_list_bucket(p, end, | 444 | err = crush_decode_list_bucket(p, end, |
446 | (struct crush_bucket_list *)b); | 445 | (struct crush_bucket_list *)b); |
447 | if (err < 0) | 446 | if (err < 0) |
448 | goto bad; | 447 | goto fail; |
449 | break; | 448 | break; |
450 | case CRUSH_BUCKET_TREE: | 449 | case CRUSH_BUCKET_TREE: |
451 | err = crush_decode_tree_bucket(p, end, | 450 | err = crush_decode_tree_bucket(p, end, |
452 | (struct crush_bucket_tree *)b); | 451 | (struct crush_bucket_tree *)b); |
453 | if (err < 0) | 452 | if (err < 0) |
454 | goto bad; | 453 | goto fail; |
455 | break; | 454 | break; |
456 | case CRUSH_BUCKET_STRAW: | 455 | case CRUSH_BUCKET_STRAW: |
457 | err = crush_decode_straw_bucket(p, end, | 456 | err = crush_decode_straw_bucket(p, end, |
458 | (struct crush_bucket_straw *)b); | 457 | (struct crush_bucket_straw *)b); |
459 | if (err < 0) | 458 | if (err < 0) |
460 | goto bad; | 459 | goto fail; |
461 | break; | 460 | break; |
462 | case CRUSH_BUCKET_STRAW2: | 461 | case CRUSH_BUCKET_STRAW2: |
463 | err = crush_decode_straw2_bucket(p, end, | 462 | err = crush_decode_straw2_bucket(p, end, |
464 | (struct crush_bucket_straw2 *)b); | 463 | (struct crush_bucket_straw2 *)b); |
465 | if (err < 0) | 464 | if (err < 0) |
466 | goto bad; | 465 | goto fail; |
467 | break; | 466 | break; |
468 | } | 467 | } |
469 | } | 468 | } |
@@ -474,7 +473,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
474 | u32 yes; | 473 | u32 yes; |
475 | struct crush_rule *r; | 474 | struct crush_rule *r; |
476 | 475 | ||
477 | err = -EINVAL; | ||
478 | ceph_decode_32_safe(p, end, yes, bad); | 476 | ceph_decode_32_safe(p, end, yes, bad); |
479 | if (!yes) { | 477 | if (!yes) { |
480 | dout("crush_decode NO rule %d off %x %p to %p\n", | 478 | dout("crush_decode NO rule %d off %x %p to %p\n", |
@@ -489,7 +487,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
489 | /* len */ | 487 | /* len */ |
490 | ceph_decode_32_safe(p, end, yes, bad); | 488 | ceph_decode_32_safe(p, end, yes, bad); |
491 | #if BITS_PER_LONG == 32 | 489 | #if BITS_PER_LONG == 32 |
492 | err = -EINVAL; | ||
493 | if (yes > (ULONG_MAX - sizeof(*r)) | 490 | if (yes > (ULONG_MAX - sizeof(*r)) |
494 | / sizeof(struct crush_rule_step)) | 491 | / sizeof(struct crush_rule_step)) |
495 | goto bad; | 492 | goto bad; |
@@ -557,7 +554,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
557 | if (*p != end) { | 554 | if (*p != end) { |
558 | err = decode_choose_args(p, end, c); | 555 | err = decode_choose_args(p, end, c); |
559 | if (err) | 556 | if (err) |
560 | goto bad; | 557 | goto fail; |
561 | } | 558 | } |
562 | 559 | ||
563 | done: | 560 | done: |
@@ -567,10 +564,14 @@ done: | |||
567 | 564 | ||
568 | badmem: | 565 | badmem: |
569 | err = -ENOMEM; | 566 | err = -ENOMEM; |
570 | bad: | 567 | fail: |
571 | dout("crush_decode fail %d\n", err); | 568 | dout("crush_decode fail %d\n", err); |
572 | crush_destroy(c); | 569 | crush_destroy(c); |
573 | return ERR_PTR(err); | 570 | return ERR_PTR(err); |
571 | |||
572 | bad: | ||
573 | err = -EINVAL; | ||
574 | goto fail; | ||
574 | } | 575 | } |
575 | 576 | ||
576 | int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs) | 577 | int ceph_pg_compare(const struct ceph_pg *lhs, const struct ceph_pg *rhs) |
@@ -1399,7 +1400,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_items(void **p, void *end, | |||
1399 | return ERR_PTR(-EINVAL); | 1400 | return ERR_PTR(-EINVAL); |
1400 | 1401 | ||
1401 | ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); | 1402 | ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); |
1402 | pg = kzalloc(sizeof(*pg) + 2 * len * sizeof(u32), GFP_NOIO); | 1403 | pg = alloc_pg_mapping(2 * len * sizeof(u32)); |
1403 | if (!pg) | 1404 | if (!pg) |
1404 | return ERR_PTR(-ENOMEM); | 1405 | return ERR_PTR(-ENOMEM); |
1405 | 1406 | ||
@@ -1544,7 +1545,7 @@ static int osdmap_decode(void **p, void *end, struct ceph_osdmap *map) | |||
1544 | if (struct_v >= 3) { | 1545 | if (struct_v >= 3) { |
1545 | /* erasure_code_profiles */ | 1546 | /* erasure_code_profiles */ |
1546 | ceph_decode_skip_map_of_map(p, end, string, string, string, | 1547 | ceph_decode_skip_map_of_map(p, end, string, string, string, |
1547 | bad); | 1548 | e_inval); |
1548 | } | 1549 | } |
1549 | 1550 | ||
1550 | if (struct_v >= 4) { | 1551 | if (struct_v >= 4) { |
@@ -1825,9 +1826,9 @@ struct ceph_osdmap *osdmap_apply_incremental(void **p, void *end, | |||
1825 | if (struct_v >= 3) { | 1826 | if (struct_v >= 3) { |
1826 | /* new_erasure_code_profiles */ | 1827 | /* new_erasure_code_profiles */ |
1827 | ceph_decode_skip_map_of_map(p, end, string, string, string, | 1828 | ceph_decode_skip_map_of_map(p, end, string, string, string, |
1828 | bad); | 1829 | e_inval); |
1829 | /* old_erasure_code_profiles */ | 1830 | /* old_erasure_code_profiles */ |
1830 | ceph_decode_skip_set(p, end, string, bad); | 1831 | ceph_decode_skip_set(p, end, string, e_inval); |
1831 | } | 1832 | } |
1832 | 1833 | ||
1833 | if (struct_v >= 4) { | 1834 | if (struct_v >= 4) { |
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 82fd4c9c4a1b..06b147d7d9e2 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c | |||
@@ -28,6 +28,7 @@ static int dev_ifname(struct net *net, struct ifreq __user *arg) | |||
28 | 28 | ||
29 | if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) | 29 | if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) |
30 | return -EFAULT; | 30 | return -EFAULT; |
31 | ifr.ifr_name[IFNAMSIZ-1] = 0; | ||
31 | 32 | ||
32 | error = netdev_get_name(net, ifr.ifr_name, ifr.ifr_ifindex); | 33 | error = netdev_get_name(net, ifr.ifr_name, ifr.ifr_ifindex); |
33 | if (error) | 34 | if (error) |
@@ -424,6 +425,8 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) | |||
424 | if (copy_from_user(&iwr, arg, sizeof(iwr))) | 425 | if (copy_from_user(&iwr, arg, sizeof(iwr))) |
425 | return -EFAULT; | 426 | return -EFAULT; |
426 | 427 | ||
428 | iwr.ifr_name[sizeof(iwr.ifr_name) - 1] = 0; | ||
429 | |||
427 | return wext_handle_ioctl(net, &iwr, cmd, arg); | 430 | return wext_handle_ioctl(net, &iwr, cmd, arg); |
428 | } | 431 | } |
429 | 432 | ||
diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c index a0093e1b0235..fdcb1bcd2afa 100644 --- a/net/core/fib_rules.c +++ b/net/core/fib_rules.c | |||
@@ -400,6 +400,7 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
400 | err = -ENOMEM; | 400 | err = -ENOMEM; |
401 | goto errout; | 401 | goto errout; |
402 | } | 402 | } |
403 | refcount_set(&rule->refcnt, 1); | ||
403 | rule->fr_net = net; | 404 | rule->fr_net = net; |
404 | 405 | ||
405 | rule->pref = tb[FRA_PRIORITY] ? nla_get_u32(tb[FRA_PRIORITY]) | 406 | rule->pref = tb[FRA_PRIORITY] ? nla_get_u32(tb[FRA_PRIORITY]) |
@@ -517,8 +518,6 @@ int fib_nl_newrule(struct sk_buff *skb, struct nlmsghdr *nlh, | |||
517 | last = r; | 518 | last = r; |
518 | } | 519 | } |
519 | 520 | ||
520 | refcount_set(&rule->refcnt, 1); | ||
521 | |||
522 | if (last) | 521 | if (last) |
523 | list_add_rcu(&rule->list, &last->list); | 522 | list_add_rcu(&rule->list, &last->list); |
524 | else | 523 | else |
diff --git a/net/core/filter.c b/net/core/filter.c index c7f737058d89..f44fc22fd45a 100644 --- a/net/core/filter.c +++ b/net/core/filter.c | |||
@@ -2248,7 +2248,7 @@ static int bpf_skb_adjust_net(struct sk_buff *skb, s32 len_diff) | |||
2248 | bpf_skb_net_grow(skb, len_diff_abs); | 2248 | bpf_skb_net_grow(skb, len_diff_abs); |
2249 | 2249 | ||
2250 | bpf_compute_data_end(skb); | 2250 | bpf_compute_data_end(skb); |
2251 | return 0; | 2251 | return ret; |
2252 | } | 2252 | } |
2253 | 2253 | ||
2254 | BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff, | 2254 | BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff, |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index d3408a693166..8357f164c660 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -277,7 +277,7 @@ static void zap_completion_queue(void) | |||
277 | struct sk_buff *skb = clist; | 277 | struct sk_buff *skb = clist; |
278 | clist = clist->next; | 278 | clist = clist->next; |
279 | if (!skb_irq_freeable(skb)) { | 279 | if (!skb_irq_freeable(skb)) { |
280 | refcount_inc(&skb->users); | 280 | refcount_set(&skb->users, 1); |
281 | dev_kfree_skb_any(skb); /* put this one back */ | 281 | dev_kfree_skb_any(skb); /* put this one back */ |
282 | } else { | 282 | } else { |
283 | __kfree_skb(skb); | 283 | __kfree_skb(skb); |
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index d1ba90980be1..9201e3621351 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -2031,7 +2031,8 @@ static int do_setlink(const struct sk_buff *skb, | |||
2031 | struct sockaddr *sa; | 2031 | struct sockaddr *sa; |
2032 | int len; | 2032 | int len; |
2033 | 2033 | ||
2034 | len = sizeof(sa_family_t) + dev->addr_len; | 2034 | len = sizeof(sa_family_t) + max_t(size_t, dev->addr_len, |
2035 | sizeof(*sa)); | ||
2035 | sa = kmalloc(len, GFP_KERNEL); | 2036 | sa = kmalloc(len, GFP_KERNEL); |
2036 | if (!sa) { | 2037 | if (!sa) { |
2037 | err = -ENOMEM; | 2038 | err = -ENOMEM; |
@@ -4241,6 +4242,7 @@ static int rtnetlink_event(struct notifier_block *this, unsigned long event, voi | |||
4241 | 4242 | ||
4242 | switch (event) { | 4243 | switch (event) { |
4243 | case NETDEV_REBOOT: | 4244 | case NETDEV_REBOOT: |
4245 | case NETDEV_CHANGEADDR: | ||
4244 | case NETDEV_CHANGENAME: | 4246 | case NETDEV_CHANGENAME: |
4245 | case NETDEV_FEAT_CHANGE: | 4247 | case NETDEV_FEAT_CHANGE: |
4246 | case NETDEV_BONDING_FAILOVER: | 4248 | case NETDEV_BONDING_FAILOVER: |
diff --git a/net/dccp/input.c b/net/dccp/input.c index 4a05d7876850..fa6be9750bb4 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -126,7 +126,7 @@ static int dccp_rcv_closereq(struct sock *sk, struct sk_buff *skb) | |||
126 | 126 | ||
127 | static u16 dccp_reset_code_convert(const u8 code) | 127 | static u16 dccp_reset_code_convert(const u8 code) |
128 | { | 128 | { |
129 | const u16 error_code[] = { | 129 | static const u16 error_code[] = { |
130 | [DCCP_RESET_CODE_CLOSED] = 0, /* normal termination */ | 130 | [DCCP_RESET_CODE_CLOSED] = 0, /* normal termination */ |
131 | [DCCP_RESET_CODE_UNSPECIFIED] = 0, /* nothing known */ | 131 | [DCCP_RESET_CODE_UNSPECIFIED] = 0, /* nothing known */ |
132 | [DCCP_RESET_CODE_ABORTED] = ECONNRESET, | 132 | [DCCP_RESET_CODE_ABORTED] = ECONNRESET, |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 4e678fa892dd..044d2a159a3c 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -1334,13 +1334,14 @@ static struct pernet_operations fib_net_ops = { | |||
1334 | 1334 | ||
1335 | void __init ip_fib_init(void) | 1335 | void __init ip_fib_init(void) |
1336 | { | 1336 | { |
1337 | rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL); | 1337 | fib_trie_init(); |
1338 | rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL); | ||
1339 | rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL); | ||
1340 | 1338 | ||
1341 | register_pernet_subsys(&fib_net_ops); | 1339 | register_pernet_subsys(&fib_net_ops); |
1340 | |||
1342 | register_netdevice_notifier(&fib_netdev_notifier); | 1341 | register_netdevice_notifier(&fib_netdev_notifier); |
1343 | register_inetaddr_notifier(&fib_inetaddr_notifier); | 1342 | register_inetaddr_notifier(&fib_inetaddr_notifier); |
1344 | 1343 | ||
1345 | fib_trie_init(); | 1344 | rtnl_register(PF_INET, RTM_NEWROUTE, inet_rtm_newroute, NULL, NULL); |
1345 | rtnl_register(PF_INET, RTM_DELROUTE, inet_rtm_delroute, NULL, NULL); | ||
1346 | rtnl_register(PF_INET, RTM_GETROUTE, NULL, inet_dump_fib, NULL); | ||
1346 | } | 1347 | } |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 7eb252dcecee..50c74cd890bc 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -599,6 +599,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, | |||
599 | hlen = iph->ihl * 4; | 599 | hlen = iph->ihl * 4; |
600 | mtu = mtu - hlen; /* Size of data space */ | 600 | mtu = mtu - hlen; /* Size of data space */ |
601 | IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; | 601 | IPCB(skb)->flags |= IPSKB_FRAG_COMPLETE; |
602 | ll_rs = LL_RESERVED_SPACE(rt->dst.dev); | ||
602 | 603 | ||
603 | /* When frag_list is given, use it. First, check its validity: | 604 | /* When frag_list is given, use it. First, check its validity: |
604 | * some transformers could create wrong frag_list or break existing | 605 | * some transformers could create wrong frag_list or break existing |
@@ -614,14 +615,15 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, | |||
614 | if (first_len - hlen > mtu || | 615 | if (first_len - hlen > mtu || |
615 | ((first_len - hlen) & 7) || | 616 | ((first_len - hlen) & 7) || |
616 | ip_is_fragment(iph) || | 617 | ip_is_fragment(iph) || |
617 | skb_cloned(skb)) | 618 | skb_cloned(skb) || |
619 | skb_headroom(skb) < ll_rs) | ||
618 | goto slow_path; | 620 | goto slow_path; |
619 | 621 | ||
620 | skb_walk_frags(skb, frag) { | 622 | skb_walk_frags(skb, frag) { |
621 | /* Correct geometry. */ | 623 | /* Correct geometry. */ |
622 | if (frag->len > mtu || | 624 | if (frag->len > mtu || |
623 | ((frag->len & 7) && frag->next) || | 625 | ((frag->len & 7) && frag->next) || |
624 | skb_headroom(frag) < hlen) | 626 | skb_headroom(frag) < hlen + ll_rs) |
625 | goto slow_path_clean; | 627 | goto slow_path_clean; |
626 | 628 | ||
627 | /* Partially cloned skb? */ | 629 | /* Partially cloned skb? */ |
@@ -711,8 +713,6 @@ slow_path: | |||
711 | left = skb->len - hlen; /* Space per frame */ | 713 | left = skb->len - hlen; /* Space per frame */ |
712 | ptr = hlen; /* Where to start from */ | 714 | ptr = hlen; /* Where to start from */ |
713 | 715 | ||
714 | ll_rs = LL_RESERVED_SPACE(rt->dst.dev); | ||
715 | |||
716 | /* | 716 | /* |
717 | * Fragment the datagram. | 717 | * Fragment the datagram. |
718 | */ | 718 | */ |
diff --git a/net/ipv4/netfilter/nf_tables_arp.c b/net/ipv4/netfilter/nf_tables_arp.c index 805c8ddfe860..4bbc273b45e8 100644 --- a/net/ipv4/netfilter/nf_tables_arp.c +++ b/net/ipv4/netfilter/nf_tables_arp.c | |||
@@ -72,8 +72,7 @@ static const struct nf_chain_type filter_arp = { | |||
72 | .family = NFPROTO_ARP, | 72 | .family = NFPROTO_ARP, |
73 | .owner = THIS_MODULE, | 73 | .owner = THIS_MODULE, |
74 | .hook_mask = (1 << NF_ARP_IN) | | 74 | .hook_mask = (1 << NF_ARP_IN) | |
75 | (1 << NF_ARP_OUT) | | 75 | (1 << NF_ARP_OUT), |
76 | (1 << NF_ARP_FORWARD), | ||
77 | }; | 76 | }; |
78 | 77 | ||
79 | static int __init nf_tables_arp_init(void) | 78 | static int __init nf_tables_arp_init(void) |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 0905cf04c2a4..03ad8778c395 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -335,6 +335,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) | |||
335 | treq->rcv_isn = ntohl(th->seq) - 1; | 335 | treq->rcv_isn = ntohl(th->seq) - 1; |
336 | treq->snt_isn = cookie; | 336 | treq->snt_isn = cookie; |
337 | treq->ts_off = 0; | 337 | treq->ts_off = 0; |
338 | treq->txhash = net_tx_rndhash(); | ||
338 | req->mss = mss; | 339 | req->mss = mss; |
339 | ireq->ir_num = ntohs(th->dest); | 340 | ireq->ir_num = ntohs(th->dest); |
340 | ireq->ir_rmt_port = th->source; | 341 | ireq->ir_rmt_port = th->source; |
diff --git a/net/ipv4/tcp_bbr.c b/net/ipv4/tcp_bbr.c index dbcc9352a48f..69ee877574d0 100644 --- a/net/ipv4/tcp_bbr.c +++ b/net/ipv4/tcp_bbr.c | |||
@@ -112,7 +112,8 @@ struct bbr { | |||
112 | cwnd_gain:10, /* current gain for setting cwnd */ | 112 | cwnd_gain:10, /* current gain for setting cwnd */ |
113 | full_bw_cnt:3, /* number of rounds without large bw gains */ | 113 | full_bw_cnt:3, /* number of rounds without large bw gains */ |
114 | cycle_idx:3, /* current index in pacing_gain cycle array */ | 114 | cycle_idx:3, /* current index in pacing_gain cycle array */ |
115 | unused_b:6; | 115 | has_seen_rtt:1, /* have we seen an RTT sample yet? */ |
116 | unused_b:5; | ||
116 | u32 prior_cwnd; /* prior cwnd upon entering loss recovery */ | 117 | u32 prior_cwnd; /* prior cwnd upon entering loss recovery */ |
117 | u32 full_bw; /* recent bw, to estimate if pipe is full */ | 118 | u32 full_bw; /* recent bw, to estimate if pipe is full */ |
118 | }; | 119 | }; |
@@ -211,6 +212,35 @@ static u64 bbr_rate_bytes_per_sec(struct sock *sk, u64 rate, int gain) | |||
211 | return rate >> BW_SCALE; | 212 | return rate >> BW_SCALE; |
212 | } | 213 | } |
213 | 214 | ||
215 | /* Convert a BBR bw and gain factor to a pacing rate in bytes per second. */ | ||
216 | static u32 bbr_bw_to_pacing_rate(struct sock *sk, u32 bw, int gain) | ||
217 | { | ||
218 | u64 rate = bw; | ||
219 | |||
220 | rate = bbr_rate_bytes_per_sec(sk, rate, gain); | ||
221 | rate = min_t(u64, rate, sk->sk_max_pacing_rate); | ||
222 | return rate; | ||
223 | } | ||
224 | |||
225 | /* Initialize pacing rate to: high_gain * init_cwnd / RTT. */ | ||
226 | static void bbr_init_pacing_rate_from_rtt(struct sock *sk) | ||
227 | { | ||
228 | struct tcp_sock *tp = tcp_sk(sk); | ||
229 | struct bbr *bbr = inet_csk_ca(sk); | ||
230 | u64 bw; | ||
231 | u32 rtt_us; | ||
232 | |||
233 | if (tp->srtt_us) { /* any RTT sample yet? */ | ||
234 | rtt_us = max(tp->srtt_us >> 3, 1U); | ||
235 | bbr->has_seen_rtt = 1; | ||
236 | } else { /* no RTT sample yet */ | ||
237 | rtt_us = USEC_PER_MSEC; /* use nominal default RTT */ | ||
238 | } | ||
239 | bw = (u64)tp->snd_cwnd * BW_UNIT; | ||
240 | do_div(bw, rtt_us); | ||
241 | sk->sk_pacing_rate = bbr_bw_to_pacing_rate(sk, bw, bbr_high_gain); | ||
242 | } | ||
243 | |||
214 | /* Pace using current bw estimate and a gain factor. In order to help drive the | 244 | /* Pace using current bw estimate and a gain factor. In order to help drive the |
215 | * network toward lower queues while maintaining high utilization and low | 245 | * network toward lower queues while maintaining high utilization and low |
216 | * latency, the average pacing rate aims to be slightly (~1%) lower than the | 246 | * latency, the average pacing rate aims to be slightly (~1%) lower than the |
@@ -220,12 +250,13 @@ static u64 bbr_rate_bytes_per_sec(struct sock *sk, u64 rate, int gain) | |||
220 | */ | 250 | */ |
221 | static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain) | 251 | static void bbr_set_pacing_rate(struct sock *sk, u32 bw, int gain) |
222 | { | 252 | { |
253 | struct tcp_sock *tp = tcp_sk(sk); | ||
223 | struct bbr *bbr = inet_csk_ca(sk); | 254 | struct bbr *bbr = inet_csk_ca(sk); |
224 | u64 rate = bw; | 255 | u32 rate = bbr_bw_to_pacing_rate(sk, bw, gain); |
225 | 256 | ||
226 | rate = bbr_rate_bytes_per_sec(sk, rate, gain); | 257 | if (unlikely(!bbr->has_seen_rtt && tp->srtt_us)) |
227 | rate = min_t(u64, rate, sk->sk_max_pacing_rate); | 258 | bbr_init_pacing_rate_from_rtt(sk); |
228 | if (bbr->mode != BBR_STARTUP || rate > sk->sk_pacing_rate) | 259 | if (bbr_full_bw_reached(sk) || rate > sk->sk_pacing_rate) |
229 | sk->sk_pacing_rate = rate; | 260 | sk->sk_pacing_rate = rate; |
230 | } | 261 | } |
231 | 262 | ||
@@ -798,7 +829,6 @@ static void bbr_init(struct sock *sk) | |||
798 | { | 829 | { |
799 | struct tcp_sock *tp = tcp_sk(sk); | 830 | struct tcp_sock *tp = tcp_sk(sk); |
800 | struct bbr *bbr = inet_csk_ca(sk); | 831 | struct bbr *bbr = inet_csk_ca(sk); |
801 | u64 bw; | ||
802 | 832 | ||
803 | bbr->prior_cwnd = 0; | 833 | bbr->prior_cwnd = 0; |
804 | bbr->tso_segs_goal = 0; /* default segs per skb until first ACK */ | 834 | bbr->tso_segs_goal = 0; /* default segs per skb until first ACK */ |
@@ -814,11 +844,8 @@ static void bbr_init(struct sock *sk) | |||
814 | 844 | ||
815 | minmax_reset(&bbr->bw, bbr->rtt_cnt, 0); /* init max bw to 0 */ | 845 | minmax_reset(&bbr->bw, bbr->rtt_cnt, 0); /* init max bw to 0 */ |
816 | 846 | ||
817 | /* Initialize pacing rate to: high_gain * init_cwnd / RTT. */ | 847 | bbr->has_seen_rtt = 0; |
818 | bw = (u64)tp->snd_cwnd * BW_UNIT; | 848 | bbr_init_pacing_rate_from_rtt(sk); |
819 | do_div(bw, (tp->srtt_us >> 3) ? : USEC_PER_MSEC); | ||
820 | sk->sk_pacing_rate = 0; /* force an update of sk_pacing_rate */ | ||
821 | bbr_set_pacing_rate(sk, bw, bbr_high_gain); | ||
822 | 849 | ||
823 | bbr->restore_cwnd = 0; | 850 | bbr->restore_cwnd = 0; |
824 | bbr->round_start = 0; | 851 | bbr->round_start = 0; |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 25294d43e147..b057653ceca9 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1388,6 +1388,11 @@ void skb_consume_udp(struct sock *sk, struct sk_buff *skb, int len) | |||
1388 | unlock_sock_fast(sk, slow); | 1388 | unlock_sock_fast(sk, slow); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | /* we cleared the head states previously only if the skb lacks any IP | ||
1392 | * options, see __udp_queue_rcv_skb(). | ||
1393 | */ | ||
1394 | if (unlikely(IPCB(skb)->opt.optlen > 0)) | ||
1395 | skb_release_head_state(skb); | ||
1391 | consume_stateless_skb(skb); | 1396 | consume_stateless_skb(skb); |
1392 | } | 1397 | } |
1393 | EXPORT_SYMBOL_GPL(skb_consume_udp); | 1398 | EXPORT_SYMBOL_GPL(skb_consume_udp); |
@@ -1779,8 +1784,12 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
1779 | sk_mark_napi_id_once(sk, skb); | 1784 | sk_mark_napi_id_once(sk, skb); |
1780 | } | 1785 | } |
1781 | 1786 | ||
1782 | /* clear all pending head states while they are hot in the cache */ | 1787 | /* At recvmsg() time we need skb->dst to process IP options-related |
1783 | skb_release_head_state(skb); | 1788 | * cmsg, elsewhere can we clear all pending head states while they are |
1789 | * hot in the cache | ||
1790 | */ | ||
1791 | if (likely(IPCB(skb)->opt.optlen == 0)) | ||
1792 | skb_release_head_state(skb); | ||
1784 | 1793 | ||
1785 | rc = __udp_enqueue_schedule_skb(sk, skb); | 1794 | rc = __udp_enqueue_schedule_skb(sk, skb); |
1786 | if (rc < 0) { | 1795 | if (rc < 0) { |
diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c index e9065b8d3af8..abb2c307fbe8 100644 --- a/net/ipv6/output_core.c +++ b/net/ipv6/output_core.c | |||
@@ -78,7 +78,7 @@ EXPORT_SYMBOL(ipv6_select_ident); | |||
78 | 78 | ||
79 | int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | 79 | int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) |
80 | { | 80 | { |
81 | u16 offset = sizeof(struct ipv6hdr); | 81 | unsigned int offset = sizeof(struct ipv6hdr); |
82 | unsigned int packet_len = skb_tail_pointer(skb) - | 82 | unsigned int packet_len = skb_tail_pointer(skb) - |
83 | skb_network_header(skb); | 83 | skb_network_header(skb); |
84 | int found_rhdr = 0; | 84 | int found_rhdr = 0; |
@@ -86,6 +86,7 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | |||
86 | 86 | ||
87 | while (offset <= packet_len) { | 87 | while (offset <= packet_len) { |
88 | struct ipv6_opt_hdr *exthdr; | 88 | struct ipv6_opt_hdr *exthdr; |
89 | unsigned int len; | ||
89 | 90 | ||
90 | switch (**nexthdr) { | 91 | switch (**nexthdr) { |
91 | 92 | ||
@@ -111,7 +112,10 @@ int ip6_find_1stfragopt(struct sk_buff *skb, u8 **nexthdr) | |||
111 | 112 | ||
112 | exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + | 113 | exthdr = (struct ipv6_opt_hdr *)(skb_network_header(skb) + |
113 | offset); | 114 | offset); |
114 | offset += ipv6_optlen(exthdr); | 115 | len = ipv6_optlen(exthdr); |
116 | if (len + offset >= IPV6_MAXPLEN) | ||
117 | return -EINVAL; | ||
118 | offset += len; | ||
115 | *nexthdr = &exthdr->nexthdr; | 119 | *nexthdr = &exthdr->nexthdr; |
116 | } | 120 | } |
117 | 121 | ||
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 7b75b0620730..4e7817abc0b9 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
@@ -216,6 +216,7 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
216 | treq->rcv_isn = ntohl(th->seq) - 1; | 216 | treq->rcv_isn = ntohl(th->seq) - 1; |
217 | treq->snt_isn = cookie; | 217 | treq->snt_isn = cookie; |
218 | treq->ts_off = 0; | 218 | treq->ts_off = 0; |
219 | treq->txhash = net_tx_rndhash(); | ||
219 | 220 | ||
220 | /* | 221 | /* |
221 | * We need to lookup the dst_entry to get the correct window size. | 222 | * We need to lookup the dst_entry to get the correct window size. |
diff --git a/net/netfilter/core.c b/net/netfilter/core.c index 552d606e57ca..974cf2a3795a 100644 --- a/net/netfilter/core.c +++ b/net/netfilter/core.c | |||
@@ -227,114 +227,6 @@ void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg, | |||
227 | } | 227 | } |
228 | EXPORT_SYMBOL(nf_unregister_net_hooks); | 228 | EXPORT_SYMBOL(nf_unregister_net_hooks); |
229 | 229 | ||
230 | static LIST_HEAD(nf_hook_list); | ||
231 | |||
232 | static int _nf_register_hook(struct nf_hook_ops *reg) | ||
233 | { | ||
234 | struct net *net, *last; | ||
235 | int ret; | ||
236 | |||
237 | for_each_net(net) { | ||
238 | ret = nf_register_net_hook(net, reg); | ||
239 | if (ret && ret != -ENOENT) | ||
240 | goto rollback; | ||
241 | } | ||
242 | list_add_tail(®->list, &nf_hook_list); | ||
243 | |||
244 | return 0; | ||
245 | rollback: | ||
246 | last = net; | ||
247 | for_each_net(net) { | ||
248 | if (net == last) | ||
249 | break; | ||
250 | nf_unregister_net_hook(net, reg); | ||
251 | } | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | int nf_register_hook(struct nf_hook_ops *reg) | ||
256 | { | ||
257 | int ret; | ||
258 | |||
259 | rtnl_lock(); | ||
260 | ret = _nf_register_hook(reg); | ||
261 | rtnl_unlock(); | ||
262 | |||
263 | return ret; | ||
264 | } | ||
265 | EXPORT_SYMBOL(nf_register_hook); | ||
266 | |||
267 | static void _nf_unregister_hook(struct nf_hook_ops *reg) | ||
268 | { | ||
269 | struct net *net; | ||
270 | |||
271 | list_del(®->list); | ||
272 | for_each_net(net) | ||
273 | nf_unregister_net_hook(net, reg); | ||
274 | } | ||
275 | |||
276 | void nf_unregister_hook(struct nf_hook_ops *reg) | ||
277 | { | ||
278 | rtnl_lock(); | ||
279 | _nf_unregister_hook(reg); | ||
280 | rtnl_unlock(); | ||
281 | } | ||
282 | EXPORT_SYMBOL(nf_unregister_hook); | ||
283 | |||
284 | int nf_register_hooks(struct nf_hook_ops *reg, unsigned int n) | ||
285 | { | ||
286 | unsigned int i; | ||
287 | int err = 0; | ||
288 | |||
289 | for (i = 0; i < n; i++) { | ||
290 | err = nf_register_hook(®[i]); | ||
291 | if (err) | ||
292 | goto err; | ||
293 | } | ||
294 | return err; | ||
295 | |||
296 | err: | ||
297 | if (i > 0) | ||
298 | nf_unregister_hooks(reg, i); | ||
299 | return err; | ||
300 | } | ||
301 | EXPORT_SYMBOL(nf_register_hooks); | ||
302 | |||
303 | /* Caller MUST take rtnl_lock() */ | ||
304 | int _nf_register_hooks(struct nf_hook_ops *reg, unsigned int n) | ||
305 | { | ||
306 | unsigned int i; | ||
307 | int err = 0; | ||
308 | |||
309 | for (i = 0; i < n; i++) { | ||
310 | err = _nf_register_hook(®[i]); | ||
311 | if (err) | ||
312 | goto err; | ||
313 | } | ||
314 | return err; | ||
315 | |||
316 | err: | ||
317 | if (i > 0) | ||
318 | _nf_unregister_hooks(reg, i); | ||
319 | return err; | ||
320 | } | ||
321 | EXPORT_SYMBOL(_nf_register_hooks); | ||
322 | |||
323 | void nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n) | ||
324 | { | ||
325 | while (n-- > 0) | ||
326 | nf_unregister_hook(®[n]); | ||
327 | } | ||
328 | EXPORT_SYMBOL(nf_unregister_hooks); | ||
329 | |||
330 | /* Caller MUST take rtnl_lock */ | ||
331 | void _nf_unregister_hooks(struct nf_hook_ops *reg, unsigned int n) | ||
332 | { | ||
333 | while (n-- > 0) | ||
334 | _nf_unregister_hook(®[n]); | ||
335 | } | ||
336 | EXPORT_SYMBOL(_nf_unregister_hooks); | ||
337 | |||
338 | /* Returns 1 if okfn() needs to be executed by the caller, | 230 | /* Returns 1 if okfn() needs to be executed by the caller, |
339 | * -EPERM for NF_DROP, 0 otherwise. Caller must hold rcu_read_lock. */ | 231 | * -EPERM for NF_DROP, 0 otherwise. Caller must hold rcu_read_lock. */ |
340 | int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state, | 232 | int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state, |
@@ -450,40 +342,9 @@ void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *); | |||
450 | EXPORT_SYMBOL(nf_nat_decode_session_hook); | 342 | EXPORT_SYMBOL(nf_nat_decode_session_hook); |
451 | #endif | 343 | #endif |
452 | 344 | ||
453 | static int nf_register_hook_list(struct net *net) | ||
454 | { | ||
455 | struct nf_hook_ops *elem; | ||
456 | int ret; | ||
457 | |||
458 | rtnl_lock(); | ||
459 | list_for_each_entry(elem, &nf_hook_list, list) { | ||
460 | ret = nf_register_net_hook(net, elem); | ||
461 | if (ret && ret != -ENOENT) | ||
462 | goto out_undo; | ||
463 | } | ||
464 | rtnl_unlock(); | ||
465 | return 0; | ||
466 | |||
467 | out_undo: | ||
468 | list_for_each_entry_continue_reverse(elem, &nf_hook_list, list) | ||
469 | nf_unregister_net_hook(net, elem); | ||
470 | rtnl_unlock(); | ||
471 | return ret; | ||
472 | } | ||
473 | |||
474 | static void nf_unregister_hook_list(struct net *net) | ||
475 | { | ||
476 | struct nf_hook_ops *elem; | ||
477 | |||
478 | rtnl_lock(); | ||
479 | list_for_each_entry(elem, &nf_hook_list, list) | ||
480 | nf_unregister_net_hook(net, elem); | ||
481 | rtnl_unlock(); | ||
482 | } | ||
483 | |||
484 | static int __net_init netfilter_net_init(struct net *net) | 345 | static int __net_init netfilter_net_init(struct net *net) |
485 | { | 346 | { |
486 | int i, h, ret; | 347 | int i, h; |
487 | 348 | ||
488 | for (i = 0; i < ARRAY_SIZE(net->nf.hooks); i++) { | 349 | for (i = 0; i < ARRAY_SIZE(net->nf.hooks); i++) { |
489 | for (h = 0; h < NF_MAX_HOOKS; h++) | 350 | for (h = 0; h < NF_MAX_HOOKS; h++) |
@@ -500,16 +361,12 @@ static int __net_init netfilter_net_init(struct net *net) | |||
500 | return -ENOMEM; | 361 | return -ENOMEM; |
501 | } | 362 | } |
502 | #endif | 363 | #endif |
503 | ret = nf_register_hook_list(net); | ||
504 | if (ret) | ||
505 | remove_proc_entry("netfilter", net->proc_net); | ||
506 | 364 | ||
507 | return ret; | 365 | return 0; |
508 | } | 366 | } |
509 | 367 | ||
510 | static void __net_exit netfilter_net_exit(struct net *net) | 368 | static void __net_exit netfilter_net_exit(struct net *net) |
511 | { | 369 | { |
512 | nf_unregister_hook_list(net); | ||
513 | remove_proc_entry("netfilter", net->proc_net); | 370 | remove_proc_entry("netfilter", net->proc_net); |
514 | } | 371 | } |
515 | 372 | ||
diff --git a/net/netfilter/nf_conntrack_expect.c b/net/netfilter/nf_conntrack_expect.c index e03d16ed550d..899c2c36da13 100644 --- a/net/netfilter/nf_conntrack_expect.c +++ b/net/netfilter/nf_conntrack_expect.c | |||
@@ -422,7 +422,7 @@ static inline int __nf_ct_expect_check(struct nf_conntrack_expect *expect) | |||
422 | h = nf_ct_expect_dst_hash(net, &expect->tuple); | 422 | h = nf_ct_expect_dst_hash(net, &expect->tuple); |
423 | hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) { | 423 | hlist_for_each_entry_safe(i, next, &nf_ct_expect_hash[h], hnode) { |
424 | if (expect_matches(i, expect)) { | 424 | if (expect_matches(i, expect)) { |
425 | if (nf_ct_remove_expect(expect)) | 425 | if (nf_ct_remove_expect(i)) |
426 | break; | 426 | break; |
427 | } else if (expect_clash(i, expect)) { | 427 | } else if (expect_clash(i, expect)) { |
428 | ret = -EBUSY; | 428 | ret = -EBUSY; |
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c index 832c5a08d9a5..eb541786ccb7 100644 --- a/net/netfilter/nf_nat_core.c +++ b/net/netfilter/nf_nat_core.c | |||
@@ -222,20 +222,21 @@ find_appropriate_src(struct net *net, | |||
222 | .tuple = tuple, | 222 | .tuple = tuple, |
223 | .zone = zone | 223 | .zone = zone |
224 | }; | 224 | }; |
225 | struct rhlist_head *hl; | 225 | struct rhlist_head *hl, *h; |
226 | 226 | ||
227 | hl = rhltable_lookup(&nf_nat_bysource_table, &key, | 227 | hl = rhltable_lookup(&nf_nat_bysource_table, &key, |
228 | nf_nat_bysource_params); | 228 | nf_nat_bysource_params); |
229 | if (!hl) | ||
230 | return 0; | ||
231 | 229 | ||
232 | ct = container_of(hl, typeof(*ct), nat_bysource); | 230 | rhl_for_each_entry_rcu(ct, h, hl, nat_bysource) { |
231 | nf_ct_invert_tuplepr(result, | ||
232 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple); | ||
233 | result->dst = tuple->dst; | ||
233 | 234 | ||
234 | nf_ct_invert_tuplepr(result, | 235 | if (in_range(l3proto, l4proto, result, range)) |
235 | &ct->tuplehash[IP_CT_DIR_REPLY].tuple); | 236 | return 1; |
236 | result->dst = tuple->dst; | 237 | } |
237 | 238 | ||
238 | return in_range(l3proto, l4proto, result, range); | 239 | return 0; |
239 | } | 240 | } |
240 | 241 | ||
241 | /* For [FUTURE] fragmentation handling, we want the least-used | 242 | /* For [FUTURE] fragmentation handling, we want the least-used |
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c index 92b05e188fd1..733d3e4a30d8 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c | |||
@@ -472,8 +472,7 @@ static void nfnetlink_rcv_skb_batch(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
472 | if (msglen > skb->len) | 472 | if (msglen > skb->len) |
473 | msglen = skb->len; | 473 | msglen = skb->len; |
474 | 474 | ||
475 | if (nlh->nlmsg_len < NLMSG_HDRLEN || | 475 | if (skb->len < NLMSG_HDRLEN + sizeof(struct nfgenmsg)) |
476 | skb->len < NLMSG_HDRLEN + sizeof(struct nfgenmsg)) | ||
477 | return; | 476 | return; |
478 | 477 | ||
479 | err = nla_parse(cda, NFNL_BATCH_MAX, attr, attrlen, nfnl_batch_policy, | 478 | err = nla_parse(cda, NFNL_BATCH_MAX, attr, attrlen, nfnl_batch_policy, |
@@ -500,7 +499,8 @@ static void nfnetlink_rcv(struct sk_buff *skb) | |||
500 | { | 499 | { |
501 | struct nlmsghdr *nlh = nlmsg_hdr(skb); | 500 | struct nlmsghdr *nlh = nlmsg_hdr(skb); |
502 | 501 | ||
503 | if (nlh->nlmsg_len < NLMSG_HDRLEN || | 502 | if (skb->len < NLMSG_HDRLEN || |
503 | nlh->nlmsg_len < NLMSG_HDRLEN || | ||
504 | skb->len < nlh->nlmsg_len) | 504 | skb->len < nlh->nlmsg_len) |
505 | return; | 505 | return; |
506 | 506 | ||
diff --git a/net/openvswitch/conntrack.c b/net/openvswitch/conntrack.c index 08679ebb3068..e3c4c6c3fef7 100644 --- a/net/openvswitch/conntrack.c +++ b/net/openvswitch/conntrack.c | |||
@@ -629,6 +629,34 @@ ovs_ct_find_existing(struct net *net, const struct nf_conntrack_zone *zone, | |||
629 | return ct; | 629 | return ct; |
630 | } | 630 | } |
631 | 631 | ||
632 | static | ||
633 | struct nf_conn *ovs_ct_executed(struct net *net, | ||
634 | const struct sw_flow_key *key, | ||
635 | const struct ovs_conntrack_info *info, | ||
636 | struct sk_buff *skb, | ||
637 | bool *ct_executed) | ||
638 | { | ||
639 | struct nf_conn *ct = NULL; | ||
640 | |||
641 | /* If no ct, check if we have evidence that an existing conntrack entry | ||
642 | * might be found for this skb. This happens when we lose a skb->_nfct | ||
643 | * due to an upcall, or if the direction is being forced. If the | ||
644 | * connection was not confirmed, it is not cached and needs to be run | ||
645 | * through conntrack again. | ||
646 | */ | ||
647 | *ct_executed = (key->ct_state & OVS_CS_F_TRACKED) && | ||
648 | !(key->ct_state & OVS_CS_F_INVALID) && | ||
649 | (key->ct_zone == info->zone.id); | ||
650 | |||
651 | if (*ct_executed || (!key->ct_state && info->force)) { | ||
652 | ct = ovs_ct_find_existing(net, &info->zone, info->family, skb, | ||
653 | !!(key->ct_state & | ||
654 | OVS_CS_F_NAT_MASK)); | ||
655 | } | ||
656 | |||
657 | return ct; | ||
658 | } | ||
659 | |||
632 | /* Determine whether skb->_nfct is equal to the result of conntrack lookup. */ | 660 | /* Determine whether skb->_nfct is equal to the result of conntrack lookup. */ |
633 | static bool skb_nfct_cached(struct net *net, | 661 | static bool skb_nfct_cached(struct net *net, |
634 | const struct sw_flow_key *key, | 662 | const struct sw_flow_key *key, |
@@ -637,24 +665,17 @@ static bool skb_nfct_cached(struct net *net, | |||
637 | { | 665 | { |
638 | enum ip_conntrack_info ctinfo; | 666 | enum ip_conntrack_info ctinfo; |
639 | struct nf_conn *ct; | 667 | struct nf_conn *ct; |
668 | bool ct_executed = true; | ||
640 | 669 | ||
641 | ct = nf_ct_get(skb, &ctinfo); | 670 | ct = nf_ct_get(skb, &ctinfo); |
642 | /* If no ct, check if we have evidence that an existing conntrack entry | ||
643 | * might be found for this skb. This happens when we lose a skb->_nfct | ||
644 | * due to an upcall. If the connection was not confirmed, it is not | ||
645 | * cached and needs to be run through conntrack again. | ||
646 | */ | ||
647 | if (!ct && key->ct_state & OVS_CS_F_TRACKED && | ||
648 | !(key->ct_state & OVS_CS_F_INVALID) && | ||
649 | key->ct_zone == info->zone.id) { | ||
650 | ct = ovs_ct_find_existing(net, &info->zone, info->family, skb, | ||
651 | !!(key->ct_state | ||
652 | & OVS_CS_F_NAT_MASK)); | ||
653 | if (ct) | ||
654 | nf_ct_get(skb, &ctinfo); | ||
655 | } | ||
656 | if (!ct) | 671 | if (!ct) |
672 | ct = ovs_ct_executed(net, key, info, skb, &ct_executed); | ||
673 | |||
674 | if (ct) | ||
675 | nf_ct_get(skb, &ctinfo); | ||
676 | else | ||
657 | return false; | 677 | return false; |
678 | |||
658 | if (!net_eq(net, read_pnet(&ct->ct_net))) | 679 | if (!net_eq(net, read_pnet(&ct->ct_net))) |
659 | return false; | 680 | return false; |
660 | if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct))) | 681 | if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct))) |
@@ -679,7 +700,7 @@ static bool skb_nfct_cached(struct net *net, | |||
679 | return false; | 700 | return false; |
680 | } | 701 | } |
681 | 702 | ||
682 | return true; | 703 | return ct_executed; |
683 | } | 704 | } |
684 | 705 | ||
685 | #ifdef CONFIG_NF_NAT_NEEDED | 706 | #ifdef CONFIG_NF_NAT_NEEDED |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index e3beb28203eb..008bb34ee324 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -214,6 +214,7 @@ static void prb_clear_rxhash(struct tpacket_kbdq_core *, | |||
214 | static void prb_fill_vlan_info(struct tpacket_kbdq_core *, | 214 | static void prb_fill_vlan_info(struct tpacket_kbdq_core *, |
215 | struct tpacket3_hdr *); | 215 | struct tpacket3_hdr *); |
216 | static void packet_flush_mclist(struct sock *sk); | 216 | static void packet_flush_mclist(struct sock *sk); |
217 | static void packet_pick_tx_queue(struct net_device *dev, struct sk_buff *skb); | ||
217 | 218 | ||
218 | struct packet_skb_cb { | 219 | struct packet_skb_cb { |
219 | union { | 220 | union { |
@@ -260,6 +261,7 @@ static int packet_direct_xmit(struct sk_buff *skb) | |||
260 | if (skb != orig_skb) | 261 | if (skb != orig_skb) |
261 | goto drop; | 262 | goto drop; |
262 | 263 | ||
264 | packet_pick_tx_queue(dev, skb); | ||
263 | txq = skb_get_tx_queue(dev, skb); | 265 | txq = skb_get_tx_queue(dev, skb); |
264 | 266 | ||
265 | local_bh_disable(); | 267 | local_bh_disable(); |
@@ -2747,8 +2749,6 @@ tpacket_error: | |||
2747 | goto tpacket_error; | 2749 | goto tpacket_error; |
2748 | } | 2750 | } |
2749 | 2751 | ||
2750 | packet_pick_tx_queue(dev, skb); | ||
2751 | |||
2752 | skb->destructor = tpacket_destruct_skb; | 2752 | skb->destructor = tpacket_destruct_skb; |
2753 | __packet_set_status(po, ph, TP_STATUS_SENDING); | 2753 | __packet_set_status(po, ph, TP_STATUS_SENDING); |
2754 | packet_inc_pending(&po->tx_ring); | 2754 | packet_inc_pending(&po->tx_ring); |
@@ -2931,8 +2931,6 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) | |||
2931 | skb->priority = sk->sk_priority; | 2931 | skb->priority = sk->sk_priority; |
2932 | skb->mark = sockc.mark; | 2932 | skb->mark = sockc.mark; |
2933 | 2933 | ||
2934 | packet_pick_tx_queue(dev, skb); | ||
2935 | |||
2936 | if (po->has_vnet_hdr) { | 2934 | if (po->has_vnet_hdr) { |
2937 | err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le()); | 2935 | err = virtio_net_hdr_to_skb(skb, &vnet_hdr, vio_le()); |
2938 | if (err) | 2936 | if (err) |
diff --git a/net/rds/send.c b/net/rds/send.c index e81aa176f4e2..41b9f0f5bb9c 100644 --- a/net/rds/send.c +++ b/net/rds/send.c | |||
@@ -170,8 +170,8 @@ restart: | |||
170 | * The acquire_in_xmit() check above ensures that only one | 170 | * The acquire_in_xmit() check above ensures that only one |
171 | * caller can increment c_send_gen at any time. | 171 | * caller can increment c_send_gen at any time. |
172 | */ | 172 | */ |
173 | cp->cp_send_gen++; | 173 | send_gen = READ_ONCE(cp->cp_send_gen) + 1; |
174 | send_gen = cp->cp_send_gen; | 174 | WRITE_ONCE(cp->cp_send_gen, send_gen); |
175 | 175 | ||
176 | /* | 176 | /* |
177 | * rds_conn_shutdown() sets the conn state and then tests RDS_IN_XMIT, | 177 | * rds_conn_shutdown() sets the conn state and then tests RDS_IN_XMIT, |
@@ -431,7 +431,7 @@ over_batch: | |||
431 | smp_mb(); | 431 | smp_mb(); |
432 | if ((test_bit(0, &conn->c_map_queued) || | 432 | if ((test_bit(0, &conn->c_map_queued) || |
433 | !list_empty(&cp->cp_send_queue)) && | 433 | !list_empty(&cp->cp_send_queue)) && |
434 | send_gen == cp->cp_send_gen) { | 434 | send_gen == READ_ONCE(cp->cp_send_gen)) { |
435 | rds_stats_inc(s_send_lock_queue_raced); | 435 | rds_stats_inc(s_send_lock_queue_raced); |
436 | if (batch_count < send_batch_count) | 436 | if (batch_count < send_batch_count) |
437 | goto restart; | 437 | goto restart; |
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index aed6cf2e9fd8..f2e9ed34a963 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -835,7 +835,7 @@ out_nlmsg_trim: | |||
835 | } | 835 | } |
836 | 836 | ||
837 | static int | 837 | static int |
838 | act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, | 838 | tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, |
839 | struct list_head *actions, int event) | 839 | struct list_head *actions, int event) |
840 | { | 840 | { |
841 | struct sk_buff *skb; | 841 | struct sk_buff *skb; |
@@ -1018,7 +1018,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, | |||
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | if (event == RTM_GETACTION) | 1020 | if (event == RTM_GETACTION) |
1021 | ret = act_get_notify(net, portid, n, &actions, event); | 1021 | ret = tcf_get_notify(net, portid, n, &actions, event); |
1022 | else { /* delete */ | 1022 | else { /* delete */ |
1023 | ret = tcf_del_notify(net, n, &actions, portid); | 1023 | ret = tcf_del_notify(net, n, &actions, portid); |
1024 | if (ret) | 1024 | if (ret) |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 4e16b02ed832..6110447fe51d 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -228,7 +228,7 @@ struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | |||
228 | sctp_adaptation_ind_param_t aiparam; | 228 | sctp_adaptation_ind_param_t aiparam; |
229 | sctp_supported_ext_param_t ext_param; | 229 | sctp_supported_ext_param_t ext_param; |
230 | int num_ext = 0; | 230 | int num_ext = 0; |
231 | __u8 extensions[3]; | 231 | __u8 extensions[4]; |
232 | struct sctp_paramhdr *auth_chunks = NULL, | 232 | struct sctp_paramhdr *auth_chunks = NULL, |
233 | *auth_hmacs = NULL; | 233 | *auth_hmacs = NULL; |
234 | 234 | ||
@@ -396,7 +396,7 @@ struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | |||
396 | sctp_adaptation_ind_param_t aiparam; | 396 | sctp_adaptation_ind_param_t aiparam; |
397 | sctp_supported_ext_param_t ext_param; | 397 | sctp_supported_ext_param_t ext_param; |
398 | int num_ext = 0; | 398 | int num_ext = 0; |
399 | __u8 extensions[3]; | 399 | __u8 extensions[4]; |
400 | struct sctp_paramhdr *auth_chunks = NULL, | 400 | struct sctp_paramhdr *auth_chunks = NULL, |
401 | *auth_hmacs = NULL, | 401 | *auth_hmacs = NULL, |
402 | *auth_random = NULL; | 402 | *auth_random = NULL; |
diff --git a/security/keys/internal.h b/security/keys/internal.h index 91bc6214ae57..1c02c6547038 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h | |||
@@ -198,7 +198,7 @@ struct request_key_auth { | |||
198 | void *callout_info; | 198 | void *callout_info; |
199 | size_t callout_len; | 199 | size_t callout_len; |
200 | pid_t pid; | 200 | pid_t pid; |
201 | }; | 201 | } __randomize_layout; |
202 | 202 | ||
203 | extern struct key_type key_type_request_key_auth; | 203 | extern struct key_type key_type_request_key_auth; |
204 | extern struct key *request_key_auth_new(struct key *target, | 204 | extern struct key *request_key_auth_new(struct key *target, |
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 7e0405e1651d..412a7c82995a 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
@@ -120,7 +120,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
120 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 120 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
121 | size_t insns_cnt, int strict_alignment, | 121 | size_t insns_cnt, int strict_alignment, |
122 | const char *license, __u32 kern_version, | 122 | const char *license, __u32 kern_version, |
123 | char *log_buf, size_t log_buf_sz) | 123 | char *log_buf, size_t log_buf_sz, int log_level) |
124 | { | 124 | { |
125 | union bpf_attr attr; | 125 | union bpf_attr attr; |
126 | 126 | ||
@@ -131,7 +131,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
131 | attr.license = ptr_to_u64(license); | 131 | attr.license = ptr_to_u64(license); |
132 | attr.log_buf = ptr_to_u64(log_buf); | 132 | attr.log_buf = ptr_to_u64(log_buf); |
133 | attr.log_size = log_buf_sz; | 133 | attr.log_size = log_buf_sz; |
134 | attr.log_level = 2; | 134 | attr.log_level = log_level; |
135 | log_buf[0] = 0; | 135 | log_buf[0] = 0; |
136 | attr.kern_version = kern_version; | 136 | attr.kern_version = kern_version; |
137 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; | 137 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; |
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 16de44a14b48..418c86e69bcb 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
@@ -38,7 +38,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
39 | size_t insns_cnt, int strict_alignment, | 39 | size_t insns_cnt, int strict_alignment, |
40 | const char *license, __u32 kern_version, | 40 | const char *license, __u32 kern_version, |
41 | char *log_buf, size_t log_buf_sz); | 41 | char *log_buf, size_t log_buf_sz, int log_level); |
42 | 42 | ||
43 | int bpf_map_update_elem(int fd, const void *key, const void *value, | 43 | int bpf_map_update_elem(int fd, const void *key, const void *value, |
44 | __u64 flags); | 44 | __u64 flags); |
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index a4d3762cd825..83874b0e266c 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c | |||
@@ -704,7 +704,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, | |||
704 | ui_browser__gotorc(browser, row, column + 1); | 704 | ui_browser__gotorc(browser, row, column + 1); |
705 | SLsmg_draw_hline(2); | 705 | SLsmg_draw_hline(2); |
706 | 706 | ||
707 | if (row++ == 0) | 707 | if (++row == 0) |
708 | goto out; | 708 | goto out; |
709 | } else | 709 | } else |
710 | row = 0; | 710 | row = 0; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 87b431886670..413f74df08de 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
@@ -273,7 +273,7 @@ struct perf_evsel *perf_evsel__new_cycles(void) | |||
273 | struct perf_event_attr attr = { | 273 | struct perf_event_attr attr = { |
274 | .type = PERF_TYPE_HARDWARE, | 274 | .type = PERF_TYPE_HARDWARE, |
275 | .config = PERF_COUNT_HW_CPU_CYCLES, | 275 | .config = PERF_COUNT_HW_CPU_CYCLES, |
276 | .exclude_kernel = 1, | 276 | .exclude_kernel = geteuid() != 0, |
277 | }; | 277 | }; |
278 | struct perf_evsel *evsel; | 278 | struct perf_evsel *evsel; |
279 | 279 | ||
@@ -298,8 +298,10 @@ struct perf_evsel *perf_evsel__new_cycles(void) | |||
298 | goto out; | 298 | goto out; |
299 | 299 | ||
300 | /* use asprintf() because free(evsel) assumes name is allocated */ | 300 | /* use asprintf() because free(evsel) assumes name is allocated */ |
301 | if (asprintf(&evsel->name, "cycles%.*s", | 301 | if (asprintf(&evsel->name, "cycles%s%s%.*s", |
302 | attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0) | 302 | (attr.precise_ip || attr.exclude_kernel) ? ":" : "", |
303 | attr.exclude_kernel ? "u" : "", | ||
304 | attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0) | ||
303 | goto error_free; | 305 | goto error_free; |
304 | out: | 306 | out: |
305 | return evsel; | 307 | return evsel; |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5de2b86b9880..2e9eb6aa3ce2 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
@@ -2209,7 +2209,7 @@ int machine__get_kernel_start(struct machine *machine) | |||
2209 | machine->kernel_start = 1ULL << 63; | 2209 | machine->kernel_start = 1ULL << 63; |
2210 | if (map) { | 2210 | if (map) { |
2211 | err = map__load(map); | 2211 | err = map__load(map); |
2212 | if (map->start) | 2212 | if (!err) |
2213 | machine->kernel_start = map->start; | 2213 | machine->kernel_start = map->start; |
2214 | } | 2214 | } |
2215 | return err; | 2215 | return err; |
diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/test_align.c index bccebd935907..29793694cbc7 100644 --- a/tools/testing/selftests/bpf/test_align.c +++ b/tools/testing/selftests/bpf/test_align.c | |||
@@ -380,7 +380,7 @@ static int do_test_single(struct bpf_align_test *test) | |||
380 | prog_len = probe_filter_length(prog); | 380 | prog_len = probe_filter_length(prog); |
381 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | 381 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, |
382 | prog, prog_len, 1, "GPL", 0, | 382 | prog, prog_len, 1, "GPL", 0, |
383 | bpf_vlog, sizeof(bpf_vlog)); | 383 | bpf_vlog, sizeof(bpf_vlog), 2); |
384 | if (fd_prog < 0) { | 384 | if (fd_prog < 0) { |
385 | printf("Failed to load program.\n"); | 385 | printf("Failed to load program.\n"); |
386 | printf("%s", bpf_vlog); | 386 | printf("%s", bpf_vlog); |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 404aec520812..af7d173910f4 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
@@ -4969,7 +4969,7 @@ static struct bpf_test tests[] = { | |||
4969 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 4969 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
4970 | sizeof(struct test_val), 4), | 4970 | sizeof(struct test_val), 4), |
4971 | BPF_MOV64_IMM(BPF_REG_4, 0), | 4971 | BPF_MOV64_IMM(BPF_REG_4, 0), |
4972 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 4972 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
4973 | BPF_MOV64_IMM(BPF_REG_3, 0), | 4973 | BPF_MOV64_IMM(BPF_REG_3, 0), |
4974 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 4974 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
4975 | BPF_MOV64_IMM(BPF_REG_0, 0), | 4975 | BPF_MOV64_IMM(BPF_REG_0, 0), |
@@ -4995,7 +4995,7 @@ static struct bpf_test tests[] = { | |||
4995 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 4995 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
4996 | sizeof(struct test_val) + 1, 4), | 4996 | sizeof(struct test_val) + 1, 4), |
4997 | BPF_MOV64_IMM(BPF_REG_4, 0), | 4997 | BPF_MOV64_IMM(BPF_REG_4, 0), |
4998 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 4998 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
4999 | BPF_MOV64_IMM(BPF_REG_3, 0), | 4999 | BPF_MOV64_IMM(BPF_REG_3, 0), |
5000 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 5000 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
5001 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5001 | BPF_MOV64_IMM(BPF_REG_0, 0), |
@@ -5023,7 +5023,7 @@ static struct bpf_test tests[] = { | |||
5023 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 5023 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
5024 | sizeof(struct test_val) - 20, 4), | 5024 | sizeof(struct test_val) - 20, 4), |
5025 | BPF_MOV64_IMM(BPF_REG_4, 0), | 5025 | BPF_MOV64_IMM(BPF_REG_4, 0), |
5026 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 5026 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
5027 | BPF_MOV64_IMM(BPF_REG_3, 0), | 5027 | BPF_MOV64_IMM(BPF_REG_3, 0), |
5028 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 5028 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
5029 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5029 | BPF_MOV64_IMM(BPF_REG_0, 0), |
@@ -5050,7 +5050,7 @@ static struct bpf_test tests[] = { | |||
5050 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 5050 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
5051 | sizeof(struct test_val) - 19, 4), | 5051 | sizeof(struct test_val) - 19, 4), |
5052 | BPF_MOV64_IMM(BPF_REG_4, 0), | 5052 | BPF_MOV64_IMM(BPF_REG_4, 0), |
5053 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 5053 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
5054 | BPF_MOV64_IMM(BPF_REG_3, 0), | 5054 | BPF_MOV64_IMM(BPF_REG_3, 0), |
5055 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 5055 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
5056 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5056 | BPF_MOV64_IMM(BPF_REG_0, 0), |
@@ -5510,6 +5510,476 @@ static struct bpf_test tests[] = { | |||
5510 | .errstr = "invalid bpf_context access", | 5510 | .errstr = "invalid bpf_context access", |
5511 | .prog_type = BPF_PROG_TYPE_LWT_IN, | 5511 | .prog_type = BPF_PROG_TYPE_LWT_IN, |
5512 | }, | 5512 | }, |
5513 | { | ||
5514 | "bounds checks mixing signed and unsigned, positive bounds", | ||
5515 | .insns = { | ||
5516 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5517 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5518 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5519 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5520 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5521 | BPF_FUNC_map_lookup_elem), | ||
5522 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
5523 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5524 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5525 | BPF_MOV64_IMM(BPF_REG_2, 2), | ||
5526 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 3), | ||
5527 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 4, 2), | ||
5528 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5529 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5530 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5531 | BPF_EXIT_INSN(), | ||
5532 | }, | ||
5533 | .fixup_map1 = { 3 }, | ||
5534 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5535 | .errstr = "R0 min value is negative", | ||
5536 | .result = REJECT, | ||
5537 | .result_unpriv = REJECT, | ||
5538 | }, | ||
5539 | { | ||
5540 | "bounds checks mixing signed and unsigned", | ||
5541 | .insns = { | ||
5542 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5543 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5544 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5545 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5546 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5547 | BPF_FUNC_map_lookup_elem), | ||
5548 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
5549 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5550 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5551 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5552 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), | ||
5553 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5554 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5555 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5556 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5557 | BPF_EXIT_INSN(), | ||
5558 | }, | ||
5559 | .fixup_map1 = { 3 }, | ||
5560 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5561 | .errstr = "R0 min value is negative", | ||
5562 | .result = REJECT, | ||
5563 | .result_unpriv = REJECT, | ||
5564 | }, | ||
5565 | { | ||
5566 | "bounds checks mixing signed and unsigned, variant 2", | ||
5567 | .insns = { | ||
5568 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5569 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5570 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5571 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5572 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5573 | BPF_FUNC_map_lookup_elem), | ||
5574 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
5575 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5576 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5577 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5578 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5), | ||
5579 | BPF_MOV64_IMM(BPF_REG_8, 0), | ||
5580 | BPF_ALU64_REG(BPF_ADD, BPF_REG_8, BPF_REG_1), | ||
5581 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_8, 1, 2), | ||
5582 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_8), | ||
5583 | BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0), | ||
5584 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5585 | BPF_EXIT_INSN(), | ||
5586 | }, | ||
5587 | .fixup_map1 = { 3 }, | ||
5588 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5589 | .errstr = "R8 invalid mem access 'inv'", | ||
5590 | .result = REJECT, | ||
5591 | .result_unpriv = REJECT, | ||
5592 | }, | ||
5593 | { | ||
5594 | "bounds checks mixing signed and unsigned, variant 3", | ||
5595 | .insns = { | ||
5596 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5597 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5598 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5599 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5600 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5601 | BPF_FUNC_map_lookup_elem), | ||
5602 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), | ||
5603 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5604 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5605 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5606 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 4), | ||
5607 | BPF_MOV64_REG(BPF_REG_8, BPF_REG_1), | ||
5608 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_8, 1, 2), | ||
5609 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_8), | ||
5610 | BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0), | ||
5611 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5612 | BPF_EXIT_INSN(), | ||
5613 | }, | ||
5614 | .fixup_map1 = { 3 }, | ||
5615 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5616 | .errstr = "R8 invalid mem access 'inv'", | ||
5617 | .result = REJECT, | ||
5618 | .result_unpriv = REJECT, | ||
5619 | }, | ||
5620 | { | ||
5621 | "bounds checks mixing signed and unsigned, variant 4", | ||
5622 | .insns = { | ||
5623 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5624 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5625 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5626 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5627 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5628 | BPF_FUNC_map_lookup_elem), | ||
5629 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
5630 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5631 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5632 | BPF_MOV64_IMM(BPF_REG_2, 1), | ||
5633 | BPF_ALU64_REG(BPF_AND, BPF_REG_1, BPF_REG_2), | ||
5634 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5635 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5636 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5637 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5638 | BPF_EXIT_INSN(), | ||
5639 | }, | ||
5640 | .fixup_map1 = { 3 }, | ||
5641 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5642 | .errstr = "R0 min value is negative", | ||
5643 | .result = REJECT, | ||
5644 | .result_unpriv = REJECT, | ||
5645 | }, | ||
5646 | { | ||
5647 | "bounds checks mixing signed and unsigned, variant 5", | ||
5648 | .insns = { | ||
5649 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5650 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5651 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5652 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5653 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5654 | BPF_FUNC_map_lookup_elem), | ||
5655 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
5656 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5657 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5658 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5659 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5), | ||
5660 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 4), | ||
5661 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 4), | ||
5662 | BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), | ||
5663 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5664 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5665 | BPF_EXIT_INSN(), | ||
5666 | }, | ||
5667 | .fixup_map1 = { 3 }, | ||
5668 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5669 | .errstr = "R0 invalid mem access", | ||
5670 | .result = REJECT, | ||
5671 | .result_unpriv = REJECT, | ||
5672 | }, | ||
5673 | { | ||
5674 | "bounds checks mixing signed and unsigned, variant 6", | ||
5675 | .insns = { | ||
5676 | BPF_MOV64_IMM(BPF_REG_2, 0), | ||
5677 | BPF_MOV64_REG(BPF_REG_3, BPF_REG_10), | ||
5678 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -512), | ||
5679 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5680 | BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_10, -16), | ||
5681 | BPF_MOV64_IMM(BPF_REG_6, -1), | ||
5682 | BPF_JMP_REG(BPF_JGT, BPF_REG_4, BPF_REG_6, 5), | ||
5683 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_4, 1, 4), | ||
5684 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 1), | ||
5685 | BPF_MOV64_IMM(BPF_REG_5, 0), | ||
5686 | BPF_ST_MEM(BPF_H, BPF_REG_10, -512, 0), | ||
5687 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5688 | BPF_FUNC_skb_load_bytes), | ||
5689 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5690 | BPF_EXIT_INSN(), | ||
5691 | }, | ||
5692 | .errstr_unpriv = "R4 min value is negative, either use unsigned", | ||
5693 | .errstr = "R4 min value is negative, either use unsigned", | ||
5694 | .result = REJECT, | ||
5695 | .result_unpriv = REJECT, | ||
5696 | }, | ||
5697 | { | ||
5698 | "bounds checks mixing signed and unsigned, variant 7", | ||
5699 | .insns = { | ||
5700 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5701 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5702 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5703 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5704 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5705 | BPF_FUNC_map_lookup_elem), | ||
5706 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
5707 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5708 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5709 | BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024), | ||
5710 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), | ||
5711 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5712 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5713 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5714 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5715 | BPF_EXIT_INSN(), | ||
5716 | }, | ||
5717 | .fixup_map1 = { 3 }, | ||
5718 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5719 | .errstr = "R0 min value is negative", | ||
5720 | .result = REJECT, | ||
5721 | .result_unpriv = REJECT, | ||
5722 | }, | ||
5723 | { | ||
5724 | "bounds checks mixing signed and unsigned, variant 8", | ||
5725 | .insns = { | ||
5726 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5727 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5728 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5729 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5730 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5731 | BPF_FUNC_map_lookup_elem), | ||
5732 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
5733 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5734 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5735 | BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024 + 1), | ||
5736 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), | ||
5737 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5738 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5739 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5740 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5741 | BPF_EXIT_INSN(), | ||
5742 | }, | ||
5743 | .fixup_map1 = { 3 }, | ||
5744 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5745 | .errstr = "R0 min value is negative", | ||
5746 | .result = REJECT, | ||
5747 | .result_unpriv = REJECT, | ||
5748 | }, | ||
5749 | { | ||
5750 | "bounds checks mixing signed and unsigned, variant 9", | ||
5751 | .insns = { | ||
5752 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5753 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5754 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5755 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5756 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5757 | BPF_FUNC_map_lookup_elem), | ||
5758 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
5759 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5760 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5761 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5762 | BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), | ||
5763 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5764 | BPF_EXIT_INSN(), | ||
5765 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5766 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5767 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5768 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5769 | BPF_EXIT_INSN(), | ||
5770 | }, | ||
5771 | .fixup_map1 = { 3 }, | ||
5772 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5773 | .errstr = "R0 min value is negative", | ||
5774 | .result = REJECT, | ||
5775 | .result_unpriv = REJECT, | ||
5776 | }, | ||
5777 | { | ||
5778 | "bounds checks mixing signed and unsigned, variant 10", | ||
5779 | .insns = { | ||
5780 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5781 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5782 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5783 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5784 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5785 | BPF_FUNC_map_lookup_elem), | ||
5786 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 10), | ||
5787 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5788 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5789 | BPF_LD_IMM64(BPF_REG_2, -9223372036854775808ULL), | ||
5790 | BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), | ||
5791 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5792 | BPF_EXIT_INSN(), | ||
5793 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5794 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5795 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5796 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5797 | BPF_EXIT_INSN(), | ||
5798 | }, | ||
5799 | .fixup_map1 = { 3 }, | ||
5800 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5801 | .errstr = "R0 min value is negative", | ||
5802 | .result = REJECT, | ||
5803 | .result_unpriv = REJECT, | ||
5804 | }, | ||
5805 | { | ||
5806 | "bounds checks mixing signed and unsigned, variant 11", | ||
5807 | .insns = { | ||
5808 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5809 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5810 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5811 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5812 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5813 | BPF_FUNC_map_lookup_elem), | ||
5814 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
5815 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5816 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5817 | BPF_MOV64_IMM(BPF_REG_2, 0), | ||
5818 | BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), | ||
5819 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5820 | BPF_EXIT_INSN(), | ||
5821 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5822 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5823 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5824 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5825 | BPF_EXIT_INSN(), | ||
5826 | }, | ||
5827 | .fixup_map1 = { 3 }, | ||
5828 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5829 | .errstr = "R0 min value is negative", | ||
5830 | .result = REJECT, | ||
5831 | .result_unpriv = REJECT, | ||
5832 | }, | ||
5833 | { | ||
5834 | "bounds checks mixing signed and unsigned, variant 12", | ||
5835 | .insns = { | ||
5836 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5837 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5838 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5839 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5840 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5841 | BPF_FUNC_map_lookup_elem), | ||
5842 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
5843 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5844 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5845 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5846 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
5847 | /* Dead branch. */ | ||
5848 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5849 | BPF_EXIT_INSN(), | ||
5850 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5851 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5852 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5853 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5854 | BPF_EXIT_INSN(), | ||
5855 | }, | ||
5856 | .fixup_map1 = { 3 }, | ||
5857 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5858 | .errstr = "R0 min value is negative", | ||
5859 | .result = REJECT, | ||
5860 | .result_unpriv = REJECT, | ||
5861 | }, | ||
5862 | { | ||
5863 | "bounds checks mixing signed and unsigned, variant 13", | ||
5864 | .insns = { | ||
5865 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5866 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5867 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5868 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5869 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5870 | BPF_FUNC_map_lookup_elem), | ||
5871 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
5872 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5873 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5874 | BPF_MOV64_IMM(BPF_REG_2, -6), | ||
5875 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
5876 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5877 | BPF_EXIT_INSN(), | ||
5878 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5879 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5880 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5881 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5882 | BPF_EXIT_INSN(), | ||
5883 | }, | ||
5884 | .fixup_map1 = { 3 }, | ||
5885 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5886 | .errstr = "R0 min value is negative", | ||
5887 | .result = REJECT, | ||
5888 | .result_unpriv = REJECT, | ||
5889 | }, | ||
5890 | { | ||
5891 | "bounds checks mixing signed and unsigned, variant 14", | ||
5892 | .insns = { | ||
5893 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5894 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5895 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5896 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5897 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5898 | BPF_FUNC_map_lookup_elem), | ||
5899 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), | ||
5900 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5901 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5902 | BPF_MOV64_IMM(BPF_REG_2, 2), | ||
5903 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
5904 | BPF_MOV64_IMM(BPF_REG_7, 1), | ||
5905 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, 0, 2), | ||
5906 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5907 | BPF_EXIT_INSN(), | ||
5908 | BPF_ALU64_REG(BPF_ADD, BPF_REG_7, BPF_REG_1), | ||
5909 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, 4, 2), | ||
5910 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_7), | ||
5911 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5912 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5913 | BPF_EXIT_INSN(), | ||
5914 | }, | ||
5915 | .fixup_map1 = { 3 }, | ||
5916 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5917 | .errstr = "R0 min value is negative", | ||
5918 | .result = REJECT, | ||
5919 | .result_unpriv = REJECT, | ||
5920 | }, | ||
5921 | { | ||
5922 | "bounds checks mixing signed and unsigned, variant 15", | ||
5923 | .insns = { | ||
5924 | BPF_LDX_MEM(BPF_W, BPF_REG_9, BPF_REG_1, | ||
5925 | offsetof(struct __sk_buff, mark)), | ||
5926 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5927 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5928 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5929 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5930 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5931 | BPF_FUNC_map_lookup_elem), | ||
5932 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), | ||
5933 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5934 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5935 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
5936 | BPF_MOV64_IMM(BPF_REG_8, 2), | ||
5937 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_9, 42, 6), | ||
5938 | BPF_JMP_REG(BPF_JSGT, BPF_REG_8, BPF_REG_1, 3), | ||
5939 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
5940 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5941 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5942 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5943 | BPF_EXIT_INSN(), | ||
5944 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, -3), | ||
5945 | BPF_JMP_IMM(BPF_JA, 0, 0, -7), | ||
5946 | }, | ||
5947 | .fixup_map1 = { 4 }, | ||
5948 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5949 | .errstr = "R0 min value is negative", | ||
5950 | .result = REJECT, | ||
5951 | .result_unpriv = REJECT, | ||
5952 | }, | ||
5953 | { | ||
5954 | "bounds checks mixing signed and unsigned, variant 16", | ||
5955 | .insns = { | ||
5956 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
5957 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
5958 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
5959 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
5960 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
5961 | BPF_FUNC_map_lookup_elem), | ||
5962 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4), | ||
5963 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
5964 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
5965 | BPF_MOV64_IMM(BPF_REG_2, -6), | ||
5966 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
5967 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5968 | BPF_EXIT_INSN(), | ||
5969 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
5970 | BPF_JMP_IMM(BPF_JGT, BPF_REG_0, 1, 2), | ||
5971 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5972 | BPF_EXIT_INSN(), | ||
5973 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
5974 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
5975 | BPF_EXIT_INSN(), | ||
5976 | }, | ||
5977 | .fixup_map1 = { 3 }, | ||
5978 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
5979 | .errstr = "R0 min value is negative", | ||
5980 | .result = REJECT, | ||
5981 | .result_unpriv = REJECT, | ||
5982 | }, | ||
5513 | }; | 5983 | }; |
5514 | 5984 | ||
5515 | static int probe_filter_length(const struct bpf_insn *fp) | 5985 | static int probe_filter_length(const struct bpf_insn *fp) |
@@ -5633,7 +6103,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, | |||
5633 | 6103 | ||
5634 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | 6104 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, |
5635 | prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, | 6105 | prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, |
5636 | "GPL", 0, bpf_vlog, sizeof(bpf_vlog)); | 6106 | "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1); |
5637 | 6107 | ||
5638 | expected_ret = unpriv && test->result_unpriv != UNDEF ? | 6108 | expected_ret = unpriv && test->result_unpriv != UNDEF ? |
5639 | test->result_unpriv : test->result; | 6109 | test->result_unpriv : test->result; |