]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0022-KVM-x86-emulator-remove-assign_eip_near-far.patch
ee565d7b0be4d1c9cf9f08e8fa75a210108be5d6
[pve-kernel.git] / patches / kernel / 0022-KVM-x86-emulator-remove-assign_eip_near-far.patch
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
5
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.
8
9 Move mode update to the callers and remove these functions.
10
11 No functional change is intended.
12
13 Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
14 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
15 ---
16 arch/x86/kvm/emulate.c | 47 +++++++++++++++++++++---------------------
17 1 file changed, 24 insertions(+), 23 deletions(-)
18
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;
25 }
26
27 -static inline int assign_eip_near(struct x86_emulate_ctxt *ctxt, ulong dst)
28 -{
29 - return assign_eip(ctxt, dst);
30 -}
31 -
32 -static int assign_eip_far(struct x86_emulate_ctxt *ctxt, ulong dst)
33 -{
34 - int rc = update_emulation_mode(ctxt);
35 -
36 - if (rc != X86EMUL_CONTINUE)
37 - return rc;
38 -
39 - return assign_eip(ctxt, dst);
40 -}
41 -
42 static inline int jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
43 {
44 - return assign_eip_near(ctxt, ctxt->_eip + rel);
45 + return assign_eip(ctxt, ctxt->_eip + rel);
46 }
47
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)
51 return rc;
52
53 - rc = assign_eip_far(ctxt, ctxt->src.val);
54 + rc = update_emulation_mode(ctxt);
55 + if (rc != X86EMUL_CONTINUE)
56 + return rc;
57 +
58 + rc = assign_eip(ctxt, ctxt->src.val);
59 +
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)
64
65 static int em_jmp_abs(struct x86_emulate_ctxt *ctxt)
66 {
67 - return assign_eip_near(ctxt, ctxt->src.val);
68 + return assign_eip(ctxt, ctxt->src.val);
69 }
70
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)
73 long int old_eip;
74
75 old_eip = ctxt->_eip;
76 - rc = assign_eip_near(ctxt, ctxt->src.val);
77 + rc = assign_eip(ctxt, ctxt->src.val);
78 if (rc != X86EMUL_CONTINUE)
79 return rc;
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)
83 return rc;
84
85 - return assign_eip_near(ctxt, eip);
86 + return assign_eip(ctxt, eip);
87 }
88
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)
91 &new_desc);
92 if (rc != X86EMUL_CONTINUE)
93 return rc;
94 - rc = assign_eip_far(ctxt, eip);
95 +
96 + rc = update_emulation_mode(ctxt);
97 + if (rc != X86EMUL_CONTINUE)
98 + return rc;
99 +
100 + rc = assign_eip(ctxt, eip);
101 +
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)
107 return rc;
108
109 - rc = assign_eip_far(ctxt, ctxt->src.val);
110 + rc = update_emulation_mode(ctxt);
111 + if (rc != X86EMUL_CONTINUE)
112 + return rc;
113 +
114 + rc = assign_eip(ctxt, ctxt->src.val);
115 +
116 if (rc != X86EMUL_CONTINUE)
117 goto fail;
118
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)
122 return rc;
123 - rc = assign_eip_near(ctxt, eip);
124 + rc = assign_eip(ctxt, eip);
125 if (rc != X86EMUL_CONTINUE)
126 return rc;
127 rsp_increment(ctxt, ctxt->src.val);