mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: kvm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 01/36] KVM: x86 emulator: reduce duplication in one operand emulation thunks
Date: Sun, 14 Dec 2008 10:06:34 +0200	[thread overview]
Message-ID: <1229242029-13410-2-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1229242029-13410-1-git-send-email-avi@redhat.com>

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/x86_emulate.c |   66 +++++++++++++++----------------------------
 1 files changed, 23 insertions(+), 43 deletions(-)

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 8f60ace..5f87d3e 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -359,6 +359,12 @@ static u16 group2_table[] = {
 	"andl %"_msk",%"_LO32 _tmp"; "		\
 	"orl  %"_LO32 _tmp",%"_sav"; "
 
+#ifdef CONFIG_X86_64
+#define ON64(x) x
+#else
+#define ON64(x)
+#endif
+
 /* Raw emulation: instruction has two explicit operands. */
 #define __emulate_2op_nobyte(_op,_src,_dst,_eflags,_wx,_wy,_lx,_ly,_qx,_qy) \
 	do { 								    \
@@ -425,42 +431,27 @@ static u16 group2_table[] = {
 	__emulate_2op_nobyte(_op, _src, _dst, _eflags,			\
 			     "w", "r", _LO32, "r", "", "r")
 
-/* Instruction has only one explicit operand (no source operand). */
-#define emulate_1op(_op, _dst, _eflags)                                    \
+#define __emulate_1op(_op, _dst, _eflags, _suffix)			\
 	do {								\
 		unsigned long _tmp;					\
 									\
+		__asm__ __volatile__ (					\
+			_PRE_EFLAGS("0", "3", "2")			\
+			_op _suffix " %1; "				\
+			_POST_EFLAGS("0", "3", "2")			\
+			: "=m" (_eflags), "+m" ((_dst).val),		\
+			  "=&r" (_tmp)					\
+			: "i" (EFLAGS_MASK));				\
+	} while (0)
+
+/* Instruction has only one explicit operand (no source operand). */
+#define emulate_1op(_op, _dst, _eflags)                                    \
+	do {								\
 		switch ((_dst).bytes) {				        \
-		case 1:							\
-			__asm__ __volatile__ (				\
-				_PRE_EFLAGS("0", "3", "2")		\
-				_op"b %1; "				\
-				_POST_EFLAGS("0", "3", "2")		\
-				: "=m" (_eflags), "=m" ((_dst).val),	\
-				  "=&r" (_tmp)				\
-				: "i" (EFLAGS_MASK));			\
-			break;						\
-		case 2:							\
-			__asm__ __volatile__ (				\
-				_PRE_EFLAGS("0", "3", "2")		\
-				_op"w %1; "				\
-				_POST_EFLAGS("0", "3", "2")		\
-				: "=m" (_eflags), "=m" ((_dst).val),	\
-				  "=&r" (_tmp)				\
-				: "i" (EFLAGS_MASK));			\
-			break;						\
-		case 4:							\
-			__asm__ __volatile__ (				\
-				_PRE_EFLAGS("0", "3", "2")		\
-				_op"l %1; "				\
-				_POST_EFLAGS("0", "3", "2")		\
-				: "=m" (_eflags), "=m" ((_dst).val),	\
-				  "=&r" (_tmp)				\
-				: "i" (EFLAGS_MASK));			\
-			break;						\
-		case 8:							\
-			__emulate_1op_8byte(_op, _dst, _eflags);	\
-			break;						\
+		case 1:	__emulate_1op(_op, _dst, _eflags, "b"); break;	\
+		case 2:	__emulate_1op(_op, _dst, _eflags, "w"); break;	\
+		case 4:	__emulate_1op(_op, _dst, _eflags, "l"); break;	\
+		case 8:	ON64(__emulate_1op(_op, _dst, _eflags, "q")); break; \
 		}							\
 	} while (0)
 
@@ -476,19 +467,8 @@ static u16 group2_table[] = {
 			: _qy ((_src).val), "i" (EFLAGS_MASK));		\
 	} while (0)
 
-#define __emulate_1op_8byte(_op, _dst, _eflags)                           \
-	do {								  \
-		__asm__ __volatile__ (					  \
-			_PRE_EFLAGS("0", "3", "2")			  \
-			_op"q %1; "					  \
-			_POST_EFLAGS("0", "3", "2")			  \
-			: "=m" (_eflags), "=m" ((_dst).val), "=&r" (_tmp) \
-			: "i" (EFLAGS_MASK));				  \
-	} while (0)
-
 #elif defined(__i386__)
 #define __emulate_2op_8byte(_op, _src, _dst, _eflags, _qx, _qy)
-#define __emulate_1op_8byte(_op, _dst, _eflags)
 #endif				/* __i386__ */
 
 /* Fetch next part of the instruction being emulated. */
-- 
1.6.0.3


  reply	other threads:[~2008-12-14  8:09 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-14  8:06 [PATCH 00/36] KVM Updates for 2.6.29 (part 3 of 3) Avi Kivity
2008-12-14  8:06 ` Avi Kivity [this message]
2008-12-14  8:06 ` [PATCH 02/36] KVM: x86 emulator: consolidate emulation of two operand instructions Avi Kivity
2008-12-14  8:06 ` [PATCH 03/36] KVM: s390: Fix refcounting and allow module unload Avi Kivity
2008-12-14  8:06 ` [PATCH 04/36] KVM: s390: Fix memory leak of vcpu->run Avi Kivity
2008-12-14  8:06 ` [PATCH 05/36] KVM: Prevent trace call into unloaded module text Avi Kivity
2008-12-14  8:06 ` [PATCH 06/36] KVM: x86 emulator: Extract 'pop' sequence into a function Avi Kivity
2008-12-14  8:06 ` [PATCH 07/36] KVM: x86 emulator: allow pop from mmio Avi Kivity
2008-12-14  8:06 ` [PATCH 08/36] KVM: x86 emulator: switch 'pop reg' instruction to emulate_pop() Avi Kivity
2008-12-14  8:06 ` [PATCH 09/36] KVM: x86 emulator: fix ret emulation Avi Kivity
2008-12-14  8:06 ` [PATCH 10/36] KVM: x86 emulator: fix popf emulation Avi Kivity
2008-12-14  8:06 ` [PATCH 11/36] KVM: Remove extraneous semicolon after do/while Avi Kivity
2008-12-14  8:06 ` [PATCH 12/36] KVM: fix sparse warning Avi Kivity
2008-12-14  8:06 ` [PATCH 13/36] KVM: VMX: " Avi Kivity
2008-12-14  8:06 ` [PATCH 14/36] KVM: remove the IRQ ACK notifier assertions Avi Kivity
2008-12-14  8:06 ` [PATCH 15/36] KVM: make kvm_unregister_irq_ack_notifier() safe Avi Kivity
2008-12-14  8:06 ` [PATCH 16/36] KVM: don't fee an unallocated irq source id Avi Kivity
2008-12-14  8:06 ` [PATCH 17/36] KVM: add KVM_USERSPACE_IRQ_SOURCE_ID assertions Avi Kivity
2008-12-14  8:06 ` [PATCH 18/36] KVM: split out kvm_free_assigned_irq() Avi Kivity
2008-12-14  8:06 ` [PATCH 19/36] KVM: ppc: support large host pages Avi Kivity
2008-12-14  8:06 ` [PATCH 20/36] powerpc/44x: declare tlb_44x_index for use in C code Avi Kivity
2008-12-14  8:06 ` [PATCH 21/36] KVM: ppc: directly insert shadow mappings into the hardware TLB Avi Kivity
2008-12-14  8:06 ` [PATCH 22/36] KVM: ppc: save and restore guest mappings on context switch Avi Kivity
2008-12-14  8:06 ` [PATCH 23/36] KVM: ppc: Implement in-kernel exit timing statistics Avi Kivity
2008-12-14  8:06 ` [PATCH 24/36] KVM: ppc: mostly cosmetic updates to the exit timing accounting code Avi Kivity
2008-12-14  8:06 ` [PATCH 25/36] KVM: Really remove a slot when a user ask us so Avi Kivity
2008-12-14  8:06 ` [PATCH 26/36] KVM: x86 emulator: Extend the opcode descriptor Avi Kivity
2008-12-14  8:07 ` [PATCH 27/36] KVM: x86 emulator: add Src2 decode set Avi Kivity
2008-12-14  8:07 ` [PATCH 28/36] KVM: x86 emulator: add a new "implied 1" Src decode type Avi Kivity
2008-12-14  8:07 ` [PATCH 29/36] KVM: x86 emulator: add the assembler code for three operands Avi Kivity
2008-12-14  8:07 ` [PATCH 30/36] KVM: x86 emulator: add the emulation of shld and shrd instructions Avi Kivity
2008-12-14  8:07 ` [PATCH 31/36] KVM: x86 emulator: Fix handling of VMMCALL instruction Avi Kivity
2008-12-14  8:07 ` [PATCH 32/36] KVM: MMU: use page array in unsync walk Avi Kivity
2008-12-14  8:07 ` [PATCH 33/36] KVM: MMU: collapse remote TLB flushes on root sync Avi Kivity
2008-12-14  8:07 ` [PATCH 34/36] KVM: MMU: skip global pgtables on sync due to cr3 switch Avi Kivity
2008-12-14  8:07 ` [PATCH 35/36] KVM: MMU: prepopulate the shadow on invlpg Avi Kivity
2008-12-14  8:07 ` [PATCH 36/36] x86: KVM guest: kvm_get_tsc_khz: return khz, not lpj 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=1229242029-13410-2-git-send-email-avi@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®