All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC: PVH set vcpu info context in vmcs....
@ 2013-08-13  1:45 Mukesh Rathor
  2013-08-13  9:16 ` Tim Deegan
  2013-08-13 10:56 ` Jan Beulich
  0 siblings, 2 replies; 19+ messages in thread
From: Mukesh Rathor @ 2013-08-13  1:45 UTC (permalink / raw)
  To: Jan Beulich, Tim Deegan, Keir Fraser, Xen-devel

I just decided to create a new thread... Here's the code I wanted
to propose.

thanks,
Mukesh

/*
 * Set vmcs fields in support of vcpu_op -> VCPUOP_initialise hcall used
 * to initialise a secondary vcpu prior to boot. Called from 
 * arch_set_info_guest() which sets the (PVH relevant) non-vmcs fields.
 *
 * In case of linux:
 *     The call comes from cpu_initialize_context().  (boot vcpu 0 context is
 *     set by the tools via do_domctl -> vcpu_initialise).
 *
 * PVH 32bitfixme: this function needs to be modified for 32bit guest. 
 */
int vmx_pvh_set_vcpu_info(struct vcpu *v, struct vcpu_guest_context *ctxtp)
{
    int rc;

    if ( v->vcpu_id == 0 )
        return 0;

    if ( !(ctxtp->flags & VGCF_in_kernel) )
        return -EINVAL;

    if ( ctxtp->ldt_base || ctxtp->ldt_ents ||
         (ctxtp->user_regs.cs & 4) || ctxtp->user_regs.ss || 
         ctxtp->user_regs.es || ctxtp->user_regs.ds )
        return -EINVAL;

    if ( ctxtp->user_regs.cs == 0 )
        return -EINVAL;

    vmx_vmcs_enter(v);
    __vmwrite(GUEST_GDTR_BASE, ctxtp->gdt.pvh.addr);
    __vmwrite(GUEST_GDTR_LIMIT, ctxtp->gdt.pvh.limit);

    __vmwrite(GUEST_FS_BASE, ctxtp->fs_base);
    __vmwrite(GUEST_GS_BASE, ctxtp->gs_base_kernel);

    /* IA-32e: ss/es/ds are ignored, we load cs only. */ 
    __vmwrite(GUEST_CS_SELECTOR, ctxtp->user_regs.cs);
    if ( (rc = hvm_load_segment_selector(x86_seg_cs, ctxtp->user_regs.cs)) ) 
        return rc;

    __vmwrite(GUEST_FS_SELECTOR, ctxtp->user_regs.fs);
    __vmwrite(GUEST_GS_SELECTOR, ctxtp->user_regs.gs);

    if ( (rc = vmx_add_guest_msr(MSR_SHADOW_GS_BASE)) )
    {
        vmx_vmcs_exit(v);
        return rc;
    }
    vmx_write_guest_msr(MSR_SHADOW_GS_BASE, ctxtp->gs_base_user);

    vmx_vmcs_exit(v);
    return 0;
}

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-08-19 21:47 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-13  1:45 RFC: PVH set vcpu info context in vmcs Mukesh Rathor
2013-08-13  9:16 ` Tim Deegan
2013-08-13 12:10   ` Jan Beulich
2013-08-13 10:56 ` Jan Beulich
2013-08-14  2:12   ` Mukesh Rathor
2013-08-14  9:12     ` Jan Beulich
2013-08-14  9:57       ` George Dunlap
2013-08-15  0:25       ` Mukesh Rathor
2013-08-15  1:58         ` Mukesh Rathor
2013-08-15  6:34           ` Jan Beulich
2013-08-15  6:31         ` Jan Beulich
2013-08-16  2:26           ` Mukesh Rathor
2013-08-16  7:28             ` Jan Beulich
2013-08-16 22:28               ` Mukesh Rathor
2013-08-17  1:37                 ` Mukesh Rathor
2013-08-17 10:22                   ` Tim Deegan
2013-08-19 21:45                     ` Mukesh Rathor
2013-08-19  9:34                   ` Jan Beulich
2013-08-19 21:46                     ` Mukesh Rathor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.