All of lore.kernel.org
 help / color / mirror / Atom feed
* [mchinth: sep_socwatch_linux_5_9 19/41] drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-06-03  3:44 kernel test robot
  2021-06-03  3:44 ` [RFC PATCH mchinth] platform/x86: sw_copy_driver_interface_info_i can be static kernel test robot
  0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2021-06-03  3:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 30419 bytes --]

Hi Faycal,

First bad commit (maybe != root cause):

tree:   https://github.com/mchinth/linux  sep_socwatch_linux_5_9
head:   7296486889985b9d9895a39f551764a4b0425bea
commit: e65547c5a9bb37e907edecece4da7cb12dadea96 [19/41] platform/x86: Use $(srctree) instead of $(src) to adapt to kbuild regression
config: i386-randconfig-s001-20210603 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/mchinth/linux/commit/e65547c5a9bb37e907edecece4da7cb12dadea96
        git remote add mchinth https://github.com/mchinth/linux
        git fetch --no-tags mchinth  sep_socwatch_linux_5_9
        git checkout e65547c5a9bb37e907edecece4da7cb12dadea96
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   drivers/platform/x86/sepdk/sep/linuxos.c: note: in included file (through drivers/platform/x86/sepdk/inc/apic.h):
   /usr/lib/gcc/x86_64-linux-gnu/9/include/stddef.h:406:9: sparse: sparse: preprocessor token offsetof redefined
   drivers/platform/x86/sepdk/sep/linuxos.c: note: in included file (through include/uapi/linux/posix_types.h, include/uapi/linux/types.h, include/linux/types.h, ...):
   include/linux/stddef.h:17:9: sparse: this was the original definition
>> drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct path const * @@     got struct path [noderef] __rcu * @@
   drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse:     expected struct path const *
   drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse:     got struct path [noderef] __rcu *
>> drivers/platform/x86/sepdk/sep/linuxos.c:430:36: sparse: sparse: cast removes address space '__user' of expression
   drivers/platform/x86/sepdk/sep/linuxos.c:503:44: sparse: sparse: cast removes address space '__user' of expression
   drivers/platform/x86/sepdk/sep/linuxos.c:447:33: sparse: sparse: dereference of noderef expression
   drivers/platform/x86/sepdk/sep/linuxos.c:889:48: sparse: sparse: dereference of noderef expression
--
>> drivers/platform/x86/socwatch/sw_mem.c:141:18: sparse: sparse: cast to restricted gfp_t
   drivers/platform/x86/socwatch/sw_mem.c:305:38: sparse: sparse: cast to restricted gfp_t
--
>> drivers/platform/x86/socwatch/sw_hardware_io.c:149:55: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_hardware_io.c:149:55: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_hardware_io.c:149:55: sparse:     got restricted gfp_t
--
>> drivers/platform/x86/socwatch/sw_internal.c:176:50: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_internal.c:176:50: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_internal.c:176:50: sparse:     got restricted gfp_t
--
>> drivers/platform/x86/socwatch/sw_collector.c:99:68: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_collector.c:99:68: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_collector.c:99:68: sparse:     got restricted gfp_t
>> drivers/platform/x86/socwatch/sw_collector.c:85:33: sparse: sparse: symbol 'sw_copy_driver_interface_info_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:116:5: sparse: sparse: symbol 'sw_init_driver_interface_info_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:138:5: sparse: sparse: symbol 'sw_init_ops_i' was not declared. Should it be static?
   drivers/platform/x86/socwatch/sw_collector.c:186:57: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_collector.c:186:57: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_collector.c:186:57: sparse:     got restricted gfp_t
   drivers/platform/x86/socwatch/sw_collector.c:214:57: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_collector.c:214:57: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_collector.c:214:57: sparse:     got restricted gfp_t
>> drivers/platform/x86/socwatch/sw_collector.c:211:24: sparse: sparse: symbol 'sw_alloc_ops_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:323:6: sparse: sparse: symbol 'sw_free_driver_interface_info_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:329:6: sparse: sparse: symbol 'sw_free_ops_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:335:5: sparse: sparse: symbol 'sw_reset_driver_interface_info_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:453:6: sparse: sparse: symbol 'sw_free_collector_msg_i' was not declared. Should it be static?
>> drivers/platform/x86/socwatch/sw_collector.c:459:6: sparse: sparse: symbol 'sw_handle_per_cpu_msg_i' was not declared. Should it be static?
   drivers/platform/x86/socwatch/sw_collector.c:516:51: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_collector.c:516:51: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_collector.c:516:51: sparse:     got restricted gfp_t
--
>> drivers/platform/x86/socwatch/sw_tracepoint_handlers.c:237:44: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_tracepoint_handlers.c:237:44: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_tracepoint_handlers.c:237:44: sparse:     got restricted gfp_t
--
>> drivers/platform/x86/socwatch/sw_driver.c:1309:52: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got char *[assigned] out_arg @@
   drivers/platform/x86/socwatch/sw_driver.c:1309:52: sparse:     expected void [noderef] __user *to
   drivers/platform/x86/socwatch/sw_driver.c:1309:52: sparse:     got char *[assigned] out_arg
>> drivers/platform/x86/socwatch/sw_driver.c:1053:58: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void [noderef] __user *buffer @@     got char *remote_buffer @@
   drivers/platform/x86/socwatch/sw_driver.c:1053:58: sparse:     expected void [noderef] __user *buffer
   drivers/platform/x86/socwatch/sw_driver.c:1053:58: sparse:     got char *remote_buffer
>> drivers/platform/x86/socwatch/sw_driver.c:1070:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void const [noderef] __user *from @@     got char *remote_cfg @@
   drivers/platform/x86/socwatch/sw_driver.c:1070:39: sparse:     expected void const [noderef] __user *from
   drivers/platform/x86/socwatch/sw_driver.c:1070:39: sparse:     got char *remote_cfg
--
>> drivers/platform/x86/socwatch/sw_output_buffer.c:344:22: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got void *dest @@
   drivers/platform/x86/socwatch/sw_output_buffer.c:344:22: sparse:     expected void [noderef] __user *to
   drivers/platform/x86/socwatch/sw_output_buffer.c:344:22: sparse:     got void *dest
>> drivers/platform/x86/socwatch/sw_output_buffer.c:352:43: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got void * @@
   drivers/platform/x86/socwatch/sw_output_buffer.c:352:43: sparse:     expected void [noderef] __user *to
   drivers/platform/x86/socwatch/sw_output_buffer.c:352:43: sparse:     got void *
>> drivers/platform/x86/socwatch/sw_output_buffer.c:378:46: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_output_buffer.c:378:46: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_output_buffer.c:378:46: sparse:     got restricted gfp_t
   drivers/platform/x86/socwatch/sw_output_buffer.c:562:46: sparse: sparse: incorrect type in argument 2 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_output_buffer.c:562:46: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_output_buffer.c:562:46: sparse:     got restricted gfp_t
   drivers/platform/x86/socwatch/sw_output_buffer.c:575:67: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned int flags @@     got restricted gfp_t @@
   drivers/platform/x86/socwatch/sw_output_buffer.c:575:67: sparse:     expected unsigned int flags
   drivers/platform/x86/socwatch/sw_output_buffer.c:575:67: sparse:     got restricted gfp_t
>> drivers/platform/x86/socwatch/sw_output_buffer.c:774:48: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *dest @@     got void [noderef] __user *buffer @@
   drivers/platform/x86/socwatch/sw_output_buffer.c:774:48: sparse:     expected void *dest
   drivers/platform/x86/socwatch/sw_output_buffer.c:774:48: sparse:     got void [noderef] __user *buffer

Please review and possibly fold the followup patch.

vim +244 drivers/platform/x86/sepdk/sep/linuxos.c

d605aabab41663 Jon Moeller          2018-11-13  215  
d605aabab41663 Jon Moeller          2018-11-13  216  #ifdef DRV_MM_EXE_FILE_PRESENT
d605aabab41663 Jon Moeller          2018-11-13  217  static DRV_BOOL linuxos_Equal_VM_Exe_File(struct vm_area_struct *vma)
d605aabab41663 Jon Moeller          2018-11-13  218  {
d605aabab41663 Jon Moeller          2018-11-13  219  	S8 name_vm_file[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  220  	S8 name_exe_file[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  221  	S8 *pname_vm_file = NULL;
d605aabab41663 Jon Moeller          2018-11-13  222  	S8 *pname_exe_file = NULL;
d605aabab41663 Jon Moeller          2018-11-13  223  	DRV_BOOL res;
d605aabab41663 Jon Moeller          2018-11-13  224  
d605aabab41663 Jon Moeller          2018-11-13  225  	SEP_DRV_LOG_TRACE_IN("FMA: %p.", vma);
d605aabab41663 Jon Moeller          2018-11-13  226  
d605aabab41663 Jon Moeller          2018-11-13  227  	if (vma == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  228  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma).");
d605aabab41663 Jon Moeller          2018-11-13  229  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  230  	}
d605aabab41663 Jon Moeller          2018-11-13  231  
d605aabab41663 Jon Moeller          2018-11-13  232  	if (vma->vm_file == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  233  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma->vm_file).");
d605aabab41663 Jon Moeller          2018-11-13  234  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  235  	}
d605aabab41663 Jon Moeller          2018-11-13  236  
d605aabab41663 Jon Moeller          2018-11-13  237  	if (vma->vm_mm->exe_file == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  238  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma->vm_mm->exe_file).");
d605aabab41663 Jon Moeller          2018-11-13  239  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  240  	}
d605aabab41663 Jon Moeller          2018-11-13  241  
d605aabab41663 Jon Moeller          2018-11-13  242  	pname_vm_file = D_PATH(vma->vm_file,
d605aabab41663 Jon Moeller          2018-11-13  243  			name_vm_file, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13 @244  	pname_exe_file = D_PATH(vma->vm_mm->exe_file,
d605aabab41663 Jon Moeller          2018-11-13  245  			name_exe_file, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13  246  	res = strcmp(pname_vm_file, pname_exe_file) == 0;
d605aabab41663 Jon Moeller          2018-11-13  247  
d605aabab41663 Jon Moeller          2018-11-13  248  	SEP_DRV_LOG_TRACE_OUT("Res: %u.", res);
d605aabab41663 Jon Moeller          2018-11-13  249  	return res;
d605aabab41663 Jon Moeller          2018-11-13  250  }
d605aabab41663 Jon Moeller          2018-11-13  251  #endif
d605aabab41663 Jon Moeller          2018-11-13  252  
d605aabab41663 Jon Moeller          2018-11-13  253  /* ------------------------------------------------------------------------- */
d605aabab41663 Jon Moeller          2018-11-13  254  /*!
d605aabab41663 Jon Moeller          2018-11-13  255   * @fn          linuxos_Map_Kernel_Modules (void)
d605aabab41663 Jon Moeller          2018-11-13  256   *
d605aabab41663 Jon Moeller          2018-11-13  257   * @brief       Obtain kernel module details from modules list
d605aabab41663 Jon Moeller          2018-11-13  258   *              and map the details to the module record.
d605aabab41663 Jon Moeller          2018-11-13  259   *
d605aabab41663 Jon Moeller          2018-11-13  260   * @return      S32       VT_SUCCESS on success
d605aabab41663 Jon Moeller          2018-11-13  261   */
d605aabab41663 Jon Moeller          2018-11-13  262  static S32 linuxos_Map_Kernel_Modules(void)
d605aabab41663 Jon Moeller          2018-11-13  263  {
1f57010172d61a Manisha Chinthapally 2018-11-13  264  #if defined(CONFIG_MODULES)
d605aabab41663 Jon Moeller          2018-11-13  265  	struct module *current_module;
d605aabab41663 Jon Moeller          2018-11-13  266  	struct list_head *modules;
d605aabab41663 Jon Moeller          2018-11-13  267  	U16 exec_mode;
d605aabab41663 Jon Moeller          2018-11-13  268  	unsigned long long addr;
d605aabab41663 Jon Moeller          2018-11-13  269  	unsigned long long size;
d605aabab41663 Jon Moeller          2018-11-13  270  #if defined(CONFIG_RANDOMIZE_BASE)
d605aabab41663 Jon Moeller          2018-11-13  271  	unsigned long dyn_addr = 0;
d605aabab41663 Jon Moeller          2018-11-13  272  #endif
d605aabab41663 Jon Moeller          2018-11-13  273  
d605aabab41663 Jon Moeller          2018-11-13  274  	SEP_DRV_LOG_TRACE_IN("");
d605aabab41663 Jon Moeller          2018-11-13  275  
1f57010172d61a Manisha Chinthapally 2018-11-13  276  
d605aabab41663 Jon Moeller          2018-11-13  277  	mutex_lock(&module_mutex);
d605aabab41663 Jon Moeller          2018-11-13  278  
d605aabab41663 Jon Moeller          2018-11-13  279  #if defined(DRV_EM64T)
d605aabab41663 Jon Moeller          2018-11-13  280  	addr = (unsigned long)__START_KERNEL_map;
d605aabab41663 Jon Moeller          2018-11-13  281  	exec_mode = MODE_64BIT;
d605aabab41663 Jon Moeller          2018-11-13  282  #elif defined(DRV_IA32)
d605aabab41663 Jon Moeller          2018-11-13  283  	addr = (unsigned long)PAGE_OFFSET;
d605aabab41663 Jon Moeller          2018-11-13  284  	exec_mode = MODE_32BIT;
d605aabab41663 Jon Moeller          2018-11-13  285  #else
d605aabab41663 Jon Moeller          2018-11-13  286  	exec_mode = MODE_UNKNOWN;
d605aabab41663 Jon Moeller          2018-11-13  287  #endif
d605aabab41663 Jon Moeller          2018-11-13  288  
d605aabab41663 Jon Moeller          2018-11-13  289  	SEP_DRV_LOG_TRACE(
d605aabab41663 Jon Moeller          2018-11-13  290  		"     kernel module            address           size");
d605aabab41663 Jon Moeller          2018-11-13  291  	SEP_DRV_LOG_TRACE(
d605aabab41663 Jon Moeller          2018-11-13  292  		"  -------------------    ------------------    -------");
d605aabab41663 Jon Moeller          2018-11-13  293  
d605aabab41663 Jon Moeller          2018-11-13  294  	addr += (CONFIG_PHYSICAL_START + (CONFIG_PHYSICAL_ALIGN - 1)) &
d605aabab41663 Jon Moeller          2018-11-13  295  		~(CONFIG_PHYSICAL_ALIGN - 1);
d605aabab41663 Jon Moeller          2018-11-13  296  	size = (unsigned long)KERNEL_IMAGE_SIZE -
d605aabab41663 Jon Moeller          2018-11-13  297  	       ((CONFIG_PHYSICAL_START + (CONFIG_PHYSICAL_ALIGN - 1)) &
d605aabab41663 Jon Moeller          2018-11-13  298  		~(CONFIG_PHYSICAL_ALIGN - 1)) -
d605aabab41663 Jon Moeller          2018-11-13  299  	       1;
d605aabab41663 Jon Moeller          2018-11-13  300  
d605aabab41663 Jon Moeller          2018-11-13  301  #if defined(CONFIG_RANDOMIZE_BASE)
d605aabab41663 Jon Moeller          2018-11-13  302  	if (!dyn_addr) {
d605aabab41663 Jon Moeller          2018-11-13  303  		dyn_addr = (unsigned long)UTILITY_Find_Symbol("_text");
d605aabab41663 Jon Moeller          2018-11-13  304  		if (!dyn_addr) {
d605aabab41663 Jon Moeller          2018-11-13  305  			dyn_addr = (unsigned long)UTILITY_Find_Symbol("_stext");
d605aabab41663 Jon Moeller          2018-11-13  306  		}
d605aabab41663 Jon Moeller          2018-11-13  307  
d605aabab41663 Jon Moeller          2018-11-13  308  		if (dyn_addr && dyn_addr > addr) {
d605aabab41663 Jon Moeller          2018-11-13  309  			dyn_addr &= ~(PAGE_SIZE - 1);
d605aabab41663 Jon Moeller          2018-11-13  310  			size -= (dyn_addr - addr);
d605aabab41663 Jon Moeller          2018-11-13  311  			addr = dyn_addr;
d605aabab41663 Jon Moeller          2018-11-13  312  		} else {
d605aabab41663 Jon Moeller          2018-11-13  313  			SEP_DRV_LOG_WARNING_TRACE_OUT(
d605aabab41663 Jon Moeller          2018-11-13  314  				"Could not find the kernel start address!");
d605aabab41663 Jon Moeller          2018-11-13  315  		}
d605aabab41663 Jon Moeller          2018-11-13  316  	}
d605aabab41663 Jon Moeller          2018-11-13  317  #endif
d605aabab41663 Jon Moeller          2018-11-13  318  
d605aabab41663 Jon Moeller          2018-11-13  319  	linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  320  		"vmlinux", addr, size, 0, 0, 0,
d605aabab41663 Jon Moeller          2018-11-13  321  		LOPTS_1ST_MODREC | LOPTS_GLOBAL_MODULE | LOPTS_EXE, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  322  		-1, MR_SEG_NUM, 1, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  323  
d605aabab41663 Jon Moeller          2018-11-13  324  	SEP_DRV_LOG_TRACE("kmodule: %20s    0x%llx    0x%llx.", "vmlinux", addr,
d605aabab41663 Jon Moeller          2018-11-13  325  			  size);
d605aabab41663 Jon Moeller          2018-11-13  326  
d605aabab41663 Jon Moeller          2018-11-13  327  #if defined(DRV_SEP_ACRN_ON)
d605aabab41663 Jon Moeller          2018-11-13  328  	linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  329  		"VMM", 0x0, (U32)0xffffffffffffffffLL, 0, 0, 0,
d605aabab41663 Jon Moeller          2018-11-13  330  		LOPTS_1ST_MODREC | LOPTS_GLOBAL_MODULE | LOPTS_EXE, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  331  		-1, MR_SEG_NUM, 1, OS_ID_ACORN);
d605aabab41663 Jon Moeller          2018-11-13  332  #endif
d605aabab41663 Jon Moeller          2018-11-13  333  
d605aabab41663 Jon Moeller          2018-11-13  334  	for (modules = (struct list_head *)(THIS_MODULE->list.prev);
d605aabab41663 Jon Moeller          2018-11-13  335  	     (unsigned long)modules > MODULES_VADDR; modules = modules->prev)
d605aabab41663 Jon Moeller          2018-11-13  336  		;
d605aabab41663 Jon Moeller          2018-11-13  337  	list_for_each_entry (current_module, modules, list) {
d605aabab41663 Jon Moeller          2018-11-13  338  		char *name = current_module->name;
d605aabab41663 Jon Moeller          2018-11-13  339  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ||                           \
d605aabab41663 Jon Moeller          2018-11-13  340  	defined(SEP_CONFIG_MODULE_LAYOUT)
d605aabab41663 Jon Moeller          2018-11-13  341  		addr = (unsigned long)current_module->core_layout.base;
d605aabab41663 Jon Moeller          2018-11-13  342  		size = current_module->core_layout.size;
d605aabab41663 Jon Moeller          2018-11-13  343  #else
d605aabab41663 Jon Moeller          2018-11-13  344  		addr = (unsigned long)current_module->module_core;
d605aabab41663 Jon Moeller          2018-11-13  345  		size = current_module->core_size;
d605aabab41663 Jon Moeller          2018-11-13  346  #endif
d605aabab41663 Jon Moeller          2018-11-13  347  
d605aabab41663 Jon Moeller          2018-11-13  348  		if (module_is_live(current_module)) {
d605aabab41663 Jon Moeller          2018-11-13  349  			SEP_DRV_LOG_TRACE("kmodule: %20s    0x%llx    0x%llx.",
d605aabab41663 Jon Moeller          2018-11-13  350  					  name, addr, size);
d605aabab41663 Jon Moeller          2018-11-13  351  			linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  352  				name, addr, size, 0, 0, 0, LOPTS_GLOBAL_MODULE,
d605aabab41663 Jon Moeller          2018-11-13  353  				exec_mode, -1, 0, 1, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  354  		}
d605aabab41663 Jon Moeller          2018-11-13  355  	}
d605aabab41663 Jon Moeller          2018-11-13  356  
d605aabab41663 Jon Moeller          2018-11-13  357  	mutex_unlock(&module_mutex);
d605aabab41663 Jon Moeller          2018-11-13  358  #endif
d605aabab41663 Jon Moeller          2018-11-13  359  	SEP_DRV_LOG_TRACE_OUT("OS_SUCCESS");
d605aabab41663 Jon Moeller          2018-11-13  360  	return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  361  }
d605aabab41663 Jon Moeller          2018-11-13  362  
d605aabab41663 Jon Moeller          2018-11-13  363  //
d605aabab41663 Jon Moeller          2018-11-13  364  // Register the module for a process.  The task_struct and mm
d605aabab41663 Jon Moeller          2018-11-13  365  // should be locked if necessary to make sure they don't change while we're
d605aabab41663 Jon Moeller          2018-11-13  366  // iterating...
d605aabab41663 Jon Moeller          2018-11-13  367  // Used as a service routine
d605aabab41663 Jon Moeller          2018-11-13  368  //
d605aabab41663 Jon Moeller          2018-11-13  369  static S32 linuxos_VMA_For_Process(struct task_struct *p,
d605aabab41663 Jon Moeller          2018-11-13  370  				   struct vm_area_struct *vma, S32 load_event,
d605aabab41663 Jon Moeller          2018-11-13  371  				   U32 *first)
d605aabab41663 Jon Moeller          2018-11-13  372  {
d605aabab41663 Jon Moeller          2018-11-13  373  	U32 options = 0;
d605aabab41663 Jon Moeller          2018-11-13  374  	S8 name[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  375  	S8 *pname = NULL;
d605aabab41663 Jon Moeller          2018-11-13  376  	U32 ppid = 0;
d605aabab41663 Jon Moeller          2018-11-13  377  	U16 exec_mode;
d605aabab41663 Jon Moeller          2018-11-13  378  	U64 page_offset = 0;
d605aabab41663 Jon Moeller          2018-11-13  379  
d605aabab41663 Jon Moeller          2018-11-13  380  #if defined(DRV_ANDROID)
d605aabab41663 Jon Moeller          2018-11-13  381  	char andr_app[TASK_COMM_LEN];
d605aabab41663 Jon Moeller          2018-11-13  382  #endif
d605aabab41663 Jon Moeller          2018-11-13  383  
d605aabab41663 Jon Moeller          2018-11-13  384  	SEP_DRV_LOG_NOTIFICATION_TRACE_IN(
d605aabab41663 Jon Moeller          2018-11-13  385  		load_event == 1, "P = %p, vma = %p, load_event: %d, first: %p.",
d605aabab41663 Jon Moeller          2018-11-13  386  		p, vma, load_event, first);
d605aabab41663 Jon Moeller          2018-11-13  387  
d605aabab41663 Jon Moeller          2018-11-13  388  	if (p == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  389  		SEP_DRV_LOG_NOTIFICATION_ERROR(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  390  					       "Skipped p=NULL.");
d605aabab41663 Jon Moeller          2018-11-13  391  		SEP_DRV_LOG_NOTIFICATION_TRACE_OUT(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  392  						   "OS_SUCCESS (!p).");
d605aabab41663 Jon Moeller          2018-11-13  393  		return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  394  	}
d605aabab41663 Jon Moeller          2018-11-13  395  
d605aabab41663 Jon Moeller          2018-11-13  396  	if (vma->vm_file)
d605aabab41663 Jon Moeller          2018-11-13  397  		pname = D_PATH(vma->vm_file, name, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13  398  
d605aabab41663 Jon Moeller          2018-11-13  399  	page_offset = vma->vm_pgoff;
d605aabab41663 Jon Moeller          2018-11-13  400  
d605aabab41663 Jon Moeller          2018-11-13  401  	if (!IS_ERR(pname) && pname != NULL) {
d605aabab41663 Jon Moeller          2018-11-13  402  		SEP_DRV_LOG_NOTIFICATION_TRACE(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  403  					       "enum: %s, %d, %lx, %lx %llu.",
d605aabab41663 Jon Moeller          2018-11-13  404  					       pname, p->pid, vma->vm_start,
d605aabab41663 Jon Moeller          2018-11-13  405  					       (vma->vm_end - vma->vm_start),
d605aabab41663 Jon Moeller          2018-11-13  406  					       page_offset);
d605aabab41663 Jon Moeller          2018-11-13  407  
d605aabab41663 Jon Moeller          2018-11-13  408  		// if the VM_EXECUTABLE flag is set then this is the module
d605aabab41663 Jon Moeller          2018-11-13  409  		// that is being used to name the module
d605aabab41663 Jon Moeller          2018-11-13  410  		if (DRV_VM_MOD_EXECUTABLE(vma)) {
d605aabab41663 Jon Moeller          2018-11-13  411  			options |= LOPTS_EXE;
d605aabab41663 Jon Moeller          2018-11-13  412  #if defined(DRV_ANDROID)
d605aabab41663 Jon Moeller          2018-11-13  413  			if (!strcmp(pname, "/system/bin/app_process") ||
d605aabab41663 Jon Moeller          2018-11-13  414  			    !strcmp(pname, "/system/bin/app_process32") ||
d605aabab41663 Jon Moeller          2018-11-13  415  			    !strcmp(pname, "/system/bin/app_process64")) {
d605aabab41663 Jon Moeller          2018-11-13  416  				memset(andr_app, '\0', TASK_COMM_LEN);
d605aabab41663 Jon Moeller          2018-11-13  417  				strncpy(andr_app, p->comm, TASK_COMM_LEN);
d605aabab41663 Jon Moeller          2018-11-13  418  				pname = andr_app;
d605aabab41663 Jon Moeller          2018-11-13  419  			}
d605aabab41663 Jon Moeller          2018-11-13  420  #endif
d605aabab41663 Jon Moeller          2018-11-13  421  		}
d605aabab41663 Jon Moeller          2018-11-13  422  		// mark the first of the bunch...
d605aabab41663 Jon Moeller          2018-11-13  423  		if (*first == 1) {
d605aabab41663 Jon Moeller          2018-11-13  424  			options |= LOPTS_1ST_MODREC;
d605aabab41663 Jon Moeller          2018-11-13  425  			*first = 0;
d605aabab41663 Jon Moeller          2018-11-13  426  		}
d605aabab41663 Jon Moeller          2018-11-13  427  	}
d605aabab41663 Jon Moeller          2018-11-13  428  #if defined(DRV_ALLOW_VDSO)
d605aabab41663 Jon Moeller          2018-11-13  429  	else if ((vma->vm_mm  != NULL) &&
d605aabab41663 Jon Moeller          2018-11-13 @430  		 vma->vm_start == (long)vma->vm_mm->context.vdso) {
d605aabab41663 Jon Moeller          2018-11-13  431  		pname = "[vdso]";
d605aabab41663 Jon Moeller          2018-11-13  432  	}
d605aabab41663 Jon Moeller          2018-11-13  433  #endif
d605aabab41663 Jon Moeller          2018-11-13  434  #if defined(DRV_ALLOW_SYSCALL)
d605aabab41663 Jon Moeller          2018-11-13  435  	else if (vma->vm_start == VSYSCALL_START) {
d605aabab41663 Jon Moeller          2018-11-13  436  		pname = "[vsyscall]";
d605aabab41663 Jon Moeller          2018-11-13  437  	}
d605aabab41663 Jon Moeller          2018-11-13  438  #endif
d605aabab41663 Jon Moeller          2018-11-13  439  
d605aabab41663 Jon Moeller          2018-11-13  440  	if (pname != NULL) {
d605aabab41663 Jon Moeller          2018-11-13  441  		options = 0;
d605aabab41663 Jon Moeller          2018-11-13  442  		if (DRV_VM_MOD_EXECUTABLE(vma)) {
d605aabab41663 Jon Moeller          2018-11-13  443  			options |= LOPTS_EXE;
d605aabab41663 Jon Moeller          2018-11-13  444  		}
d605aabab41663 Jon Moeller          2018-11-13  445  
d605aabab41663 Jon Moeller          2018-11-13  446  		if (p && p->parent) {
d605aabab41663 Jon Moeller          2018-11-13  447  			ppid = p->parent->tgid;
d605aabab41663 Jon Moeller          2018-11-13  448  		}
d605aabab41663 Jon Moeller          2018-11-13  449  		exec_mode = linuxos_Get_Exec_Mode(p);
d605aabab41663 Jon Moeller          2018-11-13  450  		// record this module
d605aabab41663 Jon Moeller          2018-11-13  451  		linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  452  			pname, vma->vm_start, (vma->vm_end - vma->vm_start),
d605aabab41663 Jon Moeller          2018-11-13  453  			page_offset, p->pid, ppid, options, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  454  			load_event, 1, 0, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  455  	}
d605aabab41663 Jon Moeller          2018-11-13  456  
d605aabab41663 Jon Moeller          2018-11-13  457  	SEP_DRV_LOG_NOTIFICATION_TRACE_OUT(load_event == 1, "OS_SUCCESS.");
d605aabab41663 Jon Moeller          2018-11-13  458  	return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  459  }
d605aabab41663 Jon Moeller          2018-11-13  460  

:::::: The code at line 244 was first introduced by commit
:::::: d605aabab41663c9be9e8c549042933189adbf2f platform/x86: add sep and socwatch drivers without socperf.

:::::: TO: Jon Moeller <jon.moeller@intel.com>
:::::: CC: Faycal Benmlih <faycal.benmlih@intel.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 49280 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC PATCH mchinth] platform/x86: sw_copy_driver_interface_info_i can be static
  2021-06-03  3:44 [mchinth: sep_socwatch_linux_5_9 19/41] drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
@ 2021-06-03  3:44 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-06-03  3:44 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4156 bytes --]

drivers/platform/x86/socwatch/sw_collector.c:85:33: warning: symbol 'sw_copy_driver_interface_info_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:116:5: warning: symbol 'sw_init_driver_interface_info_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:138:5: warning: symbol 'sw_init_ops_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:211:24: warning: symbol 'sw_alloc_ops_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:323:6: warning: symbol 'sw_free_driver_interface_info_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:329:6: warning: symbol 'sw_free_ops_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:335:5: warning: symbol 'sw_reset_driver_interface_info_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:453:6: warning: symbol 'sw_free_collector_msg_i' was not declared. Should it be static?
drivers/platform/x86/socwatch/sw_collector.c:459:6: warning: symbol 'sw_handle_per_cpu_msg_i' was not declared. Should it be static?

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: kernel test robot <lkp@intel.com>
---
 sw_collector.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/platform/x86/socwatch/sw_collector.c b/drivers/platform/x86/socwatch/sw_collector.c
index 652d5af6113ba..212cf2b4e9645 100644
--- a/drivers/platform/x86/socwatch/sw_collector.c
+++ b/drivers/platform/x86/socwatch/sw_collector.c
@@ -82,7 +82,7 @@ const static struct sw_hw_ops *s_hw_ops;
  * Returns: a pointer to the newly allocated sw_driver_interface_info,
  *          which is a copy of the version passed in via the info pointer.
  */
-struct sw_driver_interface_info *
+static struct sw_driver_interface_info *
 sw_copy_driver_interface_info_i(const struct sw_driver_interface_info *info)
 {
 	size_t size;
@@ -113,7 +113,7 @@ sw_copy_driver_interface_info_i(const struct sw_driver_interface_info *info)
 	return node;
 }
 
-int sw_init_driver_interface_info_i(struct sw_driver_interface_info *info)
+static int sw_init_driver_interface_info_i(struct sw_driver_interface_info *info)
 {
 	/*
 	 * Do any initialization here.
@@ -135,7 +135,7 @@ int sw_init_driver_interface_info_i(struct sw_driver_interface_info *info)
 	return PW_SUCCESS;
 }
 
-int sw_init_ops_i(const struct sw_hw_ops **ops,
+static int sw_init_ops_i(const struct sw_hw_ops **ops,
 		const struct sw_driver_interface_info *info)
 {
 	int i = 0;
@@ -208,7 +208,7 @@ sw_alloc_collector_msg_i(const struct sw_driver_interface_info *info,
 	return msg;
 }
 
-const struct sw_hw_ops **sw_alloc_ops_i(pw_u16_t num_io_descriptors)
+static const struct sw_hw_ops **sw_alloc_ops_i(pw_u16_t num_io_descriptors)
 {
 	size_t size = num_io_descriptors * sizeof(struct sw_hw_ops *);
 	const struct sw_hw_ops **ops = sw_kmalloc(size, GFP_KERNEL);
@@ -320,19 +320,19 @@ int sw_add_driver_info(void *list_head,
 	return PW_SUCCESS;
 }
 
-void sw_free_driver_interface_info_i(struct sw_driver_interface_info *info)
+static void sw_free_driver_interface_info_i(struct sw_driver_interface_info *info)
 {
 	if (info)
 		sw_kfree(info);
 }
 
-void sw_free_ops_i(const struct sw_hw_ops **ops)
+static void sw_free_ops_i(const struct sw_hw_ops **ops)
 {
 	if (ops)
 		sw_kfree(ops);
 }
 
-int sw_reset_driver_interface_info_i(struct sw_driver_interface_info *info)
+static int sw_reset_driver_interface_info_i(struct sw_driver_interface_info *info)
 {
 	/*
 	 * Do any finalization here.
@@ -450,13 +450,13 @@ int sw_handle_driver_io_descriptor(
 	return PW_SUCCESS;
 }
 
-void sw_free_collector_msg_i(sw_driver_msg_t *msg)
+static void sw_free_collector_msg_i(sw_driver_msg_t *msg)
 {
 	if (msg)
 		sw_kfree(msg);
 }
 
-void sw_handle_per_cpu_msg_i(void *info, enum sw_wakeup_action action)
+static void sw_handle_per_cpu_msg_i(void *info, enum sw_wakeup_action action)
 {
 	/*
 	 * Basic algo:

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [mchinth: sep_socwatch_linux_5_9 19/41] drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-07-31  6:05 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-07-31  6:05 UTC (permalink / raw)
  To: Faycal Benmlih; +Cc: kbuild-all, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 22315 bytes --]

Hi Faycal,

First bad commit (maybe != root cause):

tree:   https://github.com/mchinth/linux  sep_socwatch_linux_5_9
head:   7296486889985b9d9895a39f551764a4b0425bea
commit: e65547c5a9bb37e907edecece4da7cb12dadea96 [19/41] platform/x86: Use $(srctree) instead of $(src) to adapt to kbuild regression
config: i386-randconfig-s032-20210730 (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/mchinth/linux/commit/e65547c5a9bb37e907edecece4da7cb12dadea96
        git remote add mchinth https://github.com/mchinth/linux
        git fetch --no-tags mchinth  sep_socwatch_linux_5_9
        git checkout e65547c5a9bb37e907edecece4da7cb12dadea96
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   drivers/platform/x86/sepdk/sep/linuxos.c: note: in included file (through drivers/platform/x86/sepdk/inc/apic.h):
   /usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h:406:9: sparse: sparse: preprocessor token offsetof redefined
   drivers/platform/x86/sepdk/sep/linuxos.c: note: in included file (through include/uapi/linux/posix_types.h, include/uapi/linux/types.h, include/linux/types.h, ...):
   include/linux/stddef.h:17:9: sparse: this was the original definition
>> drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct path const * @@     got struct path [noderef] __rcu * @@
   drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse:     expected struct path const *
   drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse:     got struct path [noderef] __rcu *
>> drivers/platform/x86/sepdk/sep/linuxos.c:430:36: sparse: sparse: cast removes address space '__user' of expression
   drivers/platform/x86/sepdk/sep/linuxos.c:503:44: sparse: sparse: cast removes address space '__user' of expression
   drivers/platform/x86/sepdk/sep/linuxos.c:447:33: sparse: sparse: dereference of noderef expression
   drivers/platform/x86/sepdk/sep/linuxos.c:889:48: sparse: sparse: dereference of noderef expression

vim +244 drivers/platform/x86/sepdk/sep/linuxos.c

d605aabab41663 Jon Moeller          2018-11-13  215  
d605aabab41663 Jon Moeller          2018-11-13  216  #ifdef DRV_MM_EXE_FILE_PRESENT
d605aabab41663 Jon Moeller          2018-11-13  217  static DRV_BOOL linuxos_Equal_VM_Exe_File(struct vm_area_struct *vma)
d605aabab41663 Jon Moeller          2018-11-13  218  {
d605aabab41663 Jon Moeller          2018-11-13  219  	S8 name_vm_file[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  220  	S8 name_exe_file[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  221  	S8 *pname_vm_file = NULL;
d605aabab41663 Jon Moeller          2018-11-13  222  	S8 *pname_exe_file = NULL;
d605aabab41663 Jon Moeller          2018-11-13  223  	DRV_BOOL res;
d605aabab41663 Jon Moeller          2018-11-13  224  
d605aabab41663 Jon Moeller          2018-11-13  225  	SEP_DRV_LOG_TRACE_IN("FMA: %p.", vma);
d605aabab41663 Jon Moeller          2018-11-13  226  
d605aabab41663 Jon Moeller          2018-11-13  227  	if (vma == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  228  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma).");
d605aabab41663 Jon Moeller          2018-11-13  229  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  230  	}
d605aabab41663 Jon Moeller          2018-11-13  231  
d605aabab41663 Jon Moeller          2018-11-13  232  	if (vma->vm_file == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  233  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma->vm_file).");
d605aabab41663 Jon Moeller          2018-11-13  234  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  235  	}
d605aabab41663 Jon Moeller          2018-11-13  236  
d605aabab41663 Jon Moeller          2018-11-13  237  	if (vma->vm_mm->exe_file == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  238  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma->vm_mm->exe_file).");
d605aabab41663 Jon Moeller          2018-11-13  239  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  240  	}
d605aabab41663 Jon Moeller          2018-11-13  241  
d605aabab41663 Jon Moeller          2018-11-13  242  	pname_vm_file = D_PATH(vma->vm_file,
d605aabab41663 Jon Moeller          2018-11-13  243  			name_vm_file, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13 @244  	pname_exe_file = D_PATH(vma->vm_mm->exe_file,
d605aabab41663 Jon Moeller          2018-11-13  245  			name_exe_file, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13  246  	res = strcmp(pname_vm_file, pname_exe_file) == 0;
d605aabab41663 Jon Moeller          2018-11-13  247  
d605aabab41663 Jon Moeller          2018-11-13  248  	SEP_DRV_LOG_TRACE_OUT("Res: %u.", res);
d605aabab41663 Jon Moeller          2018-11-13  249  	return res;
d605aabab41663 Jon Moeller          2018-11-13  250  }
d605aabab41663 Jon Moeller          2018-11-13  251  #endif
d605aabab41663 Jon Moeller          2018-11-13  252  
d605aabab41663 Jon Moeller          2018-11-13  253  /* ------------------------------------------------------------------------- */
d605aabab41663 Jon Moeller          2018-11-13  254  /*!
d605aabab41663 Jon Moeller          2018-11-13  255   * @fn          linuxos_Map_Kernel_Modules (void)
d605aabab41663 Jon Moeller          2018-11-13  256   *
d605aabab41663 Jon Moeller          2018-11-13  257   * @brief       Obtain kernel module details from modules list
d605aabab41663 Jon Moeller          2018-11-13  258   *              and map the details to the module record.
d605aabab41663 Jon Moeller          2018-11-13  259   *
d605aabab41663 Jon Moeller          2018-11-13  260   * @return      S32       VT_SUCCESS on success
d605aabab41663 Jon Moeller          2018-11-13  261   */
d605aabab41663 Jon Moeller          2018-11-13  262  static S32 linuxos_Map_Kernel_Modules(void)
d605aabab41663 Jon Moeller          2018-11-13  263  {
1f57010172d61a Manisha Chinthapally 2018-11-13  264  #if defined(CONFIG_MODULES)
d605aabab41663 Jon Moeller          2018-11-13  265  	struct module *current_module;
d605aabab41663 Jon Moeller          2018-11-13  266  	struct list_head *modules;
d605aabab41663 Jon Moeller          2018-11-13  267  	U16 exec_mode;
d605aabab41663 Jon Moeller          2018-11-13  268  	unsigned long long addr;
d605aabab41663 Jon Moeller          2018-11-13  269  	unsigned long long size;
d605aabab41663 Jon Moeller          2018-11-13  270  #if defined(CONFIG_RANDOMIZE_BASE)
d605aabab41663 Jon Moeller          2018-11-13  271  	unsigned long dyn_addr = 0;
d605aabab41663 Jon Moeller          2018-11-13  272  #endif
d605aabab41663 Jon Moeller          2018-11-13  273  
d605aabab41663 Jon Moeller          2018-11-13  274  	SEP_DRV_LOG_TRACE_IN("");
d605aabab41663 Jon Moeller          2018-11-13  275  
1f57010172d61a Manisha Chinthapally 2018-11-13  276  
d605aabab41663 Jon Moeller          2018-11-13  277  	mutex_lock(&module_mutex);
d605aabab41663 Jon Moeller          2018-11-13  278  
d605aabab41663 Jon Moeller          2018-11-13  279  #if defined(DRV_EM64T)
d605aabab41663 Jon Moeller          2018-11-13  280  	addr = (unsigned long)__START_KERNEL_map;
d605aabab41663 Jon Moeller          2018-11-13  281  	exec_mode = MODE_64BIT;
d605aabab41663 Jon Moeller          2018-11-13  282  #elif defined(DRV_IA32)
d605aabab41663 Jon Moeller          2018-11-13  283  	addr = (unsigned long)PAGE_OFFSET;
d605aabab41663 Jon Moeller          2018-11-13  284  	exec_mode = MODE_32BIT;
d605aabab41663 Jon Moeller          2018-11-13  285  #else
d605aabab41663 Jon Moeller          2018-11-13  286  	exec_mode = MODE_UNKNOWN;
d605aabab41663 Jon Moeller          2018-11-13  287  #endif
d605aabab41663 Jon Moeller          2018-11-13  288  
d605aabab41663 Jon Moeller          2018-11-13  289  	SEP_DRV_LOG_TRACE(
d605aabab41663 Jon Moeller          2018-11-13  290  		"     kernel module            address           size");
d605aabab41663 Jon Moeller          2018-11-13  291  	SEP_DRV_LOG_TRACE(
d605aabab41663 Jon Moeller          2018-11-13  292  		"  -------------------    ------------------    -------");
d605aabab41663 Jon Moeller          2018-11-13  293  
d605aabab41663 Jon Moeller          2018-11-13  294  	addr += (CONFIG_PHYSICAL_START + (CONFIG_PHYSICAL_ALIGN - 1)) &
d605aabab41663 Jon Moeller          2018-11-13  295  		~(CONFIG_PHYSICAL_ALIGN - 1);
d605aabab41663 Jon Moeller          2018-11-13  296  	size = (unsigned long)KERNEL_IMAGE_SIZE -
d605aabab41663 Jon Moeller          2018-11-13  297  	       ((CONFIG_PHYSICAL_START + (CONFIG_PHYSICAL_ALIGN - 1)) &
d605aabab41663 Jon Moeller          2018-11-13  298  		~(CONFIG_PHYSICAL_ALIGN - 1)) -
d605aabab41663 Jon Moeller          2018-11-13  299  	       1;
d605aabab41663 Jon Moeller          2018-11-13  300  
d605aabab41663 Jon Moeller          2018-11-13  301  #if defined(CONFIG_RANDOMIZE_BASE)
d605aabab41663 Jon Moeller          2018-11-13  302  	if (!dyn_addr) {
d605aabab41663 Jon Moeller          2018-11-13  303  		dyn_addr = (unsigned long)UTILITY_Find_Symbol("_text");
d605aabab41663 Jon Moeller          2018-11-13  304  		if (!dyn_addr) {
d605aabab41663 Jon Moeller          2018-11-13  305  			dyn_addr = (unsigned long)UTILITY_Find_Symbol("_stext");
d605aabab41663 Jon Moeller          2018-11-13  306  		}
d605aabab41663 Jon Moeller          2018-11-13  307  
d605aabab41663 Jon Moeller          2018-11-13  308  		if (dyn_addr && dyn_addr > addr) {
d605aabab41663 Jon Moeller          2018-11-13  309  			dyn_addr &= ~(PAGE_SIZE - 1);
d605aabab41663 Jon Moeller          2018-11-13  310  			size -= (dyn_addr - addr);
d605aabab41663 Jon Moeller          2018-11-13  311  			addr = dyn_addr;
d605aabab41663 Jon Moeller          2018-11-13  312  		} else {
d605aabab41663 Jon Moeller          2018-11-13  313  			SEP_DRV_LOG_WARNING_TRACE_OUT(
d605aabab41663 Jon Moeller          2018-11-13  314  				"Could not find the kernel start address!");
d605aabab41663 Jon Moeller          2018-11-13  315  		}
d605aabab41663 Jon Moeller          2018-11-13  316  	}
d605aabab41663 Jon Moeller          2018-11-13  317  #endif
d605aabab41663 Jon Moeller          2018-11-13  318  
d605aabab41663 Jon Moeller          2018-11-13  319  	linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  320  		"vmlinux", addr, size, 0, 0, 0,
d605aabab41663 Jon Moeller          2018-11-13  321  		LOPTS_1ST_MODREC | LOPTS_GLOBAL_MODULE | LOPTS_EXE, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  322  		-1, MR_SEG_NUM, 1, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  323  
d605aabab41663 Jon Moeller          2018-11-13  324  	SEP_DRV_LOG_TRACE("kmodule: %20s    0x%llx    0x%llx.", "vmlinux", addr,
d605aabab41663 Jon Moeller          2018-11-13  325  			  size);
d605aabab41663 Jon Moeller          2018-11-13  326  
d605aabab41663 Jon Moeller          2018-11-13  327  #if defined(DRV_SEP_ACRN_ON)
d605aabab41663 Jon Moeller          2018-11-13  328  	linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  329  		"VMM", 0x0, (U32)0xffffffffffffffffLL, 0, 0, 0,
d605aabab41663 Jon Moeller          2018-11-13  330  		LOPTS_1ST_MODREC | LOPTS_GLOBAL_MODULE | LOPTS_EXE, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  331  		-1, MR_SEG_NUM, 1, OS_ID_ACORN);
d605aabab41663 Jon Moeller          2018-11-13  332  #endif
d605aabab41663 Jon Moeller          2018-11-13  333  
d605aabab41663 Jon Moeller          2018-11-13  334  	for (modules = (struct list_head *)(THIS_MODULE->list.prev);
d605aabab41663 Jon Moeller          2018-11-13  335  	     (unsigned long)modules > MODULES_VADDR; modules = modules->prev)
d605aabab41663 Jon Moeller          2018-11-13  336  		;
d605aabab41663 Jon Moeller          2018-11-13  337  	list_for_each_entry (current_module, modules, list) {
d605aabab41663 Jon Moeller          2018-11-13  338  		char *name = current_module->name;
d605aabab41663 Jon Moeller          2018-11-13  339  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ||                           \
d605aabab41663 Jon Moeller          2018-11-13  340  	defined(SEP_CONFIG_MODULE_LAYOUT)
d605aabab41663 Jon Moeller          2018-11-13  341  		addr = (unsigned long)current_module->core_layout.base;
d605aabab41663 Jon Moeller          2018-11-13  342  		size = current_module->core_layout.size;
d605aabab41663 Jon Moeller          2018-11-13  343  #else
d605aabab41663 Jon Moeller          2018-11-13  344  		addr = (unsigned long)current_module->module_core;
d605aabab41663 Jon Moeller          2018-11-13  345  		size = current_module->core_size;
d605aabab41663 Jon Moeller          2018-11-13  346  #endif
d605aabab41663 Jon Moeller          2018-11-13  347  
d605aabab41663 Jon Moeller          2018-11-13  348  		if (module_is_live(current_module)) {
d605aabab41663 Jon Moeller          2018-11-13  349  			SEP_DRV_LOG_TRACE("kmodule: %20s    0x%llx    0x%llx.",
d605aabab41663 Jon Moeller          2018-11-13  350  					  name, addr, size);
d605aabab41663 Jon Moeller          2018-11-13  351  			linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  352  				name, addr, size, 0, 0, 0, LOPTS_GLOBAL_MODULE,
d605aabab41663 Jon Moeller          2018-11-13  353  				exec_mode, -1, 0, 1, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  354  		}
d605aabab41663 Jon Moeller          2018-11-13  355  	}
d605aabab41663 Jon Moeller          2018-11-13  356  
d605aabab41663 Jon Moeller          2018-11-13  357  	mutex_unlock(&module_mutex);
d605aabab41663 Jon Moeller          2018-11-13  358  #endif
d605aabab41663 Jon Moeller          2018-11-13  359  	SEP_DRV_LOG_TRACE_OUT("OS_SUCCESS");
d605aabab41663 Jon Moeller          2018-11-13  360  	return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  361  }
d605aabab41663 Jon Moeller          2018-11-13  362  
d605aabab41663 Jon Moeller          2018-11-13  363  //
d605aabab41663 Jon Moeller          2018-11-13  364  // Register the module for a process.  The task_struct and mm
d605aabab41663 Jon Moeller          2018-11-13  365  // should be locked if necessary to make sure they don't change while we're
d605aabab41663 Jon Moeller          2018-11-13  366  // iterating...
d605aabab41663 Jon Moeller          2018-11-13  367  // Used as a service routine
d605aabab41663 Jon Moeller          2018-11-13  368  //
d605aabab41663 Jon Moeller          2018-11-13  369  static S32 linuxos_VMA_For_Process(struct task_struct *p,
d605aabab41663 Jon Moeller          2018-11-13  370  				   struct vm_area_struct *vma, S32 load_event,
d605aabab41663 Jon Moeller          2018-11-13  371  				   U32 *first)
d605aabab41663 Jon Moeller          2018-11-13  372  {
d605aabab41663 Jon Moeller          2018-11-13  373  	U32 options = 0;
d605aabab41663 Jon Moeller          2018-11-13  374  	S8 name[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  375  	S8 *pname = NULL;
d605aabab41663 Jon Moeller          2018-11-13  376  	U32 ppid = 0;
d605aabab41663 Jon Moeller          2018-11-13  377  	U16 exec_mode;
d605aabab41663 Jon Moeller          2018-11-13  378  	U64 page_offset = 0;
d605aabab41663 Jon Moeller          2018-11-13  379  
d605aabab41663 Jon Moeller          2018-11-13  380  #if defined(DRV_ANDROID)
d605aabab41663 Jon Moeller          2018-11-13  381  	char andr_app[TASK_COMM_LEN];
d605aabab41663 Jon Moeller          2018-11-13  382  #endif
d605aabab41663 Jon Moeller          2018-11-13  383  
d605aabab41663 Jon Moeller          2018-11-13  384  	SEP_DRV_LOG_NOTIFICATION_TRACE_IN(
d605aabab41663 Jon Moeller          2018-11-13  385  		load_event == 1, "P = %p, vma = %p, load_event: %d, first: %p.",
d605aabab41663 Jon Moeller          2018-11-13  386  		p, vma, load_event, first);
d605aabab41663 Jon Moeller          2018-11-13  387  
d605aabab41663 Jon Moeller          2018-11-13  388  	if (p == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  389  		SEP_DRV_LOG_NOTIFICATION_ERROR(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  390  					       "Skipped p=NULL.");
d605aabab41663 Jon Moeller          2018-11-13  391  		SEP_DRV_LOG_NOTIFICATION_TRACE_OUT(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  392  						   "OS_SUCCESS (!p).");
d605aabab41663 Jon Moeller          2018-11-13  393  		return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  394  	}
d605aabab41663 Jon Moeller          2018-11-13  395  
d605aabab41663 Jon Moeller          2018-11-13  396  	if (vma->vm_file)
d605aabab41663 Jon Moeller          2018-11-13  397  		pname = D_PATH(vma->vm_file, name, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13  398  
d605aabab41663 Jon Moeller          2018-11-13  399  	page_offset = vma->vm_pgoff;
d605aabab41663 Jon Moeller          2018-11-13  400  
d605aabab41663 Jon Moeller          2018-11-13  401  	if (!IS_ERR(pname) && pname != NULL) {
d605aabab41663 Jon Moeller          2018-11-13  402  		SEP_DRV_LOG_NOTIFICATION_TRACE(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  403  					       "enum: %s, %d, %lx, %lx %llu.",
d605aabab41663 Jon Moeller          2018-11-13  404  					       pname, p->pid, vma->vm_start,
d605aabab41663 Jon Moeller          2018-11-13  405  					       (vma->vm_end - vma->vm_start),
d605aabab41663 Jon Moeller          2018-11-13  406  					       page_offset);
d605aabab41663 Jon Moeller          2018-11-13  407  
d605aabab41663 Jon Moeller          2018-11-13  408  		// if the VM_EXECUTABLE flag is set then this is the module
d605aabab41663 Jon Moeller          2018-11-13  409  		// that is being used to name the module
d605aabab41663 Jon Moeller          2018-11-13  410  		if (DRV_VM_MOD_EXECUTABLE(vma)) {
d605aabab41663 Jon Moeller          2018-11-13  411  			options |= LOPTS_EXE;
d605aabab41663 Jon Moeller          2018-11-13  412  #if defined(DRV_ANDROID)
d605aabab41663 Jon Moeller          2018-11-13  413  			if (!strcmp(pname, "/system/bin/app_process") ||
d605aabab41663 Jon Moeller          2018-11-13  414  			    !strcmp(pname, "/system/bin/app_process32") ||
d605aabab41663 Jon Moeller          2018-11-13  415  			    !strcmp(pname, "/system/bin/app_process64")) {
d605aabab41663 Jon Moeller          2018-11-13  416  				memset(andr_app, '\0', TASK_COMM_LEN);
d605aabab41663 Jon Moeller          2018-11-13  417  				strncpy(andr_app, p->comm, TASK_COMM_LEN);
d605aabab41663 Jon Moeller          2018-11-13  418  				pname = andr_app;
d605aabab41663 Jon Moeller          2018-11-13  419  			}
d605aabab41663 Jon Moeller          2018-11-13  420  #endif
d605aabab41663 Jon Moeller          2018-11-13  421  		}
d605aabab41663 Jon Moeller          2018-11-13  422  		// mark the first of the bunch...
d605aabab41663 Jon Moeller          2018-11-13  423  		if (*first == 1) {
d605aabab41663 Jon Moeller          2018-11-13  424  			options |= LOPTS_1ST_MODREC;
d605aabab41663 Jon Moeller          2018-11-13  425  			*first = 0;
d605aabab41663 Jon Moeller          2018-11-13  426  		}
d605aabab41663 Jon Moeller          2018-11-13  427  	}
d605aabab41663 Jon Moeller          2018-11-13  428  #if defined(DRV_ALLOW_VDSO)
d605aabab41663 Jon Moeller          2018-11-13  429  	else if ((vma->vm_mm  != NULL) &&
d605aabab41663 Jon Moeller          2018-11-13 @430  		 vma->vm_start == (long)vma->vm_mm->context.vdso) {
d605aabab41663 Jon Moeller          2018-11-13  431  		pname = "[vdso]";
d605aabab41663 Jon Moeller          2018-11-13  432  	}
d605aabab41663 Jon Moeller          2018-11-13  433  #endif
d605aabab41663 Jon Moeller          2018-11-13  434  #if defined(DRV_ALLOW_SYSCALL)
d605aabab41663 Jon Moeller          2018-11-13  435  	else if (vma->vm_start == VSYSCALL_START) {
d605aabab41663 Jon Moeller          2018-11-13  436  		pname = "[vsyscall]";
d605aabab41663 Jon Moeller          2018-11-13  437  	}
d605aabab41663 Jon Moeller          2018-11-13  438  #endif
d605aabab41663 Jon Moeller          2018-11-13  439  
d605aabab41663 Jon Moeller          2018-11-13  440  	if (pname != NULL) {
d605aabab41663 Jon Moeller          2018-11-13  441  		options = 0;
d605aabab41663 Jon Moeller          2018-11-13  442  		if (DRV_VM_MOD_EXECUTABLE(vma)) {
d605aabab41663 Jon Moeller          2018-11-13  443  			options |= LOPTS_EXE;
d605aabab41663 Jon Moeller          2018-11-13  444  		}
d605aabab41663 Jon Moeller          2018-11-13  445  
d605aabab41663 Jon Moeller          2018-11-13  446  		if (p && p->parent) {
d605aabab41663 Jon Moeller          2018-11-13  447  			ppid = p->parent->tgid;
d605aabab41663 Jon Moeller          2018-11-13  448  		}
d605aabab41663 Jon Moeller          2018-11-13  449  		exec_mode = linuxos_Get_Exec_Mode(p);
d605aabab41663 Jon Moeller          2018-11-13  450  		// record this module
d605aabab41663 Jon Moeller          2018-11-13  451  		linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  452  			pname, vma->vm_start, (vma->vm_end - vma->vm_start),
d605aabab41663 Jon Moeller          2018-11-13  453  			page_offset, p->pid, ppid, options, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  454  			load_event, 1, 0, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  455  	}
d605aabab41663 Jon Moeller          2018-11-13  456  
d605aabab41663 Jon Moeller          2018-11-13  457  	SEP_DRV_LOG_NOTIFICATION_TRACE_OUT(load_event == 1, "OS_SUCCESS.");
d605aabab41663 Jon Moeller          2018-11-13  458  	return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  459  }
d605aabab41663 Jon Moeller          2018-11-13  460  

:::::: The code at line 244 was first introduced by commit
:::::: d605aabab41663c9be9e8c549042933189adbf2f platform/x86: add sep and socwatch drivers without socperf.

:::::: TO: Jon Moeller <jon.moeller@intel.com>
:::::: CC: Faycal Benmlih <faycal.benmlih@intel.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 37755 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [mchinth: sep_socwatch_linux_5_9 19/41] drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-07-31  6:05 ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-07-31  6:05 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 22613 bytes --]

Hi Faycal,

First bad commit (maybe != root cause):

tree:   https://github.com/mchinth/linux  sep_socwatch_linux_5_9
head:   7296486889985b9d9895a39f551764a4b0425bea
commit: e65547c5a9bb37e907edecece4da7cb12dadea96 [19/41] platform/x86: Use $(srctree) instead of $(src) to adapt to kbuild regression
config: i386-randconfig-s032-20210730 (attached as .config)
compiler: gcc-10 (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://github.com/mchinth/linux/commit/e65547c5a9bb37e907edecece4da7cb12dadea96
        git remote add mchinth https://github.com/mchinth/linux
        git fetch --no-tags mchinth  sep_socwatch_linux_5_9
        git checkout e65547c5a9bb37e907edecece4da7cb12dadea96
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
   drivers/platform/x86/sepdk/sep/linuxos.c: note: in included file (through drivers/platform/x86/sepdk/inc/apic.h):
   /usr/lib/gcc/x86_64-linux-gnu/10/include/stddef.h:406:9: sparse: sparse: preprocessor token offsetof redefined
   drivers/platform/x86/sepdk/sep/linuxos.c: note: in included file (through include/uapi/linux/posix_types.h, include/uapi/linux/types.h, include/linux/types.h, ...):
   include/linux/stddef.h:17:9: sparse: this was the original definition
>> drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct path const * @@     got struct path [noderef] __rcu * @@
   drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse:     expected struct path const *
   drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse:     got struct path [noderef] __rcu *
>> drivers/platform/x86/sepdk/sep/linuxos.c:430:36: sparse: sparse: cast removes address space '__user' of expression
   drivers/platform/x86/sepdk/sep/linuxos.c:503:44: sparse: sparse: cast removes address space '__user' of expression
   drivers/platform/x86/sepdk/sep/linuxos.c:447:33: sparse: sparse: dereference of noderef expression
   drivers/platform/x86/sepdk/sep/linuxos.c:889:48: sparse: sparse: dereference of noderef expression

vim +244 drivers/platform/x86/sepdk/sep/linuxos.c

d605aabab41663 Jon Moeller          2018-11-13  215  
d605aabab41663 Jon Moeller          2018-11-13  216  #ifdef DRV_MM_EXE_FILE_PRESENT
d605aabab41663 Jon Moeller          2018-11-13  217  static DRV_BOOL linuxos_Equal_VM_Exe_File(struct vm_area_struct *vma)
d605aabab41663 Jon Moeller          2018-11-13  218  {
d605aabab41663 Jon Moeller          2018-11-13  219  	S8 name_vm_file[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  220  	S8 name_exe_file[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  221  	S8 *pname_vm_file = NULL;
d605aabab41663 Jon Moeller          2018-11-13  222  	S8 *pname_exe_file = NULL;
d605aabab41663 Jon Moeller          2018-11-13  223  	DRV_BOOL res;
d605aabab41663 Jon Moeller          2018-11-13  224  
d605aabab41663 Jon Moeller          2018-11-13  225  	SEP_DRV_LOG_TRACE_IN("FMA: %p.", vma);
d605aabab41663 Jon Moeller          2018-11-13  226  
d605aabab41663 Jon Moeller          2018-11-13  227  	if (vma == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  228  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma).");
d605aabab41663 Jon Moeller          2018-11-13  229  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  230  	}
d605aabab41663 Jon Moeller          2018-11-13  231  
d605aabab41663 Jon Moeller          2018-11-13  232  	if (vma->vm_file == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  233  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma->vm_file).");
d605aabab41663 Jon Moeller          2018-11-13  234  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  235  	}
d605aabab41663 Jon Moeller          2018-11-13  236  
d605aabab41663 Jon Moeller          2018-11-13  237  	if (vma->vm_mm->exe_file == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  238  		SEP_DRV_LOG_TRACE_OUT("FALSE (!vma->vm_mm->exe_file).");
d605aabab41663 Jon Moeller          2018-11-13  239  		return FALSE;
d605aabab41663 Jon Moeller          2018-11-13  240  	}
d605aabab41663 Jon Moeller          2018-11-13  241  
d605aabab41663 Jon Moeller          2018-11-13  242  	pname_vm_file = D_PATH(vma->vm_file,
d605aabab41663 Jon Moeller          2018-11-13  243  			name_vm_file, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13 @244  	pname_exe_file = D_PATH(vma->vm_mm->exe_file,
d605aabab41663 Jon Moeller          2018-11-13  245  			name_exe_file, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13  246  	res = strcmp(pname_vm_file, pname_exe_file) == 0;
d605aabab41663 Jon Moeller          2018-11-13  247  
d605aabab41663 Jon Moeller          2018-11-13  248  	SEP_DRV_LOG_TRACE_OUT("Res: %u.", res);
d605aabab41663 Jon Moeller          2018-11-13  249  	return res;
d605aabab41663 Jon Moeller          2018-11-13  250  }
d605aabab41663 Jon Moeller          2018-11-13  251  #endif
d605aabab41663 Jon Moeller          2018-11-13  252  
d605aabab41663 Jon Moeller          2018-11-13  253  /* ------------------------------------------------------------------------- */
d605aabab41663 Jon Moeller          2018-11-13  254  /*!
d605aabab41663 Jon Moeller          2018-11-13  255   * @fn          linuxos_Map_Kernel_Modules (void)
d605aabab41663 Jon Moeller          2018-11-13  256   *
d605aabab41663 Jon Moeller          2018-11-13  257   * @brief       Obtain kernel module details from modules list
d605aabab41663 Jon Moeller          2018-11-13  258   *              and map the details to the module record.
d605aabab41663 Jon Moeller          2018-11-13  259   *
d605aabab41663 Jon Moeller          2018-11-13  260   * @return      S32       VT_SUCCESS on success
d605aabab41663 Jon Moeller          2018-11-13  261   */
d605aabab41663 Jon Moeller          2018-11-13  262  static S32 linuxos_Map_Kernel_Modules(void)
d605aabab41663 Jon Moeller          2018-11-13  263  {
1f57010172d61a Manisha Chinthapally 2018-11-13  264  #if defined(CONFIG_MODULES)
d605aabab41663 Jon Moeller          2018-11-13  265  	struct module *current_module;
d605aabab41663 Jon Moeller          2018-11-13  266  	struct list_head *modules;
d605aabab41663 Jon Moeller          2018-11-13  267  	U16 exec_mode;
d605aabab41663 Jon Moeller          2018-11-13  268  	unsigned long long addr;
d605aabab41663 Jon Moeller          2018-11-13  269  	unsigned long long size;
d605aabab41663 Jon Moeller          2018-11-13  270  #if defined(CONFIG_RANDOMIZE_BASE)
d605aabab41663 Jon Moeller          2018-11-13  271  	unsigned long dyn_addr = 0;
d605aabab41663 Jon Moeller          2018-11-13  272  #endif
d605aabab41663 Jon Moeller          2018-11-13  273  
d605aabab41663 Jon Moeller          2018-11-13  274  	SEP_DRV_LOG_TRACE_IN("");
d605aabab41663 Jon Moeller          2018-11-13  275  
1f57010172d61a Manisha Chinthapally 2018-11-13  276  
d605aabab41663 Jon Moeller          2018-11-13  277  	mutex_lock(&module_mutex);
d605aabab41663 Jon Moeller          2018-11-13  278  
d605aabab41663 Jon Moeller          2018-11-13  279  #if defined(DRV_EM64T)
d605aabab41663 Jon Moeller          2018-11-13  280  	addr = (unsigned long)__START_KERNEL_map;
d605aabab41663 Jon Moeller          2018-11-13  281  	exec_mode = MODE_64BIT;
d605aabab41663 Jon Moeller          2018-11-13  282  #elif defined(DRV_IA32)
d605aabab41663 Jon Moeller          2018-11-13  283  	addr = (unsigned long)PAGE_OFFSET;
d605aabab41663 Jon Moeller          2018-11-13  284  	exec_mode = MODE_32BIT;
d605aabab41663 Jon Moeller          2018-11-13  285  #else
d605aabab41663 Jon Moeller          2018-11-13  286  	exec_mode = MODE_UNKNOWN;
d605aabab41663 Jon Moeller          2018-11-13  287  #endif
d605aabab41663 Jon Moeller          2018-11-13  288  
d605aabab41663 Jon Moeller          2018-11-13  289  	SEP_DRV_LOG_TRACE(
d605aabab41663 Jon Moeller          2018-11-13  290  		"     kernel module            address           size");
d605aabab41663 Jon Moeller          2018-11-13  291  	SEP_DRV_LOG_TRACE(
d605aabab41663 Jon Moeller          2018-11-13  292  		"  -------------------    ------------------    -------");
d605aabab41663 Jon Moeller          2018-11-13  293  
d605aabab41663 Jon Moeller          2018-11-13  294  	addr += (CONFIG_PHYSICAL_START + (CONFIG_PHYSICAL_ALIGN - 1)) &
d605aabab41663 Jon Moeller          2018-11-13  295  		~(CONFIG_PHYSICAL_ALIGN - 1);
d605aabab41663 Jon Moeller          2018-11-13  296  	size = (unsigned long)KERNEL_IMAGE_SIZE -
d605aabab41663 Jon Moeller          2018-11-13  297  	       ((CONFIG_PHYSICAL_START + (CONFIG_PHYSICAL_ALIGN - 1)) &
d605aabab41663 Jon Moeller          2018-11-13  298  		~(CONFIG_PHYSICAL_ALIGN - 1)) -
d605aabab41663 Jon Moeller          2018-11-13  299  	       1;
d605aabab41663 Jon Moeller          2018-11-13  300  
d605aabab41663 Jon Moeller          2018-11-13  301  #if defined(CONFIG_RANDOMIZE_BASE)
d605aabab41663 Jon Moeller          2018-11-13  302  	if (!dyn_addr) {
d605aabab41663 Jon Moeller          2018-11-13  303  		dyn_addr = (unsigned long)UTILITY_Find_Symbol("_text");
d605aabab41663 Jon Moeller          2018-11-13  304  		if (!dyn_addr) {
d605aabab41663 Jon Moeller          2018-11-13  305  			dyn_addr = (unsigned long)UTILITY_Find_Symbol("_stext");
d605aabab41663 Jon Moeller          2018-11-13  306  		}
d605aabab41663 Jon Moeller          2018-11-13  307  
d605aabab41663 Jon Moeller          2018-11-13  308  		if (dyn_addr && dyn_addr > addr) {
d605aabab41663 Jon Moeller          2018-11-13  309  			dyn_addr &= ~(PAGE_SIZE - 1);
d605aabab41663 Jon Moeller          2018-11-13  310  			size -= (dyn_addr - addr);
d605aabab41663 Jon Moeller          2018-11-13  311  			addr = dyn_addr;
d605aabab41663 Jon Moeller          2018-11-13  312  		} else {
d605aabab41663 Jon Moeller          2018-11-13  313  			SEP_DRV_LOG_WARNING_TRACE_OUT(
d605aabab41663 Jon Moeller          2018-11-13  314  				"Could not find the kernel start address!");
d605aabab41663 Jon Moeller          2018-11-13  315  		}
d605aabab41663 Jon Moeller          2018-11-13  316  	}
d605aabab41663 Jon Moeller          2018-11-13  317  #endif
d605aabab41663 Jon Moeller          2018-11-13  318  
d605aabab41663 Jon Moeller          2018-11-13  319  	linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  320  		"vmlinux", addr, size, 0, 0, 0,
d605aabab41663 Jon Moeller          2018-11-13  321  		LOPTS_1ST_MODREC | LOPTS_GLOBAL_MODULE | LOPTS_EXE, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  322  		-1, MR_SEG_NUM, 1, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  323  
d605aabab41663 Jon Moeller          2018-11-13  324  	SEP_DRV_LOG_TRACE("kmodule: %20s    0x%llx    0x%llx.", "vmlinux", addr,
d605aabab41663 Jon Moeller          2018-11-13  325  			  size);
d605aabab41663 Jon Moeller          2018-11-13  326  
d605aabab41663 Jon Moeller          2018-11-13  327  #if defined(DRV_SEP_ACRN_ON)
d605aabab41663 Jon Moeller          2018-11-13  328  	linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  329  		"VMM", 0x0, (U32)0xffffffffffffffffLL, 0, 0, 0,
d605aabab41663 Jon Moeller          2018-11-13  330  		LOPTS_1ST_MODREC | LOPTS_GLOBAL_MODULE | LOPTS_EXE, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  331  		-1, MR_SEG_NUM, 1, OS_ID_ACORN);
d605aabab41663 Jon Moeller          2018-11-13  332  #endif
d605aabab41663 Jon Moeller          2018-11-13  333  
d605aabab41663 Jon Moeller          2018-11-13  334  	for (modules = (struct list_head *)(THIS_MODULE->list.prev);
d605aabab41663 Jon Moeller          2018-11-13  335  	     (unsigned long)modules > MODULES_VADDR; modules = modules->prev)
d605aabab41663 Jon Moeller          2018-11-13  336  		;
d605aabab41663 Jon Moeller          2018-11-13  337  	list_for_each_entry (current_module, modules, list) {
d605aabab41663 Jon Moeller          2018-11-13  338  		char *name = current_module->name;
d605aabab41663 Jon Moeller          2018-11-13  339  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0) ||                           \
d605aabab41663 Jon Moeller          2018-11-13  340  	defined(SEP_CONFIG_MODULE_LAYOUT)
d605aabab41663 Jon Moeller          2018-11-13  341  		addr = (unsigned long)current_module->core_layout.base;
d605aabab41663 Jon Moeller          2018-11-13  342  		size = current_module->core_layout.size;
d605aabab41663 Jon Moeller          2018-11-13  343  #else
d605aabab41663 Jon Moeller          2018-11-13  344  		addr = (unsigned long)current_module->module_core;
d605aabab41663 Jon Moeller          2018-11-13  345  		size = current_module->core_size;
d605aabab41663 Jon Moeller          2018-11-13  346  #endif
d605aabab41663 Jon Moeller          2018-11-13  347  
d605aabab41663 Jon Moeller          2018-11-13  348  		if (module_is_live(current_module)) {
d605aabab41663 Jon Moeller          2018-11-13  349  			SEP_DRV_LOG_TRACE("kmodule: %20s    0x%llx    0x%llx.",
d605aabab41663 Jon Moeller          2018-11-13  350  					  name, addr, size);
d605aabab41663 Jon Moeller          2018-11-13  351  			linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  352  				name, addr, size, 0, 0, 0, LOPTS_GLOBAL_MODULE,
d605aabab41663 Jon Moeller          2018-11-13  353  				exec_mode, -1, 0, 1, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  354  		}
d605aabab41663 Jon Moeller          2018-11-13  355  	}
d605aabab41663 Jon Moeller          2018-11-13  356  
d605aabab41663 Jon Moeller          2018-11-13  357  	mutex_unlock(&module_mutex);
d605aabab41663 Jon Moeller          2018-11-13  358  #endif
d605aabab41663 Jon Moeller          2018-11-13  359  	SEP_DRV_LOG_TRACE_OUT("OS_SUCCESS");
d605aabab41663 Jon Moeller          2018-11-13  360  	return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  361  }
d605aabab41663 Jon Moeller          2018-11-13  362  
d605aabab41663 Jon Moeller          2018-11-13  363  //
d605aabab41663 Jon Moeller          2018-11-13  364  // Register the module for a process.  The task_struct and mm
d605aabab41663 Jon Moeller          2018-11-13  365  // should be locked if necessary to make sure they don't change while we're
d605aabab41663 Jon Moeller          2018-11-13  366  // iterating...
d605aabab41663 Jon Moeller          2018-11-13  367  // Used as a service routine
d605aabab41663 Jon Moeller          2018-11-13  368  //
d605aabab41663 Jon Moeller          2018-11-13  369  static S32 linuxos_VMA_For_Process(struct task_struct *p,
d605aabab41663 Jon Moeller          2018-11-13  370  				   struct vm_area_struct *vma, S32 load_event,
d605aabab41663 Jon Moeller          2018-11-13  371  				   U32 *first)
d605aabab41663 Jon Moeller          2018-11-13  372  {
d605aabab41663 Jon Moeller          2018-11-13  373  	U32 options = 0;
d605aabab41663 Jon Moeller          2018-11-13  374  	S8 name[MAXNAMELEN];
d605aabab41663 Jon Moeller          2018-11-13  375  	S8 *pname = NULL;
d605aabab41663 Jon Moeller          2018-11-13  376  	U32 ppid = 0;
d605aabab41663 Jon Moeller          2018-11-13  377  	U16 exec_mode;
d605aabab41663 Jon Moeller          2018-11-13  378  	U64 page_offset = 0;
d605aabab41663 Jon Moeller          2018-11-13  379  
d605aabab41663 Jon Moeller          2018-11-13  380  #if defined(DRV_ANDROID)
d605aabab41663 Jon Moeller          2018-11-13  381  	char andr_app[TASK_COMM_LEN];
d605aabab41663 Jon Moeller          2018-11-13  382  #endif
d605aabab41663 Jon Moeller          2018-11-13  383  
d605aabab41663 Jon Moeller          2018-11-13  384  	SEP_DRV_LOG_NOTIFICATION_TRACE_IN(
d605aabab41663 Jon Moeller          2018-11-13  385  		load_event == 1, "P = %p, vma = %p, load_event: %d, first: %p.",
d605aabab41663 Jon Moeller          2018-11-13  386  		p, vma, load_event, first);
d605aabab41663 Jon Moeller          2018-11-13  387  
d605aabab41663 Jon Moeller          2018-11-13  388  	if (p == NULL) {
d605aabab41663 Jon Moeller          2018-11-13  389  		SEP_DRV_LOG_NOTIFICATION_ERROR(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  390  					       "Skipped p=NULL.");
d605aabab41663 Jon Moeller          2018-11-13  391  		SEP_DRV_LOG_NOTIFICATION_TRACE_OUT(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  392  						   "OS_SUCCESS (!p).");
d605aabab41663 Jon Moeller          2018-11-13  393  		return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  394  	}
d605aabab41663 Jon Moeller          2018-11-13  395  
d605aabab41663 Jon Moeller          2018-11-13  396  	if (vma->vm_file)
d605aabab41663 Jon Moeller          2018-11-13  397  		pname = D_PATH(vma->vm_file, name, MAXNAMELEN);
d605aabab41663 Jon Moeller          2018-11-13  398  
d605aabab41663 Jon Moeller          2018-11-13  399  	page_offset = vma->vm_pgoff;
d605aabab41663 Jon Moeller          2018-11-13  400  
d605aabab41663 Jon Moeller          2018-11-13  401  	if (!IS_ERR(pname) && pname != NULL) {
d605aabab41663 Jon Moeller          2018-11-13  402  		SEP_DRV_LOG_NOTIFICATION_TRACE(load_event == 1,
d605aabab41663 Jon Moeller          2018-11-13  403  					       "enum: %s, %d, %lx, %lx %llu.",
d605aabab41663 Jon Moeller          2018-11-13  404  					       pname, p->pid, vma->vm_start,
d605aabab41663 Jon Moeller          2018-11-13  405  					       (vma->vm_end - vma->vm_start),
d605aabab41663 Jon Moeller          2018-11-13  406  					       page_offset);
d605aabab41663 Jon Moeller          2018-11-13  407  
d605aabab41663 Jon Moeller          2018-11-13  408  		// if the VM_EXECUTABLE flag is set then this is the module
d605aabab41663 Jon Moeller          2018-11-13  409  		// that is being used to name the module
d605aabab41663 Jon Moeller          2018-11-13  410  		if (DRV_VM_MOD_EXECUTABLE(vma)) {
d605aabab41663 Jon Moeller          2018-11-13  411  			options |= LOPTS_EXE;
d605aabab41663 Jon Moeller          2018-11-13  412  #if defined(DRV_ANDROID)
d605aabab41663 Jon Moeller          2018-11-13  413  			if (!strcmp(pname, "/system/bin/app_process") ||
d605aabab41663 Jon Moeller          2018-11-13  414  			    !strcmp(pname, "/system/bin/app_process32") ||
d605aabab41663 Jon Moeller          2018-11-13  415  			    !strcmp(pname, "/system/bin/app_process64")) {
d605aabab41663 Jon Moeller          2018-11-13  416  				memset(andr_app, '\0', TASK_COMM_LEN);
d605aabab41663 Jon Moeller          2018-11-13  417  				strncpy(andr_app, p->comm, TASK_COMM_LEN);
d605aabab41663 Jon Moeller          2018-11-13  418  				pname = andr_app;
d605aabab41663 Jon Moeller          2018-11-13  419  			}
d605aabab41663 Jon Moeller          2018-11-13  420  #endif
d605aabab41663 Jon Moeller          2018-11-13  421  		}
d605aabab41663 Jon Moeller          2018-11-13  422  		// mark the first of the bunch...
d605aabab41663 Jon Moeller          2018-11-13  423  		if (*first == 1) {
d605aabab41663 Jon Moeller          2018-11-13  424  			options |= LOPTS_1ST_MODREC;
d605aabab41663 Jon Moeller          2018-11-13  425  			*first = 0;
d605aabab41663 Jon Moeller          2018-11-13  426  		}
d605aabab41663 Jon Moeller          2018-11-13  427  	}
d605aabab41663 Jon Moeller          2018-11-13  428  #if defined(DRV_ALLOW_VDSO)
d605aabab41663 Jon Moeller          2018-11-13  429  	else if ((vma->vm_mm  != NULL) &&
d605aabab41663 Jon Moeller          2018-11-13 @430  		 vma->vm_start == (long)vma->vm_mm->context.vdso) {
d605aabab41663 Jon Moeller          2018-11-13  431  		pname = "[vdso]";
d605aabab41663 Jon Moeller          2018-11-13  432  	}
d605aabab41663 Jon Moeller          2018-11-13  433  #endif
d605aabab41663 Jon Moeller          2018-11-13  434  #if defined(DRV_ALLOW_SYSCALL)
d605aabab41663 Jon Moeller          2018-11-13  435  	else if (vma->vm_start == VSYSCALL_START) {
d605aabab41663 Jon Moeller          2018-11-13  436  		pname = "[vsyscall]";
d605aabab41663 Jon Moeller          2018-11-13  437  	}
d605aabab41663 Jon Moeller          2018-11-13  438  #endif
d605aabab41663 Jon Moeller          2018-11-13  439  
d605aabab41663 Jon Moeller          2018-11-13  440  	if (pname != NULL) {
d605aabab41663 Jon Moeller          2018-11-13  441  		options = 0;
d605aabab41663 Jon Moeller          2018-11-13  442  		if (DRV_VM_MOD_EXECUTABLE(vma)) {
d605aabab41663 Jon Moeller          2018-11-13  443  			options |= LOPTS_EXE;
d605aabab41663 Jon Moeller          2018-11-13  444  		}
d605aabab41663 Jon Moeller          2018-11-13  445  
d605aabab41663 Jon Moeller          2018-11-13  446  		if (p && p->parent) {
d605aabab41663 Jon Moeller          2018-11-13  447  			ppid = p->parent->tgid;
d605aabab41663 Jon Moeller          2018-11-13  448  		}
d605aabab41663 Jon Moeller          2018-11-13  449  		exec_mode = linuxos_Get_Exec_Mode(p);
d605aabab41663 Jon Moeller          2018-11-13  450  		// record this module
d605aabab41663 Jon Moeller          2018-11-13  451  		linuxos_Load_Image_Notify_Routine(
d605aabab41663 Jon Moeller          2018-11-13  452  			pname, vma->vm_start, (vma->vm_end - vma->vm_start),
d605aabab41663 Jon Moeller          2018-11-13  453  			page_offset, p->pid, ppid, options, exec_mode,
d605aabab41663 Jon Moeller          2018-11-13  454  			load_event, 1, 0, OS_ID_NATIVE);
d605aabab41663 Jon Moeller          2018-11-13  455  	}
d605aabab41663 Jon Moeller          2018-11-13  456  
d605aabab41663 Jon Moeller          2018-11-13  457  	SEP_DRV_LOG_NOTIFICATION_TRACE_OUT(load_event == 1, "OS_SUCCESS.");
d605aabab41663 Jon Moeller          2018-11-13  458  	return OS_SUCCESS;
d605aabab41663 Jon Moeller          2018-11-13  459  }
d605aabab41663 Jon Moeller          2018-11-13  460  

:::::: The code at line 244 was first introduced by commit
:::::: d605aabab41663c9be9e8c549042933189adbf2f platform/x86: add sep and socwatch drivers without socperf.

:::::: TO: Jon Moeller <jon.moeller@intel.com>
:::::: CC: Faycal Benmlih <faycal.benmlih@intel.com>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37755 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-31  6:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03  3:44 [mchinth: sep_socwatch_linux_5_9 19/41] drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
2021-06-03  3:44 ` [RFC PATCH mchinth] platform/x86: sw_copy_driver_interface_info_i can be static kernel test robot
2021-07-31  6:05 [mchinth: sep_socwatch_linux_5_9 19/41] drivers/platform/x86/sepdk/sep/linuxos.c:244:26: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
2021-07-31  6:05 ` kernel test robot

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.