[tip:x86/sev 43/49] drivers/virt/coco/sevguest/sevguest.c:579:17: sparse: sparse: incorrect type in argument 1 (different address spaces)
From: kernel test robot
Date: Fri Apr 15 2022 - 08:29:32 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/sev
head: 101826e02ac6c829bf4e768295e79ae9c37b4b2a
commit: fce96cf0443083e37455eff8f78fd240c621dae3 [43/49] virt: Add SEV-SNP guest driver
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20220415/202204152027.aJdnJRgJ-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.2.0-19) 11.2.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=fce96cf0443083e37455eff8f78fd240c621dae3
git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
git fetch --no-tags tip x86/sev
git checkout fce96cf0443083e37455eff8f78fd240c621dae3
# save the config file to linux build tree
mkdir build_dir
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=x86_64 SHELL=/bin/bash drivers/virt/coco/sevguest/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
sparse warnings: (new ones prefixed by >>)
>> drivers/virt/coco/sevguest/sevguest.c:579:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *addr @@ got struct snp_secrets_page_layout *[assigned] layout @@
drivers/virt/coco/sevguest/sevguest.c:579:17: sparse: expected void volatile [noderef] __iomem *addr
drivers/virt/coco/sevguest/sevguest.c:579:17: sparse: got struct snp_secrets_page_layout *[assigned] layout
vim +579 drivers/virt/coco/sevguest/sevguest.c
504
505 static int __init snp_guest_probe(struct platform_device *pdev)
506 {
507 struct snp_secrets_page_layout *layout;
508 struct snp_guest_platform_data *data;
509 struct device *dev = &pdev->dev;
510 struct snp_guest_dev *snp_dev;
511 struct miscdevice *misc;
512 int ret;
513
514 if (!dev->platform_data)
515 return -ENODEV;
516
517 data = (struct snp_guest_platform_data *)dev->platform_data;
518 layout = (__force void *)ioremap_encrypted(data->secrets_gpa, PAGE_SIZE);
519 if (!layout)
520 return -ENODEV;
521
522 ret = -ENOMEM;
523 snp_dev = devm_kzalloc(&pdev->dev, sizeof(struct snp_guest_dev), GFP_KERNEL);
524 if (!snp_dev)
525 goto e_unmap;
526
527 ret = -EINVAL;
528 snp_dev->vmpck = get_vmpck(vmpck_id, layout, &snp_dev->os_area_msg_seqno);
529 if (!snp_dev->vmpck) {
530 dev_err(dev, "invalid vmpck id %d\n", vmpck_id);
531 goto e_unmap;
532 }
533
534 /* Verify that VMPCK is not zero. */
535 if (is_vmpck_empty(snp_dev)) {
536 dev_err(dev, "vmpck id %d is null\n", vmpck_id);
537 goto e_unmap;
538 }
539
540 platform_set_drvdata(pdev, snp_dev);
541 snp_dev->dev = dev;
542 snp_dev->layout = layout;
543
544 /* Allocate the shared page used for the request and response message. */
545 snp_dev->request = alloc_shared_pages(sizeof(struct snp_guest_msg));
546 if (!snp_dev->request)
547 goto e_unmap;
548
549 snp_dev->response = alloc_shared_pages(sizeof(struct snp_guest_msg));
550 if (!snp_dev->response)
551 goto e_free_request;
552
553 ret = -EIO;
554 snp_dev->crypto = init_crypto(snp_dev, snp_dev->vmpck, VMPCK_KEY_LEN);
555 if (!snp_dev->crypto)
556 goto e_free_response;
557
558 misc = &snp_dev->misc;
559 misc->minor = MISC_DYNAMIC_MINOR;
560 misc->name = DEVICE_NAME;
561 misc->fops = &snp_guest_fops;
562
563 /* initial the input address for guest request */
564 snp_dev->input.req_gpa = __pa(snp_dev->request);
565 snp_dev->input.resp_gpa = __pa(snp_dev->response);
566
567 ret = misc_register(misc);
568 if (ret)
569 goto e_free_response;
570
571 dev_info(dev, "Initialized SNP guest driver (using vmpck_id %d)\n", vmpck_id);
572 return 0;
573
574 e_free_response:
575 free_shared_pages(snp_dev->response, sizeof(struct snp_guest_msg));
576 e_free_request:
577 free_shared_pages(snp_dev->request, sizeof(struct snp_guest_msg));
578 e_unmap:
> 579 iounmap(layout);
580 return ret;
581 }
582
--
0-DAY CI Kernel Test Service
https://01.org/lkp