From: Paolo Bonzini <pbonzini@redhat.com>
To: Vitaly Kuznetsov <vkuznets@redhat.com>, qemu-devel@nongnu.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [PATCH] target/i386: support KVM_FEATURE_ASYNC_PF_INT
Date: Sat, 12 Sep 2020 08:02:09 +0200 [thread overview]
Message-ID: <f0c66049-57c0-4955-bac8-f7f090f7e12e@redhat.com> (raw)
In-Reply-To: <20200908141206.357450-1-vkuznets@redhat.com>
On 08/09/20 16:12, Vitaly Kuznetsov wrote:
> Linux-5.8 introduced interrupt based mechanism for 'page ready' events
> delivery and disabled the old, #PF based one (see commit 2635b5c4a0e4
> "KVM: x86: interrupt based APF 'page ready' event delivery"). Linux
> guest switches to using in in 5.9 (see commit b1d405751cd5 "KVM: x86:
> Switch KVM guest to using interrupts for page ready APF delivery").
> The feature has a new KVM_FEATURE_ASYNC_PF_INT bit assigned and
> the interrupt vector is set in MSR_KVM_ASYNC_PF_INT MSR. Support this
> in QEMU.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
> - Note, Linux-5.9-rc4 is currently broken (see
> https://lore.kernel.org/kvm/20200908135350.355053-3-vkuznets@redhat.com/T/#u)
> but I hope it will get fixed before 5.9 is released.
> ---
> target/i386/cpu.c | 4 +++-
> target/i386/cpu.h | 1 +
> target/i386/kvm.c | 10 ++++++++++
> target/i386/machine.c | 19 +++++++++++++++++++
> 4 files changed, 33 insertions(+), 1 deletion(-)
>
> diff --git a/target/i386/cpu.c b/target/i386/cpu.c
> index 49d89585288d..76037843511f 100644
> --- a/target/i386/cpu.c
> +++ b/target/i386/cpu.c
> @@ -903,7 +903,7 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
> "kvmclock", "kvm-nopiodelay", "kvm-mmu", "kvmclock",
> "kvm-asyncpf", "kvm-steal-time", "kvm-pv-eoi", "kvm-pv-unhalt",
> NULL, "kvm-pv-tlb-flush", NULL, "kvm-pv-ipi",
> - "kvm-poll-control", "kvm-pv-sched-yield", NULL, NULL,
> + "kvm-poll-control", "kvm-pv-sched-yield", "kvm-asyncpf-int", NULL,
> NULL, NULL, NULL, NULL,
> NULL, NULL, NULL, NULL,
> "kvmclock-stable-bit", NULL, NULL, NULL,
> @@ -4209,6 +4209,7 @@ static PropValue kvm_default_props[] = {
> { "kvmclock", "on" },
> { "kvm-nopiodelay", "on" },
> { "kvm-asyncpf", "on" },
> + { "kvm-asyncpf-int", "on" },
> { "kvm-steal-time", "on" },
> { "kvm-pv-eoi", "on" },
> { "kvmclock-stable-bit", "on" },
> @@ -7092,6 +7093,7 @@ static void x86_cpu_initfn(Object *obj)
> object_property_add_alias(obj, "kvm_nopiodelay", obj, "kvm-nopiodelay");
> object_property_add_alias(obj, "kvm_mmu", obj, "kvm-mmu");
> object_property_add_alias(obj, "kvm_asyncpf", obj, "kvm-asyncpf");
> + object_property_add_alias(obj, "kvm_asyncpf_int", obj, "kvm-asyncpf-int");
> object_property_add_alias(obj, "kvm_steal_time", obj, "kvm-steal-time");
> object_property_add_alias(obj, "kvm_pv_eoi", obj, "kvm-pv-eoi");
> object_property_add_alias(obj, "kvm_pv_unhalt", obj, "kvm-pv-unhalt");
> diff --git a/target/i386/cpu.h b/target/i386/cpu.h
> index d3097be6a50a..18e99e9b392a 100644
> --- a/target/i386/cpu.h
> +++ b/target/i386/cpu.h
> @@ -1492,6 +1492,7 @@ typedef struct CPUX86State {
> uint64_t wall_clock_msr;
> uint64_t steal_time_msr;
> uint64_t async_pf_en_msr;
> + uint64_t async_pf_int_msr;
> uint64_t pv_eoi_en_msr;
> uint64_t poll_control_msr;
>
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index 205b68bc0ce8..b26370662075 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -287,6 +287,7 @@ static const struct kvm_para_features {
> { KVM_CAP_NOP_IO_DELAY, KVM_FEATURE_NOP_IO_DELAY },
> { KVM_CAP_PV_MMU, KVM_FEATURE_MMU_OP },
> { KVM_CAP_ASYNC_PF, KVM_FEATURE_ASYNC_PF },
> + { KVM_CAP_ASYNC_PF_INT, KVM_FEATURE_ASYNC_PF_INT },
> };
>
> static int get_para_features(KVMState *s)
> @@ -2820,6 +2821,9 @@ static int kvm_put_msrs(X86CPU *cpu, int level)
> if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) {
> kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, env->async_pf_en_msr);
> }
> + if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF_INT)) {
> + kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, env->async_pf_int_msr);
> + }
> if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) {
> kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, env->pv_eoi_en_msr);
> }
> @@ -3205,6 +3209,9 @@ static int kvm_get_msrs(X86CPU *cpu)
> if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF)) {
> kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_EN, 0);
> }
> + if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_ASYNC_PF_INT)) {
> + kvm_msr_entry_add(cpu, MSR_KVM_ASYNC_PF_INT, 0);
> + }
> if (env->features[FEAT_KVM] & (1 << KVM_FEATURE_PV_EOI)) {
> kvm_msr_entry_add(cpu, MSR_KVM_PV_EOI_EN, 0);
> }
> @@ -3445,6 +3452,9 @@ static int kvm_get_msrs(X86CPU *cpu)
> case MSR_KVM_ASYNC_PF_EN:
> env->async_pf_en_msr = msrs[i].data;
> break;
> + case MSR_KVM_ASYNC_PF_INT:
> + env->async_pf_int_msr = msrs[i].data;
> + break;
> case MSR_KVM_PV_EOI_EN:
> env->pv_eoi_en_msr = msrs[i].data;
> break;
> diff --git a/target/i386/machine.c b/target/i386/machine.c
> index b1acf7d0ef46..233e46bb70b5 100644
> --- a/target/i386/machine.c
> +++ b/target/i386/machine.c
> @@ -394,6 +394,13 @@ static bool async_pf_msr_needed(void *opaque)
> return cpu->env.async_pf_en_msr != 0;
> }
>
> +static bool async_pf_int_msr_needed(void *opaque)
> +{
> + X86CPU *cpu = opaque;
> +
> + return cpu->env.async_pf_int_msr != 0;
> +}
> +
> static bool pv_eoi_msr_needed(void *opaque)
> {
> X86CPU *cpu = opaque;
> @@ -467,6 +474,17 @@ static const VMStateDescription vmstate_async_pf_msr = {
> }
> };
>
> +static const VMStateDescription vmstate_async_pf_int_msr = {
> + .name = "cpu/async_pf_int_msr",
> + .version_id = 1,
> + .minimum_version_id = 1,
> + .needed = async_pf_int_msr_needed,
> + .fields = (VMStateField[]) {
> + VMSTATE_UINT64(env.async_pf_int_msr, X86CPU),
> + VMSTATE_END_OF_LIST()
> + }
> +};
> +
> static const VMStateDescription vmstate_pv_eoi_msr = {
> .name = "cpu/async_pv_eoi_msr",
> .version_id = 1,
> @@ -1438,6 +1456,7 @@ VMStateDescription vmstate_x86_cpu = {
> .subsections = (const VMStateDescription*[]) {
> &vmstate_exception_info,
> &vmstate_async_pf_msr,
> + &vmstate_async_pf_int_msr,
> &vmstate_pv_eoi_msr,
> &vmstate_steal_time_msr,
> &vmstate_poll_control_msr,
>
Queued, thanks.
Paolo
next prev parent reply other threads:[~2020-09-12 6:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-08 14:12 [PATCH] target/i386: support KVM_FEATURE_ASYNC_PF_INT Vitaly Kuznetsov
2020-09-12 6:02 ` Paolo Bonzini [this message]
2020-09-25 19:21 ` Paolo Bonzini
2020-09-29 12:06 ` Vitaly Kuznetsov
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=f0c66049-57c0-4955-bac8-f7f090f7e12e@redhat.com \
--to=pbonzini@redhat.com \
--cc=ehabkost@redhat.com \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vkuznets@redhat.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).