All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: drivers/firmware/efi/mokvar-table.c:142:33: sparse: sparse: incorrect type in argument 1 (different address spaces)
Date: Thu, 20 May 2021 05:53:04 +0800	[thread overview]
Message-ID: <202105200558.079JCXai-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6695 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c3d0e3fd41b7f0f5d5d5b6022ab7e813f04ea727
commit: 58c909022a5a56cd1d9e89c8c5461fd1f6a27bb5 efi: Support for MOK variable config table
date:   8 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-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.3-341-g8af24329-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58c909022a5a56cd1d9e89c8c5461fd1f6a27bb5
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 58c909022a5a56cd1d9e89c8c5461fd1f6a27bb5
        # 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__' W=1 ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/firmware/efi/mokvar-table.c:142:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *va @@
   drivers/firmware/efi/mokvar-table.c:142:33: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/firmware/efi/mokvar-table.c:142:33: sparse:     got void *va
>> drivers/firmware/efi/mokvar-table.c:151:28: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *va @@     got void [noderef] __iomem * @@
   drivers/firmware/efi/mokvar-table.c:151:28: sparse:     expected void *va
   drivers/firmware/efi/mokvar-table.c:151:28: sparse:     got void [noderef] __iomem *
   drivers/firmware/efi/mokvar-table.c:179:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *va @@
   drivers/firmware/efi/mokvar-table.c:179:17: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/firmware/efi/mokvar-table.c:179:17: sparse:     got void *va

vim +142 drivers/firmware/efi/mokvar-table.c

    77	
    78	/*
    79	 * efi_mokvar_table_init() - Early boot validation of EFI MOK config table
    80	 *
    81	 * If present, validate and compute the size of the EFI MOK variable
    82	 * configuration table. This table may be provided by an EFI boot loader
    83	 * as an alternative to ordinary EFI variables, due to platform-dependent
    84	 * limitations. The memory occupied by this table is marked as reserved.
    85	 *
    86	 * This routine must be called before efi_free_boot_services() in order
    87	 * to guarantee that it can mark the table as reserved.
    88	 *
    89	 * Implicit inputs:
    90	 * efi.mokvar_table:	Physical address of EFI MOK variable config table
    91	 *			or special value that indicates no such table.
    92	 *
    93	 * Implicit outputs:
    94	 * efi_mokvar_table_size: Computed size of EFI MOK variable config table.
    95	 *			The table is considered present and valid if this
    96	 *			is non-zero.
    97	 */
    98	void __init efi_mokvar_table_init(void)
    99	{
   100		efi_memory_desc_t md;
   101		u64 end_pa;
   102		void *va = NULL;
   103		size_t cur_offset = 0;
   104		size_t offset_limit;
   105		size_t map_size = 0;
   106		size_t map_size_needed = 0;
   107		size_t size;
   108		struct efi_mokvar_table_entry *mokvar_entry;
   109		int err = -EINVAL;
   110	
   111		if (!efi_enabled(EFI_MEMMAP))
   112			return;
   113	
   114		if (efi.mokvar_table == EFI_INVALID_TABLE_ADDR)
   115			return;
   116		/*
   117		 * The EFI MOK config table must fit within a single EFI memory
   118		 * descriptor range.
   119		 */
   120		err = efi_mem_desc_lookup(efi.mokvar_table, &md);
   121		if (err) {
   122			pr_warn("EFI MOKvar config table is not within the EFI memory map\n");
   123			return;
   124		}
   125		end_pa = efi_mem_desc_end(&md);
   126		if (efi.mokvar_table >= end_pa) {
   127			pr_err("EFI memory descriptor containing MOKvar config table is invalid\n");
   128			return;
   129		}
   130		offset_limit = end_pa - efi.mokvar_table;
   131		/*
   132		 * Validate the MOK config table. Since there is no table header
   133		 * from which we could get the total size of the MOK config table,
   134		 * we compute the total size as we validate each variably sized
   135		 * entry, remapping as necessary.
   136		 */
   137		while (cur_offset + sizeof(*mokvar_entry) <= offset_limit) {
   138			mokvar_entry = va + cur_offset;
   139			map_size_needed = cur_offset + sizeof(*mokvar_entry);
   140			if (map_size_needed > map_size) {
   141				if (va)
 > 142					early_memunmap(va, map_size);
   143				/*
   144				 * Map a little more than the fixed size entry
   145				 * header, anticipating some data. It's safe to
   146				 * do so as long as we stay within current memory
   147				 * descriptor.
   148				 */
   149				map_size = min(map_size_needed + 2*EFI_PAGE_SIZE,
   150					       offset_limit);
 > 151				va = early_memremap(efi.mokvar_table, map_size);
   152				if (!va) {
   153					pr_err("Failed to map EFI MOKvar config table pa=0x%lx, size=%zu.\n",
   154					       efi.mokvar_table, map_size);
   155					return;
   156				}
   157				mokvar_entry = va + cur_offset;
   158			}
   159	
   160			/* Check for last sentinel entry */
   161			if (mokvar_entry->name[0] == '\0') {
   162				if (mokvar_entry->data_size != 0)
   163					break;
   164				err = 0;
   165				break;
   166			}
   167	
   168			/* Sanity check that the name is null terminated */
   169			size = strnlen(mokvar_entry->name,
   170				       sizeof(mokvar_entry->name));
   171			if (size >= sizeof(mokvar_entry->name))
   172				break;
   173	
   174			/* Advance to the next entry */
   175			cur_offset = map_size_needed + mokvar_entry->data_size;
   176		}
   177	
   178		if (va)
   179			early_memunmap(va, map_size);
   180		if (err) {
   181			pr_err("EFI MOKvar config table is not valid\n");
   182			return;
   183		}
   184		efi_mem_reserve(efi.mokvar_table, map_size_needed);
   185		efi_mokvar_table_size = map_size_needed;
   186	}
   187	

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

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 61968 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Lenny Szubowicz <lszubowi@redhat.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
	Ard Biesheuvel <ardb@kernel.org>
