Re: [PATCH 3/4] intel_idle: Add support for using intel_idle in a VM guest using just hlt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 17, 2023 at 10:34 AM Xiaoyao Li <xiaoyao.li@xxxxxxxxx> wrote:
>
> + KVM maillist.
>
> On 6/5/2023 11:47 PM, arjan@xxxxxxxxxxxxxxx wrote:
> ...
> >
> > +static int __init intel_idle_vminit(const struct x86_cpu_id *id)
> > +{
> > +     int retval;
> > +
> > +     cpuidle_state_table = vmguest_cstates;
> > +
> > +     icpu = (const struct idle_cpu *)id->driver_data;
> > +
> > +     pr_debug("v" INTEL_IDLE_VERSION " model 0x%X\n",
> > +              boot_cpu_data.x86_model);
> > +
> > +     intel_idle_cpuidle_devices = alloc_percpu(struct cpuidle_device);
> > +     if (!intel_idle_cpuidle_devices)
> > +             return -ENOMEM;
> > +
> > +     intel_idle_cpuidle_driver_init(&intel_idle_driver);
> > +
> > +     retval = cpuidle_register_driver(&intel_idle_driver);
> > +     if (retval) {
> > +             struct cpuidle_driver *drv = cpuidle_get_driver();
> > +             printk(KERN_DEBUG pr_fmt("intel_idle yielding to %s\n"),
> > +                    drv ? drv->name : "none");
> > +             goto init_driver_fail;
> > +     }
> > +
> > +     retval = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "idle/intel:online",
> > +                                intel_idle_cpu_online, NULL);
> > +     if (retval < 0)
> > +             goto hp_setup_fail;
> > +
> > +     return 0;
> > +hp_setup_fail:
> > +     intel_idle_cpuidle_devices_uninit();
> > +     cpuidle_unregister_driver(&intel_idle_driver);
> > +init_driver_fail:
> > +     free_percpu(intel_idle_cpuidle_devices);
> > +     return retval;
> > +}
> > +
> >   static int __init intel_idle_init(void)
> >   {
> >       const struct x86_cpu_id *id;
> > @@ -2074,6 +2195,8 @@ static int __init intel_idle_init(void)
> >       id = x86_match_cpu(intel_idle_ids);
> >       if (id) {
> >               if (!boot_cpu_has(X86_FEATURE_MWAIT)) {
> > +                     if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
> > +                             return intel_idle_vminit(id);
>
> It leads to below MSR access error on SPR.
>
> [    4.158636] unchecked MSR access error: RDMSR from 0xe2 at rIP:
> 0xffffffffbcaeebed (intel_idle_init_cstates_icpu.constprop.0+0x2dd/0x5a0)
> [    4.174991] Call Trace:
> [    4.179611]  <TASK>
> [    4.183610]  ? ex_handler_msr+0x11e/0x150
> [    4.190624]  ? fixup_exception+0x17e/0x3c0
> [    4.197648]  ? gp_try_fixup_and_notify+0x1d/0xc0
> [    4.205579]  ? exc_general_protection+0x1bb/0x410
> [    4.213620]  ? asm_exc_general_protection+0x26/0x30
> [    4.221624]  ? __pfx_intel_idle_init+0x10/0x10
> [    4.228588]  ? intel_idle_init_cstates_icpu.constprop.0+0x2dd/0x5a0
> [    4.238632]  ? __pfx_intel_idle_init+0x10/0x10
> [    4.246632]  ? __pfx_intel_idle_init+0x10/0x10
> [    4.253616]  intel_idle_vminit.isra.0+0xf5/0x1d0
> [    4.261580]  ? __pfx_intel_idle_init+0x10/0x10
> [    4.269670]  ? __pfx_intel_idle_init+0x10/0x10
> [    4.274605]  do_one_initcall+0x50/0x230
> [    4.279873]  do_initcalls+0xb3/0x130
> [    4.286535]  kernel_init_freeable+0x255/0x310
> [    4.293688]  ? __pfx_kernel_init+0x10/0x10
> [    4.300630]  kernel_init+0x1a/0x1c0
> [    4.305681]  ret_from_fork+0x29/0x50
> [    4.312700]  </TASK>
>
> On Intel SPR, the call site is
>
> intel_idle_vminit()
>    -> intel_idle_cpuidle_driver_init()
>      -> intel_idle_init_cstates_icpu()
>        -> spr_idle_state_table_update()
>          -> rdmsrl(MSR_PKG_CST_CONFIG_CONTROL, msr);
>
> However, current KVM doesn't provide emulation for
> MSR_PKG_CST_CONFIG_CONTROL. It leads to #GP on accessing.
>
> >                       pr_debug("Please enable MWAIT in BIOS SETUP\n");
> >                       return -ENODEV;
> >               }

Well, I'm waiting for a fix from Arjan, thanks!



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux