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 36c6f7897b1f..c4e3f9103870 100644
|
||
|
--- a/arch/x86/kvm/emulate.c
|
||
|
+++ b/arch/x86/kvm/emulate.c
|
||
|
@@ -855,24 +855,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,
|
||
|
@@ -2201,7 +2186,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;
|
||
|
@@ -2211,7 +2201,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)
|
||
|
@@ -2220,7 +2210,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;
|
||
|
@@ -2258,7 +2248,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)
|
||
|
@@ -2279,7 +2269,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;
|
||
|
@@ -3499,7 +3495,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;
|
||
|
|
||
|
@@ -3532,7 +3533,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);
|