CC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Alexandre Ghiti <[email protected]>
CC: Palmer Dabbelt <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   df0cc57e057f18e44dac8e6c18aba47ab53202f9
commit: 0aba691a7443a7541c1dc56423e0c92cc6ea7164 riscv: Introduce 
va_kernel_pa_offset for 32-bit kernel
date:   5 months ago
:::::: branch date: 22 hours ago
:::::: commit date: 5 months ago
config: riscv-randconfig-c006-20220109 
(https://download.01.org/0day-ci/archive/20220111/[email protected]/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 
f3a344d2125fa37e59bae1b0874442c650a19607)
reproduce (this is a W=1 build):
        wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0aba691a7443a7541c1dc56423e0c92cc6ea7164
        git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 0aba691a7443a7541c1dc56423e0c92cc6ea7164
        # save the config file to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 
clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


clang-analyzer warnings: (new ones prefixed by >>)
           ^     ~~~~~~~~~~~~~~~~~~~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   drivers/mmc/core/sdio_cis.c:63:3: warning: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy]
                   strcpy(string, buf);
                   ^~~~~~
   drivers/mmc/core/sdio_cis.c:63:3: note: Call to function 'strcpy' is 
insecure as it does not provide bounding of the memory buffer. Replace 
unbounded copy functions with analogous functions that support length arguments 
such as 'strlcpy'. CWE-119
                   strcpy(string, buf);
                   ^~~~~~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   drivers/mmc/core/regulator.c:181:17: warning: Value stored to 'dev' during 
its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct device *dev = mmc_dev(mmc);
                          ^~~
   drivers/mmc/core/regulator.c:181:17: note: Value stored to 'dev' during its 
