From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: arch/um/kernel/um_arch.c:336 linux_main() warn: impossible condition '(task_size > 1024 * (1 << 22)) => (0-u32max > 4294967296)'
Date: Thu, 19 Dec 2024 03:46:14 +0800 [thread overview]
Message-ID: <202412190317.9HCF0iDF-lkp@intel.com> (raw)
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Benjamin Berg <benjamin.berg@intel.com>
CC: Johannes Berg <johannes.berg@intel.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: aef25be35d23ec768eed08bfcf7ca3cf9685bc28
commit: 830003c73d190259e45d0a99a0e3d14cb73e0af0 um: Limit TASK_SIZE to the addressable range
date: 10 weeks ago
:::::: branch date: 22 hours ago
:::::: commit date: 10 weeks ago
config: um-randconfig-r073-20241219 (https://download.01.org/0day-ci/archive/20241219/202412190317.9HCF0iDF-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202412190317.9HCF0iDF-lkp@intel.com/
smatch warnings:
arch/um/kernel/um_arch.c:336 linux_main() warn: impossible condition '(task_size > 1024 * (1 << 22)) => (0-u32max > 4294967296)'
vim +336 arch/um/kernel/um_arch.c
d8fb32f4790f2a2 Anton Ivanov 2021-03-12 304
7a3a06d0e158fc8 Alon Bar-Lev 2007-02-12 305 int __init linux_main(int argc, char **argv)
^1da177e4c3f415 Linus Torvalds 2005-04-16 306 {
^1da177e4c3f415 Linus Torvalds 2005-04-16 307 unsigned long avail, diff;
^1da177e4c3f415 Linus Torvalds 2005-04-16 308 unsigned long virtmem_size, max_physmem;
60a2988aea701a6 Jeff Dike 2008-05-12 309 unsigned long stack;
3af9c5bed1b8f28 WANG Cong 2008-04-28 310 unsigned int i;
3af9c5bed1b8f28 WANG Cong 2008-04-28 311 int add;
^1da177e4c3f415 Linus Torvalds 2005-04-16 312
^1da177e4c3f415 Linus Torvalds 2005-04-16 313 for (i = 1; i < argc; i++) {
ba180fd437156f7 Jeff Dike 2007-10-16 314 if ((i == 1) && (argv[i][0] == ' '))
ba180fd437156f7 Jeff Dike 2007-10-16 315 continue;
^1da177e4c3f415 Linus Torvalds 2005-04-16 316 add = 1;
^1da177e4c3f415 Linus Torvalds 2005-04-16 317 uml_checksetup(argv[i], &add);
^1da177e4c3f415 Linus Torvalds 2005-04-16 318 if (add)
^1da177e4c3f415 Linus Torvalds 2005-04-16 319 add_arg(argv[i]);
^1da177e4c3f415 Linus Torvalds 2005-04-16 320 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 321 if (have_root == 0)
d7ffac33631b2f7 Thomas Meyer 2021-01-05 322 add_arg(DEFAULT_COMMAND_LINE_ROOT);
d7ffac33631b2f7 Thomas Meyer 2021-01-05 323
d7ffac33631b2f7 Thomas Meyer 2021-01-05 324 if (have_console == 0)
d7ffac33631b2f7 Thomas Meyer 2021-01-05 325 add_arg(DEFAULT_COMMAND_LINE_CONSOLE);
^1da177e4c3f415 Linus Torvalds 2005-04-16 326
40fb16a360d9c64 Tom Spink 2008-06-05 327 host_task_size = os_get_top_address();
91f0a0c5cc5bc86 Benjamin Berg 2024-09-19 328 /* reserve a few pages for the stubs */
91f0a0c5cc5bc86 Benjamin Berg 2024-09-19 329 stub_start = host_task_size - STUB_DATA_PAGES * PAGE_SIZE;
6032aca0deb9c13 Johannes Berg 2023-04-14 330 /* another page for the code portion */
6032aca0deb9c13 Johannes Berg 2023-04-14 331 stub_start -= PAGE_SIZE;
6032aca0deb9c13 Johannes Berg 2023-04-14 332 host_task_size = stub_start;
bfc58e2b98e9973 Johannes Berg 2021-01-13 333
830003c73d19025 Benjamin Berg 2024-09-19 334 /* Limit TASK_SIZE to what is addressable by the page table */
830003c73d19025 Benjamin Berg 2024-09-19 335 task_size = host_task_size;
830003c73d19025 Benjamin Berg 2024-09-19 @336 if (task_size > (unsigned long long) PTRS_PER_PGD * PGDIR_SIZE)
830003c73d19025 Benjamin Berg 2024-09-19 337 task_size = PTRS_PER_PGD * PGDIR_SIZE;
830003c73d19025 Benjamin Berg 2024-09-19 338
536788fe2d28e11 Jeff Dike 2008-02-08 339 /*
536788fe2d28e11 Jeff Dike 2008-02-08 340 * TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
536788fe2d28e11 Jeff Dike 2008-02-08 341 * out
536788fe2d28e11 Jeff Dike 2008-02-08 342 */
830003c73d19025 Benjamin Berg 2024-09-19 343 task_size = task_size & PGDIR_MASK;
536788fe2d28e11 Jeff Dike 2008-02-08 344
ba180fd437156f7 Jeff Dike 2007-10-16 345 /* OS sanity checks that need to happen before the kernel runs */
60d339f6fe08310 Gennady Sharapov 2005-09-03 346 os_early_checks();
cb66504d65e5421 Paolo 'Blaisorblade' Giarrusso 2005-07-27 347
d8fb32f4790f2a2 Anton Ivanov 2021-03-12 348 get_host_cpu_features(parse_host_cpu_flags, parse_cache_line);
d8fb32f4790f2a2 Anton Ivanov 2021-03-12 349
^1da177e4c3f415 Linus Torvalds 2005-04-16 350 brk_start = (unsigned long) sbrk(0);
77bf4400319db9d Jeff Dike 2007-10-16 351
ba180fd437156f7 Jeff Dike 2007-10-16 352 /*
ba180fd437156f7 Jeff Dike 2007-10-16 353 * Increase physical memory size for exec-shield users
ba180fd437156f7 Jeff Dike 2007-10-16 354 * so they actually get what they asked for. This should
ba180fd437156f7 Jeff Dike 2007-10-16 355 * add zero for non-exec shield users
ba180fd437156f7 Jeff Dike 2007-10-16 356 */
^1da177e4c3f415 Linus Torvalds 2005-04-16 357
^1da177e4c3f415 Linus Torvalds 2005-04-16 358 diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
^1da177e4c3f415 Linus Torvalds 2005-04-16 359 if (diff > 1024 * 1024) {
d3878bb8003009d Masami Hiramatsu 2017-05-18 360 os_info("Adding %ld bytes to physical memory to account for "
^1da177e4c3f415 Linus Torvalds 2005-04-16 361 "exec-shield gap\n", diff);
^1da177e4c3f415 Linus Torvalds 2005-04-16 362 physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
^1da177e4c3f415 Linus Torvalds 2005-04-16 363 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 364
05eacfd00ccf239 Nicolas Iooss 2014-10-12 365 uml_physmem = (unsigned long) __binary_start & PAGE_MASK;
^1da177e4c3f415 Linus Torvalds 2005-04-16 366
^1da177e4c3f415 Linus Torvalds 2005-04-16 367 /* Reserve up to 4M after the current brk */
^1da177e4c3f415 Linus Torvalds 2005-04-16 368 uml_reserved = ROUND_4M(brk_start) + (1 << 22);
^1da177e4c3f415 Linus Torvalds 2005-04-16 369
96b644bdec977b9 Serge Hallyn 2006-10-02 370 setup_machinename(init_utsname()->machine);
^1da177e4c3f415 Linus Torvalds 2005-04-16 371
cd05cbed42b7316 Tiwei Bie 2024-09-16 372 physmem_size = (physmem_size + PAGE_SIZE - 1) & PAGE_MASK;
^1da177e4c3f415 Linus Torvalds 2005-04-16 373 iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
cd05cbed42b7316 Tiwei Bie 2024-09-16 374
536788fe2d28e11 Jeff Dike 2008-02-08 375 max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
^1da177e4c3f415 Linus Torvalds 2005-04-16 376
^1da177e4c3f415 Linus Torvalds 2005-04-16 377 if (physmem_size + iomem_size > max_physmem) {
cd05cbed42b7316 Tiwei Bie 2024-09-16 378 physmem_size = max_physmem - iomem_size;
cd05cbed42b7316 Tiwei Bie 2024-09-16 379 os_info("Physical memory size shrunk to %llu bytes\n",
cd05cbed42b7316 Tiwei Bie 2024-09-16 380 physmem_size);
^1da177e4c3f415 Linus Torvalds 2005-04-16 381 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 382
^1da177e4c3f415 Linus Torvalds 2005-04-16 383 high_physmem = uml_physmem + physmem_size;
^1da177e4c3f415 Linus Torvalds 2005-04-16 384 end_iomem = high_physmem + iomem_size;
^1da177e4c3f415 Linus Torvalds 2005-04-16 385 high_memory = (void *) end_iomem;
^1da177e4c3f415 Linus Torvalds 2005-04-16 386
^1da177e4c3f415 Linus Torvalds 2005-04-16 387 start_vm = VMALLOC_START;
^1da177e4c3f415 Linus Torvalds 2005-04-16 388
^1da177e4c3f415 Linus Torvalds 2005-04-16 389 virtmem_size = physmem_size;
60a2988aea701a6 Jeff Dike 2008-05-12 390 stack = (unsigned long) argv;
60a2988aea701a6 Jeff Dike 2008-05-12 391 stack &= ~(1024 * 1024 - 1);
60a2988aea701a6 Jeff Dike 2008-05-12 392 avail = stack - start_vm;
ba180fd437156f7 Jeff Dike 2007-10-16 393 if (physmem_size > avail)
ba180fd437156f7 Jeff Dike 2007-10-16 394 virtmem_size = avail;
^1da177e4c3f415 Linus Torvalds 2005-04-16 395 end_vm = start_vm + virtmem_size;
^1da177e4c3f415 Linus Torvalds 2005-04-16 396
^1da177e4c3f415 Linus Torvalds 2005-04-16 397 if (virtmem_size < physmem_size)
d3878bb8003009d Masami Hiramatsu 2017-05-18 398 os_info("Kernel virtual memory size shrunk to %lu bytes\n",
^1da177e4c3f415 Linus Torvalds 2005-04-16 399 virtmem_size);
^1da177e4c3f415 Linus Torvalds 2005-04-16 400
^1da177e4c3f415 Linus Torvalds 2005-04-16 401 os_flush_stdout();
^1da177e4c3f415 Linus Torvalds 2005-04-16 402
77bf4400319db9d Jeff Dike 2007-10-16 403 return start_uml();
^1da177e4c3f415 Linus Torvalds 2005-04-16 404 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 405
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reply other threads:[~2024-12-18 19:46 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=202412190317.9HCF0iDF-lkp@intel.com \
--to=lkp@intel.com \
--cc=error27@gmail.com \
--cc=oe-kbuild@lists.linux.dev \
/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.