public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
To: Cam Macdonell <cam-edFDblaTWIyXbbII50Afww@public.gmane.org>
Cc: kvm-devel <kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
Subject: Re: What happens on an INT80 instruction
Date: Mon, 01 Oct 2007 16:06:19 -0500	[thread overview]
Message-ID: <4701614B.8090107@codemonkey.ws> (raw)
In-Reply-To: <47015E42.4000403-edFDblaTWIyXbbII50Afww@public.gmane.org>

Cam Macdonell wrote:
> Anthony Liguori wrote:
>> Cameron Macdonell wrote:
>>> Hi,
>>>
>>> I'm trying to understand guest virtualization at the lower levels.  
>>> I  have a somewhat basic question:  How does KVM virtualize an 
>>> int80  instruction from a guest?  A pointer to an answer is just as 
>>> good as  an answer itself.
>>>   
>>
>> The same thing happens as it does on normal hardware.
>>
>> The way VT/SVM works (at a high level), is that certain instructions 
>> and events check a special area called the VMCS/VMCB to determine 
>> whether the event should generate a vmexit which is really just a 
>> special type of trap.
>>
>
> Thanks Anthony.  Does an int80 from an application in the guest always 
> cause a vmexit (in kvm's case at least)?

No, an int80 would never generate a trap in KVM.  The only way to make 
it generate a trap is for an int80 to trigger some other event that 
would generate a trap.  This is what I meant by taking over the guest's 
IDT such that you could change the int80 handler to do a hypercall.

I presume you're looking into doing a guest IDS right?

Regards,

Anthony Liguori

> Thanks,
> Cam
>
>> There are no hooks for interrupts 32-255 so the hardware operates as 
>> it normally would.  If you're interested in getting a trap for int80 
>> within KVM, you'll have to trap sidt/lidt and virtualize the IDT.  
>> You'll need to setup a fake IDT and have the int80 handler do a 
>> hypercall.  This is complicated if the guest is using a fast-syscall 
>> mechanism.  It may be a little challenging finding a piece of guest 
>> memory to take over that has a valid virtual mapping.  To solve this 
>> in the general case, you'll need to have the guest be aware of a 
>> memory hole.  If you can limit yourself to things like Linux and 
>> Windows, you can probably just rely on some memory within the BIOS 
>> area (both Linux and Windows always have valid mappings of the BIOS 
>> memory).
>>
>> If you need to enforce that int80s go to you, you'll need to 
>> write-protect this memory too.
>>
>> Regards,
>>
>> Anthony Liguori
>>
>>> Thanks,
>>> Cam
>>>
>>>
>>>
>>> ------------------------------------------------------------------------- 
>>>
>>> This SF.net email is sponsored by: Microsoft
>>> Defy all challenges. Microsoft(R) Visual Studio 2005.
>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>>> _______________________________________________
>>> kvm-devel mailing list
>>> kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
>>> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>>>
>>>   
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

  parent reply	other threads:[~2007-10-01 21:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-01  0:41 What happens on an INT80 instruction Cameron Macdonell
     [not found] ` <C40FB9CB-3FBB-4C8E-A5EB-C419DB48CA7E-edFDblaTWIyXbbII50Afww@public.gmane.org>
2007-10-01  1:31   ` Anthony Liguori
     [not found]     ` <47004DDE.1060603-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-01 20:53       ` Cam Macdonell
     [not found]         ` <47015E42.4000403-edFDblaTWIyXbbII50Afww@public.gmane.org>
2007-10-01 21:06           ` Anthony Liguori [this message]
     [not found]             ` <4701614B.8090107-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-01 23:23               ` Cam Macdonell
     [not found]                 ` <4701818B.4040108-edFDblaTWIyXbbII50Afww@public.gmane.org>
2007-10-02  7:41                   ` Jun Koi
2007-10-02 12:43                   ` Gregory Haskins
2007-10-02  7:42       ` Jun Koi
     [not found]         ` <fdaac4d50710020042w1bc2afcdx98f8c1a5b9df85b0-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2007-10-02 13:49           ` Anthony Liguori
     [not found]             ` <47024C4D.6060302-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-10-02 14:13               ` Avi Kivity
     [not found]                 ` <470251F9.7030902-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-10-02 14:25                   ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4701614B.8090107@codemonkey.ws \
    --to=anthony-rdkfgonbjusknkdkm+me6a@public.gmane.org \
    --cc=cam-edFDblaTWIyXbbII50Afww@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox