From nobody Sat Feb 7 21:16:09 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 973F7C7EE23 for ; Tue, 30 May 2023 18:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233159AbjE3SDe (ORCPT ); Tue, 30 May 2023 14:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbjE3SD0 (ORCPT ); Tue, 30 May 2023 14:03:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20E71E5 for ; Tue, 30 May 2023 11:03:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A793E62C1E for ; Tue, 30 May 2023 18:03:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBB31C4339B; Tue, 30 May 2023 18:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685469803; bh=rRFiekp/e4p9IosGOeiClcA0ZQRFHAsurfVAIwKYtNA=; h=From:To:Cc:Subject:Date:From; b=kfKhO+115F+K6AN+J8c3KwpDdC0A/fljxKFJOwFNZTrsM0wqJ47qSC4SmyDG/ywQa rpWpiB6ciiDy+op+OmmhgwSRoI3V7MI0SkNvepDwfBp02IZq1cX02k1ZXMOVDTtsg4 abXf+RQ9Hl4Enio2jc8gYZ85+o1svPLjfQ3Exim4U7LMa+rj/fl61MfnwhFhXhZrGv jHw/nlB7deHg/gajRIxZidsczL0WIRfX0lnwPgKL8RR2ZIZTpEeVnxr+/1GRq2lNza oASt27IP2SarlOpnEDJt5txd4KdxEMyg0xE8jYiyCHqhpElaemCQkpW/B5ESBXJGSr A+haUxRPOhcfw== From: Masahiro Yamada To: patches@armlinux.org.uk Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , linux-arm-kernel@lists.infradead.org, Masahiro Yamada , Russell King Subject: [PATCH] ARM: module: use sign_extend32() to extend the signedness Date: Wed, 31 May 2023 03:03:08 +0900 Message-Id: <20230530180308.112297-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The function name clarifies the intention. Signed-off-by: Masahiro Yamada --- KernelVersion: v6.4-rc1 arch/arm/kernel/module.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index d59c36dc0494..e74d84f58b77 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -169,8 +169,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab,= unsigned int symindex, =20 offset =3D __mem_to_opcode_arm(*(u32 *)loc); offset =3D (offset & 0x00ffffff) << 2; - if (offset & 0x02000000) - offset -=3D 0x04000000; + offset =3D sign_extend32(offset, 25); =20 offset +=3D sym->st_value - loc; =20 @@ -236,7 +235,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab,= unsigned int symindex, case R_ARM_MOVT_PREL: offset =3D tmp =3D __mem_to_opcode_arm(*(u32 *)loc); offset =3D ((offset & 0xf0000) >> 4) | (offset & 0xfff); - offset =3D (offset ^ 0x8000) - 0x8000; + offset =3D sign_extend32(offset, 15); =20 offset +=3D sym->st_value; if (ELF32_R_TYPE(rel->r_info) =3D=3D R_ARM_MOVT_PREL || @@ -344,8 +343,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab,= unsigned int symindex, ((~(j2 ^ sign) & 1) << 22) | ((upper & 0x03ff) << 12) | ((lower & 0x07ff) << 1); - if (offset & 0x01000000) - offset -=3D 0x02000000; + offset =3D sign_extend32(offset, 24); offset +=3D sym->st_value - loc; =20 /* @@ -401,7 +399,7 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab,= unsigned int symindex, offset =3D ((upper & 0x000f) << 12) | ((upper & 0x0400) << 1) | ((lower & 0x7000) >> 4) | (lower & 0x00ff); - offset =3D (offset ^ 0x8000) - 0x8000; + offset =3D sign_extend32(offset, 15); offset +=3D sym->st_value; =20 if (ELF32_R_TYPE(rel->r_info) =3D=3D R_ARM_THM_MOVT_PREL || --=20 2.39.2