Subject: drivers/firmware/efi/mokvar-table.c:142:33: sparse: sparse: incorrect type in argument 1 (different address spaces)
Date: Thu, 20 May 2021 05:53:04 +0800	[thread overview]
Message-ID: <202105200558.079JCXai-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 6543 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   c3d0e3fd41b7f0f5d5d5b6022ab7e813f04ea727
commit: 58c909022a5a56cd1d9e89c8c5461fd1f6a27bb5 efi: Support for MOK variable config table
date:   8 months ago
config: ia64-allmodconfig (attached as .config)
compiler: ia64-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.3-341-g8af24329-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=58c909022a5a56cd1d9e89c8c5461fd1f6a27bb5
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 58c909022a5a56cd1d9e89c8c5461fd1f6a27bb5
        # 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__' W=1 ARCH=ia64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> drivers/firmware/efi/mokvar-table.c:142:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *va @@
   drivers/firmware/efi/mokvar-table.c:142:33: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/firmware/efi/mokvar-table.c:142:33: sparse:     got void *va
>> drivers/firmware/efi/mokvar-table.c:151:28: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void *va @@     got void [noderef] __iomem * @@
   drivers/firmware/efi/mokvar-table.c:151:28: sparse:     expected void *va
   drivers/firmware/efi/mokvar-table.c:151:28: sparse:     got void [noderef] __iomem *
   drivers/firmware/efi/mokvar-table.c:179:17: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void volatile [noderef] __iomem *addr @@     got void *va @@
   drivers/firmware/efi/mokvar-table.c:179:17: sparse:     expected void volatile [noderef] __iomem *addr
   drivers/firmware/efi/mokvar-table.c:179:17: sparse:     got void *va

