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 17/37] KVM: x86 emulator: implement 'ret far' instruction (opcode 0xcb)
Date: Fri, 27 Feb 2009 12:26:40 +0200	[thread overview]
Message-ID: <1235730420-7929-18-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1235730420-7929-1-git-send-email-avi@redhat.com>

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

diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
index 94459f3..ca91749 100644
--- a/arch/x86/kvm/x86_emulate.c
+++ b/arch/x86/kvm/x86_emulate.c
@@ -178,7 +178,7 @@ static u32 opcode_table[256] = {
 	0, ImplicitOps | Stack, 0, 0,
 	ByteOp | DstMem | SrcImm | ModRM | Mov, DstMem | SrcImm | ModRM | Mov,
 	/* 0xC8 - 0xCF */
-	0, 0, 0, 0, 0, 0, 0, 0,
+	0, 0, 0, ImplicitOps | Stack, 0, 0, 0, 0,
 	/* 0xD0 - 0xD7 */
 	ByteOp | DstMem | SrcImplicit | ModRM, DstMem | SrcImplicit | ModRM,
 	ByteOp | DstMem | SrcImplicit | ModRM, DstMem | SrcImplicit | ModRM,
@@ -1278,6 +1278,25 @@ static inline int emulate_grp9(struct x86_emulate_ctxt *ctxt,
 	return 0;
 }
 
+static int emulate_ret_far(struct x86_emulate_ctxt *ctxt,
+			   struct x86_emulate_ops *ops)
+{
+	struct decode_cache *c = &ctxt->decode;
+	int rc;
+	unsigned long cs;
+
+	rc = emulate_pop(ctxt, ops, &c->eip, c->op_bytes);
+	if (rc)
+		return rc;
+	if (c->op_bytes == 4)
+		c->eip = (u32)c->eip;
+	rc = emulate_pop(ctxt, ops, &cs, c->op_bytes);
+	if (rc)
+		return rc;
+	rc = kvm_load_segment_descriptor(ctxt->vcpu, (u16)cs, 1, VCPU_SREG_CS);
+	return rc;
+}
+
 static inline int writeback(struct x86_emulate_ctxt *ctxt,
 			    struct x86_emulate_ops *ops)
 {
@@ -1735,6 +1754,11 @@ special_insn:
 	mov:
 		c->dst.val = c->src.val;
 		break;
+	case 0xcb:		/* ret far */
+		rc = emulate_ret_far(ctxt, ops);
+		if (rc)
+			goto done;
+		break;
 	case 0xd0 ... 0xd1:	/* Grp2 */
 		c->src.val = 1;
 		emulate_grp2(ctxt);
-- 
1.6.0.6


  parent reply	other threads:[~2009-02-27 10:31 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-27 10:26 [PATCH 00/37] KVM Updates for the 2.6.30 merge window (2/3) Avi Kivity
2009-02-27 10:26 ` [PATCH 01/37] KVM: ppc: rename 44x MMU functions used in booke.c Avi Kivity
2009-02-27 10:26 ` [PATCH 02/37] KVM: ppc: remove last 44x-specific bits from booke.c Avi Kivity
2009-02-27 10:26 ` [PATCH 03/37] KVM: ppc: use macros instead of hardcoded literals for instruction decoding Avi Kivity
2009-02-27 10:26 ` [PATCH 04/37] KVM: ppc: split out common Book E instruction emulation Avi Kivity
2009-02-27 10:26 ` [PATCH 05/37] KVM: ppc: Add dbsr in kvm_vcpu_arch Avi Kivity
2009-02-27 10:26 ` [PATCH 06/37] KVM: ppc: No need to include core-header for KVM in asm-offsets.c currently Avi Kivity
2009-02-27 10:26 ` [PATCH 07/37] KVM: ppc: ifdef iccci with CONFIG_44x Avi Kivity
2009-02-27 10:26 ` [PATCH 08/37] KVM: ppc: E500 core-specific code Avi Kivity
2009-02-27 10:26 ` [PATCH 09/37] KVM: ppc: Add kvmppc_mmu_dtlb/itlb_miss for booke Avi Kivity
2009-02-27 10:26 ` [PATCH 10/37] KVM: ppc: distinguish between interrupts and priorities Avi Kivity
2009-02-27 10:26 ` [PATCH 11/37] KVM: ppc: Add extra E500 exceptions Avi Kivity
2009-02-27 10:26 ` [PATCH 12/37] KVM: VMX: Fix guest state validity checks Avi Kivity
2009-02-27 10:26 ` [PATCH 13/37] KVM: VMX: don't clobber segment AR if emulating invalid state Avi Kivity
2009-02-27 10:26 ` [PATCH 14/37] KVM: VMX: Prevent exit handler from running if emulating due to " Avi Kivity
2009-02-27 10:26 ` [PATCH 15/37] KVM: x86 emulator: Make emulate_pop() a little more generic Avi Kivity
2009-02-27 10:26 ` [PATCH 16/37] KVM: VMX: When emulating on invalid vmx state, don't return to userspace unnecessarily Avi Kivity
2009-02-27 10:26 ` Avi Kivity [this message]
2009-02-27 10:26 ` [PATCH 18/37] KVM: Properly lock PIT creation Avi Kivity
2009-02-27 10:26 ` [PATCH 19/37] KVM: ppc: remove debug support broken by KVM debug rewrite Avi Kivity
2009-02-27 10:26 ` [PATCH 20/37] KVM: Remove duplicated prototype of kvm_arch_destroy_vm Avi Kivity
2009-02-27 10:26 ` [PATCH 21/37] KVM: Add support to disable MSI for assigned device Avi Kivity
2009-02-27 10:26 ` [PATCH 22/37] KVM: SVM: Add microcode patch level dummy Avi Kivity
2009-02-27 10:26 ` [PATCH 23/37] KVM: MMU: Optimize page unshadowing Avi Kivity
2009-02-27 10:26 ` [PATCH 24/37] KVM: Add CONFIG_HAVE_KVM_IRQCHIP Avi Kivity
2009-02-27 10:26 ` [PATCH 25/37] KVM: Interrupt mask notifiers for ioapic Avi Kivity
2009-02-27 10:26 ` [PATCH 26/37] KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked Avi Kivity
2009-02-27 10:26 ` [PATCH 27/37] KVM: ia64: expose registers in struct kvm_regs Avi Kivity
2009-02-27 10:26 ` [PATCH 28/37] KVM: SVM: Fix typo in has_svm() Avi Kivity
2009-02-27 10:26 ` [PATCH 29/37] KVM: MMU: drop zeroing on mmu_memory_cache_alloc Avi Kivity
2009-02-27 10:26 ` [PATCH 30/37] KVM: MMU: Rename "metaphysical" attribute to "direct" Avi Kivity
2009-02-27 10:26 ` [PATCH 31/37] KVM: MMU: Only enable cr4_pge role in shadow mode Avi Kivity
2009-02-27 10:26 ` [PATCH 32/37] powerpc/fsl-booke: declare tlbcam_index for use in c Avi Kivity
2009-02-27 10:26 ` [PATCH 33/37] KVM: ppc: Fix e500 warnings and some spelling problems Avi Kivity
2009-02-27 10:26 ` [PATCH 34/37] KVM: ppc: Move to new TLB invalidate interface Avi Kivity
2009-02-27 10:26 ` [PATCH 35/37] KVM: x86: Fix typos and whitespace errors Avi Kivity
2009-02-27 10:26 ` [PATCH 36/37] KVM: Userspace controlled irq routing Avi Kivity
2009-02-27 10:27 ` [PATCH 37/37] KVM: Avoid using CONFIG_ in userspace visible headers 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=1235730420-7929-18-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

Powered by JetHome