From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/4] KVM: VMX: Add functions to fill VMCSINFO Date: Wed, 11 Apr 2012 11:48:14 +0300 Message-ID: <4F85454E.6020201@redhat.com> References: <4F84E0DF.8040206@cn.fujitsu.com> <4F84E365.10201@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: dzickus-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, luto-3s7WtUTddSA@public.gmane.org, gregkh-l3A5Bk7waGM@public.gmane.org, kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, joerg.roedel-5C7GfCeVMHo@public.gmane.org, mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org, kexec-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, paul.gortmaker-CWA4WttNNZF54TAoqtyWWQ@public.gmane.org, ludwig.nussel-l3A5Bk7waGM@public.gmane.org, ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org To: zhangyanfei Return-path: In-Reply-To: <4F84E365.10201-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kexec-bounces-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Errors-To: kexec-bounces+glkk-kexec=m.gmane.org-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: kvm.vger.kernel.org On 04/11/2012 04:50 AM, zhangyanfei wrote: > This patch is to implement the feature that at initialization of > kvm_intel module, fills VMCSINFO with a VMCS revision identifier, > and encoded offsets of VMCS fields. The reason why we put the > VMCSINFO processing at the initialization of kvm_intel module > is that it's dangerous to rob VMX resources while kvm module is > loaded. Maybe it should be done by a separate module. > + > + kvm_cpu_vmxon(__pa(per_cpu(vmxarea, raw_smp_processor_id()))); > + vmcs_load(vmcs); Should do this after writing into the vmcs directly (vmcs_load() may cache some information for vmcs_read()). > + > + VMCSINFO_REVISION_ID(vmcs->revision_id); > + > + /* > + * Write encoded offsets into VMCS data for later vmcs_read. > + */ > + for (offset = FIELD_START; offset < vmcs_config.size; > + offset += sizeof(u16)) > + *(u16 *)((char *)vmcs + offset) = ENCODING_OFFSET(offset); This assumes vmcs field contents use the same encoding as vmread/vmwrite. I guess it's a reasonable assumption. -- error compiling committee.c: too many arguments to function