[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202305071045.e0D7M8pZ-lkp@intel.com>
Date: Sun, 7 May 2023 10:11:31 +0800
From: kernel test robot <lkp@...el.com>
To: Yimin Gu <ustcymgu@...il.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
Palmer Dabbelt <palmer@...osinc.com>,
Jesse Taube <Mr.Bossman075@...il.com>,
Damien Le Moal <damien.lemoal@...nsource.wdc.com>,
Conor Dooley <conor.dooley@...rochip.com>
Subject: kernel/events/core.c:7429 perf_virt_to_phys() warn: always true
condition '(virt >= 0) => (0-u64max >= 0)'
Hi Yimin,
FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: fc4354c6e5c21257cf4a50b32f7c11c7d65c55b3
commit: b5e2c507b06c9d36411845149162a804ae7b04a9 riscv: Kconfig: Allow RV32 to build with no MMU
date: 6 weeks ago
config: riscv-randconfig-m041-20230507 (https://download.01.org/0day-ci/archive/20230507/202305071045.e0D7M8pZ-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202305071045.e0D7M8pZ-lkp@intel.com/
New smatch warnings:
kernel/events/core.c:7429 perf_virt_to_phys() warn: always true condition '(virt >= 0) => (0-u64max >= 0)'
Old smatch warnings:
arch/riscv/include/asm/atomic.h:204 arch_atomic_fetch_add_unless() warn: inconsistent indenting
vim +7429 kernel/events/core.c
5622f295b53fb6 kernel/perf_counter.c Markus Metzger 2009-09-15 7418
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7419 static u64 perf_virt_to_phys(u64 virt)
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7420 {
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7421 u64 phys_addr = 0;
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7422
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7423 if (!virt)
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7424 return 0;
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7425
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7426 if (virt >= TASK_SIZE) {
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7427 /* If it's vmalloc()d memory, leave phys_addr as 0 */
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7428 if (virt_addr_valid((void *)(uintptr_t)virt) &&
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 @7429 !(virt >= VMALLOC_START && virt < VMALLOC_END))
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7430 phys_addr = (u64)virt_to_phys((void *)(uintptr_t)virt);
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7431 } else {
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7432 /*
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7433 * Walking the pages tables for user address.
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7434 * Interrupts are disabled, so it prevents any tear down
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7435 * of the page tables.
dadbb612f6e50b kernel/events/core.c Souptick Joarder 2020-06-07 7436 * Try IRQ-safe get_user_page_fast_only first.
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7437 * If failed, leave phys_addr as 0.
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7438 */
d3296fb372bf74 kernel/events/core.c Jiri Olsa 2020-04-07 7439 if (current->mm != NULL) {
4716023a8f6a0f kernel/events/core.c Greg Thelen 2021-11-10 7440 struct page *p;
4716023a8f6a0f kernel/events/core.c Greg Thelen 2021-11-10 7441
d3296fb372bf74 kernel/events/core.c Jiri Olsa 2020-04-07 7442 pagefault_disable();
4716023a8f6a0f kernel/events/core.c Greg Thelen 2021-11-10 7443 if (get_user_page_fast_only(virt, 0, &p)) {
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7444 phys_addr = page_to_phys(p) + virt % PAGE_SIZE;
4716023a8f6a0f kernel/events/core.c Greg Thelen 2021-11-10 7445 put_page(p);
4716023a8f6a0f kernel/events/core.c Greg Thelen 2021-11-10 7446 }
d3296fb372bf74 kernel/events/core.c Jiri Olsa 2020-04-07 7447 pagefault_enable();
d3296fb372bf74 kernel/events/core.c Jiri Olsa 2020-04-07 7448 }
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7449 }
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7450
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7451 return phys_addr;
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7452 }
fc7ce9c74c3ad2 kernel/events/core.c Kan Liang 2017-08-28 7453
:::::: The code at line 7429 was first introduced by commit
:::::: fc7ce9c74c3ad232b084d80148654f926d01ece7 perf/core, x86: Add PERF_SAMPLE_PHYS_ADDR
:::::: TO: Kan Liang <kan.liang@...el.com>
:::::: CC: Ingo Molnar <mingo@...nel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
Powered by blists - more mailing lists