[librm] Speed up real-to-protected mode transition under KVM

Ensure that all segment registers have zero in the low two bits before
transitioning to protected mode.  This allows the CPU state to
immediately be deemed to be "valid", and eliminates the need for any
further emulated instructions.

Load the protected-mode interrupt descriptor table after switching to
protected mode, since this avoids triggering an EXCEPTION_NMI and
corresponding VM exit.

This reduces the time taken by real_to_prot under KVM by around 50%.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2014-05-02 13:18:55 +01:00
parent 5a08b63cb7
commit c64747db50
3 changed files with 22 additions and 5 deletions

View File

@@ -26,10 +26,9 @@ static struct interrupt_vector intr_vec[ IRQ_MAX + 1 ];
struct interrupt_descriptor idt[NUM_INT] __attribute__ (( aligned ( 16 ) ));
/** The interrupt descriptor table register */
struct idtr __data16 ( idtr ) = {
struct idtr idtr = {
.limit = ( sizeof ( idt ) - 1 ),
};
#define idtr __use_data16 ( idtr )
/**
* Allocate space on the real-mode stack and copy data there from a