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

From: kernel test robot
Date: Sat Aug 08 2020 - 08:48:13 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 449dc8c97089a6e09fb2dac4d92b1b7ac0eb7c1e
commit: a20a8fa42def548f46c7e0401a94f62b8e595883 powerpc/fadump: define OPAL register/un-register callback functions
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 a20a8fa42def548f46c7e0401a94f62b8e595883
# 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:33: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:33:41: sparse: expected unsigned long long [usertype] boot_mem_dest_addr
>> arch/powerpc/platforms/powernv/opal-fadump.c:33:41: sparse: got restricted __be64 const [usertype] dest
arch/powerpc/platforms/powernv/opal-fadump.c:58:33: 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:58:33: sparse: expected restricted __be64 [usertype] dest
arch/powerpc/platforms/powernv/opal-fadump.c:58:33: sparse: got unsigned long long [usertype] addr
arch/powerpc/platforms/powernv/opal-fadump.c:59:33: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be64 [usertype] size @@ got unsigned long boot_memory_size @@
arch/powerpc/platforms/powernv/opal-fadump.c:59:33: sparse: expected restricted __be64 [usertype] size
arch/powerpc/platforms/powernv/opal-fadump.c:59:33: sparse: got unsigned long boot_memory_size
arch/powerpc/platforms/powernv/opal-fadump.c:66:53: sparse: sparse: restricted __be64 degrades to integer
>> arch/powerpc/platforms/powernv/opal-fadump.c:118: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:118:56: sparse: expected unsigned long long [usertype] src
>> arch/powerpc/platforms/powernv/opal-fadump.c:118:56: sparse: got restricted __be64 [usertype] src
>> arch/powerpc/platforms/powernv/opal-fadump.c:119: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:119:56: sparse: expected unsigned long long [usertype] dest
>> arch/powerpc/platforms/powernv/opal-fadump.c:119:56: sparse: got restricted __be64 [usertype] dest
>> arch/powerpc/platforms/powernv/opal-fadump.c:120: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:120:56: sparse: expected unsigned long long [usertype] size
>> arch/powerpc/platforms/powernv/opal-fadump.c:120:56: sparse: got restricted __be64 [usertype] size

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

25
26 static void opal_fadump_update_config(struct fw_dump *fadump_conf,
27 const struct opal_fadump_mem_struct *fdm)
28 {
29 /*
30 * The destination address of the first boot memory region is the
31 * destination address of boot memory regions.
32 */
> 33 fadump_conf->boot_mem_dest_addr = fdm->rgn[0].dest;
34 pr_debug("Destination address of boot memory regions: %#016llx\n",
35 fadump_conf->boot_mem_dest_addr);
36
37 fadump_conf->fadumphdr_addr = fdm->fadumphdr_addr;
38 }
39
40 /* Initialize kernel metadata */
41 static void opal_fadump_init_metadata(struct opal_fadump_mem_struct *fdm)
42 {
43 fdm->version = OPAL_FADUMP_VERSION;
44 fdm->region_cnt = 0;
45 fdm->registered_regions = 0;
46 fdm->fadumphdr_addr = 0;
47 }
48
49 static u64 opal_fadump_init_mem_struct(struct fw_dump *fadump_conf)
50 {
51 u64 addr = fadump_conf->reserve_dump_area_start;
52
53 opal_fdm = __va(fadump_conf->kernel_metadata);
54 opal_fadump_init_metadata(opal_fdm);
55
56 opal_fdm->region_cnt = 1;
57 opal_fdm->rgn[0].src = 0;
> 58 opal_fdm->rgn[0].dest = addr;
> 59 opal_fdm->rgn[0].size = fadump_conf->boot_memory_size;
60 addr += fadump_conf->boot_memory_size;
61
62 /*
63 * Kernel metadata is passed to f/w and retrieved in capture kerenl.
64 * So, use it to save fadump header address instead of calculating it.
65 */
> 66 opal_fdm->fadumphdr_addr = (opal_fdm->rgn[0].dest +
67 fadump_conf->boot_memory_size);
68
69 opal_fadump_update_config(fadump_conf, opal_fdm);
70
71 return addr;
72 }
73
74 static u64 opal_fadump_get_metadata_size(void)
75 {
76 return PAGE_ALIGN(sizeof(struct opal_fadump_mem_struct));
77 }
78
79 static int opal_fadump_setup_metadata(struct fw_dump *fadump_conf)
80 {
81 int err = 0;
82 s64 ret;
83
84 /*
85 * Use the last page(s) in FADump memory reservation for
86 * kernel metadata.
87 */
88 fadump_conf->kernel_metadata = (fadump_conf->reserve_dump_area_start +
89 fadump_conf->reserve_dump_area_size -
90 opal_fadump_get_metadata_size());
91 pr_info("Kernel metadata addr: %llx\n", fadump_conf->kernel_metadata);
92
93 /* Initialize kernel metadata before registering the address with f/w */
94 opal_fdm = __va(fadump_conf->kernel_metadata);
95 opal_fadump_init_metadata(opal_fdm);
96
97 /*
98 * Register metadata address with f/w. Can be retrieved in
99 * the capture kernel.
100 */
101 ret = opal_mpipl_register_tag(OPAL_MPIPL_TAG_KERNEL,
102 fadump_conf->kernel_metadata);
103 if (ret != OPAL_SUCCESS) {
104 pr_err("Failed to set kernel metadata tag!\n");
105 err = -EPERM;
106 }
107
108 return err;
109 }
110
111 static int opal_fadump_register(struct fw_dump *fadump_conf)
112 {
113 s64 rc = OPAL_PARAMETER;
114 int i, err = -EIO;
115
116 for (i = 0; i < opal_fdm->region_cnt; i++) {
117 rc = opal_mpipl_update(OPAL_MPIPL_ADD_RANGE,
> 118 opal_fdm->rgn[i].src,
> 119 opal_fdm->rgn[i].dest,
> 120 opal_fdm->rgn[i].size);
121 if (rc != OPAL_SUCCESS)
122 break;
123
124 opal_fdm->registered_regions++;
125 }
126
127 switch (rc) {
128 case OPAL_SUCCESS:
129 pr_info("Registration is successful!\n");
130 fadump_conf->dump_registered = 1;
131 err = 0;
132 break;
133 case OPAL_RESOURCE:
134 /* If MAX regions limit in f/w is hit, warn and proceed. */
135 pr_warn("%d regions could not be registered for MPIPL as MAX limit is reached!\n",
136 (opal_fdm->region_cnt - opal_fdm->registered_regions));
137 fadump_conf->dump_registered = 1;
138 err = 0;
139 break;
140 case OPAL_PARAMETER:
141 pr_err("Failed to register. Parameter Error(%lld).\n", rc);
142 break;
143 case OPAL_HARDWARE:
144 pr_err("Support not available.\n");
145 fadump_conf->fadump_supported = 0;
146 fadump_conf->fadump_enabled = 0;
147 break;
148 default:
149 pr_err("Failed to register. Unknown Error(%lld).\n", rc);
150 break;
151 }
152
153 /*
154 * If some regions were registered before OPAL_MPIPL_ADD_RANGE
155 * OPAL call failed, unregister all regions.
156 */
157 if ((err < 0) && (opal_fdm->registered_regions > 0))
158 opal_fadump_unregister(fadump_conf);
159
160 return err;
161 }
162

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

Attachment: .config.gz
Description: application/gzip