initialization is never read
           struct device *dev = mmc_dev(mmc);
                          ^~~
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (3 in non-user code, 1 with check filters).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   lib/percpu_test.c:115:2: warning: Value stored to 'ul' is never read 
[clang-analyzer-deadcode.DeadStores]
           ul = 3;
           ^    ~
   lib/percpu_test.c:115:2: note: Value stored to 'ul' is never read
           ul = 3;
           ^    ~
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   4 warnings generated.
   Suppressed 4 warnings (4 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   3 warnings generated.
   Suppressed 3 warnings (3 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   2 warnings generated.
   Suppressed 2 warnings (2 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.
   5 warnings generated.
>> drivers/nvme/host/core.c:872:4: warning: Potential leak of memory pointed to 
>> by '_x' [clang-analyzer-unix.Malloc]
                           clear_bit_unlock(0, &ns->ctrl->discard_page_busy);
                           ^
   drivers/nvme/host/core.c:845:10: note: Calling 'kzalloc'
           range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:721:9: note: Memory is allocated
           return kmalloc(size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/core.c:845:10: note: Returned allocated memory
           range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/core.c:846:6: note: Assuming 'range' is non-null
           if (!range) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   drivers/nvme/host/core.c:846:2: note: '?' condition is false
           if (!range) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   drivers/nvme/host/core.c:846:7: note: 'range' is non-null
           if (!range) {
                ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                                
        ^~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   drivers/nvme/host/core.c:846:2: note: '?' condition is false
           if (!range) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   drivers/nvme/host/core.c:846:2: note: Taking false branch
           if (!range) {
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/nvme/host/core.c:858:2: note: Assuming field 'bio' is null
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:2: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
           ^~~~~~~~~~~~~~
   include/linux/compiler.h:56:45: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   drivers/nvme/host/core.c:858:2: note: '?' condition is false
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:2: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   drivers/nvme/host/core.c:858:2: note: Field 'bio' is null
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:11: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
                    ^
   drivers/nvme/host/core.c:858:2: note: '?' condition is false
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:2: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
--
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   drivers/nvme/host/core.c:871:7: note: '_x' is >= -1073741824
                   if (virt_to_page(range) == ns->ctrl->discard_page)
                       ^
   arch/riscv/include/asm/page.h:152:42: note: expanded from macro 
'virt_to_page'
   #define virt_to_page(vaddr)     (pfn_to_page(virt_to_pfn(vaddr)))
                                                ^
   arch/riscv/include/asm/page.h:149:41: note: expanded from macro 'virt_to_pfn'
   #define virt_to_pfn(vaddr)      (phys_to_pfn(__pa(vaddr)))
                                                ^
   arch/riscv/include/asm/page.h:143:18: note: expanded from macro '__pa'
   #define __pa(x)         __virt_to_phys((unsigned long)(x))
                           ^
   note: (skipping 6 expansions in backtrace; use -fmacro-backtrace-limit=0 to 
see all)
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       
~~~~~~~~~~~~~~~~~^~~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   drivers/nvme/host/core.c:871:7: note: Left side of '&&' is true
                   if (virt_to_page(range) == ns->ctrl->discard_page)
                       ^
   arch/riscv/include/asm/page.h:152:42: note: expanded from macro 
'virt_to_page'
   #define virt_to_page(vaddr)     (pfn_to_page(virt_to_pfn(vaddr)))
                                                ^
   arch/riscv/include/asm/page.h:149:41: note: expanded from macro 'virt_to_pfn'
   #define virt_to_pfn(vaddr)      (phys_to_pfn(__pa(vaddr)))
                                                ^
   arch/riscv/include/asm/page.h:143:18: note: expanded from macro '__pa'
   #define __pa(x)         __virt_to_phys((unsigned long)(x))
                           ^
   arch/riscv/include/asm/page.h:138:27: note: expanded from macro 
'__virt_to_phys'
   #define __virt_to_phys(x)       __va_to_pa_nodebug(x)
                                   ^
   arch/riscv/include/asm/page.h:130:2: note: expanded from macro 
'__va_to_pa_nodebug'
           is_linear_mapping(_x) ?                                              
   \
           ^
   arch/riscv/include/asm/page.h:109:3: note: expanded from macro 
'is_linear_mapping'
           ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < 
kernel_map.virt_addr))
            ^
   drivers/nvme/host/core.c:871:7: note: Left side of '||' is true
                   if (virt_to_page(range) == ns->ctrl->discard_page)
                       ^
   arch/riscv/include/asm/page.h:152:42: note: expanded from macro 
'virt_to_page'
   #define virt_to_page(vaddr)     (pfn_to_page(virt_to_pfn(vaddr)))
                                                ^
   arch/riscv/include/asm/page.h:149:41: note: expanded from macro 'virt_to_pfn'
   #define virt_to_pfn(vaddr)      (phys_to_pfn(__pa(vaddr)))
                                                ^
   arch/riscv/include/asm/page.h:143:18: note: expanded from macro '__pa'
   #define __pa(x)         __virt_to_phys((unsigned long)(x))
                           ^
   arch/riscv/include/asm/page.h:138:27: note: expanded from macro 
'__virt_to_phys'
   #define __virt_to_phys(x)       __va_to_pa_nodebug(x)
                                   ^
   arch/riscv/include/asm/page.h:130:2: note: expanded from macro 
'__va_to_pa_nodebug'
           is_linear_mapping(_x) ?                                              
   \
           ^
   arch/riscv/include/asm/page.h:109:52: note: expanded from macro 
'is_linear_mapping'
           ((x) >= PAGE_OFFSET && (!IS_ENABLED(CONFIG_64BIT) || (x) < 
kernel_map.virt_addr))
                                                             ^
   drivers/nvme/host/core.c:871:3: note: Assuming the condition is true
                   if (virt_to_page(range) == ns->ctrl->discard_page)
                   ^
   include/linux/compiler.h:56:44: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       
~~~~~~~~~~~~~~~~~^~~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   drivers/nvme/host/core.c:871:3: note: '?' condition is true
                   if (virt_to_page(range) == ns->ctrl->discard_page)
                   ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   drivers/nvme/host/core.c:871:3: note: Taking true branch
                   if (virt_to_page(range) == ns->ctrl->discard_page)
                   ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/nvme/host/core.c:872:4: note: Potential leak of memory pointed to by 
'_x'
                           clear_bit_unlock(0, &ns->ctrl->discard_page_busy);
                           ^
>> drivers/nvme/host/core.c:872:4: warning: Potential leak of memory pointed to 
>> by '_y' [clang-analyzer-unix.Malloc]
                           clear_bit_unlock(0, &ns->ctrl->discard_page_busy);
                           ^
   drivers/nvme/host/core.c:845:10: note: Calling 'kzalloc'
           range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/slab.h:721:9: note: Memory is allocated
           return kmalloc(size, flags | __GFP_ZERO);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/core.c:845:10: note: Returned allocated memory
           range = kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/nvme/host/core.c:846:6: note: Assuming 'range' is non-null
           if (!range) {
               ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   drivers/nvme/host/core.c:846:2: note: '?' condition is false
           if (!range) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   drivers/nvme/host/core.c:846:7: note: 'range' is non-null
           if (!range) {
                ^
   include/linux/compiler.h:56:47: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                                                 ^~~~
   include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                                
        ^~~~
   include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
            ^~~~
   drivers/nvme/host/core.c:846:2: note: '?' condition is false
           if (!range) {
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                                       ^
   include/linux/compiler.h:69:2: note: expanded from macro '__trace_if_value'
           (cond) ?                                        \
           ^
   drivers/nvme/host/core.c:846:2: note: Taking false branch
           if (!range) {
           ^
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/nvme/host/core.c:858:2: note: Assuming field 'bio' is null
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:2: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
           ^~~~~~~~~~~~~~
   include/linux/compiler.h:56:45: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                                      ^~~~
   drivers/nvme/host/core.c:858:2: note: '?' condition is false
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:2: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:31: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))
                                 ^
   drivers/nvme/host/core.c:858:2: note: Field 'bio' is null
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:11: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
                    ^
   drivers/nvme/host/core.c:858:2: note: '?' condition is false
           __rq_for_each_bio(bio, req) {
           ^
   include/linux/blkdev.h:848:2: note: expanded from macro '__rq_for_each_bio'
           if ((rq->bio))                  \
           ^
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^
   include/linux/compiler.h:58:69: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : 
__trace_if_value(cond))

vim +/_x +872 drivers/nvme/host/core.c

8093f7ca73c163 Ming Lin             2016-04-12  830  
fc17b6534eb839 Christoph Hellwig    2017-06-03  831  static blk_status_t 
nvme_setup_discard(struct nvme_ns *ns, struct request *req,
8093f7ca73c163 Ming Lin             2016-04-12  832             struct 
nvme_command *cmnd)
8093f7ca73c163 Ming Lin             2016-04-12  833  {
b35ba01ea69791 Christoph Hellwig    2017-02-08  834     unsigned short segments 
= blk_rq_nr_discard_segments(req), n = 0;
8093f7ca73c163 Ming Lin             2016-04-12  835     struct nvme_dsm_range 
*range;
b35ba01ea69791 Christoph Hellwig    2017-02-08  836     struct bio *bio;
8093f7ca73c163 Ming Lin             2016-04-12  837  
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  838     /*
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  839      * Some devices do not 
consider the DSM 'Number of Ranges' field when
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  840      * determining how much 
data to DMA. Always allocate memory for maximum
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  841      * number of segments 
to prevent device reading beyond end of buffer.
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  842      */
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  843     static const size_t 
alloc_size = sizeof(*range) * NVME_DSM_MAX_RANGES;
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  844  
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  845     range = 
kzalloc(alloc_size, GFP_ATOMIC | __GFP_NOWARN);
cb5b7262b011cf Jens Axboe           2018-12-12  846     if (!range) {
cb5b7262b011cf Jens Axboe           2018-12-12  847             /*
cb5b7262b011cf Jens Axboe           2018-12-12  848              * If we fail 
allocation our range, fallback to the controller
cb5b7262b011cf Jens Axboe           2018-12-12  849              * discard 
page. If that's also busy, it's safe to return
cb5b7262b011cf Jens Axboe           2018-12-12  850              * busy, as we 
know we can make progress once that's freed.
cb5b7262b011cf Jens Axboe           2018-12-12  851              */
cb5b7262b011cf Jens Axboe           2018-12-12  852             if 
(test_and_set_bit_lock(0, &ns->ctrl->discard_page_busy))
fc17b6534eb839 Christoph Hellwig    2017-06-03  853                     return 
BLK_STS_RESOURCE;
8093f7ca73c163 Ming Lin             2016-04-12  854  
cb5b7262b011cf Jens Axboe           2018-12-12  855             range = 
page_address(ns->ctrl->discard_page);
cb5b7262b011cf Jens Axboe           2018-12-12  856     }
cb5b7262b011cf Jens Axboe           2018-12-12  857  
b35ba01ea69791 Christoph Hellwig    2017-02-08  858     __rq_for_each_bio(bio, 
req) {
314d48dd224897 Damien Le Moal       2019-10-21  859             u64 slba = 
nvme_sect_to_lba(ns, bio->bi_iter.bi_sector);
b35ba01ea69791 Christoph Hellwig    2017-02-08  860             u32 nlb = 
bio->bi_iter.bi_size >> ns->lba_shift;
b35ba01ea69791 Christoph Hellwig    2017-02-08  861  
8cb6af7b3a6d47 Keith Busch          2018-01-31  862             if (n < 
segments) {
b35ba01ea69791 Christoph Hellwig    2017-02-08  863                     
range[n].cattr = cpu_to_le32(0);
b35ba01ea69791 Christoph Hellwig    2017-02-08  864                     
range[n].nlb = cpu_to_le32(nlb);
b35ba01ea69791 Christoph Hellwig    2017-02-08  865                     
range[n].slba = cpu_to_le64(slba);
8cb6af7b3a6d47 Keith Busch          2018-01-31  866             }
b35ba01ea69791 Christoph Hellwig    2017-02-08  867             n++;
b35ba01ea69791 Christoph Hellwig    2017-02-08  868     }
b35ba01ea69791 Christoph Hellwig    2017-02-08  869  
b35ba01ea69791 Christoph Hellwig    2017-02-08  870     if (WARN_ON_ONCE(n != 
segments)) {
cb5b7262b011cf Jens Axboe           2018-12-12  871             if 
(virt_to_page(range) == ns->ctrl->discard_page)
cb5b7262b011cf Jens Axboe           2018-12-12 @872                     
clear_bit_unlock(0, &ns->ctrl->discard_page_busy);
cb5b7262b011cf Jens Axboe           2018-12-12  873             else
b35ba01ea69791 Christoph Hellwig    2017-02-08  874                     
kfree(range);
fc17b6534eb839 Christoph Hellwig    2017-06-03  875             return 
BLK_STS_IOERR;
b35ba01ea69791 Christoph Hellwig    2017-02-08  876     }
8093f7ca73c163 Ming Lin             2016-04-12  877  
8093f7ca73c163 Ming Lin             2016-04-12  878     cmnd->dsm.opcode = 
nvme_cmd_dsm;
ed754e5deeb17f Christoph Hellwig    2017-11-09  879     cmnd->dsm.nsid = 
cpu_to_le32(ns->head->ns_id);
f1dd03a84dbf3e Christoph Hellwig    2017-03-31  880     cmnd->dsm.nr = 
cpu_to_le32(segments - 1);
8093f7ca73c163 Ming Lin             2016-04-12  881     cmnd->dsm.attributes = 
cpu_to_le32(NVME_DSMGMT_AD);
8093f7ca73c163 Ming Lin             2016-04-12  882  
f9d03f96b98800 Christoph Hellwig    2016-12-08  883     
req->special_vec.bv_page = virt_to_page(range);
f9d03f96b98800 Christoph Hellwig    2016-12-08  884     
req->special_vec.bv_offset = offset_in_page(range);
530436c45ef2e4 Eduard Hasenleithner 2019-11-12  885     req->special_vec.bv_len 
= alloc_size;
f9d03f96b98800 Christoph Hellwig    2016-12-08  886     req->rq_flags |= 
RQF_SPECIAL_PAYLOAD;
8093f7ca73c163 Ming Lin             2016-04-12  887  
fc17b6534eb839 Christoph Hellwig    2017-06-03  888     return BLK_STS_OK;
8093f7ca73c163 Ming Lin             2016-04-12  889  }
8093f7ca73c163 Ming Lin             2016-04-12  890  

:::::: The code at line 872 was first introduced by commit
:::::: cb5b7262b011cfb793519bf97e54dff5282da23c nvme: provide fallback for 
discard alloc failure

:::::: TO: Jens Axboe <[email protected]>
:::::: CC: Christoph Hellwig <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to