1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Maxim Levitsky <mlevitsk@redhat.com>
3 Date: Tue, 21 Jun 2022 18:08:54 +0300
4 Subject: [PATCH] KVM: x86: emulator: remove assign_eip_near/far
6 Now the assign_eip_far just updates the emulation mode in addition to
7 updating the rip, it doesn't make sense to keep that function.
9 Move mode update to the callers and remove these functions.
11 No functional change is intended.
13 Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
14 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
16 arch/x86/kvm/emulate.c | 47 +++++++++++++++++++++---------------------
17 1 file changed, 24 insertions(+), 23 deletions(-)
19 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
20 index 36c6f7897b1f..c4e3f9103870 100644
21 --- a/arch/x86/kvm/emulate.c
22 +++ b/arch/x86/kvm/emulate.c
23 @@ -855,24 +855,9 @@ static inline int update_emulation_mode(struct x86_emulate_ctxt *ctxt)
24 return X86EMUL_CONTINUE;
27 -static inline int assign_eip_near(struct x86_emulate_ctxt *ctxt, ulong dst)
29 - return assign_eip(ctxt, dst);
32 -static int assign_eip_far(struct x86_emulate_ctxt *ctxt, ulong dst)
34 - int rc = update_emulation_mode(ctxt);
36 - if (rc != X86EMUL_CONTINUE)
39 - return assign_eip(ctxt, dst);
42 static inline int jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
44 - return assign_eip_near(ctxt, ctxt->_eip + rel);
45 + return assign_eip(ctxt, ctxt->_eip + rel);
48 static int linear_read_system(struct x86_emulate_ctxt *ctxt, ulong linear,
49 @@ -2201,7 +2186,12 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
50 if (rc != X86EMUL_CONTINUE)
53 - rc = assign_eip_far(ctxt, ctxt->src.val);
54 + rc = update_emulation_mode(ctxt);
55 + if (rc != X86EMUL_CONTINUE)
58 + rc = assign_eip(ctxt, ctxt->src.val);
60 /* Error handling is not implemented. */
61 if (rc != X86EMUL_CONTINUE)
62 return X86EMUL_UNHANDLEABLE;
63 @@ -2211,7 +2201,7 @@ static int em_jmp_far(struct x86_emulate_ctxt *ctxt)
65 static int em_jmp_abs(struct x86_emulate_ctxt *ctxt)
67 - return assign_eip_near(ctxt, ctxt->src.val);
68 + return assign_eip(ctxt, ctxt->src.val);
71 static int em_call_near_abs(struct x86_emulate_ctxt *ctxt)
72 @@ -2220,7 +2210,7 @@ static int em_call_near_abs(struct x86_emulate_ctxt *ctxt)
76 - rc = assign_eip_near(ctxt, ctxt->src.val);
77 + rc = assign_eip(ctxt, ctxt->src.val);
78 if (rc != X86EMUL_CONTINUE)
80 ctxt->src.val = old_eip;
81 @@ -2258,7 +2248,7 @@ static int em_ret(struct x86_emulate_ctxt *ctxt)
82 if (rc != X86EMUL_CONTINUE)
85 - return assign_eip_near(ctxt, eip);
86 + return assign_eip(ctxt, eip);
89 static int em_ret_far(struct x86_emulate_ctxt *ctxt)
90 @@ -2279,7 +2269,13 @@ static int em_ret_far(struct x86_emulate_ctxt *ctxt)
92 if (rc != X86EMUL_CONTINUE)
94 - rc = assign_eip_far(ctxt, eip);
96 + rc = update_emulation_mode(ctxt);
97 + if (rc != X86EMUL_CONTINUE)
100 + rc = assign_eip(ctxt, eip);
102 /* Error handling is not implemented. */
103 if (rc != X86EMUL_CONTINUE)
104 return X86EMUL_UNHANDLEABLE;
105 @@ -3499,7 +3495,12 @@ static int em_call_far(struct x86_emulate_ctxt *ctxt)
106 if (rc != X86EMUL_CONTINUE)
109 - rc = assign_eip_far(ctxt, ctxt->src.val);
110 + rc = update_emulation_mode(ctxt);
111 + if (rc != X86EMUL_CONTINUE)
114 + rc = assign_eip(ctxt, ctxt->src.val);
116 if (rc != X86EMUL_CONTINUE)
119 @@ -3532,7 +3533,7 @@ static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt)
120 rc = emulate_pop(ctxt, &eip, ctxt->op_bytes);
121 if (rc != X86EMUL_CONTINUE)
123 - rc = assign_eip_near(ctxt, eip);
124 + rc = assign_eip(ctxt, eip);
125 if (rc != X86EMUL_CONTINUE)
127 rsp_increment(ctxt, ctxt->src.val);