All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Benjamin Berg <benjamin.berg@intel.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	Johannes Berg <johannes.berg@intel.com>
Subject: [linux-next:master 3814/4143] arch/um/kernel/um_arch.c:336:16: warning: result of comparison of constant 4294967296 with expression of type 'typeof (task_size)' (aka 'unsigned long') is always false
Date: Sat, 12 Oct 2024 07:19:23 +0800	[thread overview]
Message-ID: <202410120738.fFMnOYWI-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   d61a00525464bfc5fe92c6ad713350988e492b88
commit: 830003c73d190259e45d0a99a0e3d14cb73e0af0 [3814/4143] um: Limit TASK_SIZE to the addressable range
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20241012/202410120738.fFMnOYWI-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241012/202410120738.fFMnOYWI-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/202410120738.fFMnOYWI-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from arch/um/kernel/um_arch.c:19:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:8:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from arch/um/kernel/um_arch.c:19:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:8:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from arch/um/kernel/um_arch.c:19:
   In file included from include/linux/suspend.h:5:
   In file included from include/linux/swap.h:9:
   In file included from include/linux/memcontrol.h:13:
   In file included from include/linux/cgroup.h:26:
   In file included from include/linux/kernel_stat.h:8:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from arch/um/include/asm/hardirq.h:5:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/um/include/asm/io.h:24:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:693:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     693 |         readsb(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:701:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     701 |         readsw(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:709:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     709 |         readsl(PCI_IOBASE + addr, buffer, count);
         |                ~~~~~~~~~~ ^
   include/asm-generic/io.h:718:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     718 |         writesb(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:727:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     727 |         writesw(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
   include/asm-generic/io.h:736:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     736 |         writesl(PCI_IOBASE + addr, buffer, count);
         |                 ~~~~~~~~~~ ^
>> arch/um/kernel/um_arch.c:336:16: warning: result of comparison of constant 4294967296 with expression of type 'typeof (task_size)' (aka 'unsigned long') is always false [-Wtautological-constant-out-of-range-compare]
     336 |         if (task_size > (unsigned long long) PTRS_PER_PGD * PGDIR_SIZE)
         |             ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   13 warnings generated.


vim +336 arch/um/kernel/um_arch.c

   304	
   305	int __init linux_main(int argc, char **argv)
   306	{
   307		unsigned long avail, diff;
   308		unsigned long virtmem_size, max_physmem;
   309		unsigned long stack;
   310		unsigned int i;
   311		int add;
   312	
   313		for (i = 1; i < argc; i++) {
   314			if ((i == 1) && (argv[i][0] == ' '))
   315				continue;
   316			add = 1;
   317			uml_checksetup(argv[i], &add);
   318			if (add)
   319				add_arg(argv[i]);
   320		}
   321		if (have_root == 0)
   322			add_arg(DEFAULT_COMMAND_LINE_ROOT);
   323	
   324		if (have_console == 0)
   325			add_arg(DEFAULT_COMMAND_LINE_CONSOLE);
   326	
   327		host_task_size = os_get_top_address();
   328		/* reserve a few pages for the stubs */
   329		stub_start = host_task_size - STUB_DATA_PAGES * PAGE_SIZE;
   330		/* another page for the code portion */
   331		stub_start -= PAGE_SIZE;
   332		host_task_size = stub_start;
   333	
   334		/* Limit TASK_SIZE to what is addressable by the page table */
   335		task_size = host_task_size;
 > 336		if (task_size > (unsigned long long) PTRS_PER_PGD * PGDIR_SIZE)
   337			task_size = PTRS_PER_PGD * PGDIR_SIZE;
   338	
   339		/*
   340		 * TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps
   341		 * out
   342		 */
   343		task_size = task_size & PGDIR_MASK;
   344	
   345		/* OS sanity checks that need to happen before the kernel runs */
   346		os_early_checks();
   347	
   348		get_host_cpu_features(parse_host_cpu_flags, parse_cache_line);
   349	
   350		brk_start = (unsigned long) sbrk(0);
   351	
   352		/*
   353		 * Increase physical memory size for exec-shield users
   354		 * so they actually get what they asked for. This should
   355		 * add zero for non-exec shield users
   356		 */
   357	
   358		diff = UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
   359		if (diff > 1024 * 1024) {
   360			os_info("Adding %ld bytes to physical memory to account for "
   361				"exec-shield gap\n", diff);
   362			physmem_size += UML_ROUND_UP(brk_start) - UML_ROUND_UP(&_end);
   363		}
   364	
   365		uml_physmem = (unsigned long) __binary_start & PAGE_MASK;
   366	
   367		/* Reserve up to 4M after the current brk */
   368		uml_reserved = ROUND_4M(brk_start) + (1 << 22);
   369	
   370		setup_machinename(init_utsname()->machine);
   371	
   372		physmem_size = (physmem_size + PAGE_SIZE - 1) & PAGE_MASK;
   373		iomem_size = (iomem_size + PAGE_SIZE - 1) & PAGE_MASK;
   374	
   375		max_physmem = TASK_SIZE - uml_physmem - iomem_size - MIN_VMALLOC;
   376	
   377		if (physmem_size + iomem_size > max_physmem) {
   378			physmem_size = max_physmem - iomem_size;
   379			os_info("Physical memory size shrunk to %llu bytes\n",
   380				physmem_size);
   381		}
   382	
   383		high_physmem = uml_physmem + physmem_size;
   384		end_iomem = high_physmem + iomem_size;
   385		high_memory = (void *) end_iomem;
   386	
   387		start_vm = VMALLOC_START;
   388	
   389		virtmem_size = physmem_size;
   390		stack = (unsigned long) argv;
   391		stack &= ~(1024 * 1024 - 1);
   392		avail = stack - start_vm;
   393		if (physmem_size > avail)
   394			virtmem_size = avail;
   395		end_vm = start_vm + virtmem_size;
   396	
   397		if (virtmem_size < physmem_size)
   398			os_info("Kernel virtual memory size shrunk to %lu bytes\n",
   399				virtmem_size);
   400	
   401		os_flush_stdout();
   402	
   403		return start_uml();
   404	}
   405	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2024-10-11 23:19 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=202410120738.fFMnOYWI-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=benjamin.berg@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@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.