From: Paolo Bonzini <pbonzini@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>, kvm-devel <kvm@vger.kernel.org>
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Andrea Arcangeli" <aarcange@redhat.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Wanpeng Li" <kernellwp@gmail.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Raslan KarimAllah" <karahmed@amazon.de>,
"Boris Ostrovsky" <boris.ostrovsky@oracle.com>,
"Ankur Arora" <ankur.a.arora@oracle.com>,
"Christian Borntraeger" <borntraeger@de.ibm.com>
Subject: Re: [patch 2/3] kvm: x86: add host poll control msrs
Date: Thu, 6 Jun 2019 14:04:12 +0200 [thread overview]
Message-ID: <bf43271d-dcd4-bbe3-a6eb-c3e6f7cddff2@redhat.com> (raw)
In-Reply-To: <20190603225254.292226777@amt.cnet>
> Add an MSRs which allows the guest to disable
> host polling (specifically the cpuidle-haltpoll,
> when performing polling in the guest, disables
> host side polling).
>
> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Queued this patch while waiting for Rafal's review.
Paolo
> ---
> Documentation/virtual/kvm/msr.txt | 9 +++++++++
> arch/x86/include/asm/kvm_host.h | 2 ++
> arch/x86/include/uapi/asm/kvm_para.h | 2 ++
> arch/x86/kvm/Kconfig | 1 +
> arch/x86/kvm/cpuid.c | 3 ++-
> arch/x86/kvm/x86.c | 23 +++++++++++++++++++++++
> 6 files changed, 39 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.git/Documentation/virtual/kvm/msr.txt
> ===================================================================
> --- linux-2.6.git.orig/Documentation/virtual/kvm/msr.txt 2018-05-18 15:40:19.697438928 -0300
> +++ linux-2.6.git/Documentation/virtual/kvm/msr.txt 2019-06-03 19:37:49.618543527 -0300
> @@ -273,3 +273,12 @@
> guest must both read the least significant bit in the memory area and
> clear it using a single CPU instruction, such as test and clear, or
> compare and exchange.
> +
> +MSR_KVM_POLL_CONTROL: 0x4b564d05
> + Control host side polling.
> +
> + data: Bit 0 enables (1) or disables (0) host halt poll
> + logic.
> + KVM guests can disable host halt polling when performing
> + polling themselves.
> +
> Index: linux-2.6.git/arch/x86/include/asm/kvm_host.h
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/include/asm/kvm_host.h 2019-05-29 14:46:14.516005546 -0300
> +++ linux-2.6.git/arch/x86/include/asm/kvm_host.h 2019-06-03 19:37:49.619543530 -0300
> @@ -755,6 +755,8 @@
> struct gfn_to_hva_cache data;
> } pv_eoi;
>
> + u64 msr_kvm_poll_control;
> +
> /*
> * Indicate whether the access faults on its page table in guest
> * which is set when fix page fault and used to detect unhandeable
> Index: linux-2.6.git/arch/x86/include/uapi/asm/kvm_para.h
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/include/uapi/asm/kvm_para.h 2019-01-04 12:07:15.936947406 -0200
> +++ linux-2.6.git/arch/x86/include/uapi/asm/kvm_para.h 2019-06-03 19:37:49.620543534 -0300
> @@ -29,6 +29,7 @@
> #define KVM_FEATURE_PV_TLB_FLUSH 9
> #define KVM_FEATURE_ASYNC_PF_VMEXIT 10
> #define KVM_FEATURE_PV_SEND_IPI 11
> +#define KVM_FEATURE_POLL_CONTROL 12
>
> #define KVM_HINTS_REALTIME 0
>
> @@ -47,6 +48,7 @@
> #define MSR_KVM_ASYNC_PF_EN 0x4b564d02
> #define MSR_KVM_STEAL_TIME 0x4b564d03
> #define MSR_KVM_PV_EOI_EN 0x4b564d04
> +#define MSR_KVM_POLL_CONTROL 0x4b564d05
>
> struct kvm_steal_time {
> __u64 steal;
> Index: linux-2.6.git/arch/x86/kvm/Kconfig
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/kvm/Kconfig 2019-05-29 14:46:14.530005593 -0300
> +++ linux-2.6.git/arch/x86/kvm/Kconfig 2019-06-03 19:37:49.620543534 -0300
> @@ -41,6 +41,7 @@
> select PERF_EVENTS
> select HAVE_KVM_MSI
> select HAVE_KVM_CPU_RELAX_INTERCEPT
> + select HAVE_KVM_NO_POLL
> select KVM_GENERIC_DIRTYLOG_READ_PROTECT
> select KVM_VFIO
> select SRCU
> Index: linux-2.6.git/arch/x86/kvm/cpuid.c
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/kvm/cpuid.c 2019-05-29 14:46:14.530005593 -0300
> +++ linux-2.6.git/arch/x86/kvm/cpuid.c 2019-06-03 19:37:49.621543537 -0300
> @@ -643,7 +643,8 @@
> (1 << KVM_FEATURE_PV_UNHALT) |
> (1 << KVM_FEATURE_PV_TLB_FLUSH) |
> (1 << KVM_FEATURE_ASYNC_PF_VMEXIT) |
> - (1 << KVM_FEATURE_PV_SEND_IPI);
> + (1 << KVM_FEATURE_PV_SEND_IPI) |
> + (1 << KVM_FEATURE_POLL_CONTROL);
>
> if (sched_info_on())
> entry->eax |= (1 << KVM_FEATURE_STEAL_TIME);
> Index: linux-2.6.git/arch/x86/kvm/x86.c
> ===================================================================
> --- linux-2.6.git.orig/arch/x86/kvm/x86.c 2019-05-29 14:46:14.537005616 -0300
> +++ linux-2.6.git/arch/x86/kvm/x86.c 2019-06-03 19:37:49.624543547 -0300
> @@ -1177,6 +1177,7 @@
> MSR_IA32_POWER_CTL,
>
> MSR_K7_HWCR,
> + MSR_KVM_POLL_CONTROL,
> };
>
> static unsigned num_emulated_msrs;
> @@ -2628,6 +2629,14 @@
> return 1;
> break;
>
> + case MSR_KVM_POLL_CONTROL:
> + /* only enable bit supported */
> + if (data & (-1ULL << 1))
> + return 1;
> +
> + vcpu->arch.msr_kvm_poll_control = data;
> + break;
> +
> case MSR_IA32_MCG_CTL:
> case MSR_IA32_MCG_STATUS:
> case MSR_IA32_MC0_CTL ... MSR_IA32_MCx_CTL(KVM_MAX_MCE_BANKS) - 1:
> @@ -2877,6 +2886,9 @@
> case MSR_KVM_PV_EOI_EN:
> msr_info->data = vcpu->arch.pv_eoi.msr_val;
> break;
> + case MSR_KVM_POLL_CONTROL:
> + msr_info->data = vcpu->arch.msr_kvm_poll_control;
> + break;
> case MSR_IA32_P5_MC_ADDR:
> case MSR_IA32_P5_MC_TYPE:
> case MSR_IA32_MCG_CAP:
> @@ -8874,6 +8886,10 @@
> msr.host_initiated = true;
> kvm_write_tsc(vcpu, &msr);
> vcpu_put(vcpu);
> +
> + /* poll control enabled by default */
> + vcpu->arch.msr_kvm_poll_control = 1;
> +
> mutex_unlock(&vcpu->mutex);
>
> if (!kvmclock_periodic_sync)
> @@ -9948,6 +9964,13 @@
> }
> EXPORT_SYMBOL_GPL(kvm_vector_hashing_enabled);
>
> +bool kvm_arch_no_poll(struct kvm_vcpu *vcpu)
> +{
> + return (vcpu->arch.msr_kvm_poll_control & 1) == 0;
> +}
> +EXPORT_SYMBOL_GPL(kvm_arch_no_poll);
> +
> +
> EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit);
> EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_fast_mmio);
> EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_inj_virq);
>
>
next prev parent reply other threads:[~2019-06-06 12:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-03 22:52 [patch 0/3] cpuidle-haltpoll driver (v2) Marcelo Tosatti
2019-06-03 22:52 ` [patch 1/3] drivers/cpuidle: add cpuidle-haltpoll driver Marcelo Tosatti
2019-06-05 8:16 ` Ankur Arora
2019-06-06 17:51 ` Andrea Arcangeli
2019-06-07 20:20 ` Marcelo Tosatti
2019-06-06 19:03 ` Peter Zijlstra
2019-06-07 9:54 ` Rafael J. Wysocki
2019-06-03 22:52 ` [patch 2/3] kvm: x86: add host poll control msrs Marcelo Tosatti
2019-06-06 12:04 ` Paolo Bonzini [this message]
2019-06-03 22:52 ` [patch 3/3] cpuidle-haltpoll: disable host side polling when kvm virtualized Marcelo Tosatti
2019-06-04 1:26 ` kbuild test robot
2019-06-04 12:24 ` [patch v2 " Marcelo Tosatti
2019-06-06 18:25 ` Joao Martins
2019-06-06 18:36 ` Andrea Arcangeli
2019-06-06 18:51 ` Joao Martins
2019-06-06 19:22 ` Joao Martins
2019-06-06 21:01 ` Andrea Arcangeli
2019-06-07 20:38 ` Marcelo Tosatti
2019-06-07 20:25 ` Marcelo Tosatti
2019-06-07 9:49 ` [patch 0/3] cpuidle-haltpoll driver (v2) Rafael J. Wysocki
2019-06-07 17:16 ` Marcelo Tosatti
2019-06-07 18:22 ` Paolo Bonzini
2019-06-07 21:38 ` Marcelo Tosatti
2019-06-10 14:59 ` Marcelo Tosatti
2019-06-10 22:03 ` Rafael J. Wysocki
2019-06-11 14:26 ` Marcelo Tosatti
2019-06-11 21:24 ` Rafael J. Wysocki
2019-06-17 15:57 ` Peter Zijlstra
2019-06-11 19:40 [patch 0/3] cpuidle-haltpoll driver (v3) Marcelo Tosatti
2019-06-11 19:40 ` [patch 2/3] kvm: x86: add host poll control msrs Marcelo Tosatti
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=bf43271d-dcd4-bbe3-a6eb-c3e6f7cddff2@redhat.com \
--to=pbonzini@redhat.com \
--cc=aarcange@redhat.com \
--cc=ankur.a.arora@oracle.com \
--cc=boris.ostrovsky@oracle.com \
--cc=borntraeger@de.ibm.com \
--cc=karahmed@amazon.de \
--cc=kernellwp@gmail.com \
--cc=konrad.wilk@oracle.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=peterz@infradead.org \
--cc=rafael.j.wysocki@intel.com \
--cc=rkrcmar@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).