public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* unix lite
@ 2007-04-23 14:57 Omar Khan
       [not found] ` <loom.20070423T164130-191-eS7Uydv5nfjZ+VzJOa5vwg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Omar Khan @ 2007-04-23 14:57 UTC (permalink / raw)
  To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f


hi,
   
   I am trying to run unix like operating system (mainly meant for educational
purposes) on kvm called "Unix Lite" (http://www.unixlite.org/). It runs fine on
qemu but on kvm it gives the unhandled vm exit 0x9. This is caused by the
hardware task switch that is used in unix lite. The code for the switch is :

void gdt_t::swtch(tss_t * from, tss_t * to)
{
        /* also clear "busy tss" flag */
        tss[0].init(X86AVL386TSS, (u32_t)from, sizeof(tss_t)-1);
        tss[1].init(X86AVL386TSS, (u32_t)to, sizeof(tss_t)-1);
        asm volatile(
                "ltr %w0\n\t"
                "ljmp %1,$0\n\t"
                ::"r"(TSS0SEL),"i"(TSS1SEL));
}

As you can see the code is basically saving the context of one task and loading
from the next. The unhandled exit is caused by the ljmp which causes the switch.
What would be a good way to convert this to a software switch only? Just
manually push the current state on the outgoing task state segment(we have the
pointers to this) and load from the incoming task's state segment? I am new to
this therefore I am not sure how to save the current CS:IP pair and whether this
is the way to do it or not, any help/hints will be welcomed.

Thanks 

Omar 


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

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

* Re: unix lite
       [not found] ` <loom.20070423T164130-191-eS7Uydv5nfjZ+VzJOa5vwg@public.gmane.org>
@ 2007-04-24  8:41   ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2007-04-24  8:41 UTC (permalink / raw)
  To: Omar Khan; +Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f

Omar Khan wrote:
> hi,
>    
>    I am trying to run unix like operating system (mainly meant for educational
> purposes) on kvm called "Unix Lite" (http://www.unixlite.org/). It runs fine on
> qemu but on kvm it gives the unhandled vm exit 0x9. This is caused by the
> hardware task switch that is used in unix lite. The code for the switch is :
>
> void gdt_t::swtch(tss_t * from, tss_t * to)
> {
>         /* also clear "busy tss" flag */
>         tss[0].init(X86AVL386TSS, (u32_t)from, sizeof(tss_t)-1);
>         tss[1].init(X86AVL386TSS, (u32_t)to, sizeof(tss_t)-1);
>         asm volatile(
>                 "ltr %w0\n\t"
>                 "ljmp %1,$0\n\t"
>                 ::"r"(TSS0SEL),"i"(TSS1SEL));
> }
>
> As you can see the code is basically saving the context of one task and loading
> from the next. The unhandled exit is caused by the ljmp which causes the switch.
> What would be a good way to convert this to a software switch only? Just
> manually push the current state on the outgoing task state segment(we have the
> pointers to this) and load from the incoming task's state segment? I am new to
> this therefore I am not sure how to save the current CS:IP pair and whether this
> is the way to do it or not, any help/hints will be welcomed.
>   

There are two ways that you can go about this.

First, tying to change the code.  For that you need to find out exactly
what state is changed on the task switch.  If the different contexts map
the kernel differently, then you can't really change the code.  If they
don't, just follow the study task switching in the manuals and perform
the same actions in software.

Changing esp and eip is not too difficult, see Linux__switch_to() in
include/asm-i386/system.h.

Second, you can teach kvm about task switching.  Code the actions that
the processor takes into a kvm_task_switch() function and wire the
vmexit handlers accordingly.


-- 
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

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

end of thread, other threads:[~2007-04-24  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-23 14:57 unix lite Omar Khan
     [not found] ` <loom.20070423T164130-191-eS7Uydv5nfjZ+VzJOa5vwg@public.gmane.org>
2007-04-24  8:41   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox