summaryrefslogtreecommitdiffstats
path: root/src/arch/i386/include/librm.h
diff options
context:
space:
mode:
authorMichael Brown2014-05-01 15:58:24 +0200
committerMichael Brown2014-05-02 16:23:20 +0200
commit5a08b63cb7fe3e0c03245c55d955e45226e08bc3 (patch)
tree54dcd3365d2300a31c071bd64a5af222cd3e4018 /src/arch/i386/include/librm.h
parent[librm] Add meaningful labels at section changes (diff)
downloadipxe-5a08b63cb7fe3e0c03245c55d955e45226e08bc3.tar.gz
ipxe-5a08b63cb7fe3e0c03245c55d955e45226e08bc3.tar.xz
ipxe-5a08b63cb7fe3e0c03245c55d955e45226e08bc3.zip
[librm] Speed up protected-to-real mode transition under KVM
On an Intel CPU supporting VMX, KVM will emulate instructions while the CPU state remains "invalid". In real mode, the CPU state is defined to be "invalid" if any segment register has a base which is not equal to (sreg<<4) or a limit which is not equal to 64kB. We don't actually use the base stored in the REAL_DS descriptor for any significant purpose. Change the base stored in this descriptor to be equal to (REAL_DS<<4). A segment register loaded with REAL_DS is then automatically valid in both real and protected modes. This allows KVM to stop emulating instructions much sooner. The only use of REAL_DS for memory accesses currently occurs in the indirect ljmp within prot_to_real. Change this to a direct ljmp, storing rm_cs in .text16 as part of the ljmp instruction. This removes the only memory access via REAL_DS (thereby allowing for the above descriptor base address hack), and also simplifies the ljmp instruction (which will still have to be emulated). Load the real-mode interrupt descriptor table register before switching to real mode, since this avoids triggering an EXCEPTION_NMI and corresponding VM exit. This reduces the time taken by prot_to_real under KVM by around 65%. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/arch/i386/include/librm.h')
-rw-r--r--src/arch/i386/include/librm.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/arch/i386/include/librm.h b/src/arch/i386/include/librm.h
index 4a4e61aa..c8ba72b5 100644
--- a/src/arch/i386/include/librm.h
+++ b/src/arch/i386/include/librm.h
@@ -165,8 +165,8 @@ extern char *text16;
/* Variables in librm.S, present in the normal data segment */
extern uint16_t rm_sp;
extern uint16_t rm_ss;
-extern uint16_t __data16 ( rm_cs );
-#define rm_cs __use_data16 ( rm_cs )
+extern uint16_t __text16 ( rm_cs );
+#define rm_cs __use_text16 ( rm_cs )
extern uint16_t __text16 ( rm_ds );
#define rm_ds __use_text16 ( rm_ds )