arch/powerpc/platforms/powernv/opal-fadump.c:130:22: sparse: sparse: incorrect type in assignment (different base types)

From: kernel test robot
Date: Sat Aug 08 2020 - 18:57:46 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 11030fe96b57ad843518b0e9430f3cd4b3610ce2
commit: 7dee93a9a8808b3d8595e1cc79ccb8b1a7bc7a77 powerpc/fadump: support holes in kernel boot memory area
date: 11 months ago
config: powerpc64-randconfig-s032-20200808 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 9.3.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.2-118-ge1578773-dirty
git checkout 7dee93a9a8808b3d8595e1cc79ccb8b1a7bc7a77
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=powerpc64

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/powerpc/platforms/powernv/opal-fadump.c:104:41: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long long [usertype] boot_mem_dest_addr @@ got restricted __be64 const [usertype] dest @@
arch/powerpc/platforms/powernv/opal-fadump.c:104:41: sparse: expected unsigned long long [usertype] boot_mem_dest_addr
arch/powerpc/platforms/powernv/opal-fadump.c:104:41: sparse: got restricted __be64 const [usertype] dest
>> arch/powerpc/platforms/powernv/opal-fadump.c:130:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long base @@ got restricted __be64 const [usertype] src @@
>> arch/powerpc/platforms/powernv/opal-fadump.c:130:22: sparse: expected unsigned long base
>> arch/powerpc/platforms/powernv/opal-fadump.c:130:22: sparse: got restricted __be64 const [usertype] src
>> arch/powerpc/platforms/powernv/opal-fadump.c:131:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long size @@ got restricted __be64 const [usertype] size @@
>> arch/powerpc/platforms/powernv/opal-fadump.c:131:22: sparse: expected unsigned long size
arch/powerpc/platforms/powernv/opal-fadump.c:131:22: sparse: got restricted __be64 const [usertype] size
arch/powerpc/platforms/powernv/opal-fadump.c:146:46: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long reserve_dump_area_start @@ got restricted __be64 const [usertype] dest @@
arch/powerpc/platforms/powernv/opal-fadump.c:146:46: sparse: expected unsigned long reserve_dump_area_start
arch/powerpc/platforms/powernv/opal-fadump.c:146:46: sparse: got restricted __be64 const [usertype] dest
>> arch/powerpc/platforms/powernv/opal-fadump.c:196:41: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] src @@ got unsigned long long @@
arch/powerpc/platforms/powernv/opal-fadump.c:196:41: sparse: expected restricted __be64 [usertype] src
>> arch/powerpc/platforms/powernv/opal-fadump.c:196:41: sparse: got unsigned long long
arch/powerpc/platforms/powernv/opal-fadump.c:197:41: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] dest @@ got unsigned long long [usertype] addr @@
arch/powerpc/platforms/powernv/opal-fadump.c:197:41: sparse: expected restricted __be64 [usertype] dest
arch/powerpc/platforms/powernv/opal-fadump.c:197:41: sparse: got unsigned long long [usertype] addr
>> arch/powerpc/platforms/powernv/opal-fadump.c:198:41: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] size @@ got unsigned long long @@
arch/powerpc/platforms/powernv/opal-fadump.c:198:41: sparse: expected restricted __be64 [usertype] size
arch/powerpc/platforms/powernv/opal-fadump.c:198:41: sparse: got unsigned long long
arch/powerpc/platforms/powernv/opal-fadump.c:208:53: sparse: sparse: restricted __be64 degrades to integer
arch/powerpc/platforms/powernv/opal-fadump.c:276:56: sparse: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned long long [usertype] src @@ got restricted __be64 [usertype] src @@
arch/powerpc/platforms/powernv/opal-fadump.c:276:56: sparse: expected unsigned long long [usertype] src
arch/powerpc/platforms/powernv/opal-fadump.c:276:56: sparse: got restricted __be64 [usertype] src
arch/powerpc/platforms/powernv/opal-fadump.c:277:56: sparse: sparse: incorrect type in argument 3 (different base types) @@ expected unsigned long long [usertype] dest @@ got restricted __be64 [usertype] dest @@
arch/powerpc/platforms/powernv/opal-fadump.c:277:56: sparse: expected unsigned long long [usertype] dest
arch/powerpc/platforms/powernv/opal-fadump.c:277:56: sparse: got restricted __be64 [usertype] dest
arch/powerpc/platforms/powernv/opal-fadump.c:278:56: sparse: sparse: incorrect type in argument 4 (different base types) @@ expected unsigned long long [usertype] size @@ got restricted __be64 [usertype] size @@
arch/powerpc/platforms/powernv/opal-fadump.c:278:56: sparse: expected unsigned long long [usertype] size
arch/powerpc/platforms/powernv/opal-fadump.c:278:56: sparse: got restricted __be64 [usertype] size
arch/powerpc/platforms/powernv/opal-fadump.c:573:38: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long long [usertype] dumped_bytes @@ got restricted __be64 const [usertype] size @@
arch/powerpc/platforms/powernv/opal-fadump.c:573:38: sparse: expected unsigned long long [usertype] dumped_bytes
arch/powerpc/platforms/powernv/opal-fadump.c:573:38: sparse: got restricted __be64 const [usertype] size
arch/powerpc/platforms/powernv/opal-fadump.c:689:16: sparse: sparse: cast to restricted __be64
arch/powerpc/platforms/powernv/opal-fadump.c:707:24: sparse: sparse: cast to restricted __be64
arch/powerpc/platforms/powernv/opal-fadump.c: note: in included file:
arch/powerpc/platforms/powernv/opal-fadump.h:138:33: sparse: sparse: restricted __be64 degrades to integer

