[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202110011850.Hl0uhHMQ-lkp@intel.com>
Date: Fri, 1 Oct 2021 18:12:56 +0800
From: kernel test robot <lkp@...el.com>
To: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>
Subject: [intel-tdx:guest 104/126]
drivers/firmware/efi/libstub/x86-stub.c:646:50: sparse: sparse: non
size-preserving pointer to integer cast
tree: https://github.com/intel/tdx.git guest
head: 00e7708dd946e76b7a5e973162ae71111ca32aea
commit: c2b1173a3ae221b105ef9302dbd370389120d346 [104/126] efi/x86: Implement support for unaccepted memory
config: i386-randconfig-s001-20211001 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/intel/tdx/commit/c2b1173a3ae221b105ef9302dbd370389120d346
git remote add intel-tdx https://github.com/intel/tdx.git
git fetch --no-tags intel-tdx guest
git checkout c2b1173a3ae221b105ef9302dbd370389120d346
# save the attached .config to linux build tree
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/firmware/efi/libstub/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/firmware/efi/libstub/x86-stub.c:646:50: sparse: sparse: non size-preserving pointer to integer cast
vim +646 drivers/firmware/efi/libstub/x86-stub.c
579
580 static efi_status_t allocate_e820(struct boot_params *params,
581 struct efi_boot_memmap *map,
582 struct setup_data **e820ext,
583 u32 *e820ext_size)
584 {
585 efi_status_t status;
586 __u32 nr_desc;
587 bool unaccepted_memory_present = false;
588 u64 max_addr = 0;
589 int i;
590
591 status = efi_get_memory_map(map);
592 if (status != EFI_SUCCESS)
593 return status;
594
595 nr_desc = *map->map_size / *map->desc_size;
596 if (nr_desc > ARRAY_SIZE(params->e820_table) - EFI_MMAP_NR_SLACK_SLOTS) {
597 u32 nr_e820ext = nr_desc - ARRAY_SIZE(params->e820_table) -
598 EFI_MMAP_NR_SLACK_SLOTS;
599
600 status = alloc_e820ext(nr_e820ext, e820ext, e820ext_size);
601 if (status != EFI_SUCCESS)
602 goto out;
603 }
604
605 if (!IS_ENABLED(CONFIG_UNACCEPTED_MEMORY))
606 goto out;
607
608 /* Check if there's any unaccepted memory and find the max address */
609 for (i = 0; i < nr_desc; i++) {
610 efi_memory_desc_t *d;
611
612 d = efi_early_memdesc_ptr(*map->map, *map->desc_size, i);
613 if (d->type == EFI_UNACCEPTED_MEMORY)
614 unaccepted_memory_present = true;
615 if (d->phys_addr + d->num_pages * PAGE_SIZE > max_addr)
616 max_addr = d->phys_addr + d->num_pages * PAGE_SIZE;
617 }
618
619 /*
620 * If unaccepted memory present allocate a bitmap to track what memory
621 * has to be accepted before access.
622 *
623 * One bit in the bitmap represents 2MiB in the address space: one 4k
624 * page is enough to track 64GiB or physical address space.
625 *
626 * In the worst case scenario -- a huge hole in the middle of the
627 * address space -- It needs 256MiB to handle 4PiB of the address
628 * space.
629 *
630 * TODO: handle situation if params->unaccepted_memory has already set.
631 * It's required to deal with kexec.
632 *
633 * The bitmap will be populated in setup_e820() according to the memory
634 * map after efi_exit_boot_services().
635 */
636 if (unaccepted_memory_present) {
637 unsigned long *unaccepted_memory = NULL;
638 u64 size = DIV_ROUND_UP(max_addr, PMD_SIZE * BITS_PER_BYTE);
639
640 status = efi_allocate_pages(size,
641 (unsigned long *)&unaccepted_memory,
642 ULONG_MAX);
643 if (status != EFI_SUCCESS)
644 goto out;
645 memset(unaccepted_memory, 0, size);
> 646 params->unaccepted_memory = (u64)unaccepted_memory;
647 }
648
649 out:
650 efi_bs_call(free_pool, *map->map);
651 return status;
652
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (36948 bytes)
Powered by blists - more mailing lists