On Tue, Jul 06, 2010, Dong, Eddie wrote about "RE: [PATCH 8/24] Hold a vmcs02 
for each vmcs12":
> > +/* Allocate an L0 VMCS (vmcs02) for the current L1 VMCS (vmcs12), if
> > one + * does not already exist. The allocation is done in L0 memory,
>...
> > +static int nested_create_current_vmcs(struct kvm_vcpu *vcpu)
> > +{
> > +   struct vmcs_list *new_l2_guest;
> > +   struct vmcs *l2_vmcs;
> > +
> > +   if (nested_get_current_vmcs(vcpu))
> > +           return 0; /* nothing to do - we already have a VMCS */
> > +
> > +   if (to_vmx(vcpu)->nested.l2_vmcs_num >= NESTED_MAX_VMCS)
> > +           return -ENOMEM;
> > +
> > +   new_l2_guest = (struct vmcs_list *)
> > +           kmalloc(sizeof(struct vmcs_list), GFP_KERNEL);
> > +   if (!new_l2_guest)
> > +           return -ENOMEM;
> > +
> > +   l2_vmcs = alloc_vmcs();
> 
> I didn't see where it was used. Hints on the usage?

Hi, I'm afraid I didn't understand the question. Where is what used?

What nested_create_current_vmcs does (as the comment above it explains) is
to allocate a vmcs02 for the current vmcs12, or return one that has been
previously allocated (and saved in a list we hold of these mappings).

The alloc_vmcs() call you pointed to happens when there isn't yet a vmcs02
for this vmcs12, and we need to allocate a new one. A few lines down this
new mapping between a vmcs12 address to vmcs02 is put in new_l2_guest and
that is inserted into the list of mappings.

Does this answer your question?

By the way, in my latest version of the code, l2_vmcs is now better named,
"vmcs02" :-)


> > +   if (!l2_vmcs) {
> > +           kfree(new_l2_guest);
> > +           return -ENOMEM;
> > +   }
> > +
> > +   new_l2_guest->vmcs_addr = to_vmx(vcpu)->nested.current_vmptr;
> > +   new_l2_guest->l2_vmcs = l2_vmcs;
> > +   list_add(&(new_l2_guest->list),
> > &(to_vmx(vcpu)->nested.l2_vmcs_list));
> > +   to_vmx(vcpu)->nested.l2_vmcs_num++; +   return 0;
> > +}

-- 
Nadav Har'El                        |          Monday, Aug  2 2010, 22 Av 5770
[email protected]             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |A computer program does what you tell it
http://nadav.harel.org.il           |to do, not what you want it to do.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to