From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 09/11] KVM: nVMX: Copy VMCS12 to processor-specific shadow vmcs Date: Tue, 9 Apr 2013 15:47:50 +0300 Message-ID: <20130409124750.GW17919@redhat.com> References: <1362931402-abelg@il.ibm.com> <20130310160756.0E882380134@moren.haifa.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, owasserm@redhat.com, nadav@harel.org.il, jun.nakajima@intel.com, dongxiao.xu@intel.com To: Abel Gordon Return-path: Received: from mx1.redhat.com ([209.132.183.28]:53602 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935437Ab3DIMsA (ORCPT ); Tue, 9 Apr 2013 08:48:00 -0400 Content-Disposition: inline In-Reply-To: <20130310160756.0E882380134@moren.haifa.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, Mar 10, 2013 at 06:07:56PM +0200, Abel Gordon wrote: > Introduce a function used to copy fields from the software controlled VMCS12 > to the processor-specific shadow vmcs > > Signed-off-by: Abel Gordon > --- > arch/x86/kvm/vmx.c | 45 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 45 insertions(+) > > --- .before/arch/x86/kvm/vmx.c 2013-03-10 18:00:55.000000000 +0200 > +++ .after/arch/x86/kvm/vmx.c 2013-03-10 18:00:55.000000000 +0200 > @@ -672,6 +672,7 @@ static void vmx_get_segment(struct kvm_v > struct kvm_segment *var, int seg); > static bool guest_state_valid(struct kvm_vcpu *vcpu); > static u32 vmx_segment_access_rights(struct kvm_segment *var); > +static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx); > static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx); > > static DEFINE_PER_CPU(struct vmcs *, vmxarea); > @@ -5813,6 +5814,50 @@ static void copy_shadow_to_vmcs12(struct > vmcs_load(vmx->loaded_vmcs->vmcs); > } > > +static void copy_vmcs12_to_shadow(struct vcpu_vmx *vmx) > +{ > + int num_lists = 2; int num_lists = ARRAY_SIZE(fields) > + unsigned long *fields[] = { > + (unsigned long *)shadow_read_write_fields, > + (unsigned long *)shadow_read_only_fields > + }; > + int max_fields[] = { > + max_shadow_read_write_fields, > + max_shadow_read_only_fields > + }; > + int i, q; > + unsigned long field; > + u64 field_value = 0; > + struct vmcs *shadow_vmcs = vmx->nested.current_shadow_vmcs; > + > + vmcs_load(shadow_vmcs); > + > + for (q = 0; q < num_lists; q++) { > + for (i = 0; i < max_fields[q]; i++) { > + field = fields[q][i]; > + vmcs12_read_any(&vmx->vcpu, field, &field_value); > + > + switch (vmcs_field_type(field)) { > + case VMCS_FIELD_TYPE_U16: > + vmcs_write16(field, (u16)field_value); > + break; > + case VMCS_FIELD_TYPE_U32: > + vmcs_write32(field, (u32)field_value); > + break; > + case VMCS_FIELD_TYPE_U64: > + vmcs_write64(field, (u64)field_value); > + break; > + case VMCS_FIELD_TYPE_NATURAL_WIDTH: > + vmcs_writel(field, (long)field_value); > + break; > + } > + } > + } > + > + vmcs_clear(shadow_vmcs); > + vmcs_load(vmx->loaded_vmcs->vmcs); > +} > + > /* > * VMX instructions which assume a current vmcs12 (i.e., that VMPTRLD was > * used before) all generate the same failure when it is missing. > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Gleb.