From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 2/3] KVM: X86: Provides userspace with a capability to not intercept HLT
Date: Thu, 8 Mar 2018 21:40:29 +0100 [thread overview]
Message-ID: <20180308204029.GK12290@flask> (raw)
In-Reply-To: <1519897782-8124-2-git-send-email-wanpengli@tencent.com>
2018-03-01 17:49+0800, Wanpeng Li:
> From: Wanpeng Li <wanpengli@tencent.com>
>
> If host CPUs are dedicated to a VM, we can avoid VM exits on HLT.
> This patch adds the per-VM non-HLT-exiting capability.
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Radim Krčmář <rkrcmar@redhat.com>
> Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
> ---
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index dff3a5d..fcf8339 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1394,6 +1394,9 @@ static void init_vmcb(struct vcpu_svm *svm)
> set_intercept(svm, INTERCEPT_MWAIT);
> }
>
> + if (!kvm_hlt_in_guest(svm->vcpu.kvm))
> + set_intercept(svm, INTERCEPT_HLT);
We unconditionally set INTERCEPT_HLT just above, so that line has to be
removed.
> +
> control->iopm_base_pa = __sme_set(iopm_base);
> control->msrpm_base_pa = __sme_set(__pa(svm->msrpm));
> control->int_ctl = V_INTR_MASKING_MASK;
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> @@ -2525,6 +2525,19 @@ static int nested_vmx_check_exception(struct kvm_vcpu *vcpu, unsigned long *exit
> return 0;
> }
>
> +static void vmx_clear_hlt(struct kvm_vcpu *vcpu)
> +{
> + /*
> + * Ensure that we clear the HLT state in the VMCS. We don't need to
> + * explicitly skip the instruction because if the HLT state is set,
> + * then the instruction is already executing and RIP has already been
> + * advanced.
> + */
> + if (kvm_hlt_in_guest(vcpu->kvm) &&
> + vmcs_read32(GUEST_ACTIVITY_STATE) == GUEST_ACTIVITY_HLT)
> + vmcs_write32(GUEST_ACTIVITY_STATE, GUEST_ACTIVITY_ACTIVE);
> +}
The clearing seems to be still missing around SMM -- I think you need to
call vmx_clear_hlt() from pre_enter_smm().
Thanks.
next prev parent reply other threads:[~2018-03-08 20:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-01 9:49 [PATCH 1/3] KVM: X86: Provides userspace with a capability to not intercept MWAIT Wanpeng Li
2018-03-01 9:49 ` [PATCH 2/3] KVM: X86: Provides userspace with a capability to not intercept HLT Wanpeng Li
2018-03-08 20:40 ` Radim Krčmář [this message]
2018-03-09 0:51 ` Wanpeng Li
2018-03-01 9:49 ` [PATCH 3/3] KVM: X86: Provides userspace with a capability to not intercept PAUSE Wanpeng Li
2018-03-08 20:52 ` Radim Krčmář
2018-03-08 20:31 ` [PATCH 1/3] KVM: X86: Provides userspace with a capability to not intercept MWAIT Radim Krčmář
2018-03-08 20:55 ` Radim Krčmář
2018-03-09 2:34 ` Wanpeng Li
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=20180308204029.GK12290@flask \
--to=rkrcmar@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@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 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.