[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] Purpose of do_general_protection() in Xen


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: "Peter Teoh" <htmldeveloper@xxxxxxxxx>
  • Date: Wed, 10 Oct 2007 00:12:09 +0800
  • Delivery-date: Tue, 09 Oct 2007 09:12:51 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=NUkHTJf6U6ojMRMQ+z9UuPwT9OhbRxOr2lvPcfm98llHVBfqhC8cEkGr6U/N+B1QAyD8rE2f7Lz4OTO/A6I6QIXeLCNxz7Im+jaJVIssI6mJn8O0FlZ2VIk66gvYO0drqY0P3PYp+ETJN+S6wqp/KomyvHCID7z6T6z14NwrcfA=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

This part of the code puzzle me a lot:

in arch/x86/traps.c: do_general_protection():

asmlinkage int do_general_protection(struct cpu_user_regs *regs)
{

And reading through the remarks:

    /*
     * Cunning trick to allow arbitrary "INT n" handling.
     *
     * We set DPL == 0 on all vectors in the IDT. This prevents any INT <n>
     * instruction from trapping to the appropriate vector, when that might not
     * be expected by Xen or the guest OS. For example, that entry might be for
     * a fault handler (unlike traps, faults don't increment EIP), or might
     * expect an error code on the stack (which a software trap never
     * provides), or might be a hardware interrupt handler that doesn't like
     * being called spuriously.
     *
     * Instead, a GPF occurs with the faulting IDT vector in the error code.
     * Bit 1 is set to indicate that an IDT entry caused the fault. Bit 0 is
     * clear to indicate that it's a software fault, not hardware.
       */

Now question is:

The code in Xen hypervisor is running at CPL 0, and so if the DPL of
IDT is set to 0, upon encountering interrupt condition, the
corresponding entries in IDT will still be executed, and not
triggering a GPF (triggered only if DPL of IDT entries is >0, right?).

Where is the code that set the DPL of IDT to zero?

And why do we need to handle this "cunning trick"?   Can't we just the
normal interrupt table?

Thank you very much for your help.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.