From: kernel test robot <lkp@intel.com>
To: Yimin Gu <ustcymgu@gmail.com>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
Palmer Dabbelt <palmer@rivosinc.com>,
Jesse Taube <Mr.Bossman075@gmail.com>,
Damien Le Moal <damien.lemoal@opensource.wdc.com>,
Conor Dooley <conor.dooley@microchip.com>
Subject: kernel/events/core.c:7429 perf_virt_to_phys() warn: always true condition '(virt >= 0) => (0-u64max >= 0)'
Date: Sun, 7 May 2023 10:11:31 +0800 [thread overview]
Message-ID: <202305071045.e0D7M8pZ-lkp@intel.com> (raw)
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@intel.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@intel.com>
:::::: CC: Ingo Molnar <mingo@kernel.org>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
reply other threads:[~2023-05-07 2:12 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=202305071045.e0D7M8pZ-lkp@intel.com \
--to=lkp@intel.com \
--cc=Mr.Bossman075@gmail.com \
--cc=conor.dooley@microchip.com \
--cc=damien.lemoal@opensource.wdc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=palmer@rivosinc.com \
--cc=ustcymgu@gmail.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