From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH] KVM: nVMX: Fully support of nested VMX preemption timer Date: Sun, 25 Aug 2013 09:43:12 +0200 Message-ID: <5219B590.7040304@web.de> References: <1377369850-18583-1-git-send-email-root@Blade1-01.Blade1-01> <5219A7BA.8050602@web.de> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="usij5sD8XmBoQsV3KVD8IBEV4hkPD3S7g" Cc: gleb@redhat.com, kvm@vger.kernel.org, kvm-owner@vger.kernel.org, pbonzini@redhat.com, =?ISO-2022-JP?B?IhskQk17PVU0cRsoQiA8QXJ0aHVyIENodW5x?= =?ISO-2022-JP?B?aSBMaT4i?= To: Abel Gordon Return-path: Received: from mout.web.de ([212.227.15.4]:65370 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754236Ab3HYHnP (ORCPT ); Sun, 25 Aug 2013 03:43:15 -0400 Received: from mchn199C.mchp.siemens.de ([95.157.58.223]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M5g0a-1VxcNd1zC4-00xXpm for ; Sun, 25 Aug 2013 09:43:14 +0200 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --usij5sD8XmBoQsV3KVD8IBEV4hkPD3S7g Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: quoted-printable On 2013-08-25 09:37, Abel Gordon wrote: >=20 >=20 >> From: Jan Kiszka >> To: "=1B$BM{=3DU4q=1B(B " , >> Cc: kvm@vger.kernel.org, gleb@redhat.com, pbonzini@redhat.com >> Date: 25/08/2013 09:44 AM >> Subject: Re: [PATCH] KVM: nVMX: Fully support of nested VMX preemption= > timer >> Sent by: kvm-owner@vger.kernel.org >> >> On 2013-08-24 20:44, root wrote: >>> This patch contains the following two changes: >>> 1. Fix the bug in nested preemption timer support. If vmexit L2->L0 >>> with some reasons not emulated by L1, preemption timer value should >>> be save in such exits. >>> 2. Add support of "Save VMX-preemption timer value" VM-Exit controls >>> to nVMX. >>> >>> With this patch, nested VMX preemption timer features are fully >>> supported. >>> >>> Signed-off-by: Arthur Chunqi Li >>> --- >=20 >>> >>> @@ -7578,9 +7579,14 @@ static void prepare_vmcs02(struct kvm_vcpu >> *vcpu, struct vmcs12 *vmcs12) >>> (vmcs_config.pin_based_exec_ctrl | >>> vmcs12->pin_based_vm_exec_control)); >>> >>> - if (vmcs12->pin_based_vm_exec_control & > PIN_BASED_VMX_PREEMPTION_TIMER) >>> - vmcs_write32(VMX_PREEMPTION_TIMER_VALUE, >>> - vmcs12->vmx_preemption_timer_value); >>> + if (vmcs12->pin_based_vm_exec_control & >> PIN_BASED_VMX_PREEMPTION_TIMER) { >>> + if (vmcs12->vm_exit_controls & > VM_EXIT_SAVE_VMX_PREEMPTION_TIMER) >>> + vmcs12->vmx_preemption_timer_value =3D >>> + vmcs_read32(VMX_PREEMPTION_TIMER_VALUE); >>> + else >>> + vmcs_write32(VMX_PREEMPTION_TIMER_VALUE, >>> + vmcs12->vmx_preemption_timer_value); >>> + } >> >> This is not correct. We still need to set the vmcs to >> vmx_preemption_timer_value. The difference is that, on exit from L2, >> vmx_preemption_timer_value has to be updated according to the saved >> hardware state. The corresponding code is missing in your patch so far= =2E >=20 > I think something else maybe be missing here: assuming L0 handles exits= > for L2 without involving L1 (e.g. external interrupts or ept violations= ), > then, we may spend some cycles in L0 handling these exits. Note L1 is n= ot > aware of these exits and from L1 perspective L2 was running on the CPU.= > That means that we may need to reduce these cycles spent at > L0 from the preemtion timer or emulate a preemption timer exit to > force a transition to L1 instead of resuming L2. That's precisely what the logic I described should achieve: reload the value we saved on L2 exit on reentry. Jan --usij5sD8XmBoQsV3KVD8IBEV4hkPD3S7g Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlIZtZAACgkQitSsb3rl5xReRgCg5vWxjpuBJ8gimB/VZzsCnhJd /QoAoNO0RakvbhCpLiT3/NEUC3KWYn+X =ecLn -----END PGP SIGNATURE----- --usij5sD8XmBoQsV3KVD8IBEV4hkPD3S7g--