[linux-next:master 6403/7915] arch/nios2/kernel/misaligned.c:111:42: sparse: sparse: incorrect type in argument 1 (different address spaces)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Arnd,

First bad commit (maybe != root cause):

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   d4a0ae62a277377de396850ed4b709b6bd9b7326
commit: ec7ef42b3b2cb57268afc55637d28b3aefb1df30 [6403/7915] nios2: drop access_ok() check from __put_user()
config: nios2-allmodconfig (https://download.01.org/0day-ci/archive/20220224/202202242127.1y1iPi0I-lkp@xxxxxxxxx/config)
compiler: nios2-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=ec7ef42b3b2cb57268afc55637d28b3aefb1df30
        git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
        git fetch --no-tags linux-next master
        git checkout ec7ef42b3b2cb57268afc55637d28b3aefb1df30
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=nios2 SHELL=/bin/bash arch/nios2/kernel/ fs/fat/

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


sparse warnings: (new ones prefixed by >>)
   arch/nios2/kernel/misaligned.c:98:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:98:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:98:34: sparse:     got unsigned char [usertype] *
   arch/nios2/kernel/misaligned.c:99:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:99:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:99:34: sparse:     got unsigned char [usertype] *
>> arch/nios2/kernel/misaligned.c:111:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] *__pu_ptr @@
   arch/nios2/kernel/misaligned.c:111:42: sparse:     expected void [noderef] __user *to
   arch/nios2/kernel/misaligned.c:111:42: sparse:     got unsigned char [usertype] *__pu_ptr
   arch/nios2/kernel/misaligned.c:112:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] *__pu_ptr @@
   arch/nios2/kernel/misaligned.c:112:42: sparse:     expected void [noderef] __user *to
   arch/nios2/kernel/misaligned.c:112:42: sparse:     got unsigned char [usertype] *__pu_ptr
   arch/nios2/kernel/misaligned.c:116:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:116:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:116:34: sparse:     got unsigned char [usertype] *
   arch/nios2/kernel/misaligned.c:117:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:117:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:117:34: sparse:     got unsigned char [usertype] *
   arch/nios2/kernel/misaligned.c:133:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] *__pu_ptr @@
   arch/nios2/kernel/misaligned.c:133:42: sparse:     expected void [noderef] __user *to
   arch/nios2/kernel/misaligned.c:133:42: sparse:     got unsigned char [usertype] *__pu_ptr
   arch/nios2/kernel/misaligned.c:134:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] *__pu_ptr @@
   arch/nios2/kernel/misaligned.c:134:42: sparse:     expected void [noderef] __user *to
   arch/nios2/kernel/misaligned.c:134:42: sparse:     got unsigned char [usertype] *__pu_ptr
   arch/nios2/kernel/misaligned.c:135:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] *__pu_ptr @@
   arch/nios2/kernel/misaligned.c:135:42: sparse:     expected void [noderef] __user *to
   arch/nios2/kernel/misaligned.c:135:42: sparse:     got unsigned char [usertype] *__pu_ptr
   arch/nios2/kernel/misaligned.c:136:42: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void [noderef] __user *to @@     got unsigned char [usertype] *__pu_ptr @@
   arch/nios2/kernel/misaligned.c:136:42: sparse:     expected void [noderef] __user *to
   arch/nios2/kernel/misaligned.c:136:42: sparse:     got unsigned char [usertype] *__pu_ptr
   arch/nios2/kernel/misaligned.c:140:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:140:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:140:34: sparse:     got unsigned char [usertype] *
   arch/nios2/kernel/misaligned.c:141:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:141:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:141:34: sparse:     got unsigned char [usertype] *
   arch/nios2/kernel/misaligned.c:142:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:142:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:142:34: sparse:     got unsigned char [usertype] *
   arch/nios2/kernel/misaligned.c:143:34: sparse: sparse: incorrect type in initializer (different address spaces) @@     expected unsigned char const [noderef] __user *__gu_ptr @@     got unsigned char [usertype] * @@
   arch/nios2/kernel/misaligned.c:143:34: sparse:     expected unsigned char const [noderef] __user *__gu_ptr
   arch/nios2/kernel/misaligned.c:143:34: sparse:     got unsigned char [usertype] *
--
>> fs/fat/dir.c:759:1: sparse: sparse: invalid initializer

vim +111 arch/nios2/kernel/misaligned.c

