From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [ardb:for-kernelci 13/17] arch/arm64/kernel/pi/early_map_kernel.c:134:31: warning: Comparing pointers that point to different objects [comparePointers]
Date: Thu, 07 Jul 2022 16:06:37 +0800 [thread overview]
Message-ID: <202207071540.joMsMwGI-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 8132 bytes --]
::::::
:::::: Manual check reason: "low confidence static check warning: arch/arm64/kernel/pi/early_map_kernel.c:134:31: warning: Comparing pointers that point to different objects [comparePointers]"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Ard Biesheuvel <ardb@kernel.org>
tree: git://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git for-kernelci
head: 3ed2d2fa189b2f472547045b3af344e7806f7779
commit: 32a20e7c99cc0d6b5948880ea9cfc14068b22f7b [13/17] arm64: head: move early kernel mapping and relocation code to C code
:::::: branch date: 7 days ago
:::::: commit date: 7 days ago
compiler: aarch64-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout 32a20e7c99cc0d6b5948880ea9cfc14068b22f7b
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
>> arch/arm64/kernel/pi/early_map_kernel.c:134:31: warning: Comparing pointers that point to different objects [comparePointers]
for (rela = rela_start; rela < rela_end; rela++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:125:25: note: Variable declared here.
extern const Elf64_Rela rela_start[], rela_end[];
^
arch/arm64/kernel/pi/early_map_kernel.c:134:14: note: Array decayed to pointer here.
for (rela = rela_start; rela < rela_end; rela++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:125:39: note: Variable declared here.
extern const Elf64_Rela rela_start[], rela_end[];
^
arch/arm64/kernel/pi/early_map_kernel.c:134:33: note: Array decayed to pointer here.
for (rela = rela_start; rela < rela_end; rela++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:134:31: note: Comparing pointers that point to different objects
for (rela = rela_start; rela < rela_end; rela++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:169:31: warning: Comparing pointers that point to different objects [comparePointers]
for (relr = relr_start; relr < relr_end; relr++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:126:18: note: Variable declared here.
extern const u64 relr_start[], relr_end[];
^
arch/arm64/kernel/pi/early_map_kernel.c:169:14: note: Array decayed to pointer here.
for (relr = relr_start; relr < relr_end; relr++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:126:32: note: Variable declared here.
extern const u64 relr_start[], relr_end[];
^
arch/arm64/kernel/pi/early_map_kernel.c:169:33: note: Array decayed to pointer here.
for (relr = relr_start; relr < relr_end; relr++) {
^
arch/arm64/kernel/pi/early_map_kernel.c:169:31: note: Comparing pointers that point to different objects
for (relr = relr_start; relr < relr_end; relr++) {
^
vim +134 arch/arm64/kernel/pi/early_map_kernel.c
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 127
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 128 static void relocate_kernel(u64 offset)
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 129 {
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 130 const Elf64_Rela *rela;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 131 const u64 *relr;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 132 u64 *place;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 133
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 @134 for (rela = rela_start; rela < rela_end; rela++) {
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 135 if (ELF64_R_TYPE(rela->r_info) != R_AARCH64_RELATIVE)
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 136 continue;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 137 place = (u64 *)(rela->r_offset + offset);
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 138 *place = rela->r_addend + offset;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 139 }
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 140
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 141 if (!IS_ENABLED(CONFIG_RELR) || !offset)
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 142 return;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 143
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 144 /*
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 145 * Apply RELR relocations.
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 146 *
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 147 * RELR is a compressed format for storing relative relocations. The
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 148 * encoded sequence of entries looks like:
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 149 * [ AAAAAAAA BBBBBBB1 BBBBBBB1 ... AAAAAAAA BBBBBB1 ... ]
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 150 *
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 151 * i.e. start with an address, followed by any number of bitmaps. The
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 152 * address entry encodes 1 relocation. The subsequent bitmap entries
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 153 * encode up to 63 relocations each, at subsequent offsets following
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 154 * the last address entry.
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 155 *
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 156 * The bitmap entries must have 1 in the least significant bit. The
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 157 * assumption here is that an address cannot have 1 in lsb. Odd
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 158 * addresses are not supported. Any odd addresses are stored in the
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 159 * RELA section, which is handled above.
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 160 *
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 161 * Excluding the least significant bit in the bitmap, each non-zero bit
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 162 * in the bitmap represents a relocation to be applied to a
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 163 * corresponding machine word that follows the base address word. The
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 164 * second least significant bit represents the machine word immediately
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 165 * following the initial address, and each bit that follows represents
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 166 * the next word, in linear order. As such, a single bitmap can encode
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 167 * up to 63 relocations in a 64-bit object.
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 168 */
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 169 for (relr = relr_start; relr < relr_end; relr++) {
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 170 u64 *p, r = *relr;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 171
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 172 if ((r & 1) == 0) {
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 173 place = (u64 *)(r + offset);
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 174 *place++ += offset;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 175 } else {
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 176 for (p = place; r; p++) {
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 177 r >>= 1;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 178 if (r & 1)
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 179 *p += offset;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 180 }
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 181 place += 63;
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 182 }
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 183 }
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 184 }
32a20e7c99cc0d6 Ard Biesheuvel 2022-06-29 185
--
0-DAY CI Kernel Test Service
https://01.org/lkp
reply other threads:[~2022-07-07 8:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202207071540.joMsMwGI-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.