From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 3/9] KVM: x86: add pcommit support Date: Tue, 8 Sep 2015 22:17:19 +0800 Message-ID: <55EEEDEF.4070902@linux.intel.com> References: <1440132611-26052-1-git-send-email-guangrong.xiao@linux.intel.com> <1440132611-26052-4-git-send-email-guangrong.xiao@linux.intel.com> <55ED729F.2020107@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: gleb@kernel.org, mtosatti@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Paolo Bonzini Return-path: Received: from mga09.intel.com ([134.134.136.24]:14269 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754603AbbIHOXR (ORCPT ); Tue, 8 Sep 2015 10:23:17 -0400 In-Reply-To: <55ED729F.2020107@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/07/2015 07:18 PM, Paolo Bonzini wrote: >> >> +static int handle_pcommit(struct kvm_vcpu *vcpu) >> +{ >> + /* we never catch pcommit instruct for L1 guest. */ >> + BUG(); > > Please WARN instead. > Okay. >> + return 1; >> +} >> + >> /* >> * The exit handlers return 1 if the exit was handled fully and gu= est execution >> * may resume. Otherwise they set the kvm_run parameter to indica= te what needs >> @@ -7258,6 +7269,7 @@ static int (*const kvm_vmx_exit_handlers[])(st= ruct kvm_vcpu *vcpu) =3D { >> [EXIT_REASON_XSAVES] =3D handle_xsaves, >> [EXIT_REASON_XRSTORS] =3D handle_xrstors, >> [EXIT_REASON_PML_FULL] =3D handle_pml_full, >> + [EXIT_REASON_PCOMMIT] =3D handle_pcommit, >> }; >> >> static const int kvm_vmx_max_exit_handlers =3D >> @@ -7559,6 +7571,8 @@ static bool nested_vmx_exit_handled(struct kvm= _vcpu *vcpu) >> * the XSS exit bitmap in vmcs12. >> */ >> return nested_cpu_has2(vmcs12, SECONDARY_EXEC_XSAVES); >> + case EXIT_REASON_PCOMMIT: >> + return nested_cpu_has2(vmcs12, SECONDARY_EXEC_PCOMMIT); >> default: >> return true; >> } >> @@ -8688,6 +8702,10 @@ static void vmx_cpuid_update(struct kvm_vcpu = *vcpu) >> if (best) >> best->ebx &=3D ~bit(X86_FEATURE_INVPCID); >> } >> + >> + if (!guest_cpuid_has_pcommit(vcpu) && nested) >> + vmx->nested.nested_vmx_secondary_ctls_high &=3D >> + ~SECONDARY_EXEC_PCOMMIT; > > Why is this needed? > If pcommit is not allowed in L1 guest, L1 is not allowed to intercept p= commit for L2. BTW, the spec saied: | IA32_VMX_PROCBASED_CTLS2[53] (which enumerates support for the 1-sett= ing of =E2=80=9CPCOMMIT exiting=E2=80=9D) is | always the same as CPUID.07H:EBX.PCOMMIT[bit 22]. Thus, software can = set =E2=80=9CPCOMMIT exiting=E2=80=9D to 1 | if and only if the PCOMMIT instruction is enumerated via CPUID