All of lore.kernel.org
 help / color / mirror / Atom feed
* [joro:sev-es-kexec 7/12] arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-07-08  5:01 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-07-08  5:01 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: kbuild-all, linux-kernel

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git sev-es-kexec
head:   3467dc3cdbe65c619cd9b5c8db47da63b0655300
commit: 2740e3cdcb62ce9ce27839885b033c3d1f647710 [7/12] x86/sev: Setup code to park APs in the AP Jump Table
config: x86_64-randconfig-s021-20210702 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git/commit/?id=2740e3cdcb62ce9ce27839885b033c3d1f647710
        git remote add joro https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git
        git fetch --no-tags joro sev-es-kexec
        git checkout 2740e3cdcb62ce9ce27839885b033c3d1f647710
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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 >>)
>> arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *base @@     got unsigned short [noderef] [usertype] __iomem *[assigned] jump_table @@
   arch/x86/kernel/sev.c:841:41: sparse:     expected void *base
   arch/x86/kernel/sev.c:841:41: sparse:     got unsigned short [noderef] [usertype] __iomem *[assigned] jump_table
>> arch/x86/kernel/sev.c:834:32: sparse: sparse: dereference of noderef expression
   arch/x86/kernel/sev.c:835:32: sparse: sparse: dereference of noderef expression

vim +841 arch/x86/kernel/sev.c

   783	
   784	/*
   785	 * This function sets up the AP Jump Table blob which contains code which runs
   786	 * in 16-bit protected mode to park an AP. After the AP is woken up again the
   787	 * code will disable protected mode and jump to the reset vector which is also
   788	 * stored in the AP Jump Table.
   789	 *
   790	 * The Jump Table is a safe place to park an AP, because it is owned by the
   791	 * BIOS and writable by the OS. Putting the code in kernel memory would break
   792	 * with kexec, because by the time th APs wake up the memory is owned by
   793	 * the new kernel, and possibly already overwritten.
   794	 *
   795	 * Kexec is also the reason this function is called as an init-call after SMP
   796	 * bringup. Only after all CPUs are up there is a guarantee that no AP is still
   797	 * parked in AP jump-table code.
   798	 */
   799	static int __init sev_es_setup_ap_jump_table_blob(void)
   800	{
   801		size_t blob_size = rm_ap_jump_table_blob_end - rm_ap_jump_table_blob;
   802		u16 startup_cs, startup_ip;
   803		u16 __iomem *jump_table;
   804		phys_addr_t pa;
   805	
   806		if (!sev_es_active())
   807			return 0;
   808	
   809		if (sev_get_ghcb_proto_ver() < 2) {
   810			pr_info("AP Jump Table parking requires at least GHCB protocol version 2\n");
   811			return 0;
   812		}
   813	
   814		pa = get_jump_table_addr();
   815	
   816		/* Overflow and size checks for untrusted Jump Table address */
   817		if (pa + PAGE_SIZE < pa || pa + PAGE_SIZE > SZ_4G) {
   818			pr_info("AP Jump Table is above 4GB - not enabling AP Jump Table parking\n");
   819			return 0;
   820		}
   821	
   822		/* On UP guests there is no jump table so this is not a failure */
   823		if (!pa)
   824			return 0;
   825	
   826		jump_table = ioremap_encrypted(pa, PAGE_SIZE);
   827		if (WARN_ON(!jump_table))
   828			return -EINVAL;
   829	
   830		/*
   831		 * Safe reset vector to restore it later because the blob will
   832		 * overwrite it.
   833		 */
 > 834		startup_ip = jump_table[0];
   835		startup_cs = jump_table[1];
   836	
   837		/* Install AP Jump Table Blob with real mode AP parking code */
   838		memcpy_toio(jump_table, rm_ap_jump_table_blob, blob_size);
   839	
   840		/* Setup AP Jumptable GDT */
 > 841		sev_es_setup_ap_jump_table_data(jump_table, (u32)pa);
   842	
   843		writew(startup_ip, &jump_table[0]);
   844		writew(startup_cs, &jump_table[1]);
   845	
   846		iounmap(jump_table);
   847	
   848		pr_info("AP Jump Table Blob successfully set up\n");
   849	
   850		/* Mark AP Jump Table blob as available */
   851		sev_ap_jumptable_blob_installed = true;
   852	
   853		return 0;
   854	}
   855	core_initcall(sev_es_setup_ap_jump_table_blob);
   856	

