From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227aDpWBV6hVeBxksFaNXDYqUS6kKjjgv92pO+CAwzMtaEMqFE5PBzd6f4k/2+4Kqh4ap/au ARC-Seal: i=1; a=rsa-sha256; t=1517256453; cv=none; d=google.com; s=arc-20160816; b=EmSIYkA97uMQC5KEdhlAZ3wUeQDteK8u6Ht2SYxsIae2RIxkwWIXL84aXPn4j5sjiK tqPUp7EyqApNVa1S79xtovIA0N00RYUgfy5gB5KD8PXnrp50g7HQ2PxHVEYfP/C0lqYq p1ZJs7xcqmewox1LoYLlVXhytV+acJz+U7HFLRoqs/AkFB9bRWFSKxf28X2FPKbRW7Pq 4dPeJ0vmC4LYQtWZVRY2g0cnPQTPU7rnYjZ9MZg1Bevp5UU+4XjggjB91t+wiPtR9UTC NAA8QT+yL2yLHaysBtyiYHaVK4/9vJySwBZRuyZxk/ZMFHY2W23VrGE8GCHYq0Vq0Gc2 jBqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ZKqAzmUrJfET+ATbVtecfUZtJH2YsaqYeCKYR1+cMYw=; b=zbMQPK5d1g15lQ8aNhnobJUt7M3JJcf03Onkr3MGbFlvE2AGQoStEESfUVKHRWmgxD Ky8dQPfQ1kTIBVX9VLuZ37akhX22k2rk3Dj6NJiOe62W6WjkcqSP1Z5w4mOeC42cr0gC pDazivjhjlG9cbN2ObDduxWoE3gdbVzYpFVu4qPXvvc3BRJw5kpwl4fVlifrng5jM2qv UL2LpnIRVevjpX2dy3pCTbKr1Sw90HE6ghSjSt9qSqs0tz/aP2zqwtphSJDT4tWiAY0T 4mRE3WbDTcFzRmSgJlDqNFbNUDlk73sJ9CXVC5PKQLe7IIabUQe/5UFK7c09Gl/J8Xc3 s65g== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Russell King Subject: [PATCH 4.14 14/71] ARM: net: bpf: avoid bx instruction on non-Thumb capable CPUs Date: Mon, 29 Jan 2018 13:56:42 +0100 Message-Id: <20180129123828.240787243@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590958702813481125?= X-GMAIL-MSGID: =?utf-8?q?1590958702813481125?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Russell King commit e9062481824384f00299971f923fecf6b3668001 upstream. Avoid the 'bx' instruction on CPUs that have no support for Thumb and thus do not implement this instruction by moving the generation of this opcode to a separate function that selects between: bx reg and mov pc, reg according to the capabilities of the CPU. Fixes: 39c13c204bb1 ("arm: eBPF JIT compiler") Signed-off-by: Russell King Signed-off-by: Greg Kroah-Hartman --- arch/arm/net/bpf_jit_32.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/arch/arm/net/bpf_jit_32.c +++ b/arch/arm/net/bpf_jit_32.c @@ -285,16 +285,20 @@ static inline void emit_mov_i(const u8 r emit_mov_i_no8m(rd, val, ctx); } -static inline void emit_blx_r(u8 tgt_reg, struct jit_ctx *ctx) +static void emit_bx_r(u8 tgt_reg, struct jit_ctx *ctx) { - ctx->seen |= SEEN_CALL; -#if __LINUX_ARM_ARCH__ < 5 - emit(ARM_MOV_R(ARM_LR, ARM_PC), ctx); - if (elf_hwcap & HWCAP_THUMB) emit(ARM_BX(tgt_reg), ctx); else emit(ARM_MOV_R(ARM_PC, tgt_reg), ctx); +} + +static inline void emit_blx_r(u8 tgt_reg, struct jit_ctx *ctx) +{ + ctx->seen |= SEEN_CALL; +#if __LINUX_ARM_ARCH__ < 5 + emit(ARM_MOV_R(ARM_LR, ARM_PC), ctx); + emit_bx_r(tgt_reg, ctx); #else emit(ARM_BLX_R(tgt_reg), ctx); #endif @@ -997,7 +1001,7 @@ static int emit_bpf_tail_call(struct jit emit_a32_mov_i(tmp2[1], off, false, ctx); emit(ARM_LDR_R(tmp[1], tmp[1], tmp2[1]), ctx); emit(ARM_ADD_I(tmp[1], tmp[1], ctx->prologue_bytes), ctx); - emit(ARM_BX(tmp[1]), ctx); + emit_bx_r(tmp[1], ctx); /* out: */ if (out_offset == -1) @@ -1166,7 +1170,7 @@ static void build_epilogue(struct jit_ct emit(ARM_POP(reg_set), ctx); /* Return back to the callee function */ if (!(ctx->seen & SEEN_CALL)) - emit(ARM_BX(ARM_LR), ctx); + emit_bx_r(ARM_LR, ctx); #endif }