public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: emulator: drop unneeded call to get_segment()
@ 2012-07-25 12:49 Gleb Natapov
  2012-07-26  9:21 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Gleb Natapov @ 2012-07-25 12:49 UTC (permalink / raw)
  To: kvm; +Cc: avi, mtosatti

setup_syscalls_segments() calls get_segment() and than overwrites all
but one of the structure fields and this one should also be overwritten
anyway, so we can drop call to get_segment() and avoid a couple of vmreads
on vmx. Also drop zeroing ss/cs structures since most of the fields are
set anyway. Just set those that were not set explicitly.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 85b611e..a3d4546 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2038,12 +2038,6 @@ static void
 setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
 			struct desc_struct *cs, struct desc_struct *ss)
 {
-	u16 selector;
-
-	memset(cs, 0, sizeof(struct desc_struct));
-	ctxt->ops->get_segment(ctxt, &selector, cs, NULL, VCPU_SREG_CS);
-	memset(ss, 0, sizeof(struct desc_struct));
-
 	cs->l = 0;		/* will be adjusted later */
 	set_desc_base(cs, 0);	/* flat segment */
 	cs->g = 1;		/* 4kb granularity */
@@ -2053,6 +2047,7 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
 	cs->dpl = 0;		/* will be adjusted later */
 	cs->p = 1;
 	cs->d = 1;
+	cs->avl = 0;
 
 	set_desc_base(ss, 0);	/* flat segment */
 	set_desc_limit(ss, 0xfffff);	/* 4GB limit */
@@ -2062,6 +2057,8 @@ setup_syscalls_segments(struct x86_emulate_ctxt *ctxt,
 	ss->d = 1;		/* 32bit stack segment */
 	ss->dpl = 0;
 	ss->p = 1;
+	ss->l = 0;
+	ss->avl = 0;
 }
 
 static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
--
			Gleb.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: emulator: drop unneeded call to get_segment()
  2012-07-25 12:49 [PATCH] KVM: emulator: drop unneeded call to get_segment() Gleb Natapov
@ 2012-07-26  9:21 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2012-07-26  9:21 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mtosatti

On 07/25/2012 03:49 PM, Gleb Natapov wrote:
> setup_syscalls_segments() calls get_segment() and than overwrites all
> but one of the structure fields and this one should also be overwritten
> anyway, so we can drop call to get_segment() and avoid a couple of vmreads
> on vmx. Also drop zeroing ss/cs structures since most of the fields are
> set anyway. Just set those that were not set explicitly.
> 

Applied, thanks.


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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-26  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-25 12:49 [PATCH] KVM: emulator: drop unneeded call to get_segment() Gleb Natapov
2012-07-26  9:21 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox