linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wincy Van <fanwenyi0529@gmail.com>
To: "Zhang, Yang Z" <yang.z.zhang@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	"gleb@kernel.org" <gleb@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	Wanpeng Li <wanpeng.li@linux.intel.com>,
	Jan Kiszka <jan.kiszka@web.de>
Subject: Re: [PATCH v4 2/6] KVM: nVMX: Enable nested virtualize x2apic mode
Date: Thu, 29 Jan 2015 11:53:28 +0800	[thread overview]
Message-ID: <CACzj_yXbEirXExiC3p2m_zf9AGLYGKU5fLGHdizPN10eL4Q5Ug@mail.gmail.com> (raw)
In-Reply-To: <A9667DDFB95DB7438FA9D7D576C3D87E0AC2E2AF@SHSMSX104.ccr.corp.intel.com>

On Thu, Jan 29, 2015 at 10:54 AM, Zhang, Yang Z <yang.z.zhang@intel.com> wrote:
>> -8646,7 +8750,8 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu,
>> struct vmcs12 *vmcs12)
>>                         else
>>                                 vmcs_write64(APIC_ACCESS_ADDR,
>>
>> page_to_phys(vmx->nested.apic_access_page));
>> -               } else if
>> (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm)) {
>> +               } else if (!(nested_cpu_has_virt_x2apic_mode(vmcs12)) &&
>> +
>> + (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm))) {
>>                         exec_control |=
>
> You don't load L2's apic_page in your patch correctly when x2apic mode is used. Here is the right change for prepare_vmcs02()(maybe other place also need change too):
>
> @@ -8585,7 +8585,8 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
>                                 CPU_BASED_ACTIVATE_SECONDARY_CONTROLS))
>                         exec_control |= vmcs12->secondary_vm_exec_control;
>
> -               if (exec_control & SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES) {
> +               if (exec_control & (SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
> +                                   SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE)) {
>                         /*
>                          * If translation failed, no matter: This feature asks
>                          * to exit when accessing the given address, and if it
> @@ -8594,7 +8595,8 @@ static void prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
>                          */
>                         if (!vmx->nested.apic_access_page)
>                                 exec_control &=
> -                                 ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
> +                                 ~ (SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
> +                                    SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE);
>                         else
>                                 vmcs_write64(APIC_ACCESS_ADDR,
>                                   page_to_phys(vmx->nested.apic_access_page));
>

I think we don't need to do this, if L1 enables x2apic mode, we have
already checked that the
vmcs12->SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES is 0. "exec_control |=
vmcs12->secondary_vm_exec_control;" merged L1's settings, including
x2apic mode. the special case is vm_need_virtualize_apic_accesses, if
vm_need_virtualize_apic_accesses returns true, the
nested_cpu_has_virt_x2apic_mode will prevent us to set the apic access
bit.


Thanks,
Wincy

  reply	other threads:[~2015-01-29  3:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-28 15:56 [PATCH v4 2/6] KVM: nVMX: Enable nested virtualize x2apic mode Wincy Van
2015-01-29  2:54 ` Zhang, Yang Z
2015-01-29  3:53   ` Wincy Van [this message]
2015-01-29  4:05     ` Zhang, Yang Z

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=CACzj_yXbEirXExiC3p2m_zf9AGLYGKU5fLGHdizPN10eL4Q5Ug@mail.gmail.com \
    --to=fanwenyi0529@gmail.com \
    --cc=gleb@kernel.org \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=wanpeng.li@linux.intel.com \
    --cc=yang.z.zhang@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).