tree:
https://android.googlesource.com/kernel/common android-trusty-5.4
head: 939619581245887280b236c7596fa7fc7efeb48a
commit: 939619581245887280b236c7596fa7fc7efeb48a [1/1] ANDROID: trusty: Implement
share-memory interface based on Arm FF-A 1.0 EAC 1_0
config: i386-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce (this is a W=1 build):
git checkout 939619581245887280b236c7596fa7fc7efeb48a
# save the attached .config to linux build tree
make W=1 ARCH=i386
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp(a)intel.com>
All warnings (new ones prefixed by >>):
drivers/trusty/trusty.c: In function 'trusty_share_memory':
drivers/trusty/trusty.c:263:41: error: implicit declaration of function
'phys_to_page'; did you mean 'pfn_to_page'?
[-Werror=implicit-function-declaration]
263 | ret = trusty_encode_page_info(&pg_inf, phys_to_page(sg_dma_address(sg)),
| ^~~~~~~~~~~~
| pfn_to_page
drivers/trusty/trusty.c:263:41: warning: passing argument 2 of
'trusty_encode_page_info' makes pointer from integer without a cast
[-Wint-conversion]
263 | ret = trusty_encode_page_info(&pg_inf, phys_to_page(sg_dma_address(sg)),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| int
In file included from drivers/trusty/trusty.c:26:
include/linux/trusty/trusty.h:70:21: note: expected 'struct page *' but
argument is of type 'int'
70 | struct page *page, pgprot_t pgprot);
| ~~~~~~~~~~~~~^~~~
In file included from include/linux/delay.h:22,
from drivers/trusty/trusty.c:15:
include/linux/kernel.h:842:29: warning: comparison of distinct pointer types lacks a
cast
842 | (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
| ^~
include/linux/kernel.h:856:4: note: in expansion of macro '__typecheck'
856 | (__typecheck(x, y) && __no_side_effects(x, y))
| ^~~~~~~~~~~
include/linux/kernel.h:866:24: note: in expansion of macro '__safe_cmp'
866 | __builtin_choose_expr(__safe_cmp(x, y), \
| ^~~~~~~~~~
include/linux/kernel.h:875:19: note: in expansion of macro '__careful_cmp'
875 | #define min(x, y) __careful_cmp(x, y, <)
| ^~~~~~~~~~~~~
drivers/trusty/trusty.c:306:19: note: in expansion of macro 'min'
306 | size_t lcount = min(count, (PAGE_SIZE - cons_mrd_offset) /
| ^~~
> drivers/trusty/trusty.c:344:41: warning: left shift count >=
width of type [-Wshift-count-overflow]
344 | ffa_handle = smc_ret.r2 |
smc_ret.r3 << 32;
| ^~
In file included from include/linux/printk.h:329,
from include/linux/kernel.h:15,
from include/linux/delay.h:22,
from drivers/trusty/trusty.c:15:
> drivers/trusty/trusty.c:345:20: warning: format '%lx'
expects argument of type 'long unsigned int', but argument 7 has type
'u64' {aka 'long long unsigned int'} [-Wformat=]
345 |
dev_dbg(s->dev, "%s: fragment_len %zd/%zd, got handle 0x%lx\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dynamic_debug.h:125:15: note: in definition of macro
'__dynamic_func_call'
125 | func(&id, ##__VA_ARGS__); \
| ^~~~~~~~~~~
include/linux/dynamic_debug.h:157:2: note: in expansion of macro
'_dynamic_func_call'
157 | _dynamic_func_call(fmt,__dynamic_dev_dbg, \
| ^~~~~~~~~~~~~~~~~~
include/linux/device.h:1818:2: note: in expansion of macro 'dynamic_dev_dbg'
1818 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~~~~~~~~~
include/linux/device.h:1818:23: note: in expansion of macro 'dev_fmt'
1818 | dynamic_dev_dbg(dev, dev_fmt(fmt), ##__VA_ARGS__)
| ^~~~~~~
drivers/trusty/trusty.c:345:4: note: in expansion of macro 'dev_dbg'
345 | dev_dbg(s->dev, "%s: fragment_len %zd/%zd, got handle
0x%lx\n",
| ^~~~~~~
drivers/trusty/trusty.c:345:62: note: format string is defined here
345 | dev_dbg(s->dev, "%s: fragment_len %zd/%zd, got handle
0x%lx\n",
| ~~^
| |
| long unsigned int
| %llx
In file included from include/linux/of_platform.h:9,
from drivers/trusty/trusty.c:18:
> drivers/trusty/trusty.c:361:20: warning: format '%x'
expects argument of type 'unsigned int', but argument 6 has type 'ulong'
{aka 'long unsigned int'} [-Wformat=]
361 | dev_err(s->dev,
"%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE failed 0x%x 0x%x 0x%x",
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:1724:22: note: in definition of macro 'dev_fmt'
1724 | #define dev_fmt(fmt) fmt
| ^~~
drivers/trusty/trusty.c:361:4: note: in expansion of macro 'dev_err'
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
| ^~~~~~~
drivers/trusty/trusty.c:361:78: note: format string is defined here
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
| ~^
| |
|
unsigned int
|
%lx
In file included from include/linux/of_platform.h:9,
from drivers/trusty/trusty.c:18:
drivers/trusty/trusty.c:361:20: warning: format '%x' expects argument of type
'unsigned int', but argument 7 has type 'ulong' {aka 'long unsigned
int'} [-Wformat=]
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:1724:22: note: in definition of macro 'dev_fmt'
1724 | #define dev_fmt(fmt) fmt
| ^~~
drivers/trusty/trusty.c:361:4: note: in expansion of macro 'dev_err'
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
| ^~~~~~~
drivers/trusty/trusty.c:361:83: note: format string is defined here
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
|
~^
|
|
|
unsigned int
|
%lx
In file included from include/linux/of_platform.h:9,
from drivers/trusty/trusty.c:18:
drivers/trusty/trusty.c:361:20: warning: format '%x' expects argument of type
'unsigned int', but argument 8 has type 'ulong' {aka 'long unsigned
int'} [-Wformat=]
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
|
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:1724:22: note: in definition of macro 'dev_fmt'
1724 | #define dev_fmt(fmt) fmt
| ^~~
drivers/trusty/trusty.c:361:4: note: in expansion of macro 'dev_err'
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
| ^~~~~~~
drivers/trusty/trusty.c:361:88: note: format string is defined here
361 | dev_err(s->dev, "%s: fragment_len %zd/%zd, SMC_FC_FFA_MEM_SHARE
failed 0x%x 0x%x 0x%x",
|
~^
|
|
|
unsigned int
|
%lx
In file included from include/linux/of_platform.h:9,
from drivers/trusty/trusty.c:18:
drivers/trusty/trusty.c: In function 'trusty_reclaim_memory':
drivers/trusty/trusty.c:442:19: warning: format '%x' expects argument of type
'unsigned int', but argument 4 has type 'ulong' {aka 'long unsigned
int'} [-Wformat=]
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:1724:22: note: in definition of macro 'dev_fmt'
1724 | #define dev_fmt(fmt) fmt
| ^~~
drivers/trusty/trusty.c:442:3: note: in expansion of macro 'dev_err'
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ^~~~~~~
drivers/trusty/trusty.c:442:57: note: format string is defined here
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ~^
| |
| unsigned int
| %lx
In file included from include/linux/of_platform.h:9,
from drivers/trusty/trusty.c:18:
drivers/trusty/trusty.c:442:19: warning: format '%x' expects argument of type
'unsigned int', but argument 5 has type 'ulong' {aka 'long unsigned
int'} [-Wformat=]
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:1724:22: note: in definition of macro 'dev_fmt'
1724 | #define dev_fmt(fmt) fmt
| ^~~
drivers/trusty/trusty.c:442:3: note: in expansion of macro 'dev_err'
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ^~~~~~~
drivers/trusty/trusty.c:442:62: note: format string is defined here
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ~^
| |
| unsigned int
| %lx
In file included from include/linux/of_platform.h:9,
from drivers/trusty/trusty.c:18:
drivers/trusty/trusty.c:442:19: warning: format '%x' expects argument of type
'unsigned int', but argument 6 has type 'ulong' {aka 'long unsigned
int'} [-Wformat=]
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/device.h:1724:22: note: in definition of macro 'dev_fmt'
1724 | #define dev_fmt(fmt) fmt
| ^~~
drivers/trusty/trusty.c:442:3: note: in expansion of macro 'dev_err'
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ^~~~~~~
drivers/trusty/trusty.c:442:67: note: format string is defined here
442 | dev_err(s->dev, "%s: SMC_FC_FFA_MEM_RECLAIM failed 0x%x 0x%x
0x%x",
| ~^
| |
| unsigned int
| %lx
vim +344 drivers/trusty/trusty.c
218
219 int trusty_share_memory(struct device *dev, uint64_t *id,
220 struct scatterlist *sglist, unsigned int nents,
221 pgprot_t pgprot)
222 {
223 struct trusty_state *s = platform_get_drvdata(to_platform_device(dev));
224 int ret;
225 struct ns_mem_page_info pg_inf;
226 struct scatterlist *sg;
227 size_t count;
228 size_t i;
229 size_t len;
230 u64 ffa_handle = 0;
231 size_t total_len;
232 size_t endpoint_count = 1;
233 struct ffa_mtd *mtd = s->ffa_tx;
234 size_t comp_mrd_offset = offsetof(struct ffa_mtd, emad[endpoint_count]);
235 struct ffa_comp_mrd *comp_mrd = s->ffa_tx + comp_mrd_offset;
236 struct ffa_cons_mrd *cons_mrd = comp_mrd->address_range_array;
237 size_t cons_mrd_offset = (void *)cons_mrd - s->ffa_tx;
238 struct smc_ret8 smc_ret;
239 uint32_t cookie_low;
240 uint32_t cookie_high;
241
242 dev_dbg(s->dev, "%s\n", __func__);
243
244 if (WARN_ON(dev->driver != &trusty_driver.driver))
245 return -EINVAL;
246
247 if (WARN_ON(nents < 1))
248 return -EINVAL;
249
250 if (nents != 1 && s->api_version < TRUSTY_API_VERSION_MEM_OBJ) {
251 dev_err(s->dev, "%s: old trusty version does not support non-contiguous
memory objects\n",
252 __func__);
253 return -ENOTSUPP;
254 }
255
256 count = dma_map_sg(dev, sglist, nents, DMA_BIDIRECTIONAL);
257 if (count != nents) {
258 dev_err(s->dev, "failed to dma map sg_table\n");
259 return -EINVAL;
260 }
261
262 sg = sglist;
263 ret = trusty_encode_page_info(&pg_inf, phys_to_page(sg_dma_address(sg)),
264 pgprot);
265 if (ret) {
266 dev_err(s->dev, "%s: trusty_encode_page_info failed\n",
267 __func__);
268 goto err_encode_page_info;
269 }
270
271 if (s->api_version < TRUSTY_API_VERSION_MEM_OBJ) {
272 *id = pg_inf.compat_attr;
273 return 0;
274 }
275
276 len = 0;
277 for_each_sg(sglist, sg, nents, i)
278 len += sg_dma_len(sg);
279
280 mutex_lock(&s->share_memory_msg_lock);
281
282 mtd->sender_id = s->ffa_local_id;
283 mtd->memory_region_attributes = pg_inf.ffa_mem_attr;
284 mtd->reserved_3 = 0;
285 mtd->flags = 0;
286 mtd->handle = 0;
287 mtd->tag = 0;
288 mtd->reserved_24_27 = 0;
289 mtd->emad_count = endpoint_count;
290 for (i = 0; i < endpoint_count; i++) {
291 struct ffa_emad *emad = &mtd->emad[i];
292 /* TODO: support stream ids */
293 emad->mapd.endpoint_id = s->ffa_remote_id;
294 emad->mapd.memory_access_permissions = pg_inf.ffa_mem_perm;
295 emad->mapd.flags = 0;
296 emad->comp_mrd_offset = comp_mrd_offset;
297 emad->reserved_8_15 = 0;
298 }
299 comp_mrd->total_page_count = len / PAGE_SIZE;
300 comp_mrd->address_range_count = nents;
301 comp_mrd->reserved_8_15 = 0;
302
303 total_len = cons_mrd_offset + nents * sizeof(*cons_mrd);
304 sg = sglist;
305 while (count) {
306 size_t lcount = min(count, (PAGE_SIZE - cons_mrd_offset) /
307 sizeof(*cons_mrd));
308 size_t fragment_len = lcount * sizeof(*cons_mrd) +
309 cons_mrd_offset;
310
311 for (i = 0; i < lcount; i++) {
312 cons_mrd[i].address = sg_dma_address(sg);
313 cons_mrd[i].page_count = sg_dma_len(sg) / PAGE_SIZE;
314 cons_mrd[i].reserved_12_15 = 0;
315 sg = sg_next(sg);
316 }
317 count -= lcount;
318 if (cons_mrd_offset) {
319 /* First fragment */
320 smc_ret = trusty_smc8(SMC_FC_FFA_MEM_SHARE, total_len,
321 fragment_len, 0, 0, 0, 0, 0);
322 } else {
323 smc_ret = trusty_smc8(SMC_FC_FFA_MEM_FRAG_TX,
324 cookie_low, cookie_high,
325 fragment_len, 0, 0, 0, 0);
326 }
327 if (smc_ret.r0 == SMC_FC_FFA_MEM_FRAG_RX) {
328 cookie_low = smc_ret.r1;
329 cookie_high = smc_ret.r2;
330 dev_dbg(s->dev, "cookie %x %x", cookie_low,
331 cookie_high);
332 if (!count) {
333 /*
334 * We have sent all our descriptors. Expected
335 * SMC_FC_FFA_SUCCESS, not a request to send
336 * another fragment.
337 */
338 dev_err(s->dev, "%s: fragment_len %zd/%zd, unexpected
SMC_FC_FFA_MEM_FRAG_RX\n",
339 __func__, fragment_len, total_len);
340 ret = -EIO;
341 break;
342 }
343 } else if (smc_ret.r0 == SMC_FC_FFA_SUCCESS) {
344 ffa_handle = smc_ret.r2 | smc_ret.r3 << 32;
345 dev_dbg(s->dev, "%s: fragment_len %zd/%zd, got handle 0x%lx\n",
346 __func__, fragment_len, total_len,
347 ffa_handle);
348 if (count) {
349 /*
350 * We have not sent all our descriptors.
351 * Expected SMC_FC_FFA_MEM_FRAG_RX not
352 * SMC_FC_FFA_SUCCESS.
353 */
354 dev_err(s->dev, "%s: fragment_len %zd/%zd, unexpected
SMC_FC_FFA_SUCCESS, count %d != 0\n",
355 __func__, fragment_len, total_len,
356 count);
357 ret = -EIO;
358 break;
359 }
360 } else {
361 dev_err(s->dev, "%s: fragment_len %zd/%zd,
SMC_FC_FFA_MEM_SHARE failed 0x%x 0x%x 0x%x",
362 __func__, fragment_len,
total_len,
363 smc_ret.r0, smc_ret.r1, smc_ret.r2);
364 ret = -EIO;
365 break;
366 }
367
368 cons_mrd = s->ffa_tx;
369 cons_mrd_offset = 0;
370 }
371
372 mutex_unlock(&s->share_memory_msg_lock);
373
374 if (!ret) {
375 *id = ffa_handle;
376 dev_dbg(s->dev, "%s: done\n", __func__);
377 return 0;
378 }
379
380 dev_err(s->dev, "%s: failed %d", __func__, ret);
381
382 err_encode_page_info:
383 dma_unmap_sg(dev, sglist, nents, DMA_BIDIRECTIONAL);
384 return ret;
385 }
386 EXPORT_SYMBOL(trusty_share_memory);
387
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org