From: Greg Kroah-Hartman Date: Sun, 9 Jan 2022 13:07:38 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v4.4.299~17 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a73b4b93361124d5b6a796be0f937118656f6a40;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: arm64-move-vhe-work-to-end-of-el2_setup.patch arm64-reduce-el2_setup-branching.patch arm64-remove-a-redundancy-in-sysreg.h.patch arm64-sysreg-move-to-use-definitions-for-all-the-sctlr-bits.patch bug-split-build_bug-stuff-out-into-linux-build_bug.h.patch phonet-refcount-leak-in-pep_sock_accep.patch rndis_host-support-hytera-digital-radios.patch xfs-map-unwritten-blocks-in-xfs_ioc_-alloc-free-sp-just-like-fallocate.patch --- diff --git a/queue-4.9/arm64-move-vhe-work-to-end-of-el2_setup.patch b/queue-4.9/arm64-move-vhe-work-to-end-of-el2_setup.patch new file mode 100644 index 00000000000..abb1e92ed56 --- /dev/null +++ b/queue-4.9/arm64-move-vhe-work-to-end-of-el2_setup.patch @@ -0,0 +1,83 @@ +From foo@baz Sun Jan 9 01:56:51 PM CET 2022 +From: Nathan Chancellor +Date: Fri, 7 Jan 2022 12:43:34 -0700 +Subject: arm64: move !VHE work to end of el2_setup +To: Greg Kroah-Hartman , Sasha Levin , Catalin Marinas , Will Deacon +Cc: Mark Rutland , Marc Zyngier , Nick Desaulniers , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev +Message-ID: <20220107194335.3090066-5-nathan@kernel.org> + +From: Mark Rutland + +commit d61c97a7773d0848b4bf5c4697855c7ce117362c upstream. + +We only need to initialise sctlr_el1 if we're installing an EL2 stub, so +we may as well defer this until we're doing so. Similarly, we can defer +intialising CPTR_EL2 until then, as we do not access any trapped +functionality as part of el2_setup. + +This patch modified el2_setup accordingly, allowing us to remove a +branch and simplify the code flow. + +Acked-by: Marc Zyngier +Signed-off-by: Mark Rutland +Cc: Will Deacon +Signed-off-by: Catalin Marinas +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/kernel/head.S | 37 +++++++++++++++++-------------------- + 1 file changed, 17 insertions(+), 20 deletions(-) + +--- a/arch/arm64/kernel/head.S ++++ b/arch/arm64/kernel/head.S +@@ -553,26 +553,6 @@ set_hcr: + msr vpidr_el2, x0 + msr vmpidr_el2, x1 + +- /* +- * When VHE is not in use, early init of EL2 and EL1 needs to be +- * done here. +- * When VHE _is_ in use, EL1 will not be used in the host and +- * requires no configuration, and all non-hyp-specific EL2 setup +- * will be done via the _EL1 system register aliases in __cpu_setup. +- */ +- cbnz x2, 1f +- +- /* sctlr_el1 */ +- mov x0, #0x0800 // Set/clear RES{1,0} bits +-CPU_BE( movk x0, #0x33d0, lsl #16 ) // Set EE and E0E on BE systems +-CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems +- msr sctlr_el1, x0 +- +- /* Coprocessor traps. */ +- mov x0, #0x33ff +- msr cptr_el2, x0 // Disable copro. traps to EL2 +-1: +- + #ifdef CONFIG_COMPAT + msr hstr_el2, xzr // Disable CP15 traps to EL2 + #endif +@@ -598,6 +578,23 @@ CPU_LE( movk x0, #0x30d0, lsl #16 ) // C + ret + + install_el2_stub: ++ /* ++ * When VHE is not in use, early init of EL2 and EL1 needs to be ++ * done here. ++ * When VHE _is_ in use, EL1 will not be used in the host and ++ * requires no configuration, and all non-hyp-specific EL2 setup ++ * will be done via the _EL1 system register aliases in __cpu_setup. ++ */ ++ /* sctlr_el1 */ ++ mov x0, #0x0800 // Set/clear RES{1,0} bits ++CPU_BE( movk x0, #0x33d0, lsl #16 ) // Set EE and E0E on BE systems ++CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems ++ msr sctlr_el1, x0 ++ ++ /* Coprocessor traps. */ ++ mov x0, #0x33ff ++ msr cptr_el2, x0 // Disable copro. traps to EL2 ++ + /* Hypervisor stub */ + adrp x0, __hyp_stub_vectors + add x0, x0, #:lo12:__hyp_stub_vectors diff --git a/queue-4.9/arm64-reduce-el2_setup-branching.patch b/queue-4.9/arm64-reduce-el2_setup-branching.patch new file mode 100644 index 00000000000..42679a87f36 --- /dev/null +++ b/queue-4.9/arm64-reduce-el2_setup-branching.patch @@ -0,0 +1,61 @@ +From foo@baz Sun Jan 9 01:56:51 PM CET 2022 +From: Nathan Chancellor +Date: Fri, 7 Jan 2022 12:43:33 -0700 +Subject: arm64: reduce el2_setup branching +To: Greg Kroah-Hartman , Sasha Levin , Catalin Marinas , Will Deacon +Cc: Mark Rutland , Marc Zyngier , Nick Desaulniers , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev +Message-ID: <20220107194335.3090066-4-nathan@kernel.org> + +From: Mark Rutland + +commit 3ad47d055aa88d9f4189253f5b5c485f4c4626b2 upstream. + +The early el2_setup code is a little convoluted, with two branches where +one would do. This makes the code more painful to read than is +necessary. + +We can remove a branch and simplify the logic by moving the early return +in the booted-at-EL1 case earlier in the function. This separates it +from all the setup logic that only makes sense for EL2. + +Acked-by: Marc Zyngier +Signed-off-by: Mark Rutland +Cc: Will Deacon +Signed-off-by: Catalin Marinas +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/kernel/head.S | 15 +++++++-------- + 1 file changed, 7 insertions(+), 8 deletions(-) + +--- a/arch/arm64/kernel/head.S ++++ b/arch/arm64/kernel/head.S +@@ -489,13 +489,8 @@ ENTRY(el2_setup) + msr SPsel, #1 // We want to use SP_EL{1,2} + mrs x0, CurrentEL + cmp x0, #CurrentEL_EL2 +- b.ne 1f +- mrs x0, sctlr_el2 +-CPU_BE( orr x0, x0, #(1 << 25) ) // Set the EE bit for EL2 +-CPU_LE( bic x0, x0, #(1 << 25) ) // Clear the EE bit for EL2 +- msr sctlr_el2, x0 +- b 2f +-1: mrs x0, sctlr_el1 ++ b.eq 1f ++ mrs x0, sctlr_el1 + CPU_BE( orr x0, x0, #(3 << 24) ) // Set the EE and E0E bits for EL1 + CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1 + msr sctlr_el1, x0 +@@ -503,7 +498,11 @@ CPU_LE( bic x0, x0, #(3 << 24) ) // Clea + isb + ret + +-2: ++1: mrs x0, sctlr_el2 ++CPU_BE( orr x0, x0, #(1 << 25) ) // Set the EE bit for EL2 ++CPU_LE( bic x0, x0, #(1 << 25) ) // Clear the EE bit for EL2 ++ msr sctlr_el2, x0 ++ + #ifdef CONFIG_ARM64_VHE + /* + * Check for VHE being present. For the rest of the EL2 setup, diff --git a/queue-4.9/arm64-remove-a-redundancy-in-sysreg.h.patch b/queue-4.9/arm64-remove-a-redundancy-in-sysreg.h.patch new file mode 100644 index 00000000000..fdf86f3940d --- /dev/null +++ b/queue-4.9/arm64-remove-a-redundancy-in-sysreg.h.patch @@ -0,0 +1,36 @@ +From foo@baz Sun Jan 9 01:56:51 PM CET 2022 +From: Nathan Chancellor +Date: Fri, 7 Jan 2022 12:43:32 -0700 +Subject: arm64: Remove a redundancy in sysreg.h +To: Greg Kroah-Hartman , Sasha Levin , Catalin Marinas , Will Deacon +Cc: Mark Rutland , Marc Zyngier , Nick Desaulniers , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev +Message-ID: <20220107194335.3090066-3-nathan@kernel.org> + +From: Stefan Traby + +commit d38338e396ee0571b3502962fd2fbaec4d2d9a8f upstream. + +This is really trivial; there is a dup (1 << 16) in the code + +Acked-by: Will Deacon +Signed-off-by: Stefan Traby +Signed-off-by: Marc Zyngier +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/include/asm/sysreg.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +--- a/arch/arm64/include/asm/sysreg.h ++++ b/arch/arm64/include/asm/sysreg.h +@@ -95,8 +95,8 @@ + #define SCTLR_ELx_M 1 + + #define SCTLR_EL2_RES1 ((1 << 4) | (1 << 5) | (1 << 11) | (1 << 16) | \ +- (1 << 16) | (1 << 18) | (1 << 22) | (1 << 23) | \ +- (1 << 28) | (1 << 29)) ++ (1 << 18) | (1 << 22) | (1 << 23) | (1 << 28) | \ ++ (1 << 29)) + + #define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ + SCTLR_ELx_SA | SCTLR_ELx_I) diff --git a/queue-4.9/arm64-sysreg-move-to-use-definitions-for-all-the-sctlr-bits.patch b/queue-4.9/arm64-sysreg-move-to-use-definitions-for-all-the-sctlr-bits.patch new file mode 100644 index 00000000000..0d882dcdedf --- /dev/null +++ b/queue-4.9/arm64-sysreg-move-to-use-definitions-for-all-the-sctlr-bits.patch @@ -0,0 +1,222 @@ +From foo@baz Sun Jan 9 01:56:51 PM CET 2022 +From: Nathan Chancellor +Date: Fri, 7 Jan 2022 12:43:35 -0700 +Subject: arm64: sysreg: Move to use definitions for all the SCTLR bits +To: Greg Kroah-Hartman , Sasha Levin , Catalin Marinas , Will Deacon +Cc: Mark Rutland , Marc Zyngier , Nick Desaulniers , linux-arm-kernel@lists.infradead.org, stable@vger.kernel.org, llvm@lists.linux.dev +Message-ID: <20220107194335.3090066-6-nathan@kernel.org> + +From: James Morse + +commit 7a00d68ebe5f07cb1db17e7fedfd031f0d87e8bb upstream. + +__cpu_setup() configures SCTLR_EL1 using some hard coded hex masks, +and el2_setup() duplicates some this when setting RES1 bits. + +Lets make this the same as KVM's hyp_init, which uses named bits. + +First, we add definitions for all the SCTLR_EL{1,2} bits, the RES{1,0} +bits, and those we want to set or clear. + +Add a build_bug checks to ensures all bits are either set or clear. +This means we don't need to preserve endian-ness configuration +generated elsewhere. + +Finally, move the head.S and proc.S users of these hard-coded masks +over to the macro versions. + +Signed-off-by: James Morse +Signed-off-by: Catalin Marinas +Signed-off-by: Ard Biesheuvel +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + arch/arm64/include/asm/sysreg.h | 65 ++++++++++++++++++++++++++++++++++++++-- + arch/arm64/kernel/head.S | 13 +------- + arch/arm64/mm/proc.S | 24 -------------- + 3 files changed, 67 insertions(+), 35 deletions(-) + +--- a/arch/arm64/include/asm/sysreg.h ++++ b/arch/arm64/include/asm/sysreg.h +@@ -20,6 +20,7 @@ + #ifndef __ASM_SYSREG_H + #define __ASM_SYSREG_H + ++#include + #include + + #include +@@ -88,25 +89,81 @@ + + /* Common SCTLR_ELx flags. */ + #define SCTLR_ELx_EE (1 << 25) ++#define SCTLR_ELx_WXN (1 << 19) + #define SCTLR_ELx_I (1 << 12) + #define SCTLR_ELx_SA (1 << 3) + #define SCTLR_ELx_C (1 << 2) + #define SCTLR_ELx_A (1 << 1) + #define SCTLR_ELx_M 1 + ++#define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ ++ SCTLR_ELx_SA | SCTLR_ELx_I) ++ ++/* SCTLR_EL2 specific flags. */ + #define SCTLR_EL2_RES1 ((1 << 4) | (1 << 5) | (1 << 11) | (1 << 16) | \ + (1 << 18) | (1 << 22) | (1 << 23) | (1 << 28) | \ + (1 << 29)) ++#define SCTLR_EL2_RES0 ((1 << 6) | (1 << 7) | (1 << 8) | (1 << 9) | \ ++ (1 << 10) | (1 << 13) | (1 << 14) | (1 << 15) | \ ++ (1 << 17) | (1 << 20) | (1 << 21) | (1 << 24) | \ ++ (1 << 26) | (1 << 27) | (1 << 30) | (1 << 31)) ++ ++#ifdef CONFIG_CPU_BIG_ENDIAN ++#define ENDIAN_SET_EL2 SCTLR_ELx_EE ++#define ENDIAN_CLEAR_EL2 0 ++#else ++#define ENDIAN_SET_EL2 0 ++#define ENDIAN_CLEAR_EL2 SCTLR_ELx_EE ++#endif ++ ++/* SCTLR_EL2 value used for the hyp-stub */ ++#define SCTLR_EL2_SET (ENDIAN_SET_EL2 | SCTLR_EL2_RES1) ++#define SCTLR_EL2_CLEAR (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ ++ SCTLR_ELx_SA | SCTLR_ELx_I | SCTLR_ELx_WXN | \ ++ ENDIAN_CLEAR_EL2 | SCTLR_EL2_RES0) ++ ++/* Check all the bits are accounted for */ ++#define SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS BUILD_BUG_ON((SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != ~0) + +-#define SCTLR_ELx_FLAGS (SCTLR_ELx_M | SCTLR_ELx_A | SCTLR_ELx_C | \ +- SCTLR_ELx_SA | SCTLR_ELx_I) + + /* SCTLR_EL1 specific flags. */ + #define SCTLR_EL1_UCI (1 << 26) ++#define SCTLR_EL1_E0E (1 << 24) + #define SCTLR_EL1_SPAN (1 << 23) ++#define SCTLR_EL1_NTWE (1 << 18) ++#define SCTLR_EL1_NTWI (1 << 16) + #define SCTLR_EL1_UCT (1 << 15) ++#define SCTLR_EL1_DZE (1 << 14) ++#define SCTLR_EL1_UMA (1 << 9) + #define SCTLR_EL1_SED (1 << 8) ++#define SCTLR_EL1_ITD (1 << 7) + #define SCTLR_EL1_CP15BEN (1 << 5) ++#define SCTLR_EL1_SA0 (1 << 4) ++ ++#define SCTLR_EL1_RES1 ((1 << 11) | (1 << 20) | (1 << 22) | (1 << 28) | \ ++ (1 << 29)) ++#define SCTLR_EL1_RES0 ((1 << 6) | (1 << 10) | (1 << 13) | (1 << 17) | \ ++ (1 << 21) | (1 << 27) | (1 << 30) | (1 << 31)) ++ ++#ifdef CONFIG_CPU_BIG_ENDIAN ++#define ENDIAN_SET_EL1 (SCTLR_EL1_E0E | SCTLR_ELx_EE) ++#define ENDIAN_CLEAR_EL1 0 ++#else ++#define ENDIAN_SET_EL1 0 ++#define ENDIAN_CLEAR_EL1 (SCTLR_EL1_E0E | SCTLR_ELx_EE) ++#endif ++ ++#define SCTLR_EL1_SET (SCTLR_ELx_M | SCTLR_ELx_C | SCTLR_ELx_SA |\ ++ SCTLR_EL1_SA0 | SCTLR_EL1_SED | SCTLR_ELx_I |\ ++ SCTLR_EL1_DZE | SCTLR_EL1_UCT | SCTLR_EL1_NTWI |\ ++ SCTLR_EL1_NTWE | SCTLR_EL1_SPAN | ENDIAN_SET_EL1 |\ ++ SCTLR_EL1_UCI | SCTLR_EL1_RES1) ++#define SCTLR_EL1_CLEAR (SCTLR_ELx_A | SCTLR_EL1_CP15BEN | SCTLR_EL1_ITD |\ ++ SCTLR_EL1_UMA | SCTLR_ELx_WXN | ENDIAN_CLEAR_EL1 |\ ++ SCTLR_EL1_RES0) ++ ++/* Check all the bits are accounted for */ ++#define SCTLR_EL1_BUILD_BUG_ON_MISSING_BITS BUILD_BUG_ON((SCTLR_EL1_SET ^ SCTLR_EL1_CLEAR) != ~0) + + /* id_aa64isar0 */ + #define ID_AA64ISAR0_RDM_SHIFT 28 +@@ -244,6 +301,7 @@ + + #else + ++#include + #include + + asm( +@@ -300,6 +358,9 @@ static inline void config_sctlr_el1(u32 + { + u32 val; + ++ SCTLR_EL2_BUILD_BUG_ON_MISSING_BITS; ++ SCTLR_EL1_BUILD_BUG_ON_MISSING_BITS; ++ + val = read_sysreg(sctlr_el1); + val &= ~clear; + val |= set; +--- a/arch/arm64/kernel/head.S ++++ b/arch/arm64/kernel/head.S +@@ -490,17 +490,13 @@ ENTRY(el2_setup) + mrs x0, CurrentEL + cmp x0, #CurrentEL_EL2 + b.eq 1f +- mrs x0, sctlr_el1 +-CPU_BE( orr x0, x0, #(3 << 24) ) // Set the EE and E0E bits for EL1 +-CPU_LE( bic x0, x0, #(3 << 24) ) // Clear the EE and E0E bits for EL1 ++ mov_q x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1) + msr sctlr_el1, x0 + mov w0, #BOOT_CPU_MODE_EL1 // This cpu booted in EL1 + isb + ret + +-1: mrs x0, sctlr_el2 +-CPU_BE( orr x0, x0, #(1 << 25) ) // Set the EE bit for EL2 +-CPU_LE( bic x0, x0, #(1 << 25) ) // Clear the EE bit for EL2 ++1: mov_q x0, (SCTLR_EL2_RES1 | ENDIAN_SET_EL2) + msr sctlr_el2, x0 + + #ifdef CONFIG_ARM64_VHE +@@ -585,10 +581,7 @@ install_el2_stub: + * requires no configuration, and all non-hyp-specific EL2 setup + * will be done via the _EL1 system register aliases in __cpu_setup. + */ +- /* sctlr_el1 */ +- mov x0, #0x0800 // Set/clear RES{1,0} bits +-CPU_BE( movk x0, #0x33d0, lsl #16 ) // Set EE and E0E on BE systems +-CPU_LE( movk x0, #0x30d0, lsl #16 ) // Clear EE and E0E on LE systems ++ mov_q x0, (SCTLR_EL1_RES1 | ENDIAN_SET_EL1) + msr sctlr_el1, x0 + + /* Coprocessor traps. */ +--- a/arch/arm64/mm/proc.S ++++ b/arch/arm64/mm/proc.S +@@ -413,11 +413,7 @@ ENTRY(__cpu_setup) + /* + * Prepare SCTLR + */ +- adr x5, crval +- ldp w5, w6, [x5] +- mrs x0, sctlr_el1 +- bic x0, x0, x5 // clear bits +- orr x0, x0, x6 // set bits ++ mov_q x0, SCTLR_EL1_SET + /* + * Set/prepare TCR and TTBR. We use 512GB (39-bit) address range for + * both user and kernel. +@@ -453,21 +449,3 @@ ENTRY(__cpu_setup) + msr tcr_el1, x10 + ret // return to head.S + ENDPROC(__cpu_setup) +- +- /* +- * We set the desired value explicitly, including those of the +- * reserved bits. The values of bits EE & E0E were set early in +- * el2_setup, which are left untouched below. +- * +- * n n T +- * U E WT T UD US IHBS +- * CE0 XWHW CZ ME TEEA S +- * .... .IEE .... NEAI TE.I ..AD DEN0 ACAM +- * 0011 0... 1101 ..0. ..0. 10.. .0.. .... < hardware reserved +- * .... .1.. .... 01.1 11.1 ..01 0.01 1101 < software settings +- */ +- .type crval, #object +-crval: +- .word 0xfcffffff // clear +- .word 0x34d5d91d // set +- .popsection diff --git a/queue-4.9/bug-split-build_bug-stuff-out-into-linux-build_bug.h.patch b/queue-4.9/bug-split-build_bug-stuff-out-into-linux-build_bug.h.patch new file mode 100644 index 00000000000..90df03ae55a --- /dev/null +++ b/queue-4.9/bug-split-build_bug-stuff-out-into-linux-build_bug.h.patch @@ -0,0 +1,214 @@ +From bc6245e5efd70c41eaf9334b1b5e646745cb0fb3 Mon Sep 17 00:00:00 2001 +From: Ian Abbott +Date: Mon, 10 Jul 2017 15:51:07 -0700 +Subject: bug: split BUILD_BUG stuff out into + +From: Ian Abbott + +commit bc6245e5efd70c41eaf9334b1b5e646745cb0fb3 upstream. + +Including pulls in a lot of bloat from and + that is not needed to call the BUILD_BUG() family of +macros. Split them out into their own header, . + +Also correct some checkpatch.pl errors for the BUILD_BUG_ON_ZERO() and +BUILD_BUG_ON_NULL() macros by adding parentheses around the bitfield +widths that begin with a minus sign. + +Link: http://lkml.kernel.org/r/20170525120316.24473-6-abbotti@mev.co.uk +Signed-off-by: Ian Abbott +Acked-by: Michal Nazarewicz +Acked-by: Kees Cook +Cc: Steven Rostedt +Cc: Peter Zijlstra +Cc: Jakub Kicinski +Cc: Rasmus Villemoes +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +[nathan: Just take this patch, not the checkpatch.pl patches before it] +Signed-off-by: Nathan Chancellor +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/bug.h | 72 --------------------------------------- + include/linux/build_bug.h | 84 ++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 85 insertions(+), 71 deletions(-) + create mode 100644 include/linux/build_bug.h + +--- a/include/linux/bug.h ++++ b/include/linux/bug.h +@@ -3,6 +3,7 @@ + + #include + #include ++#include + + enum bug_trap_type { + BUG_TRAP_TYPE_NONE = 0, +@@ -13,80 +14,9 @@ enum bug_trap_type { + struct pt_regs; + + #ifdef __CHECKER__ +-#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) +-#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) +-#define BUILD_BUG_ON_ZERO(e) (0) +-#define BUILD_BUG_ON_NULL(e) ((void*)0) +-#define BUILD_BUG_ON_INVALID(e) (0) +-#define BUILD_BUG_ON_MSG(cond, msg) (0) +-#define BUILD_BUG_ON(condition) (0) +-#define BUILD_BUG() (0) + #define MAYBE_BUILD_BUG_ON(cond) (0) + #else /* __CHECKER__ */ + +-/* Force a compilation error if a constant expression is not a power of 2 */ +-#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \ +- BUILD_BUG_ON(((n) & ((n) - 1)) != 0) +-#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ +- BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) +- +-/* Force a compilation error if condition is true, but also produce a +- result (of value 0 and type size_t), so the expression can be used +- e.g. in a structure initializer (or where-ever else comma expressions +- aren't permitted). */ +-#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) +-#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) +- +-/* +- * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the +- * expression but avoids the generation of any code, even if that expression +- * has side-effects. +- */ +-#define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e)))) +- +-/** +- * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied +- * error message. +- * @condition: the condition which the compiler should know is false. +- * +- * See BUILD_BUG_ON for description. +- */ +-#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) +- +-/** +- * BUILD_BUG_ON - break compile if a condition is true. +- * @condition: the condition which the compiler should know is false. +- * +- * If you have some code which relies on certain constants being equal, or +- * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to +- * detect if someone changes it. +- * +- * The implementation uses gcc's reluctance to create a negative array, but gcc +- * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to +- * inline functions). Luckily, in 4.3 they added the "error" function +- * attribute just for this type of case. Thus, we use a negative sized array +- * (should always create an error on gcc versions older than 4.4) and then call +- * an undefined function with the error attribute (should always create an +- * error on gcc 4.3 and later). If for some reason, neither creates a +- * compile-time error, we'll still have a link-time error, which is harder to +- * track down. +- */ +-#ifndef __OPTIMIZE__ +-#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +-#else +-#define BUILD_BUG_ON(condition) \ +- BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) +-#endif +- +-/** +- * BUILD_BUG - break compile if used. +- * +- * If you have some code that you expect the compiler to eliminate at +- * build time, you should use BUILD_BUG to detect if it is +- * unexpectedly used. +- */ +-#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") +- + #define MAYBE_BUILD_BUG_ON(cond) \ + do { \ + if (__builtin_constant_p((cond))) \ +--- /dev/null ++++ b/include/linux/build_bug.h +@@ -0,0 +1,84 @@ ++#ifndef _LINUX_BUILD_BUG_H ++#define _LINUX_BUILD_BUG_H ++ ++#include ++ ++#ifdef __CHECKER__ ++#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) ++#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) ++#define BUILD_BUG_ON_ZERO(e) (0) ++#define BUILD_BUG_ON_NULL(e) ((void *)0) ++#define BUILD_BUG_ON_INVALID(e) (0) ++#define BUILD_BUG_ON_MSG(cond, msg) (0) ++#define BUILD_BUG_ON(condition) (0) ++#define BUILD_BUG() (0) ++#else /* __CHECKER__ */ ++ ++/* Force a compilation error if a constant expression is not a power of 2 */ ++#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \ ++ BUILD_BUG_ON(((n) & ((n) - 1)) != 0) ++#define BUILD_BUG_ON_NOT_POWER_OF_2(n) \ ++ BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) ++ ++/* ++ * Force a compilation error if condition is true, but also produce a ++ * result (of value 0 and type size_t), so the expression can be used ++ * e.g. in a structure initializer (or where-ever else comma expressions ++ * aren't permitted). ++ */ ++#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:(-!!(e)); })) ++#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:(-!!(e)); })) ++ ++/* ++ * BUILD_BUG_ON_INVALID() permits the compiler to check the validity of the ++ * expression but avoids the generation of any code, even if that expression ++ * has side-effects. ++ */ ++#define BUILD_BUG_ON_INVALID(e) ((void)(sizeof((__force long)(e)))) ++ ++/** ++ * BUILD_BUG_ON_MSG - break compile if a condition is true & emit supplied ++ * error message. ++ * @condition: the condition which the compiler should know is false. ++ * ++ * See BUILD_BUG_ON for description. ++ */ ++#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ++ ++/** ++ * BUILD_BUG_ON - break compile if a condition is true. ++ * @condition: the condition which the compiler should know is false. ++ * ++ * If you have some code which relies on certain constants being equal, or ++ * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to ++ * detect if someone changes it. ++ * ++ * The implementation uses gcc's reluctance to create a negative array, but gcc ++ * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to ++ * inline functions). Luckily, in 4.3 they added the "error" function ++ * attribute just for this type of case. Thus, we use a negative sized array ++ * (should always create an error on gcc versions older than 4.4) and then call ++ * an undefined function with the error attribute (should always create an ++ * error on gcc 4.3 and later). If for some reason, neither creates a ++ * compile-time error, we'll still have a link-time error, which is harder to ++ * track down. ++ */ ++#ifndef __OPTIMIZE__ ++#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) ++#else ++#define BUILD_BUG_ON(condition) \ ++ BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ++#endif ++ ++/** ++ * BUILD_BUG - break compile if used. ++ * ++ * If you have some code that you expect the compiler to eliminate at ++ * build time, you should use BUILD_BUG to detect if it is ++ * unexpectedly used. ++ */ ++#define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") ++ ++#endif /* __CHECKER__ */ ++ ++#endif /* _LINUX_BUILD_BUG_H */ diff --git a/queue-4.9/phonet-refcount-leak-in-pep_sock_accep.patch b/queue-4.9/phonet-refcount-leak-in-pep_sock_accep.patch new file mode 100644 index 00000000000..84d2eedd699 --- /dev/null +++ b/queue-4.9/phonet-refcount-leak-in-pep_sock_accep.patch @@ -0,0 +1,31 @@ +From bcd0f93353326954817a4f9fa55ec57fb38acbb0 Mon Sep 17 00:00:00 2001 +From: Hangyu Hua +Date: Thu, 9 Dec 2021 16:28:39 +0800 +Subject: phonet: refcount leak in pep_sock_accep + +From: Hangyu Hua + +commit bcd0f93353326954817a4f9fa55ec57fb38acbb0 upstream. + +sock_hold(sk) is invoked in pep_sock_accept(), but __sock_put(sk) is not +invoked in subsequent failure branches(pep_accept_conn() != 0). + +Signed-off-by: Hangyu Hua +Link: https://lore.kernel.org/r/20211209082839.33985-1-hbh25y@gmail.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Aayush Agarwal +Signed-off-by: Greg Kroah-Hartman +--- + net/phonet/pep.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/net/phonet/pep.c ++++ b/net/phonet/pep.c +@@ -878,6 +878,7 @@ static struct sock *pep_sock_accept(stru + + err = pep_accept_conn(newsk, skb); + if (err) { ++ __sock_put(sk); + sock_put(newsk); + newsk = NULL; + goto drop; diff --git a/queue-4.9/rndis_host-support-hytera-digital-radios.patch b/queue-4.9/rndis_host-support-hytera-digital-radios.patch new file mode 100644 index 00000000000..9e36db4f52f --- /dev/null +++ b/queue-4.9/rndis_host-support-hytera-digital-radios.patch @@ -0,0 +1,51 @@ +From 29262e1f773b4b6a43711120be564c57fca07cfb Mon Sep 17 00:00:00 2001 +From: Thomas Toye +Date: Sat, 1 Jan 2022 18:22:07 +0100 +Subject: rndis_host: support Hytera digital radios + +From: Thomas Toye + +commit 29262e1f773b4b6a43711120be564c57fca07cfb upstream. + +Hytera makes a range of digital (DMR) radios. These radios can be +programmed to a allow a computer to control them over Ethernet over USB, +either using NCM or RNDIS. + +This commit adds support for RNDIS for Hytera radios. I tested with a +Hytera PD785 and a Hytera MD785G. When these radios are programmed to +set up a Radio to PC Network using RNDIS, an USB interface will be added +with class 2 (Communications), subclass 2 (Abstract Modem Control) and +an interface protocol of 255 ("vendor specific" - lsusb even hints "MSFT +RNDIS?"). + +This patch is similar to the solution of this StackOverflow user, but +that only works for the Hytera MD785: +https://stackoverflow.com/a/53550858 + +To use the "Radio to PC Network" functionality of Hytera DMR radios, the +radios need to be programmed correctly in CPS (Hytera's Customer +Programming Software). "Forward to PC" should be checked in "Network" +(under "General Setting" in "Conventional") and the "USB Network +Communication Protocol" should be set to RNDIS. + +Signed-off-by: Thomas Toye +Signed-off-by: David S. Miller +Signed-off-by: Greg Kroah-Hartman +--- + drivers/net/usb/rndis_host.c | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/drivers/net/usb/rndis_host.c ++++ b/drivers/net/usb/rndis_host.c +@@ -620,6 +620,11 @@ static const struct usb_device_id produc + USB_CLASS_COMM, 2 /* ACM */, 0x0ff), + .driver_info = (unsigned long) &rndis_poll_status_info, + }, { ++ /* Hytera Communications DMR radios' "Radio to PC Network" */ ++ USB_VENDOR_AND_INTERFACE_INFO(0x238b, ++ USB_CLASS_COMM, 2 /* ACM */, 0x0ff), ++ .driver_info = (unsigned long)&rndis_info, ++}, { + /* RNDIS is MSFT's un-official variant of CDC ACM */ + USB_INTERFACE_INFO(USB_CLASS_COMM, 2 /* ACM */, 0x0ff), + .driver_info = (unsigned long) &rndis_info, diff --git a/queue-4.9/series b/queue-4.9/series index 31cdad800cf..5f1aa8363c3 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -6,3 +6,11 @@ ieee802154-atusb-fix-uninit-value-in-atusb_set_extended_addr.patch mac80211-initialize-variable-have_higher_than_11mbit.patch i40e-fix-incorrect-netdev-s-real-number-of-rx-tx-queues.patch sch_qfq-prevent-shift-out-of-bounds-in-qfq_init_qdisc.patch +xfs-map-unwritten-blocks-in-xfs_ioc_-alloc-free-sp-just-like-fallocate.patch +rndis_host-support-hytera-digital-radios.patch +bug-split-build_bug-stuff-out-into-linux-build_bug.h.patch +arm64-remove-a-redundancy-in-sysreg.h.patch +arm64-reduce-el2_setup-branching.patch +arm64-move-vhe-work-to-end-of-el2_setup.patch +arm64-sysreg-move-to-use-definitions-for-all-the-sctlr-bits.patch +phonet-refcount-leak-in-pep_sock_accep.patch diff --git a/queue-4.9/xfs-map-unwritten-blocks-in-xfs_ioc_-alloc-free-sp-just-like-fallocate.patch b/queue-4.9/xfs-map-unwritten-blocks-in-xfs_ioc_-alloc-free-sp-just-like-fallocate.patch new file mode 100644 index 00000000000..b626a83127e --- /dev/null +++ b/queue-4.9/xfs-map-unwritten-blocks-in-xfs_ioc_-alloc-free-sp-just-like-fallocate.patch @@ -0,0 +1,35 @@ +From 983d8e60f50806f90534cc5373d0ce867e5aaf79 Mon Sep 17 00:00:00 2001 +From: "Darrick J. Wong" +Date: Wed, 22 Dec 2021 14:19:18 -0800 +Subject: xfs: map unwritten blocks in XFS_IOC_{ALLOC,FREE}SP just like fallocate + +From: Darrick J. Wong + +commit 983d8e60f50806f90534cc5373d0ce867e5aaf79 upstream. + +The old ALLOCSP/FREESP ioctls in XFS can be used to preallocate space at +the end of files, just like fallocate and RESVSP. Make the behavior +consistent with the other ioctls. + +Reported-by: Kirill Tkhai +Signed-off-by: Darrick J. Wong +Signed-off-by: Darrick J. Wong +Reviewed-by: Dave Chinner +Reviewed-by: Eric Sandeen +Signed-off-by: Greg Kroah-Hartman +--- + fs/xfs/xfs_ioctl.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/fs/xfs/xfs_ioctl.c ++++ b/fs/xfs/xfs_ioctl.c +@@ -712,7 +712,8 @@ xfs_ioc_space( + flags |= XFS_PREALLOC_CLEAR; + if (bf->l_start > XFS_ISIZE(ip)) { + error = xfs_alloc_file_space(ip, XFS_ISIZE(ip), +- bf->l_start - XFS_ISIZE(ip), 0); ++ bf->l_start - XFS_ISIZE(ip), ++ XFS_BMAPI_PREALLOC); + if (error) + goto out_unlock; + }