f6df304f26
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
128 lines
3.7 KiB
Diff
128 lines
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Maxim Levitsky <mlevitsk@redhat.com>
|
|
Date: Tue, 21 Jun 2022 18:08:54 +0300
|
|
Subject: [PATCH] KVM: x86: emulator: remove assign_eip_near/far
|
|
|
|
Now the assign_eip_far just updates the emulation mode in addition to
|
|
updating the rip, it doesn't make sense to keep that function.
|
|
|
|
Move mode update to the callers and remove these functions.
|
|
|
|
No functional change is intended.
|
|
|
|
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
|
|
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
|
|
---
|
|
arch/x86/kvm/emulate.c | 47 +++++++++++++++++++++---------------------
|
|
1 file changed, 24 insertions(+), 23 deletions(-)
|
|
|
|
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
|
|
index 1b5123a882a1..9e305e0cd815 100644
|
|
--- a/arch/x86/kvm/emulate.c
|
|
+++ b/arch/x86/kvm/emulate.c
|
|
@@ -857,24 +857,9 @@ static inline int update_emulation_mode(struct x86_emulate_ctxt *ctxt)
|
|
return X86EMUL_CONTINUE;
|
|
}
|
|
|
|
-static inline int assign_eip_near(struct x86_emulate_ctxt *ctxt, ulong dst)
|
|
-{
|
|
- return assign_eip(ctxt, dst);
|
|
-}
|
|
-
|
|
-static int assign_eip_far(struct x86_emulate_ctxt *ctxt, ulong dst)
|
|
-{
|
|
- int rc = update_emulation_mode(ctxt);
|
|
-
|
|
- if (rc != X86EMUL_CONTINUE)
|
|
- return rc;
|
|
-
|
|
- return assign_eip(ctxt, dst);
|
|
-}
|
|
-
|
|
static inline int jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
|
|
{
|
|
- return assign_eip_near(ctxt, ctxt->_eip + rel);
|
|
+ return assign_eip(ctxt, ctxt->_eip + rel);
|
|
}
|
|
|
|
static int linear_read_system(struct x86_emulate_ctxt *ctxt, ulong linear,
|
|
@@ -2183,7 +2168,12 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
|
|
- rc = assign_eip_far(ctxt, ctxt->src.val);
|
|
+ rc = update_emulation_mode(ctxt);
|
|
+ if (rc != X86EMUL_CONTINUE)
|
|
+ return rc;
|
|
+
|
|
+ rc = assign_eip(ctxt, ctxt->src.val);
|
|
+
|
|
/* Error handling is not implemented. */
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return X86EMUL_UNHANDLEABLE;
|
|
@@ -2193,7 +2183,7 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
|
|
|
|
static int em_jmp_abs(struct x86_emulate_ctxt *ctxt)
|
|
{
|
|
- return assign_eip_near(ctxt, ctxt->src.val);
|
|
+ return assign_eip(ctxt, ctxt->src.val);
|
|
}
|
|
|
|
static int em_call_near_abs(struct x86_emulate_ctxt *ctxt)
|
|
@@ -2202,7 +2192,7 @@ static int em_call_near_abs(struct x86_emulate_ctxt *ctxt)
|
|
long int old_eip;
|
|
|
|
old_eip = ctxt->_eip;
|
|
- rc = assign_eip_near(ctxt, ctxt->src.val);
|
|
+ rc = assign_eip(ctxt, ctxt->src.val);
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
ctxt->src.val = old_eip;
|
|
@@ -2240,7 +2230,7 @@ static int em_ret(struct x86_emulate_ctxt *ctxt)
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
|
|
- return assign_eip_near(ctxt, eip);
|
|
+ return assign_eip(ctxt, eip);
|
|
}
|
|
|
|
static int em_ret_far(struct x86_emulate_ctxt *ctxt)
|
|
@@ -2264,7 +2254,13 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
|
|
&new_desc);
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
- rc = assign_eip_far(ctxt, eip);
|
|
+
|
|
+ rc = update_emulation_mode(ctxt);
|
|
+ if (rc != X86EMUL_CONTINUE)
|
|
+ return rc;
|
|
+
|
|
+ rc = assign_eip(ctxt, eip);
|
|
+
|
|
/* Error handling is not implemented. */
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return X86EMUL_UNHANDLEABLE;
|
|
@@ -3488,7 +3484,12 @@ static int em_call_far(struct x86_emulate_ctxt *ctxt)
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
|
|
- rc = assign_eip_far(ctxt, ctxt->src.val);
|
|
+ rc = update_emulation_mode(ctxt);
|
|
+ if (rc != X86EMUL_CONTINUE)
|
|
+ return rc;
|
|
+
|
|
+ rc = assign_eip(ctxt, ctxt->src.val);
|
|
+
|
|
if (rc != X86EMUL_CONTINUE)
|
|
goto fail;
|
|
|
|
@@ -3521,7 +3522,7 @@ static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt)
|
|
rc = emulate_pop(ctxt, &eip, ctxt->op_bytes);
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
- rc = assign_eip_near(ctxt, eip);
|
|
+ rc = assign_eip(ctxt, eip);
|
|
if (rc != X86EMUL_CONTINUE)
|
|
return rc;
|
|
rsp_increment(ctxt, ctxt->src.val);
|