public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Maxim Levitsky <mlevitsk@redhat.com>
To: kvm@vger.kernel.org
Cc: Sean Christopherson <seanjc@google.com>,
	x86@kernel.org, Kees Cook <keescook@chromium.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Borislav Petkov <bp@alien8.de>, Joerg Roedel <joro@8bytes.org>,
	Ingo Molnar <mingo@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>,
	Maxim Levitsky <mlevitsk@redhat.com>
Subject: [PATCH v2 03/11] KVM: x86: emulator: remove assign_eip_near/far
Date: Tue, 21 Jun 2022 18:08:54 +0300	[thread overview]
Message-ID: <20220621150902.46126-4-mlevitsk@redhat.com> (raw)
In-Reply-To: <20220621150902.46126-1-mlevitsk@redhat.com>

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>
---
 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 2c0087df2d7e6a..334a06e6c9b093 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -866,24 +866,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,
@@ -2213,7 +2198,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;
@@ -2223,7 +2213,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)
@@ -2232,7 +2222,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;
@@ -2270,7 +2260,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)
@@ -2291,7 +2281,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;
@@ -3511,7 +3507,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;
 
@@ -3544,7 +3545,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);
-- 
2.26.3


  parent reply	other threads:[~2022-06-21 15:09 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 15:08 [PATCH v2 00/11] SMM emulation and interrupt shadow fixes Maxim Levitsky
2022-06-21 15:08 ` [PATCH v2 01/11] KVM: x86: emulator: em_sysexit should update ctxt->mode Maxim Levitsky
2022-06-21 15:08 ` [PATCH v2 02/11] KVM: x86: emulator: introduce update_emulation_mode Maxim Levitsky
2022-07-20 23:44   ` Sean Christopherson
2022-07-21 11:52     ` Maxim Levitsky
2022-07-21 14:23       ` Sean Christopherson
2022-06-21 15:08 ` Maxim Levitsky [this message]
2022-07-20 23:51   ` [PATCH v2 03/11] KVM: x86: emulator: remove assign_eip_near/far Sean Christopherson
2022-07-21 11:52     ` Maxim Levitsky
2022-06-21 15:08 ` [PATCH v2 04/11] KVM: x86: emulator: update the emulation mode after rsm Maxim Levitsky
2022-06-21 15:08 ` [PATCH v2 05/11] KVM: x86: emulator: update the emulation mode after CR0 write Maxim Levitsky
2022-07-20 23:50   ` Sean Christopherson
2022-07-21 11:53     ` Maxim Levitsky
2022-07-21 14:11       ` Sean Christopherson
2022-07-21 14:57         ` Maxim Levitsky
2022-06-21 15:08 ` [PATCH v2 06/11] KVM: x86: emulator/smm: number of GPRs in the SMRAM image depends on the image format Maxim Levitsky
2022-07-21  0:06   ` Sean Christopherson
2022-07-21  0:09     ` Sean Christopherson
2022-06-21 15:08 ` [PATCH v2 07/11] KVM: x86: emulator/smm: add structs for KVM's smram layout Maxim Levitsky
2022-07-21  0:40   ` Sean Christopherson
2022-07-21 11:54     ` Maxim Levitsky
2022-06-21 15:08 ` [PATCH v2 08/11] KVM: x86: emulator/smm: use smram struct for 32 bit smram load/restore Maxim Levitsky
2022-06-21 15:09 ` [PATCH v2 09/11] KVM: x86: emulator/smm: use smram struct for 64 " Maxim Levitsky
2022-07-21  0:38   ` Sean Christopherson
2022-07-21 11:54     ` Maxim Levitsky
2022-06-21 15:09 ` [PATCH v2 10/11] KVM: x86: SVM: use smram structs Maxim Levitsky
2022-07-21  0:18   ` Sean Christopherson
2022-07-21 11:54     ` Maxim Levitsky
2022-07-21  0:39   ` Sean Christopherson
2022-07-21 11:54     ` Maxim Levitsky
2022-06-21 15:09 ` [PATCH v2 11/11] KVM: x86: emulator/smm: preserve interrupt shadow in SMRAM Maxim Levitsky
2022-06-29 16:31   ` Jim Mattson
2022-06-30  6:00     ` Maxim Levitsky
2022-06-30 16:00       ` Jim Mattson
2022-07-05 13:38         ` Maxim Levitsky
2022-07-05 13:40           ` Maxim Levitsky
2022-07-05 13:51             ` Maxim Levitsky
2022-07-06 18:13           ` Jim Mattson
2022-07-06 20:00             ` Maxim Levitsky
2022-07-06 20:38               ` Jim Mattson
2022-07-10 16:05                 ` Maxim Levitsky
2022-06-29  7:21 ` [PATCH v2 00/11] SMM emulation and interrupt shadow fixes Maxim Levitsky
2022-07-14 11:06 ` Maxim Levitsky
2022-07-20  8:47   ` Maxim Levitsky

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=20220621150902.46126-4-mlevitsk@redhat.com \
    --to=mlevitsk@redhat.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=keescook@chromium.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@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