82ed08dd1b0e0e Ley Foon Tan  2014-11-06   62  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   63  /*
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   64   * (mis)alignment handler
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   65   */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   66  asmlinkage void handle_unaligned_c(struct pt_regs *fp, int cause)
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   67  {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   68  	u32 isn, addr, val;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   69  	int in_kernel;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   70  	u8 a, b, d0, d1, d2, d3;
db5a7e55468147 Bernd Weiberg 2015-09-04   71  	s16 imm16;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   72  	unsigned int fault;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   73  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   74  	/* back up one instruction */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   75  	fp->ea -= 4;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   76  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   77  	if (fixup_exception(fp)) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   78  		return;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   79  	}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   80  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   81  	in_kernel = !user_mode(fp);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   82  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   83  	isn = *(unsigned long *)(fp->ea);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   84  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   85  	fault = 0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   86  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   87  	/* do fixup if in kernel or mode turned on */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   88  	if (in_kernel || (ma_usermode & UM_FIXUP)) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   89  		/* decompose instruction */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   90  		a = (isn >> 27) & 0x1f;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   91  		b = (isn >> 22) & 0x1f;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   92  		imm16 = (isn >> 6) & 0xffff;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   93  		addr = get_reg_val(fp, a) + imm16;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   94  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   95  		/* do fixup to saved registers */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   96  		switch (isn & 0x3f) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   97  		case INST_LDHU:
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   98  			fault |= __get_user(d0, (u8 *)(addr+0));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06   99  			fault |= __get_user(d1, (u8 *)(addr+1));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  100  			val = (d1 << 8) | d0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  101  			put_reg_val(fp, b, val);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  102  			break;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  103  		case INST_STH:
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  104  			val = get_reg_val(fp, b);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  105  			d1 = val >> 8;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  106  			d0 = val >> 0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  107  			if (in_kernel) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  108  				*(u8 *)(addr+0) = d0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  109  				*(u8 *)(addr+1) = d1;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  110  			} else {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06 @111  				fault |= __put_user(d0, (u8 *)(addr+0));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  112  				fault |= __put_user(d1, (u8 *)(addr+1));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  113  			}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  114  			break;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  115  		case INST_LDH:
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  116  			fault |= __get_user(d0, (u8 *)(addr+0));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  117  			fault |= __get_user(d1, (u8 *)(addr+1));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  118  			val = (short)((d1 << 8) | d0);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  119  			put_reg_val(fp, b, val);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  120  			break;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  121  		case INST_STW:
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  122  			val = get_reg_val(fp, b);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  123  			d3 = val >> 24;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  124  			d2 = val >> 16;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  125  			d1 = val >> 8;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  126  			d0 = val >> 0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  127  			if (in_kernel) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  128  				*(u8 *)(addr+0) = d0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  129  				*(u8 *)(addr+1) = d1;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  130  				*(u8 *)(addr+2) = d2;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  131  				*(u8 *)(addr+3) = d3;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  132  			} else {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  133  				fault |= __put_user(d0, (u8 *)(addr+0));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  134  				fault |= __put_user(d1, (u8 *)(addr+1));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  135  				fault |= __put_user(d2, (u8 *)(addr+2));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  136  				fault |= __put_user(d3, (u8 *)(addr+3));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  137  			}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  138  			break;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  139  		case INST_LDW:
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  140  			fault |= __get_user(d0, (u8 *)(addr+0));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  141  			fault |= __get_user(d1, (u8 *)(addr+1));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  142  			fault |= __get_user(d2, (u8 *)(addr+2));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  143  			fault |= __get_user(d3, (u8 *)(addr+3));
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  144  			val = (d3 << 24) | (d2 << 16) | (d1 << 8) | d0;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  145  			put_reg_val(fp, b, val);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  146  			break;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  147  		}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  148  	}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  149  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  150  	addr = RDCTL(CTL_BADADDR);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  151  	cause >>= 2;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  152  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  153  	if (fault) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  154  		if (in_kernel) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  155  			pr_err("fault during kernel misaligned fixup @ %#lx; addr 0x%08x; isn=0x%08x\n",
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  156  				fp->ea, (unsigned int)addr,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  157  				(unsigned int)isn);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  158  		} else {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  159  			pr_err("fault during user misaligned fixup @ %#lx; isn=%08x addr=0x%08x sp=0x%08lx pid=%d\n",
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  160  				fp->ea,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  161  				(unsigned int)isn, addr, fp->sp,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  162  				current->pid);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  163  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  164  			_exception(SIGSEGV, fp, SEGV_MAPERR, fp->ea);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  165  			return;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  166  		}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  167  	}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  168  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  169  	/*
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  170  	 * kernel mode -
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  171  	 *  note exception and skip bad instruction (return)
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  172  	 */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  173  	if (in_kernel) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  174  		fp->ea += 4;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  175  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  176  		if (ma_usermode & KM_WARN) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  177  			pr_err("kernel unaligned access @ %#lx; BADADDR 0x%08x; cause=%d, isn=0x%08x\n",
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  178  				fp->ea,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  179  				(unsigned int)addr, cause,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  180  				(unsigned int)isn);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  181  			/* show_regs(fp); */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  182  		}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  183  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  184  		return;
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  185  	}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  186  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  187  	/*
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  188  	 * user mode -
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  189  	 *  possibly warn,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  190  	 *  possibly send SIGBUS signal to process
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  191  	 */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  192  	if (ma_usermode & UM_WARN) {
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  193  		pr_err("user unaligned access @ %#lx; isn=0x%08lx ea=0x%08lx ra=0x%08lx sp=0x%08lx\n",
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  194  			(unsigned long)addr, (unsigned long)isn,
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  195  			fp->ea, fp->ra, fp->sp);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  196  	}
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  197  
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  198  	if (ma_usermode & UM_SIGNAL)
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  199  		_exception(SIGBUS, fp, BUS_ADRALN, fp->ea);
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  200  	else
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  201  		fp->ea += 4;	/* else advance */
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  202  }
82ed08dd1b0e0e Ley Foon Tan  2014-11-06  203  

:::::: The code at line 111 was first introduced by commit
:::::: 82ed08dd1b0e0e0728f9188f66795c49dffe437d nios2: Exception handling

:::::: TO: Ley Foon Tan <lftan@xxxxxxxxxx>
:::::: CC: Ley Foon Tan <lftan@xxxxxxxxxx>

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux