public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCHv2 08/23] KVM: x86 emulator: add get_cached_segment_base() callback to x86_emulate_ops.
Date: Wed, 28 Apr 2010 19:15:29 +0300	[thread overview]
Message-ID: <1272471344-7076-9-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1272471344-7076-1-git-send-email-gleb@redhat.com>

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>
---
 arch/x86/include/asm/kvm_emulate.h |    1 +
 arch/x86/kvm/emulate.c             |   13 +------------
 arch/x86/kvm/x86.c                 |    7 +++++++
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/kvm_emulate.h b/arch/x86/include/asm/kvm_emulate.h
index f751657..df53ba2 100644
--- a/arch/x86/include/asm/kvm_emulate.h
+++ b/arch/x86/include/asm/kvm_emulate.h
@@ -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);
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 37b20c3..41c77a1 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -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 ? */
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 69db0c8..2829e8f 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3652,6 +3652,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)
 {
@@ -3742,6 +3748,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,
-- 
1.6.5


  parent reply	other threads:[~2010-04-28 16:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-28 16:15 [PATCHv2 00/23] next round of emulator cleanups Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 01/23] KVM: x86 emulator: introduce read cache Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 02/23] KVM: x86 emulator: fix Move r/m16 to segment register decoding Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 03/23] KVM: x86 emulator: cleanup xchg emulation Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 04/23] KVM: x86 emulator: cleanup nop emulation Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 05/23] KVM: x86 emulator: handle "far address" source operand Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 06/23] KVM: x86 emulator: add (set|get)_dr callbacks to x86_emulate_ops Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 07/23] KVM: x86 emulator: add (set|get)_msr " Gleb Natapov
2010-04-28 16:15 ` Gleb Natapov [this message]
2010-04-28 16:15 ` [PATCHv2 09/23] KVM: x86 emulator: cleanup some direct calls into kvm to use existing callbacks Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 10/23] KVM: x86 emulator: make set_cr() callback return error if it fails Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 11/23] KVM: x86 emulator: make (get|set)_dr() " Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 12/23] KVM: x86 emulator: fix X86EMUL_RETRY_INSTR and X86EMUL_CMPXCHG_FAILED values Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 13/23] KVM: fill in run->mmio details in (read|write)_emulated function Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 14/23] KVM: x86 emulator: x86_emulate_insn() return -1 only in case of emulation failure Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 15/23] KVM: remove export of emulator_write_emulated() Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 16/23] KVM: do not inject #PF in (read|write)_emulated() callbacks Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 17/23] KVM: handle emulation failure case first Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 18/23] KVM: x86 emulator: advance RIP outside x86 emulator code Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 19/23] KVM: x86 emulator: set RFLAGS " Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 20/23] KVM: x86 emulator: use shadowed register in emulate_sysexit() Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 21/23] KVM: x86 exmulator: handle shadowed registers outside emulator Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 22/23] KVM: x86 emulator: move interruptibility state tracking out of emulator Gleb Natapov
2010-04-28 16:15 ` [PATCHv2 23/23] KVM: x86 emulator: do not inject exception directly into vcpu Gleb Natapov
     [not found]   ` <446597.86519.qm@web55502.mail.re4.yahoo.com>
2010-04-29 10:17     ` qemu-kvm.0.12.2 aborts on linux Gleb Natapov
     [not found]       ` <792291.45224.qm@web55507.mail.re4.yahoo.com>
2010-05-02  5:23         ` Gleb Natapov
     [not found]           ` <710443.70603.qm@web55504.mail.re4.yahoo.com>
2010-05-03  7:44             ` Gleb Natapov
2010-04-29  9:26 ` [PATCHv2 00/23] next round of emulator cleanups Avi Kivity
2010-05-05  7:57 ` Avi Kivity

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1272471344-7076-9-git-send-email-gleb@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox