tree: https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git hyperv-fixes head: ec631a371598482cc9d136b9f29345bc6d6b9608 commit: f8162cff19f12862f55c146ff221a117fac152eb [1/2] x86/hyperv: Remove BUG_ON() for kmap_local_page() config: x86_64-rhel-8.3-syz compiler: gcc-11 (Debian 11.3.0-8) 11.3.0 reproduce (this is a W=1 build): # https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git/commit/?id=f8162cff19f12862f55c146ff221a117fac152eb git remote add hyperv https://git.kernel.org/pub/scm/linux/kernel/git/hyperv/linux.git git fetch --no-tags hyperv hyperv-fixes git checkout f8162cff19f12862f55c146ff221a117fac152eb # save the config file mkdir build_dir && cp config build_dir/.config make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/hyperv/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot All warnings (new ones prefixed by >>): arch/x86/hyperv/hv_init.c: In function 'hyperv_init': >> arch/x86/hyperv/hv_init.c:447:29: warning: unused variable 'dst' [-Wunused-variable] 447 | void *src, *dst; | ^~~ vim +/dst +447 arch/x86/hyperv/hv_init.c 99a0f46af6a771 Wei Liu 2021-02-03 380 8730046c1498e8 K. Y. Srinivasan 2017-01-18 381 /* 8730046c1498e8 K. Y. Srinivasan 2017-01-18 382 * This function is to be invoked early in the boot sequence after the 8730046c1498e8 K. Y. Srinivasan 2017-01-18 383 * hypervisor has been detected. 8730046c1498e8 K. Y. Srinivasan 2017-01-18 384 * 8730046c1498e8 K. Y. Srinivasan 2017-01-18 385 * 1. Setup the hypercall page. 63ed4e0c67df33 K. Y. Srinivasan 2017-01-19 386 * 2. Register Hyper-V specific clocksource. 6b48cb5f8347bc K. Y. Srinivasan 2018-05-16 387 * 3. Setup Hyper-V specific APIC entry points. 8730046c1498e8 K. Y. Srinivasan 2017-01-18 388 */ 6b48cb5f8347bc K. Y. Srinivasan 2018-05-16 389 void __init hyperv_init(void) 8730046c1498e8 K. Y. Srinivasan 2017-01-18 390 { f3e613e72f6622 Sean Christopherson 2021-11-04 391 u64 guest_id; 8730046c1498e8 K. Y. Srinivasan 2017-01-18 392 union hv_x64_msr_hypercall_contents hypercall_msr; afca4d95dd7d79 Michael Kelley 2021-07-14 393 int cpuhp; 8730046c1498e8 K. Y. Srinivasan 2017-01-18 394 03b2a320b19f14 Juergen Gross 2017-11-09 395 if (x86_hyper_type != X86_HYPER_MS_HYPERV) 8730046c1498e8 K. Y. Srinivasan 2017-01-18 396 return; 8730046c1498e8 K. Y. Srinivasan 2017-01-18 397 afca4d95dd7d79 Michael Kelley 2021-07-14 398 if (hv_common_init()) 7415aea6072bab Vitaly Kuznetsov 2017-08-02 399 return; 7415aea6072bab Vitaly Kuznetsov 2017-08-02 400 a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 401 hv_vp_assist_page = kcalloc(num_possible_cpus(), a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 402 sizeof(*hv_vp_assist_page), GFP_KERNEL); a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 403 if (!hv_vp_assist_page) { a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 404 ms_hyperv.hints &= ~HV_X64_ENLIGHTENED_VMCS_RECOMMENDED; afca4d95dd7d79 Michael Kelley 2021-07-14 405 goto common_free; a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 406 } a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 407 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 408 if (hv_isolation_type_snp()) { 49d6a3c062a102 Tianyu Lan 2022-06-13 409 /* Negotiate GHCB Version. */ 49d6a3c062a102 Tianyu Lan 2022-06-13 410 if (!hv_ghcb_negotiate_protocol()) 49d6a3c062a102 Tianyu Lan 2022-06-13 411 hv_ghcb_terminate(SEV_TERM_SET_GEN, 49d6a3c062a102 Tianyu Lan 2022-06-13 412 GHCB_SEV_ES_PROT_UNSUPPORTED); 49d6a3c062a102 Tianyu Lan 2022-06-13 413 faff44069ff538 Tianyu Lan 2021-10-25 414 hv_ghcb_pg = alloc_percpu(union hv_ghcb *); 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 415 if (!hv_ghcb_pg) 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 416 goto free_vp_assist_page; 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 417 } 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 418 a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 419 cpuhp = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv_init:online", a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 420 hv_cpu_init, hv_cpu_die); a46d15cc1ae5af Vitaly Kuznetsov 2018-03-20 421 if (cpuhp < 0) 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 422 goto free_ghcb_page; 7415aea6072bab Vitaly Kuznetsov 2017-08-02 423 8730046c1498e8 K. Y. Srinivasan 2017-01-18 424 /* 8730046c1498e8 K. Y. Srinivasan 2017-01-18 425 * Setup the hypercall page and enable hypercalls. 8730046c1498e8 K. Y. Srinivasan 2017-01-18 426 * 1. Register the guest ID 8730046c1498e8 K. Y. Srinivasan 2017-01-18 427 * 2. Enable the hypercall and register the hypercall page 8730046c1498e8 K. Y. Srinivasan 2017-01-18 428 */ d5ebde1e2b4615 Li kunyu 2022-09-28 429 guest_id = hv_generate_guest_id(LINUX_VERSION_CODE); 8730046c1498e8 K. Y. Srinivasan 2017-01-18 430 wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id); 8730046c1498e8 K. Y. Srinivasan 2017-01-18 431 faff44069ff538 Tianyu Lan 2021-10-25 432 /* Hyper-V requires to write guest os id via ghcb in SNP IVM. */ faff44069ff538 Tianyu Lan 2021-10-25 433 hv_ghcb_msr_write(HV_X64_MSR_GUEST_OS_ID, guest_id); faff44069ff538 Tianyu Lan 2021-10-25 434 800e26b81311dc Christoph Hellwig 2020-06-25 435 hv_hypercall_pg = __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START, 800e26b81311dc Christoph Hellwig 2020-06-25 436 VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_ROX, a3a66c3822e036 Christoph Hellwig 2020-07-03 437 VM_FLUSH_RESET_PERMS, NUMA_NO_NODE, a3a66c3822e036 Christoph Hellwig 2020-07-03 438 __builtin_return_address(0)); 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 439 if (hv_hypercall_pg == NULL) 0cc4f6d9f0b9f2 Tianyu Lan 2021-10-25 440 goto clean_guest_os_id; 8730046c1498e8 K. Y. Srinivasan 2017-01-18 441 8730046c1498e8 K. Y. Srinivasan 2017-01-18 442 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); 8730046c1498e8 K. Y. Srinivasan 2017-01-18 443 hypercall_msr.enable = 1; 80f73c9f7468b1 Wei Liu 2021-02-03 444 80f73c9f7468b1 Wei Liu 2021-02-03 445 if (hv_root_partition) { 80f73c9f7468b1 Wei Liu 2021-02-03 446 struct page *pg; 80f73c9f7468b1 Wei Liu 2021-02-03 @447 void *src, *dst; 80f73c9f7468b1 Wei Liu 2021-02-03 448 80f73c9f7468b1 Wei Liu 2021-02-03 449 /* 80f73c9f7468b1 Wei Liu 2021-02-03 450 * For the root partition, the hypervisor will set up its 80f73c9f7468b1 Wei Liu 2021-02-03 451 * hypercall page. The hypervisor guarantees it will not show 80f73c9f7468b1 Wei Liu 2021-02-03 452 * up in the root's address space. The root can't change the 80f73c9f7468b1 Wei Liu 2021-02-03 453 * location of the hypercall page. 80f73c9f7468b1 Wei Liu 2021-02-03 454 * 80f73c9f7468b1 Wei Liu 2021-02-03 455 * Order is important here. We must enable the hypercall page 80f73c9f7468b1 Wei Liu 2021-02-03 456 * so it is populated with code, then copy the code to an 80f73c9f7468b1 Wei Liu 2021-02-03 457 * executable page. 80f73c9f7468b1 Wei Liu 2021-02-03 458 */ 80f73c9f7468b1 Wei Liu 2021-02-03 459 wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); 80f73c9f7468b1 Wei Liu 2021-02-03 460 80f73c9f7468b1 Wei Liu 2021-02-03 461 pg = vmalloc_to_page(hv_hypercall_pg); 80f73c9f7468b1 Wei Liu 2021-02-03 462 src = memremap(hypercall_msr.guest_physical_address << PAGE_SHIFT, PAGE_SIZE, 80f73c9f7468b1 Wei Liu 2021-02-03 463 MEMREMAP_WB); f8162cff19f128 Zhao Liu 2022-10-20 464 BUG_ON(!src); f8162cff19f128 Zhao Liu 2022-10-20 465 memcpy_to_page(pg, 0, src, HV_HYP_PAGE_SIZE); 80f73c9f7468b1 Wei Liu 2021-02-03 466 memunmap(src); 80f73c9f7468b1 Wei Liu 2021-02-03 467 } else { fc53662f13b889 Vitaly Kuznetsov 2017-08-02 468 hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg); 8730046c1498e8 K. Y. Srinivasan 2017-01-18 469 wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); 80f73c9f7468b1 Wei Liu 2021-02-03 470 } 63ed4e0c67df33 K. Y. Srinivasan 2017-01-19 471 4df4cb9e99f83b Michael Kelley 2019-11-13 472 /* fff7b5e6ee63c5 Dexuan Cui 2021-01-16 473 * hyperv_init() is called before LAPIC is initialized: see fff7b5e6ee63c5 Dexuan Cui 2021-01-16 474 * apic_intr_mode_init() -> x86_platform.apic_post_init() and fff7b5e6ee63c5 Dexuan Cui 2021-01-16 475 * apic_bsp_setup() -> setup_local_APIC(). The direct-mode STIMER fff7b5e6ee63c5 Dexuan Cui 2021-01-16 476 * depends on LAPIC, so hv_stimer_alloc() should be called from fff7b5e6ee63c5 Dexuan Cui 2021-01-16 477 * x86_init.timers.setup_percpu_clockev. 4df4cb9e99f83b Michael Kelley 2019-11-13 478 */ fff7b5e6ee63c5 Dexuan Cui 2021-01-16 479 old_setup_percpu_clockev = x86_init.timers.setup_percpu_clockev; fff7b5e6ee63c5 Dexuan Cui 2021-01-16 480 x86_init.timers.setup_percpu_clockev = hv_stimer_setup_percpu_clockev; 4df4cb9e99f83b Michael Kelley 2019-11-13 481 6b48cb5f8347bc K. Y. Srinivasan 2018-05-16 482 hv_apic_init(); 6b48cb5f8347bc K. Y. Srinivasan 2018-05-16 483 2f285f46240d67 Dexuan Cui 2018-09-18 484 x86_init.pci.arch_init = hv_pci_init; 2f285f46240d67 Dexuan Cui 2018-09-18 485 05bd330a7fd887 Dexuan Cui 2020-01-06 486 register_syscore_ops(&hv_syscore_ops); 05bd330a7fd887 Dexuan Cui 2020-01-06 487 dfe94d4086e40e Dexuan Cui 2020-12-21 488 hyperv_init_cpuhp = cpuhp; 99a0f46af6a771 Wei Liu 2021-02-03 489 99a0f46af6a771 Wei Liu 2021-02-03 490 if (cpuid_ebx(HYPERV_CPUID_FEATURES) & HV_ACCESS_PARTITION_ID) 99a0f46af6a771 Wei Liu 2021-02-03 491 hv_get_partition_id(); 99a0f46af6a771 Wei Liu 2021-02-03 492 99a0f46af6a771 Wei Liu 2021-02-03 493 BUG_ON(hv_root_partition && hv_current_partition_id == ~0ull); 99a0f46af6a771 Wei Liu 2021-02-03 494 :::::: The code at line 447 was first introduced by commit :::::: 80f73c9f7468b15484e3ee4a29870fc9fa0419cc x86/hyperv: handling hypercall page setup for root :::::: TO: Wei Liu :::::: CC: Wei Liu -- 0-DAY CI Kernel Test Service https://01.org/lkp