public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Arbel Moshe <arbel.moshe@oracle.com>
To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org
Cc: jmattson@google.com, wanpeng.li@hotmail.com,
	idan.brown@oracle.com, liran.alon@oracle.com,
	Arbel Moshe <arbel.moshe@oracle.com>,
	Krish Sadhukhan <krish.sadhukhan@oracle.com>
Subject: [PATCH v2 3/3] KVM: nVMX: Fix nested APICv Secondary CPU Controls when apicv disabled
Date: Wed, 22 Nov 2017 12:23:40 +0200	[thread overview]
Message-ID: <20171122102340.7110-4-arbel.moshe@oracle.com> (raw)
In-Reply-To: <20171122102340.7110-1-arbel.moshe@oracle.com>

Implementation of virtual APICv relies on L0 being able to use APICv.
Therefore, if enable_apicv==false, we should not expose APICv to L1.

This commit makes sure to not expose APICv Secondary CPU controls
to L1 when enable_apicv==false.

Signed-off-by: Arbel Moshe <arbel.moshe@oracle.com>
Reviewed-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
Signed-off-by: Krish Sadhukhan <krish.sadhukhan@oracle.com>
---
 arch/x86/kvm/vmx.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 0450fbdb97be..a2f157e9c33c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -2811,10 +2811,14 @@ static void nested_vmx_setup_ctls_msrs(struct vcpu_vmx *vmx)
 		SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
 		SECONDARY_EXEC_DESC |
 		SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE |
-		SECONDARY_EXEC_APIC_REGISTER_VIRT |
-		SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY |
 		SECONDARY_EXEC_WBINVD_EXITING;
 
+	if (kvm_vcpu_apicv_active(&vmx->vcpu)) {
+		vmx->nested.nested_vmx_secondary_ctls_high |=
+			(SECONDARY_EXEC_APIC_REGISTER_VIRT |
+			SECONDARY_EXEC_VIRTUAL_INTR_DELIVERY);
+	}
+
 	if (enable_ept) {
 		/* nested EPT: emulate EPT also to L1 */
 		vmx->nested.nested_vmx_secondary_ctls_high |=
-- 
2.14.1

  parent reply	other threads:[~2017-11-22 10:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-22 10:23 [PATCH v2 0/3] KVM: nVMX: Do not expose APICv to L1 if disabled on L0 Arbel Moshe
2017-11-22 10:23 ` [PATCH v2 1/3] KVM: nVMX: Refresh APICv secondary exec controls by re-calculating all of them Arbel Moshe
2017-11-22 17:17   ` Jim Mattson
2017-11-22 18:08     ` Jim Mattson
2017-11-23 23:51     ` Paolo Bonzini
2017-11-22 10:23 ` [PATCH v2 2/3] KVM: nVMX: Update nested MSRs in case APICv refreshing Arbel Moshe
2017-11-22 18:04   ` Jim Mattson
2017-11-23 23:54     ` Paolo Bonzini
2017-11-22 10:23 ` Arbel Moshe [this message]
2017-11-22 17:56   ` [PATCH v2 3/3] KVM: nVMX: Fix nested APICv Secondary CPU Controls when apicv disabled Jim Mattson
2017-11-23 23:57     ` Paolo Bonzini
2017-11-27 17:14       ` Jim Mattson

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=20171122102340.7110-4-arbel.moshe@oracle.com \
    --to=arbel.moshe@oracle.com \
    --cc=idan.brown@oracle.com \
    --cc=jmattson@google.com \
    --cc=krish.sadhukhan@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=liran.alon@oracle.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=wanpeng.li@hotmail.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