All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild-all@lists.01.org
Subject: [joro:sev-es-kexec 7/12] arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces)
Date: Thu, 08 Jul 2021 13:01:41 +0800	[thread overview]
Message-ID: <202107081335.DMkFfvlF-lkp@intel.com> (raw)

[-- 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 --]

WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: Joerg Roedel <jroedel@suse.de>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org
Subject: [joro:sev-es-kexec 7/12] arch/x86/kernel/sev.c:841:41: sparse: sparse: incorrect type in argument 1 (different address spaces)
Date: Thu, 8 Jul 2021 13:01:41 +0800	[thread overview]
Message-ID: <202107081335.DMkFfvlF-lkp@intel.com> (raw)

[-- 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 --]

             reply	other threads:[~2021-07-08  5:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08  5:01 kernel test robot [this message]
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

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=202107081335.DMkFfvlF-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.