On 04/27/2010 03:15 PM, Gleb Natapov wrote:
Use callbacks from x86_emulate_ops to access segments instead of calling
into kvm directly.



-static unsigned long seg_base(struct x86_emulate_ctxt *ctxt, int seg)
+static unsigned long seg_base(struct x86_emulate_ctxt *ctxt,
+                             struct x86_emulate_ops *ops, int seg)
  {
-       if (ctxt->mode == X86EMUL_MODE_PROT64&&  seg<  VCPU_SREG_FS)
-               return 0;
+       unsigned long base;

-       return kvm_x86_ops->get_segment_base(ctxt->vcpu, seg);

get_segment_base() is only one vmread on intel, but you replace it with reading the entire segment.

+       if (ctxt->mode == X86EMUL_MODE_PROT64) {
+               u64 val;
+               switch (seg) {
+               case VCPU_SREG_FS:
+                       ops->get_msr(ctxt->vcpu, MSR_FS_BASE,&val);
+                       break;
+               case VCPU_SREG_GS:
+                       ops->get_msr(ctxt->vcpu, MSR_GS_BASE,&val);
+                       break;
+               default:
+                       val = 0;
+                       break;
+               }

Why this ugliness?  get_cached_descriptor() should do this.


  static unsigned long seg_override_base(struct x86_emulate_ctxt *ctxt,
+                                      struct x86_emulate_ops *ops,
                                       struct decode_cache *c)
  {
        if (!c->has_seg_override)
                return 0;

-       return seg_base(ctxt, c->seg_override);
+       return seg_base(ctxt, ops, c->seg_override);
  }

Sticking ops into ctxt would reduce the size of these patches.

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to