Gan tested this and it fixed the glitch.

Merged to master at 15ae76bd6cbd..160c52e7ff54 (from, to]

You can see the entire diff with 'git diff' or at
https://github.com/brho/akaros/compare/15ae76bd6cbd...160c52e7ff54



On 2016-08-03 at 10:21 Barret Rhoden <[email protected]> wrote:
> We were returning and setting nr_guest_pcores to one less than the
> number of cores we set up.
> 
> I also got rid of using 'i' outside the loop, which was slightly
> confusing due to the other loop using its own 'i'.  I also cleaned up
> some old comments that referred to the pre-waserror error handling
> style.
> 
> Signed-off-by: Barret Rhoden <[email protected]>
> ---
>  kern/arch/x86/vmm/intel/vmx.c | 7 +++----
>  kern/arch/x86/vmm/vmm.c       | 9 ++++-----
>  2 files changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/kern/arch/x86/vmm/intel/vmx.c
> b/kern/arch/x86/vmm/intel/vmx.c index 7ca1c67d9b91..485bb272571b
> 100644 --- a/kern/arch/x86/vmm/intel/vmx.c
> +++ b/kern/arch/x86/vmm/intel/vmx.c
> @@ -802,7 +802,7 @@ construct_eptp(physaddr_t root_hpa)
>  
>  /* Helper: some fields of the VMCS need a physical page address,
> e.g. the VAPIC
>   * page.  We have the user address.  This converts the user to phys
> addr and
> - * sets that up in the VMCS.  Returns 0 on success, -1 o/w. */
> + * sets that up in the VMCS.  Throws on error. */
>  static void vmcs_set_pgaddr(struct proc *p, void *u_addr,
>                              unsigned long field, char *what)
>  {
> @@ -830,7 +830,7 @@ static void vmcs_set_pgaddr(struct proc *p, void
> *u_addr, 
>  /**
>   * vmx_setup_initial_guest_state - configures the initial state of
> guest
> - * registers and the VMCS.  Returns 0 on success, -1 o/w.
> + * registers and the VMCS.  Throws on error.
>   */
>  static void vmx_setup_initial_guest_state(struct proc *p,
>                                            struct vmm_gpcore_init
> *gpci) @@ -945,8 +945,7 @@ static void
> vmx_setup_initial_guest_state(struct proc *p,
> vmcs_writel(EOI_EXIT_BITMAP3, 0); vmcs_writel(EOI_EXIT_BITMAP3_HIGH,
> 0); 
> -     /* Initialize parts based on the users info.  If one of them
> fails, we'll do
> -      * the others but then error out. */
> +     /* Initialize parts based on the users info. */
>       vmcs_set_pgaddr(p, gpci->posted_irq_desc,
> POSTED_INTR_DESC_ADDR, "posted_irq_desc");
>       vmcs_set_pgaddr(p, gpci->vapic_addr, VIRTUAL_APIC_PAGE_ADDR,
> diff --git a/kern/arch/x86/vmm/vmm.c b/kern/arch/x86/vmm/vmm.c
> index 07815447dafc..072f3209c868 100644
> --- a/kern/arch/x86/vmm/vmm.c
> +++ b/kern/arch/x86/vmm/vmm.c
> @@ -66,13 +66,12 @@ void vmm_pcpu_init(void)
>  }
>  
>  /* Initializes a process to run virtual machine contexts, returning
> the number
> - * initialized, optionally setting errno */
> + * initialized, throwing on error. */
>  int vmm_struct_init(struct proc *p, unsigned int nr_guest_pcores,
>                      struct vmm_gpcore_init *u_gpcis, int flags)
>  {
>       ERRSTACK(1);
>       struct vmm *vmm = &p->vmm;
> -     unsigned int i;
>       struct vmm_gpcore_init gpci;
>  
>       if (flags & ~VMM_ALL_FLAGS)
> @@ -98,17 +97,17 @@ int vmm_struct_init(struct proc *p, unsigned int
> nr_guest_pcores, if (!vmm->guest_pcores)
>               error(ENOMEM, "Allocation of vmm->guest_pcores
> failed"); 
> -     for (i = 0; i < nr_guest_pcores; i++) {
> +     for (int i = 0; i < nr_guest_pcores; i++) {
>               if (copy_from_user(&gpci, &u_gpcis[i], sizeof(struct
> vmm_gpcore_init))) error(EINVAL, "Bad pointer %p for gps", u_gpcis);
>               vmm->guest_pcores[i] = create_guest_pcore(p, &gpci);
> -             vmm->nr_guest_pcores = i;
> +             vmm->nr_guest_pcores = i + 1;
>       }
>       for (int i = 0; i < VMM_VMEXIT_NR_TYPES; i++)
>               vmm->vmexits[i] = 0;
>       qunlock(&vmm->qlock);
>       poperror();
> -     return i;
> +     return vmm->nr_guest_pcores;
>  }
>  
>  /* Has no concurrency protection - only call this when you know you
> have the

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to