All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, Sean Christopherson <seanjc@google.com>
Subject: [kvm-unit-tests PATCH 09/10] nVMX: Simplify test_vmxon() by returning directly on failure
Date: Wed,  8 Jun 2022 23:52:37 +0000	[thread overview]
Message-ID: <20220608235238.3881916-10-seanjc@google.com> (raw)
In-Reply-To: <20220608235238.3881916-1-seanjc@google.com>

Return '1' directly if a VMXON subtest fails, using a second variable and
a goto is silly.

Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/vmx.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)

diff --git a/x86/vmx.c b/x86/vmx.c
index 09e54332..4562e91f 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -1455,43 +1455,35 @@ static int test_vmx_feature_control(void)
 
 static int test_vmxon(void)
 {
-	int ret, ret1;
 	u64 *vmxon_region;
 	int width = cpuid_maxphyaddr();
+	int ret;
 
 	/* Unaligned page access */
 	vmxon_region = (u64 *)((intptr_t)bsp_vmxon_region + 1);
-	ret1 = __vmxon_safe(vmxon_region);
-	report(ret1 < 0, "test vmxon with unaligned vmxon region");
-	if (ret1 >= 0) {
-		ret = 1;
-		goto out;
-	}
+	ret = __vmxon_safe(vmxon_region);
+	report(ret < 0, "test vmxon with unaligned vmxon region");
+	if (ret >= 0)
+		return 1;
 
 	/* gpa bits beyond physical address width are set*/
 	vmxon_region = (u64 *)((intptr_t)bsp_vmxon_region | ((u64)1 << (width+1)));
-	ret1 = __vmxon_safe(vmxon_region);
-	report(ret1 < 0, "test vmxon with bits set beyond physical address width");
-	if (ret1 >= 0) {
-		ret = 1;
-		goto out;
-	}
+	ret = __vmxon_safe(vmxon_region);
+	report(ret < 0, "test vmxon with bits set beyond physical address width");
+	if (ret >= 0)
+		return 1;
 
 	/* invalid revision identifier */
 	*bsp_vmxon_region = 0xba9da9;
-	ret1 = vmxon_safe();
-	report(ret1 < 0, "test vmxon with invalid revision identifier");
-	if (ret1 >= 0) {
-		ret = 1;
-		goto out;
-	}
+	ret = vmxon_safe();
+	report(ret < 0, "test vmxon with invalid revision identifier");
+	if (ret >= 0)
+		return 1;
 
 	/* and finally a valid region */
 	*bsp_vmxon_region = basic.revision;
 	ret = vmxon_safe();
 	report(!ret, "test vmxon with valid vmxon region");
-
-out:
 	return ret;
 }
 
-- 
2.36.1.255.ge46751e96f-goog


  parent reply	other threads:[~2022-06-08 23:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 23:52 [kvm-unit-tests PATCH 00/10] x86: nVMX: Add VMXON #UD test Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 01/10] x86: Use BIT() to define architectural bits Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 02/10] x86: Replace spaces with tables in processor.h Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 03/10] x86: Use "safe" terminology instead of "checking" Sean Christopherson
2023-08-22  8:09   ` Like Xu
2022-06-08 23:52 ` [kvm-unit-tests PATCH 04/10] x86: Use "safe" helpers to implement unsafe CRs accessors Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 05/10] x86: Provide result of RDMSR from "safe" variant Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 06/10] nVMX: Check the results of VMXON/VMXOFF in feature control test Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 07/10] nVMX: Check result of VMXON in INIT/SIPI tests Sean Christopherson
2022-06-08 23:52 ` [kvm-unit-tests PATCH 08/10] nVMX: Wrap VMXON in ASM_TRY(), a.k.a. in exception fixup Sean Christopherson
2022-06-08 23:52 ` Sean Christopherson [this message]
2022-06-08 23:52 ` [kvm-unit-tests PATCH 10/10] nVMX: Add subtest to verify VMXON succeeds/#UDs on good/bad CR0/CR4 Sean Christopherson

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=20220608235238.3881916-10-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.