]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
KVM: x86 emulator: add get_cached_segment_base() callback to x86_emulate_ops
authorGleb Natapov <gleb@redhat.com>
Wed, 28 Apr 2010 16:15:29 +0000 (19:15 +0300)
committerAvi Kivity <avi@redhat.com>
Sun, 1 Aug 2010 07:35:31 +0000 (10:35 +0300)
On VMX it is expensive to call get_cached_descriptor() just to get segment
base since multiple vmcs_reads are done instead of only one. Introduce
new call back get_cached_segment_base() for efficiency.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_emulate.h
arch/x86/kvm/emulate.c
arch/x86/kvm/x86.c

index f751657be73299bfb7ebf08beee51933b2797cd8..df53ba2294b6c027af36416845e03fd6f0407fb8 100644 (file)
@@ -132,6 +132,7 @@ struct x86_emulate_ops {
                                      int seg, struct kvm_vcpu *vcpu);
        u16 (*get_segment_selector)(int seg, struct kvm_vcpu *vcpu);
        void (*set_segment_selector)(u16 sel, int seg, struct kvm_vcpu *vcpu);
+       unsigned long (*get_cached_segment_base)(int seg, struct kvm_vcpu *vcpu);
        void (*get_gdt)(struct desc_ptr *dt, struct kvm_vcpu *vcpu);
        ulong (*get_cr)(int cr, struct kvm_vcpu *vcpu);
        void (*set_cr)(int cr, ulong val, struct kvm_vcpu *vcpu);
index 7c8ed560fd41002de2588a599d1320dd7d3d5e5a..8228778ace38111b31561886335f1273e30fc765 100644 (file)
@@ -2097,17 +2097,6 @@ static bool emulator_io_permited(struct x86_emulate_ctxt *ctxt,
        return true;
 }
 
-static u32 get_cached_descriptor_base(struct x86_emulate_ctxt *ctxt,
-                                     struct x86_emulate_ops *ops,
-                                     int seg)
-{
-       struct desc_struct desc;
-       if (ops->get_cached_descriptor(&desc, seg, ctxt->vcpu))
-               return get_desc_base(&desc);
-       else
-               return ~0;
-}
-
 static void save_state_to_tss16(struct x86_emulate_ctxt *ctxt,
                                struct x86_emulate_ops *ops,
                                struct tss_segment_16 *tss)
@@ -2383,7 +2372,7 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
        int ret;
        u16 old_tss_sel = ops->get_segment_selector(VCPU_SREG_TR, ctxt->vcpu);
        ulong old_tss_base =
-               get_cached_descriptor_base(ctxt, ops, VCPU_SREG_TR);
+               ops->get_cached_segment_base(VCPU_SREG_TR, ctxt->vcpu);
        u32 desc_limit;
 
        /* FIXME: old_tss_base == ~0 ? */
index e3a5455049b0715182177ed185364fb2ead7d9b7..9a469df6011ca63825135d3abd9c1248ea79f375 100644 (file)
@@ -3714,6 +3714,12 @@ static void emulator_get_gdt(struct desc_ptr *dt, struct kvm_vcpu *vcpu)
        kvm_x86_ops->get_gdt(vcpu, dt);
 }
 
+static unsigned long emulator_get_cached_segment_base(int seg,
+                                                     struct kvm_vcpu *vcpu)
+{
+       return get_segment_base(vcpu, seg);
+}
+
 static bool emulator_get_cached_descriptor(struct desc_struct *desc, int seg,
                                           struct kvm_vcpu *vcpu)
 {
@@ -3804,6 +3810,7 @@ static struct x86_emulate_ops emulate_ops = {
        .set_cached_descriptor = emulator_set_cached_descriptor,
        .get_segment_selector = emulator_get_segment_selector,
        .set_segment_selector = emulator_set_segment_selector,
+       .get_cached_segment_base = emulator_get_cached_segment_base,
        .get_gdt             = emulator_get_gdt,
        .get_cr              = emulator_get_cr,
        .set_cr              = emulator_set_cr,