From: kernel test robot <lkp@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: oe-kbuild-all@lists.linux.dev, kvm@vger.kernel.org,
Farrah Chen <farrah.chen@intel.com>
Subject: [kvm:planes-20250401 43/62] arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:269:33: error: invalid type argument of '->' (have 'struct stat')
Date: Wed, 2 Apr 2025 14:29:38 +0800 [thread overview]
Message-ID: <202504021409.aXa06kaD-lkp@intel.com> (raw)
Hi Paolo,
FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
tree: https://git.kernel.org/pub/scm/virt/kvm/kvm.git planes-20250401
head: 73685d9c23b7122b44f07d59244416f8b56ed48e
commit: 6249af4632166284e82033226a1679e38cb3e6e8 [43/62] KVM: share statistics for same vCPU id on different planes
config: arm64-randconfig-003-20250402 (https://download.01.org/0day-ci/archive/20250402/202504021409.aXa06kaD-lkp@intel.com/config)
compiler: aarch64-linux-gcc (GCC) 9.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250402/202504021409.aXa06kaD-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504021409.aXa06kaD-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c: In function 'init_elf':
>> arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:269:33: error: invalid type argument of '->' (have 'struct stat')
269 | elf.begin = mmap(0, stat->st_size, PROT_READ, MAP_PRIVATE, fd, 0);
| ^~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:279:23: error: invalid type argument of '->' (have 'struct stat')
279 | assert_ge(stat->st_size, sizeof(*elf.ehdr), "%lu");
| ^~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:182:24: note: in definition of macro 'assert_op'
182 | typeof(lhs) _lhs = (lhs); \
| ^~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:279:9: note: in expansion of macro 'assert_ge'
279 | assert_ge(stat->st_size, sizeof(*elf.ehdr), "%lu");
| ^~~~~~~~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:279:23: error: invalid type argument of '->' (have 'struct stat')
279 | assert_ge(stat->st_size, sizeof(*elf.ehdr), "%lu");
| ^~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:182:37: note: in definition of macro 'assert_op'
182 | typeof(lhs) _lhs = (lhs); \
| ^~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:279:9: note: in expansion of macro 'assert_ge'
279 | assert_ge(stat->st_size, sizeof(*elf.ehdr), "%lu");
| ^~~~~~~~~
>> arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:166:33: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'int' [-Wformat=]
166 | fprintf(stderr, "error: %s: " fmt "\n", \
| ^~~~~~~~~~~~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:186:25: note: in expansion of macro 'fatal_error'
186 | fatal_error("assertion " #lhs " " #op " " #rhs \
| ^~~~~~~~~~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:195:41: note: in expansion of macro 'assert_op'
195 | #define assert_ge(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, >=)
| ^~~~~~~~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:279:9: note: in expansion of macro 'assert_ge'
279 | assert_ge(stat->st_size, sizeof(*elf.ehdr), "%lu");
| ^~~~~~~~~
vim +269 arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
163
164 #define fatal_error(fmt, ...) \
165 ({ \
> 166 fprintf(stderr, "error: %s: " fmt "\n", \
167 elf.path, ## __VA_ARGS__); \
168 exit(EXIT_FAILURE); \
169 __builtin_unreachable(); \
170 })
171
172 #define fatal_perror(msg) \
173 ({ \
174 fprintf(stderr, "error: %s: " msg ": %s\n", \
175 elf.path, strerror(errno)); \
176 exit(EXIT_FAILURE); \
177 __builtin_unreachable(); \
178 })
179
180 #define assert_op(lhs, rhs, fmt, op) \
181 ({ \
182 typeof(lhs) _lhs = (lhs); \
183 typeof(rhs) _rhs = (rhs); \
184 \
185 if (!(_lhs op _rhs)) { \
186 fatal_error("assertion " #lhs " " #op " " #rhs \
187 " failed (lhs=" fmt ", rhs=" fmt \
188 ", line=%d)", _lhs, _rhs, __LINE__); \
189 } \
190 })
191
192 #define assert_eq(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, ==)
193 #define assert_ne(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, !=)
194 #define assert_lt(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, <)
195 #define assert_ge(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, >=)
196
197 /*
198 * Return a pointer of a given type at a given offset from
199 * the beginning of the ELF file.
200 */
201 #define elf_ptr(type, off) ((type *)(elf.begin + (off)))
202
203 /* Iterate over all sections in the ELF. */
204 #define for_each_section(var) \
205 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var)
206
207 /* Iterate over all Elf64_Rela relocations in a given section. */
208 #define for_each_rela(shdr, var) \
209 for (var = elf_ptr(Elf64_Rela, elf64toh(shdr->sh_offset)); \
210 var < elf_ptr(Elf64_Rela, elf64toh(shdr->sh_offset) + elf64toh(shdr->sh_size)); var++)
211
212 /* True if a string starts with a given prefix. */
213 static inline bool starts_with(const char *str, const char *prefix)
214 {
215 return memcmp(str, prefix, strlen(prefix)) == 0;
216 }
217
218 /* Returns a string containing the name of a given section. */
219 static inline const char *section_name(Elf64_Shdr *shdr)
220 {
221 return elf.sh_string + elf32toh(shdr->sh_name);
222 }
223
224 /* Returns a pointer to the first byte of section data. */
225 static inline const char *section_begin(Elf64_Shdr *shdr)
226 {
227 return elf_ptr(char, elf64toh(shdr->sh_offset));
228 }
229
230 /* Find a section by its offset from the beginning of the file. */
231 static inline Elf64_Shdr *section_by_off(Elf64_Off off)
232 {
233 assert_ne(off, 0UL, "%lu");
234 return elf_ptr(Elf64_Shdr, off);
235 }
236
237 /* Find a section by its index. */
238 static inline Elf64_Shdr *section_by_idx(uint16_t idx)
239 {
240 assert_ne(idx, SHN_UNDEF, "%u");
241 return &elf.sh_table[idx];
242 }
243
244 /*
245 * Memory-map the given ELF file, perform sanity checks, and
246 * populate global state.
247 */
248 static void init_elf(const char *path)
249 {
250 int fd, ret;
251 struct stat stat;
252
253 /* Store path in the global struct for error printing. */
254 elf.path = path;
255
256 /* Open the ELF file. */
257 fd = open(path, O_RDONLY);
258 if (fd < 0)
259 fatal_perror("Could not open ELF file");
260
261 /* Get status of ELF file to obtain its size. */
262 ret = fstat(fd, &stat);
263 if (ret < 0) {
264 close(fd);
265 fatal_perror("Could not get status of ELF file");
266 }
267
268 /* mmap() the entire ELF file read-only at an arbitrary address. */
> 269 elf.begin = mmap(0, stat->st_size, PROT_READ, MAP_PRIVATE, fd, 0);
270 if (elf.begin == MAP_FAILED) {
271 close(fd);
272 fatal_perror("Could not mmap ELF file");
273 }
274
275 /* mmap() was successful, close the FD. */
276 close(fd);
277
278 /* Get pointer to the ELF header. */
279 assert_ge(stat->st_size, sizeof(*elf.ehdr), "%lu");
280 elf.ehdr = elf_ptr(Elf64_Ehdr, 0);
281
282 /* Check the ELF magic. */
283 assert_eq(elf.ehdr->e_ident[EI_MAG0], ELFMAG0, "0x%x");
284 assert_eq(elf.ehdr->e_ident[EI_MAG1], ELFMAG1, "0x%x");
285 assert_eq(elf.ehdr->e_ident[EI_MAG2], ELFMAG2, "0x%x");
286 assert_eq(elf.ehdr->e_ident[EI_MAG3], ELFMAG3, "0x%x");
287
288 /* Sanity check that this is an ELF64 relocatable object for AArch64. */
289 assert_eq(elf.ehdr->e_ident[EI_CLASS], ELFCLASS64, "%u");
290 assert_eq(elf.ehdr->e_ident[EI_DATA], ELFENDIAN, "%u");
291 assert_eq(elf16toh(elf.ehdr->e_type), ET_REL, "%u");
292 assert_eq(elf16toh(elf.ehdr->e_machine), EM_AARCH64, "%u");
293
294 /* Populate fields of the global struct. */
295 elf.sh_table = section_by_off(elf64toh(elf.ehdr->e_shoff));
296 elf.sh_string = section_begin(section_by_idx(elf16toh(elf.ehdr->e_shstrndx)));
297 }
298
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2025-04-02 6:30 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=202504021409.aXa06kaD-lkp@intel.com \
--to=lkp@intel.com \
--cc=farrah.chen@intel.com \
--cc=kvm@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=pbonzini@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox