From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH v4 08/17] x86/hyperv: handling hypercall page setup for root
Date: Thu, 07 Jan 2021 05:54:40 +0800 [thread overview]
Message-ID: <202101070534.dipZ86Ps-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 12714 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210106203350.14568-9-wei.liu@kernel.org>
References: <20210106203350.14568-9-wei.liu@kernel.org>
TO: Wei Liu <wei.liu@kernel.org>
TO: "Linux on Hyper-V List" <linux-hyperv@vger.kernel.org>
CC: virtualization(a)lists.linux-foundation.org
CC: Linux Kernel List <linux-kernel@vger.kernel.org>
CC: Michael Kelley <mikelley@microsoft.com>
CC: Vineeth Pillai <viremana@linux.microsoft.com>
CC: Sunil Muthuswamy <sunilmut@microsoft.com>
CC: Nuno Das Neves <nunodasneves@linux.microsoft.com>
CC: Wei Liu <wei.liu@kernel.org>
CC: "Lillian Grassin-Drake" <ligrassi@microsoft.com>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
Hi Wei,
I love your patch! Perhaps something to improve:
[auto build test WARNING on e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62]
url: https://github.com/0day-ci/linux/commits/Wei-Liu/Introducing-Linux-root-partition-support-for-Microsoft-Hypervisor/20210107-044149
base: e71ba9452f0b5b2e8dc8aa5445198cd9214a6a62
:::::: branch date: 73 minutes ago
:::::: commit date: 73 minutes ago
config: i386-randconfig-m021-20210106 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
smatch warnings:
arch/x86/hyperv/hv_init.c:459 hyperv_init() warn: should 'hypercall_msr.guest_physical_address << 12' be a 64 bit type?
vim +459 arch/x86/hyperv/hv_init.c
3512592735f2a40 Wei Liu 2021-01-06 359
8730046c1498e8f K. Y. Srinivasan 2017-01-18 360 /*
8730046c1498e8f K. Y. Srinivasan 2017-01-18 361 * This function is to be invoked early in the boot sequence after the
8730046c1498e8f K. Y. Srinivasan 2017-01-18 362 * hypervisor has been detected.
8730046c1498e8f K. Y. Srinivasan 2017-01-18 363 *
8730046c1498e8f K. Y. Srinivasan 2017-01-18 364 * 1. Setup the hypercall page.
63ed4e0c67df332 K. Y. Srinivasan 2017-01-19 365 * 2. Register Hyper-V specific clocksource.
6b48cb5f8347bc0 K. Y. Srinivasan 2018-05-16 366 * 3. Setup Hyper-V specific APIC entry points.
8730046c1498e8f K. Y. Srinivasan 2017-01-18 367 */
6b48cb5f8347bc0 K. Y. Srinivasan 2018-05-16 368 void __init hyperv_init(void)
8730046c1498e8f K. Y. Srinivasan 2017-01-18 369 {
89a8f6d4904c8cf Vitaly Kuznetsov 2018-01-24 370 u64 guest_id, required_msrs;
8730046c1498e8f K. Y. Srinivasan 2017-01-18 371 union hv_x64_msr_hypercall_contents hypercall_msr;
1268ed0c474a5c8 K. Y. Srinivasan 2018-07-03 372 int cpuhp, i;
8730046c1498e8f K. Y. Srinivasan 2017-01-18 373
03b2a320b19f142 Juergen Gross 2017-11-09 374 if (x86_hyper_type != X86_HYPER_MS_HYPERV)
8730046c1498e8f K. Y. Srinivasan 2017-01-18 375 return;
8730046c1498e8f K. Y. Srinivasan 2017-01-18 376
89a8f6d4904c8cf Vitaly Kuznetsov 2018-01-24 377 /* Absolutely required MSRs */
dfc53baae3c6a16 Joseph Salisbury 2020-09-26 378 required_msrs = HV_MSR_HYPERCALL_AVAILABLE |
dfc53baae3c6a16 Joseph Salisbury 2020-09-26 379 HV_MSR_VP_INDEX_AVAILABLE;
89a8f6d4904c8cf Vitaly Kuznetsov 2018-01-24 380
89a8f6d4904c8cf Vitaly Kuznetsov 2018-01-24 381 if ((ms_hyperv.features & required_msrs) != required_msrs)
89a8f6d4904c8cf Vitaly Kuznetsov 2018-01-24 382 return;
89a8f6d4904c8cf Vitaly Kuznetsov 2018-01-24 383
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 384 /*
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 385 * Allocate the per-CPU state for the hypercall input arg.
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 386 * If this allocation fails, we will not be able to setup
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 387 * (per-CPU) hypercall input page and thus this failure is
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 388 * fatal on Hyper-V.
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 389 */
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 390 hyperv_pcpu_input_arg = alloc_percpu(void *);
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 391
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 392 BUG_ON(hyperv_pcpu_input_arg == NULL);
68bb7bfb7985df2 K. Y. Srinivasan 2018-05-16 393
e07078586962c9c Wei Liu 2021-01-06 394 /* Allocate the per-CPU state for output arg for root */
e07078586962c9c Wei Liu 2021-01-06 395 if (hv_root_partition) {
e07078586962c9c Wei Liu 2021-01-06 396 hyperv_pcpu_output_arg = alloc_percpu(void *);
e07078586962c9c Wei Liu 2021-01-06 397 BUG_ON(hyperv_pcpu_output_arg == NULL);
e07078586962c9c Wei Liu 2021-01-06 398 }
e07078586962c9c Wei Liu 2021-01-06 399
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 400 /* Allocate percpu VP index */
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 401 hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index),
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 402 GFP_KERNEL);
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 403 if (!hv_vp_index)
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 404 return;
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 405
1268ed0c474a5c8 K. Y. Srinivasan 2018-07-03 406 for (i = 0; i < num_possible_cpus(); i++)
1268ed0c474a5c8 K. Y. Srinivasan 2018-07-03 407 hv_vp_index[i] = VP_INVAL;
1268ed0c474a5c8 K. Y. Srinivasan 2018-07-03 408
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 409 hv_vp_assist_page = kcalloc(num_possible_cpus(),
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 410 sizeof(*hv_vp_assist_page), GFP_KERNEL);
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 411 if (!hv_vp_assist_page) {
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 412 ms_hyperv.hints &= ~HV_X64_ENLIGHTENED_VMCS_RECOMMENDED;
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 413 goto free_vp_index;
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 414 }
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 415
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 416 cpuhp = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/hyperv_init:online",
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 417 hv_cpu_init, hv_cpu_die);
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 418 if (cpuhp < 0)
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 419 goto free_vp_assist_page;
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 420
8730046c1498e8f K. Y. Srinivasan 2017-01-18 421 /*
8730046c1498e8f K. Y. Srinivasan 2017-01-18 422 * Setup the hypercall page and enable hypercalls.
8730046c1498e8f K. Y. Srinivasan 2017-01-18 423 * 1. Register the guest ID
8730046c1498e8f K. Y. Srinivasan 2017-01-18 424 * 2. Enable the hypercall and register the hypercall page
8730046c1498e8f K. Y. Srinivasan 2017-01-18 425 */
8730046c1498e8f K. Y. Srinivasan 2017-01-18 426 guest_id = generate_guest_id(0, LINUX_VERSION_CODE, 0);
8730046c1498e8f K. Y. Srinivasan 2017-01-18 427 wrmsrl(HV_X64_MSR_GUEST_OS_ID, guest_id);
8730046c1498e8f K. Y. Srinivasan 2017-01-18 428
800e26b81311dcc Christoph Hellwig 2020-06-25 429 hv_hypercall_pg = __vmalloc_node_range(PAGE_SIZE, 1, VMALLOC_START,
800e26b81311dcc Christoph Hellwig 2020-06-25 430 VMALLOC_END, GFP_KERNEL, PAGE_KERNEL_ROX,
a3a66c3822e0369 Christoph Hellwig 2020-07-03 431 VM_FLUSH_RESET_PERMS, NUMA_NO_NODE,
a3a66c3822e0369 Christoph Hellwig 2020-07-03 432 __builtin_return_address(0));
fc53662f13b889a Vitaly Kuznetsov 2017-08-02 433 if (hv_hypercall_pg == NULL) {
8730046c1498e8f K. Y. Srinivasan 2017-01-18 434 wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 435 goto remove_cpuhp_state;
8730046c1498e8f K. Y. Srinivasan 2017-01-18 436 }
8730046c1498e8f K. Y. Srinivasan 2017-01-18 437
8730046c1498e8f K. Y. Srinivasan 2017-01-18 438 rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
8730046c1498e8f K. Y. Srinivasan 2017-01-18 439 hypercall_msr.enable = 1;
c65d5f8ff5b7794 Wei Liu 2021-01-06 440
c65d5f8ff5b7794 Wei Liu 2021-01-06 441 if (hv_root_partition) {
c65d5f8ff5b7794 Wei Liu 2021-01-06 442 struct page *pg;
c65d5f8ff5b7794 Wei Liu 2021-01-06 443 void *src, *dst;
c65d5f8ff5b7794 Wei Liu 2021-01-06 444
c65d5f8ff5b7794 Wei Liu 2021-01-06 445 /*
c65d5f8ff5b7794 Wei Liu 2021-01-06 446 * For the root partition, the hypervisor will set up its
c65d5f8ff5b7794 Wei Liu 2021-01-06 447 * hypercall page. The hypervisor guarantees it will not show
c65d5f8ff5b7794 Wei Liu 2021-01-06 448 * up in the root's address space. The root can't change the
c65d5f8ff5b7794 Wei Liu 2021-01-06 449 * location of the hypercall page.
c65d5f8ff5b7794 Wei Liu 2021-01-06 450 *
c65d5f8ff5b7794 Wei Liu 2021-01-06 451 * Order is important here. We must enable the hypercall page
c65d5f8ff5b7794 Wei Liu 2021-01-06 452 * so it is populated with code, then copy the code to an
c65d5f8ff5b7794 Wei Liu 2021-01-06 453 * executable page.
c65d5f8ff5b7794 Wei Liu 2021-01-06 454 */
c65d5f8ff5b7794 Wei Liu 2021-01-06 455 wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
c65d5f8ff5b7794 Wei Liu 2021-01-06 456
c65d5f8ff5b7794 Wei Liu 2021-01-06 457 pg = vmalloc_to_page(hv_hypercall_pg);
c65d5f8ff5b7794 Wei Liu 2021-01-06 458 dst = kmap(pg);
c65d5f8ff5b7794 Wei Liu 2021-01-06 @459 src = memremap(hypercall_msr.guest_physical_address << PAGE_SHIFT, PAGE_SIZE,
c65d5f8ff5b7794 Wei Liu 2021-01-06 460 MEMREMAP_WB);
c65d5f8ff5b7794 Wei Liu 2021-01-06 461 BUG_ON(!(src && dst));
c65d5f8ff5b7794 Wei Liu 2021-01-06 462 memcpy(dst, src, HV_HYP_PAGE_SIZE);
c65d5f8ff5b7794 Wei Liu 2021-01-06 463 memunmap(src);
c65d5f8ff5b7794 Wei Liu 2021-01-06 464 kunmap(pg);
c65d5f8ff5b7794 Wei Liu 2021-01-06 465 } else {
fc53662f13b889a Vitaly Kuznetsov 2017-08-02 466 hypercall_msr.guest_physical_address = vmalloc_to_pfn(hv_hypercall_pg);
8730046c1498e8f K. Y. Srinivasan 2017-01-18 467 wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
c65d5f8ff5b7794 Wei Liu 2021-01-06 468 }
63ed4e0c67df332 K. Y. Srinivasan 2017-01-19 469
4df4cb9e99f83b7 Michael Kelley 2019-11-13 470 /*
4df4cb9e99f83b7 Michael Kelley 2019-11-13 471 * Ignore any errors in setting up stimer clockevents
4df4cb9e99f83b7 Michael Kelley 2019-11-13 472 * as we can run with the LAPIC timer as a fallback.
4df4cb9e99f83b7 Michael Kelley 2019-11-13 473 */
4df4cb9e99f83b7 Michael Kelley 2019-11-13 474 (void)hv_stimer_alloc();
4df4cb9e99f83b7 Michael Kelley 2019-11-13 475
6b48cb5f8347bc0 K. Y. Srinivasan 2018-05-16 476 hv_apic_init();
6b48cb5f8347bc0 K. Y. Srinivasan 2018-05-16 477
2f285f46240d670 Dexuan Cui 2018-09-18 478 x86_init.pci.arch_init = hv_pci_init;
2f285f46240d670 Dexuan Cui 2018-09-18 479
05bd330a7fd8875 Dexuan Cui 2020-01-06 480 register_syscore_ops(&hv_syscore_ops);
05bd330a7fd8875 Dexuan Cui 2020-01-06 481
3512592735f2a40 Wei Liu 2021-01-06 482 if (cpuid_ebx(HYPERV_CPUID_FEATURES) & HV_ACCESS_PARTITION_ID)
3512592735f2a40 Wei Liu 2021-01-06 483 hv_get_partition_id();
3512592735f2a40 Wei Liu 2021-01-06 484
3512592735f2a40 Wei Liu 2021-01-06 485 BUG_ON(hv_root_partition && hv_current_partition_id == ~0ull);
3512592735f2a40 Wei Liu 2021-01-06 486
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 487 return;
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 488
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 489 remove_cpuhp_state:
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 490 cpuhp_remove_state(cpuhp);
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 491 free_vp_assist_page:
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 492 kfree(hv_vp_assist_page);
a46d15cc1ae5af9 Vitaly Kuznetsov 2018-03-20 493 hv_vp_assist_page = NULL;
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 494 free_vp_index:
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 495 kfree(hv_vp_index);
7415aea6072bab1 Vitaly Kuznetsov 2017-08-02 496 hv_vp_index = NULL;
8730046c1498e8f K. Y. Srinivasan 2017-01-18 497 }
6ab42a66d2cc10a K. Y. Srinivasan 2017-01-18 498
---
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: 29949 bytes --]
next reply other threads:[~2021-01-06 21:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-06 21:54 kernel test robot [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-01-06 20:33 [PATCH v4 00/17] Introducing Linux root partition support for Microsoft Hypervisor Wei Liu
2021-01-06 20:33 ` [PATCH v4 08/17] x86/hyperv: handling hypercall page setup for root Wei Liu
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=202101070534.dipZ86Ps-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@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.