From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Xiaoyao Li <xiaoyao.li@intel.com>
Cc: arjan@linux.intel.com, linux-pm@vger.kernel.org,
artem.bityutskiy@linux.intel.com, rafael@kernel.org,
kvm <kvm@vger.kernel.org>, Dan Wu <dan1.wu@intel.com>
Subject: Re: [PATCH 3/4] intel_idle: Add support for using intel_idle in a VM guest using just hlt
Date: Mon, 17 Jul 2023 14:58:26 +0200 [thread overview]
Message-ID: <CAJZ5v0gaZHpAri7LRcfpS2TyK_Bsjuxkw9cZUm_uGZAgiub4Jw@mail.gmail.com> (raw)
In-Reply-To: <5c7de6d5-7706-c4a5-7c41-146db1269aff@intel.com>
On Mon, Jul 17, 2023 at 10:34 AM Xiaoyao Li <xiaoyao.li@intel.com> wrote:
>
> + KVM maillist.
>
> On 6/5/2023 11:47 PM, arjan@linux.intel.com 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!
next prev parent reply other threads:[~2023-07-17 13:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-05 15:47 [PATCH 0/4 v2] Add support for running in VM guests to intel_idle arjan
2023-06-05 15:47 ` [PATCH 1/4] intel_idle: refactor state->enter manipulation into its own function arjan
2023-06-07 7:34 ` Zhang, Rui
2023-06-07 14:08 ` Arjan van de Ven
2023-06-05 15:47 ` [PATCH 2/4] intel_idle: clean up the (new) state_update_enter_method function arjan
2023-06-12 18:09 ` Rafael J. Wysocki
2023-06-05 15:47 ` [PATCH 3/4] intel_idle: Add support for using intel_idle in a VM guest using just hlt arjan
2023-06-12 18:05 ` Rafael J. Wysocki
2023-06-12 18:07 ` Arjan van de Ven
2023-06-15 17:46 ` Rafael J. Wysocki
2023-07-17 8:34 ` Xiaoyao Li
2023-07-17 12:58 ` Rafael J. Wysocki [this message]
2023-07-17 14:07 ` Arjan van de Ven
2023-07-17 14:51 ` Rafael J. Wysocki
2023-07-17 14:53 ` Arjan van de Ven
2023-06-05 15:47 ` [PATCH 4/4] intel_idle: Add a "Long HLT" C1 state for the VM guest mode arjan
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=CAJZ5v0gaZHpAri7LRcfpS2TyK_Bsjuxkw9cZUm_uGZAgiub4Jw@mail.gmail.com \
--to=rafael@kernel.org \
--cc=arjan@linux.intel.com \
--cc=artem.bityutskiy@linux.intel.com \
--cc=dan1.wu@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=xiaoyao.li@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).