From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6AFCC433F5 for ; Sat, 8 Oct 2022 03:53:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F0146B0072; Fri, 7 Oct 2022 23:53:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19FE76B0073; Fri, 7 Oct 2022 23:53:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 040BA6B0074; Fri, 7 Oct 2022 23:53:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DF8AA6B0072 for ; Fri, 7 Oct 2022 23:53:07 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8208D160746 for ; Sat, 8 Oct 2022 03:53:07 +0000 (UTC) X-FDA: 79996411614.05.1A8E0D1 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf27.hostedemail.com (Postfix) with ESMTP id B6DF04001A for ; Sat, 8 Oct 2022 03:53:04 +0000 (UTC) Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MkrkR49VmzlWb4; Sat, 8 Oct 2022 11:48:31 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 8 Oct 2022 11:53:00 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 8 Oct 2022 11:53:00 +0800 Subject: Re: [linux-next:master 8145/11162] arch/arm/kernel/traps.c:198:37: sparse: sparse: incorrect type in assignment (different base types) To: kernel test robot CC: , Linux Memory Management List , "Russell King (Oracle)" References: <202209292229.yDd7W4uU-lkp@intel.com> From: "Leizhen (ThunderTown)" Message-ID: <0426e063-003c-d961-7ce9-fb63b16839a1@huawei.com> Date: Sat, 8 Oct 2022 11:53:00 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <202209292229.yDd7W4uU-lkp@intel.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665201185; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MfiwTj5hsjXxIqmyZ7uidRwfsilK4HnjjCo4lnQf1Uw=; b=GruMAXtkfukeim6ZI1xOuNTbPg9fhttIyq1wbwEuJJr2IRmelN9hcFhc2ORIVl1bQHLyLG ZIHqITcaHySEZGueu0I7w4u7IJQu0RmvXjoFpZaR4IJVmFoxadhQfs2DPM8z8Hjng+FVgW pNsj0lctJhFfw8jIvNyFefzQLy22e1U= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665201185; a=rsa-sha256; cv=none; b=L/dls4TI3DiDW7bLH29+9PNZ0DOC6k5N9HBQQ//ats3l8NzFXLgzau19eJE1J+XmUmcMQn ceTR1ftEYEfox9SVp+1P2d/cVv+1ZdmwqTlIMc02HtJiRC1EOxhMH8ER9ThYP7ELdtBcKf PnlJ4/YCEZDEZgJnyYMQ+UB4BRUpv8U= Authentication-Results: imf27.hostedemail.com; dkim=none; spf=pass (imf27.hostedemail.com: domain of thunder.leizhen@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=thunder.leizhen@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-Stat-Signature: suo8oxyezesnxwywf7u3twh1cny8fz9g X-Rspamd-Queue-Id: B6DF04001A X-Rspamd-Server: rspam01 X-HE-Tag: 1665201184-761768 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/9/29 23:07, kernel test robot wrote: > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > head: de90d455a35e474a184c898e66a6a108c3a99434 > commit: f640b1a57f8e9e513e26aa5b3ee0b905dfebfcf2 [8145/11162] ARM: 9225/1: Make the dumped instructions are consistent with the disassembled ones > config: arm-randconfig-s043-20220925 > compiler: arm-linux-gnueabi-gcc (GCC) 12.1.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-39-gce1a6720-dirty > # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f640b1a57f8e9e513e26aa5b3ee0b905dfebfcf2 > 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 f640b1a57f8e9e513e26aa5b3ee0b905dfebfcf2 > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm SHELL=/bin/bash > > If you fix the issue, kindly add following tag where applicable > | Reported-by: kernel test robot > > sparse warnings: (new ones prefixed by >>) > arch/arm/kernel/traps.c:191:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned short [usertype] * @@ > arch/arm/kernel/traps.c:191:39: sparse: expected void const volatile [noderef] __user *ptr > arch/arm/kernel/traps.c:191:39: sparse: got unsigned short [usertype] * > arch/arm/kernel/traps.c:193:39: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int [usertype] * @@ > arch/arm/kernel/traps.c:193:39: sparse: expected void const volatile [noderef] __user *ptr > arch/arm/kernel/traps.c:193:39: sparse: got unsigned int [usertype] * These warnings are not caused by this patch. I will use another patch to fix them. if (thumb) - bad = get_user(val, &((u16 *)addr)[i]); + bad = get_user(val, &((u16 __user *)addr)[i]); else - bad = get_user(val, &((u32 *)addr)[i]); + bad = get_user(val, &((u32 __user *)addr)[i]); >>> arch/arm/kernel/traps.c:198:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [addressable] [assigned] val @@ got restricted __le16 [usertype] @@ > arch/arm/kernel/traps.c:198:37: sparse: expected unsigned int [addressable] [assigned] val > arch/arm/kernel/traps.c:198:37: sparse: got restricted __le16 [usertype] >>> arch/arm/kernel/traps.c:200:37: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [addressable] [assigned] val @@ got restricted __le32 [usertype] @@ > arch/arm/kernel/traps.c:200:37: sparse: expected unsigned int [addressable] [assigned] val > arch/arm/kernel/traps.c:200:37: sparse: got restricted __le32 [usertype] OK, to clear this static check warning, I need to add "(__force unsigned int)" to perform the forced type conversion, because it requires that the type of 'val' be "__le16" or "__le32". > arch/arm/kernel/traps.c:465:33: sparse: sparse: cast removes address space '__user' of expression > arch/arm/kernel/traps.c:468:41: sparse: sparse: cast removes address space '__user' of expression > arch/arm/kernel/traps.c:473:33: sparse: sparse: cast removes address space '__user' of expression > > vim +198 arch/arm/kernel/traps.c > > 164 > 165 static void dump_instr(const char *lvl, struct pt_regs *regs) > 166 { > 167 unsigned long addr = instruction_pointer(regs); > 168 const int thumb = thumb_mode(regs); > 169 const int width = thumb ? 4 : 8; > 170 char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str; > 171 int i; > 172 > 173 /* > 174 * Note that we now dump the code first, just in case the backtrace > 175 * kills us. > 176 */ > 177 > 178 for (i = -4; i < 1 + !!thumb; i++) { > 179 unsigned int val, bad; > 180 > 181 if (!user_mode(regs)) { > 182 if (thumb) { > 183 u16 val16; > 184 bad = get_kernel_nofault(val16, &((u16 *)addr)[i]); > 185 val = val16; > 186 } else { > 187 bad = get_kernel_nofault(val, &((u32 *)addr)[i]); > 188 } > 189 } else { > 190 if (thumb) > 191 bad = get_user(val, &((u16 *)addr)[i]); > 192 else > 193 bad = get_user(val, &((u32 *)addr)[i]); > 194 } > 195 > 196 if (IS_ENABLED(CONFIG_CPU_ENDIAN_BE8)) { > 197 if (thumb) > > 198 val = cpu_to_le16(val); > 199 else > > 200 val = cpu_to_le32(val); > 201 } > 202 > 203 if (!bad) > 204 p += sprintf(p, i == 0 ? "(%0*x) " : "%0*x ", > 205 width, val); > 206 else { > 207 p += sprintf(p, "bad PC value"); > 208 break; > 209 } > 210 } > 211 printk("%sCode: %s\n", lvl, str); > 212 } > 213 > -- Regards, Zhen Lei