[v2] MIPS: jump_label: Fix compat branch range check

Message ID 20221103151053.213583-1-jiaxun.yang@flygoat.com
State New
Headers
Series [v2] MIPS: jump_label: Fix compat branch range check |

Commit Message

Jiaxun Yang Nov. 3, 2022, 3:10 p.m. UTC
  Cast upper bound of branch range to long to do signed compare,
avoid negative offset trigger this warning.

Fixes: 9b6584e35f40 ("MIPS: jump_label: Use compact branches for >= r6")
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Cc: stable@vger.kernel.org
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
v2: Fix typo, collect review tags.
---
 arch/mips/kernel/jump_label.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Jiaxun Yang Nov. 9, 2022, 11:07 a.m. UTC | #1
在 2022/11/3 15:10, Jiaxun Yang 写道:
> Cast upper bound of branch range to long to do signed compare,
> avoid negative offset trigger this warning.
>
> Fixes: 9b6584e35f40 ("MIPS: jump_label: Use compact branches for >= r6")
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: stable@vger.kernel.org
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Ping :-)

Thanks
- Jiaxun

> ---
> v2: Fix typo, collect review tags.
> ---
>   arch/mips/kernel/jump_label.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
> index 71a882c8c6eb..f7978d50a2ba 100644
> --- a/arch/mips/kernel/jump_label.c
> +++ b/arch/mips/kernel/jump_label.c
> @@ -56,7 +56,7 @@ void arch_jump_label_transform(struct jump_entry *e,
>   			 * The branch offset must fit in the instruction's 26
>   			 * bit field.
>   			 */
> -			WARN_ON((offset >= BIT(25)) ||
> +			WARN_ON((offset >= (long)BIT(25)) ||
>   				(offset < -(long)BIT(25)));
>   
>   			insn.j_format.opcode = bc6_op;
  
Thomas Bogendoerfer Nov. 11, 2022, 3:04 p.m. UTC | #2
On Thu, Nov 03, 2022 at 03:10:53PM +0000, Jiaxun Yang wrote:
> Cast upper bound of branch range to long to do signed compare,
> avoid negative offset trigger this warning.
> 
> Fixes: 9b6584e35f40 ("MIPS: jump_label: Use compact branches for >= r6")
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> Cc: stable@vger.kernel.org
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> v2: Fix typo, collect review tags.
> ---
>  arch/mips/kernel/jump_label.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
> index 71a882c8c6eb..f7978d50a2ba 100644
> --- a/arch/mips/kernel/jump_label.c
> +++ b/arch/mips/kernel/jump_label.c
> @@ -56,7 +56,7 @@ void arch_jump_label_transform(struct jump_entry *e,
>  			 * The branch offset must fit in the instruction's 26
>  			 * bit field.
>  			 */
> -			WARN_ON((offset >= BIT(25)) ||
> +			WARN_ON((offset >= (long)BIT(25)) ||
>  				(offset < -(long)BIT(25)));
>  
>  			insn.j_format.opcode = bc6_op;
> -- 
> 2.34.1

applied to mips-fixes.

Thomas.
  

Patch

diff --git a/arch/mips/kernel/jump_label.c b/arch/mips/kernel/jump_label.c
index 71a882c8c6eb..f7978d50a2ba 100644
--- a/arch/mips/kernel/jump_label.c
+++ b/arch/mips/kernel/jump_label.c
@@ -56,7 +56,7 @@  void arch_jump_label_transform(struct jump_entry *e,
 			 * The branch offset must fit in the instruction's 26
 			 * bit field.
 			 */
-			WARN_ON((offset >= BIT(25)) ||
+			WARN_ON((offset >= (long)BIT(25)) ||
 				(offset < -(long)BIT(25)));
 
 			insn.j_format.opcode = bc6_op;