vim +130 arch/powerpc/platforms/powernv/opal-fadump.c

110
111 /*
112 * This function is called in the capture kernel to get configuration details
113 * from metadata setup by the first kernel.
114 */
115 static void opal_fadump_get_config(struct fw_dump *fadump_conf,
116 const struct opal_fadump_mem_struct *fdm)
117 {
118 unsigned long base, size, last_end, hole_size;
119 int i;
120
121 if (!fadump_conf->dump_active)
122 return;
123
124 last_end = 0;
125 hole_size = 0;
126 fadump_conf->boot_memory_size = 0;
127
128 pr_debug("Boot memory regions:\n");
129 for (i = 0; i < fdm->region_cnt; i++) {
> 130 base = fdm->rgn[i].src;
> 131 size = fdm->rgn[i].size;
132 pr_debug("\t[%03d] base: 0x%lx, size: 0x%lx\n", i, base, size);
133
134 fadump_conf->boot_mem_addr[i] = base;
135 fadump_conf->boot_mem_sz[i] = size;
136 fadump_conf->boot_memory_size += size;
137 hole_size += (base - last_end);
138
139 last_end = base + size;
140 }
141
142 /*
143 * Start address of reserve dump area (permanent reservation) for
144 * re-registering FADump after dump capture.
145 */
146 fadump_conf->reserve_dump_area_start = fdm->rgn[0].dest;
147
148 /*
149 * Rarely, but it can so happen that system crashes before all
150 * boot memory regions are registered for MPIPL. In such
151 * cases, warn that the vmcore may not be accurate and proceed
152 * anyway as that is the best bet considering free pages, cache
153 * pages, user pages, etc are usually filtered out.
154 *
155 * Hope the memory that could not be preserved only has pages
156 * that are usually filtered out while saving the vmcore.
157 */
158 if (fdm->region_cnt > fdm->registered_regions) {
159 pr_warn("Not all memory regions were saved!!!\n");
160 pr_warn(" Unsaved memory regions:\n");
161 i = fdm->registered_regions;
162 while (i < fdm->region_cnt) {
163 pr_warn("\t[%03d] base: 0x%llx, size: 0x%llx\n",
164 i, fdm->rgn[i].src, fdm->rgn[i].size);
165 i++;
166 }
167
168 pr_warn("If the unsaved regions only contain pages that are filtered out (eg. free/user pages), the vmcore should still be usable.\n");
169 pr_warn("WARNING: If the unsaved regions contain kernel pages, the vmcore will be corrupted.\n");
170 }
171
172 fadump_conf->boot_mem_top = (fadump_conf->boot_memory_size + hole_size);
173 fadump_conf->boot_mem_regs_cnt = fdm->region_cnt;
174 opal_fadump_update_config(fadump_conf, fdm);
175 }
176
177 /* Initialize kernel metadata */
178 static void opal_fadump_init_metadata(struct opal_fadump_mem_struct *fdm)
179 {
180 fdm->version = OPAL_FADUMP_VERSION;
181 fdm->region_cnt = 0;
182 fdm->registered_regions = 0;
183 fdm->fadumphdr_addr = 0;
184 }
185
186 static u64 opal_fadump_init_mem_struct(struct fw_dump *fadump_conf)
187 {
188 u64 addr = fadump_conf->reserve_dump_area_start;
189 int i;
190
191 opal_fdm = __va(fadump_conf->kernel_metadata);
192 opal_fadump_init_metadata(opal_fdm);
193
194 /* Boot memory regions */
195 for (i = 0; i < fadump_conf->boot_mem_regs_cnt; i++) {
> 196 opal_fdm->rgn[i].src = fadump_conf->boot_mem_addr[i];
197 opal_fdm->rgn[i].dest = addr;
> 198 opal_fdm->rgn[i].size = fadump_conf->boot_mem_sz[i];
199
200 opal_fdm->region_cnt++;
201 addr += fadump_conf->boot_mem_sz[i];
202 }
203
204 /*
205 * Kernel metadata is passed to f/w and retrieved in capture kerenl.
206 * So, use it to save fadump header address instead of calculating it.
207 */
208 opal_fdm->fadumphdr_addr = (opal_fdm->rgn[0].dest +
209 fadump_conf->boot_memory_size);
210
211 opal_fadump_update_config(fadump_conf, opal_fdm);
212
213 return addr;
214 }
215

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

Attachment: .config.gz
Description: application/gzip