tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 4c388a8e740d3235a194f330c8ef327deef710f6 commit: faff44069ff538ccdfef187c4d7ec83d22dfb3a4 x86/hyperv: Add Write/Read MSR registers via ghcb page date: 3 weeks ago config: i386-randconfig-s002-20211109 (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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=faff44069ff538ccdfef187c4d7ec83d22dfb3a4 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout faff44069ff538ccdfef187c4d7ec83d22dfb3a4 # save the attached .config to linux build tree make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot sparse warnings: (new ones prefixed by >>) >> arch/x86/hyperv/hv_init.c:70:30: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got union hv_ghcb [noderef] __percpu ** @@ arch/x86/hyperv/hv_init.c:70:30: sparse: expected void const [noderef] __percpu *__vpp_verify arch/x86/hyperv/hv_init.c:70:30: sparse: got union hv_ghcb [noderef] __percpu ** arch/x86/hyperv/hv_init.c:214:36: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got union hv_ghcb [noderef] __percpu ** @@ arch/x86/hyperv/hv_init.c:214:36: sparse: expected void const [noderef] __percpu *__vpp_verify arch/x86/hyperv/hv_init.c:214:36: sparse: got union hv_ghcb [noderef] __percpu ** arch/x86/hyperv/hv_init.c:363:24: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const [noderef] __percpu *__vpp_verify @@ got void [noderef] __percpu ** @@ arch/x86/hyperv/hv_init.c:363:24: sparse: expected void const [noderef] __percpu *__vpp_verify arch/x86/hyperv/hv_init.c:363:24: sparse: got void [noderef] __percpu ** arch/x86/hyperv/hv_init.c:363:21: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected struct hv_get_partition_id *output_page @@ got void [noderef] __percpu * @@ arch/x86/hyperv/hv_init.c:363:21: sparse: expected struct hv_get_partition_id *output_page arch/x86/hyperv/hv_init.c:363:21: sparse: got void [noderef] __percpu * >> arch/x86/hyperv/hv_init.c:409:28: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected union hv_ghcb [noderef] __percpu **[addressable] [toplevel] hv_ghcb_pg @@ got union hv_ghcb *[noderef] __percpu * @@ arch/x86/hyperv/hv_init.c:409:28: sparse: expected union hv_ghcb [noderef] __percpu **[addressable] [toplevel] hv_ghcb_pg arch/x86/hyperv/hv_init.c:409:28: sparse: got union hv_ghcb *[noderef] __percpu * >> arch/x86/hyperv/hv_init.c:510:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void [noderef] __percpu *__pdata @@ got union hv_ghcb [noderef] __percpu **[addressable] [toplevel] hv_ghcb_pg @@ arch/x86/hyperv/hv_init.c:510:21: sparse: expected void [noderef] __percpu *__pdata arch/x86/hyperv/hv_init.c:510:21: sparse: got union hv_ghcb [noderef] __percpu **[addressable] [toplevel] hv_ghcb_pg vim +70 arch/x86/hyperv/hv_init.c a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 47 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 48 static int hyperv_init_ghcb(void) 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 49 { 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 50 u64 ghcb_gpa; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 51 void *ghcb_va; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 52 void **ghcb_base; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 53 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 54 if (!hv_isolation_type_snp()) 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 55 return 0; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 56 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 57 if (!hv_ghcb_pg) 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 58 return -EINVAL; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 59 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 60 /* 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 61 * GHCB page is allocated by paravisor. The address 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 62 * returned by MSR_AMD64_SEV_ES_GHCB is above shared 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 63 * memory boundary and map it here. 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 64 */ 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 65 rdmsrl(MSR_AMD64_SEV_ES_GHCB, ghcb_gpa); 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 66 ghcb_va = memremap(ghcb_gpa, HV_HYP_PAGE_SIZE, MEMREMAP_WB); 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 67 if (!ghcb_va) 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 68 return -ENOMEM; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 69 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 @70 ghcb_base = (void **)this_cpu_ptr(hv_ghcb_pg); 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 71 *ghcb_base = ghcb_va; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 72 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 73 return 0; 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 74 } 0cc4f6d9f0b9f20 Tianyu Lan 2021-10-25 75 :::::: The code at line 70 was first introduced by commit :::::: 0cc4f6d9f0b9f20f3f1e1149bdb6737c0b4e134a x86/hyperv: Initialize GHCB page in Isolation VM :::::: TO: Tianyu Lan :::::: CC: Wei Liu --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org