vim +142 drivers/firmware/efi/mokvar-table.c

    77	
    78	/*
    79	 * efi_mokvar_table_init() - Early boot validation of EFI MOK config table
    80	 *
    81	 * If present, validate and compute the size of the EFI MOK variable
    82	 * configuration table. This table may be provided by an EFI boot loader
    83	 * as an alternative to ordinary EFI variables, due to platform-dependent
    84	 * limitations. The memory occupied by this table is marked as reserved.
    85	 *
    86	 * This routine must be called before efi_free_boot_services() in order
    87	 * to guarantee that it can mark the table as reserved.
    88	 *
    89	 * Implicit inputs:
    90	 * efi.mokvar_table:	Physical address of EFI MOK variable config table
    91	 *			or special value that indicates no such table.
    92	 *
    93	 * Implicit outputs:
    94	 * efi_mokvar_table_size: Computed size of EFI MOK variable config table.
    95	 *			The table is considered present and valid if this
    96	 *			is non-zero.
    97	 */
    98	void __init efi_mokvar_table_init(void)
    99	{
   100		efi_memory_desc_t md;
   101		u64 end_pa;
   102		void *va = NULL;
   103		size_t cur_offset = 0;
   104		size_t offset_limit;
   105		size_t map_size = 0;
   106		size_t map_size_needed = 0;
   107		size_t size;
   108		struct efi_mokvar_table_entry *mokvar_entry;
   109		int err = -EINVAL;
   110	
   111		if (!efi_enabled(EFI_MEMMAP))
   112			return;
   113	
   114		if (efi.mokvar_table == EFI_INVALID_TABLE_ADDR)
   115			return;
   116		/*
   117		 * The EFI MOK config table must fit within a single EFI memory
   118		 * descriptor range.
   119		 */
   120		err = efi_mem_desc_lookup(efi.mokvar_table, &md);
   121		if (err) {
   122			pr_warn("EFI MOKvar config table is not within the EFI memory map\n");
   123			return;
   124		}
   125		end_pa = efi_mem_desc_end(&md);
   126		if (efi.mokvar_table >= end_pa) {
   127			pr_err("EFI memory descriptor containing MOKvar config table is invalid\n");
   128			return;
   129		}
   130		offset_limit = end_pa - efi.mokvar_table;
   131		/*
   132		 * Validate the MOK config table. Since there is no table header
   133		 * from which we could get the total size of the MOK config table,
   134		 * we compute the total size as we validate each variably sized
   135		 * entry, remapping as necessary.
   136		 */
   137		while (cur_offset + sizeof(*mokvar_entry) <= offset_limit) {
   138			mokvar_entry = va + cur_offset;
   139			map_size_needed = cur_offset + sizeof(*mokvar_entry);
   140			if (map_size_needed > map_size) {
   141				if (va)
 > 142					early_memunmap(va, map_size);
   143				/*
   144				 * Map a little more than the fixed size entry
   145				 * header, anticipating some data. It's safe to
   146				 * do so as long as we stay within current memory
   147				 * descriptor.
   148				 */
   149				map_size = min(map_size_needed + 2*EFI_PAGE_SIZE,
   150					       offset_limit);
 > 151				va = early_memremap(efi.mokvar_table, map_size);
   152				if (!va) {
   153					pr_err("Failed to map EFI MOKvar config table pa=0x%lx, size=%zu.\n",
   154					       efi.mokvar_table, map_size);
   155					return;
   156				}
   157				mokvar_entry = va + cur_offset;
   158			}
   159	
   160			/* Check for last sentinel entry */
   161			if (mokvar_entry->name[0] == '\0') {
   162				if (mokvar_entry->data_size != 0)
   163					break;
   164				err = 0;
   165				break;
   166			}
   167	
   168			/* Sanity check that the name is null terminated */
   169			size = strnlen(mokvar_entry->name,
   170				       sizeof(mokvar_entry->name));
   171			if (size >= sizeof(mokvar_entry->name))
   172				break;
   173	
   174			/* Advance to the next entry */
   175			cur_offset = map_size_needed + mokvar_entry->data_size;
   176		}
   177	
   178		if (va)
   179			early_memunmap(va, map_size);
   180		if (err) {
   181			pr_err("EFI MOKvar config table is not valid\n");
   182			return;
   183		}
   184		efi_mem_reserve(efi.mokvar_table, map_size_needed);
   185		efi_mokvar_table_size = map_size_needed;
   186	}
   187	

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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 61968 bytes --]

             reply	other threads:[~2021-05-19 21:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19 21:53 kernel test robot [this message]
2021-05-19 21:53 ` drivers/firmware/efi/mokvar-table.c:142:33: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202105200558.079JCXai-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild-all@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.