diff mbox series

KVM: X86: Add 'else' to unify fastop and execute call path

Message ID 1579663304-14524-1-git-send-email-linmiaohe@huawei.com (mailing list archive)
State New, archived
Headers show
Series KVM: X86: Add 'else' to unify fastop and execute call path | expand

Commit Message

Miaohe Lin Jan. 22, 2020, 3:21 a.m. UTC
From: Miaohe Lin <linmiaohe@huawei.com>

It also helps eliminate some duplicated code.

Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
 arch/x86/kvm/emulate.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Sean Christopherson Jan. 22, 2020, 4:42 a.m. UTC | #1
On Wed, Jan 22, 2020 at 11:21:44AM +0800, linmiaohe wrote:
> From: Miaohe Lin <linmiaohe@huawei.com>
> 
> It also helps eliminate some duplicated code.
> 
> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> ---

Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

>  arch/x86/kvm/emulate.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index c7a0da45f60a..0accce94f660 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -5683,11 +5683,9 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
>  		if (ctxt->d & Fastop) {
>  			void (*fop)(struct fastop *) = (void *)ctxt->execute;

The brackets can also be removed with a bit more cleanup, e.g. using a
typedef to handling casting ctxt->execute.  I'll send a patch that can be
applied on top and/or squashed with this one.

>  			rc = fastop(ctxt, fop);
> -			if (rc != X86EMUL_CONTINUE)
> -				goto done;
> -			goto writeback;
> +		} else {
> +			rc = ctxt->execute(ctxt);
>  		}
> -		rc = ctxt->execute(ctxt);
>  		if (rc != X86EMUL_CONTINUE)
>  			goto done;
>  		goto writeback;
> -- 
> 2.19.1
>
Paolo Bonzini Jan. 22, 2020, 2:24 p.m. UTC | #2
On 22/01/20 05:42, Sean Christopherson wrote:
> Reviewed-by: Sean Christopherson <sean.j.christopherson@intel.com>

Queued, thanks to both!

Paolo
diff mbox series

Patch

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index c7a0da45f60a..0accce94f660 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -5683,11 +5683,9 @@  int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
 		if (ctxt->d & Fastop) {
 			void (*fop)(struct fastop *) = (void *)ctxt->execute;
 			rc = fastop(ctxt, fop);
-			if (rc != X86EMUL_CONTINUE)
-				goto done;
-			goto writeback;
+		} else {
+			rc = ctxt->execute(ctxt);
 		}
-		rc = ctxt->execute(ctxt);
 		if (rc != X86EMUL_CONTINUE)
 			goto done;
 		goto writeback;