---
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: 41421 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [joro:sev-es-kexec 7/12] arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2021-07-08  5:01 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-07-08  5:01 UTC (permalink / raw)
  To: kbuild-all

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git sev-es-kexec
head:   3467dc3cdbe65c619cd9b5c8db47da63b0655300
commit: 2740e3cdcb62ce9ce27839885b033c3d1f647710 [7/12] x86/sev: Setup code to park APs in the AP Jump Table
config: x86_64-randconfig-s021-20210702 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.3-341-g8af24329-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git/commit/?id=2740e3cdcb62ce9ce27839885b033c3d1f647710
        git remote add joro https://git.kernel.org/pub/scm/linux/kernel/git/joro/linux.git
        git fetch --no-tags joro sev-es-kexec
        git checkout 2740e3cdcb62ce9ce27839885b033c3d1f647710
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

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 >>)
>> arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void *base @@     got unsigned short [noderef] [usertype] __iomem *[assigned] jump_table @@
   arch/x86/kernel/sev.c:841:41: sparse:     expected void *base
   arch/x86/kernel/sev.c:841:41: sparse:     got unsigned short [noderef] [usertype] __iomem *[assigned] jump_table
>> arch/x86/kernel/sev.c:834:32: sparse: sparse: dereference of noderef expression
   arch/x86/kernel/sev.c:835:32: sparse: sparse: dereference of noderef expression

vim +841 arch/x86/kernel/sev.c

   783	
   784	/*
   785	 * This function sets up the AP Jump Table blob which contains code which runs
   786	 * in 16-bit protected mode to park an AP. After the AP is woken up again the
   787	 * code will disable protected mode and jump to the reset vector which is also
   788	 * stored in the AP Jump Table.
   789	 *
   790	 * The Jump Table is a safe place to park an AP, because it is owned by the
   791	 * BIOS and writable by the OS. Putting the code in kernel memory would break
   792	 * with kexec, because by the time th APs wake up the memory is owned by
   793	 * the new kernel, and possibly already overwritten.
   794	 *
   795	 * Kexec is also the reason this function is called as an init-call after SMP
   796	 * bringup. Only after all CPUs are up there is a guarantee that no AP is still
   797	 * parked in AP jump-table code.
   798	 */
   799	static int __init sev_es_setup_ap_jump_table_blob(void)
   800	{
   801		size_t blob_size = rm_ap_jump_table_blob_end - rm_ap_jump_table_blob;
   802		u16 startup_cs, startup_ip;
   803		u16 __iomem *jump_table;
   804		phys_addr_t pa;
   805	
   806		if (!sev_es_active())
   807			return 0;
   808	
   809		if (sev_get_ghcb_proto_ver() < 2) {
   810			pr_info("AP Jump Table parking requires@least GHCB protocol version 2\n");
   811			return 0;
   812		}
   813	
   814		pa = get_jump_table_addr();
   815	
   816		/* Overflow and size checks for untrusted Jump Table address */
   817		if (pa + PAGE_SIZE < pa || pa + PAGE_SIZE > SZ_4G) {
   818			pr_info("AP Jump Table is above 4GB - not enabling AP Jump Table parking\n");
   819			return 0;
   820		}
   821	
   822		/* On UP guests there is no jump table so this is not a failure */
   823		if (!pa)
   824			return 0;
   825	
   826		jump_table = ioremap_encrypted(pa, PAGE_SIZE);
   827		if (WARN_ON(!jump_table))
   828			return -EINVAL;
   829	
   830		/*
   831		 * Safe reset vector to restore it later because the blob will
   832		 * overwrite it.
   833		 */
 > 834		startup_ip = jump_table[0];
   835		startup_cs = jump_table[1];
   836	
   837		/* Install AP Jump Table Blob with real mode AP parking code */
   838		memcpy_toio(jump_table, rm_ap_jump_table_blob, blob_size);
   839	
   840		/* Setup AP Jumptable GDT */
 > 841		sev_es_setup_ap_jump_table_data(jump_table, (u32)pa);
   842	
   843		writew(startup_ip, &jump_table[0]);
   844		writew(startup_cs, &jump_table[1]);
   845	
   846		iounmap(jump_table);
   847	
   848		pr_info("AP Jump Table Blob successfully set up\n");
   849	
   850		/* Mark AP Jump Table blob as available */
   851		sev_ap_jumptable_blob_installed = true;
   852	
   853		return 0;
   854	}
   855	core_initcall(sev_es_setup_ap_jump_table_blob);
   856	

---
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: 41421 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-08  5:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08  5:01 [joro:sev-es-kexec 7/12] arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
2021-07-08  5:01 ` kernel test robot

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.