diff mbox series

[kvm-unit-tests,v3,20/27] svm: move v2 tests run into test_run

Message ID 20221122161152.293072-21-mlevitsk@redhat.com (mailing list archive)
State New, archived
Headers show
Series kvm-unit-tests: set of fixes and new tests | expand

Commit Message

Maxim Levitsky Nov. 22, 2022, 4:11 p.m. UTC
Move v2 tests running into test_run which allows to have code that runs the
test in one place and allows to run v2 tests on a non 0 vCPU if needed.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 x86/svm.c | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

Comments

Emanuele Giuseppe Esposito Dec. 2, 2022, 9:53 a.m. UTC | #1
Am 22/11/2022 um 17:11 schrieb Maxim Levitsky:
> Move v2 tests running into test_run which allows to have code that runs the
> test in one place and allows to run v2 tests on a non 0 vCPU if needed.
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---

Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>

>  x86/svm.c | 33 +++++++++++++++++++--------------
>  1 file changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/x86/svm.c b/x86/svm.c
> index 220bce66..2ab553a5 100644
> --- a/x86/svm.c
> +++ b/x86/svm.c
> @@ -106,6 +106,13 @@ int svm_vmrun(void)
>  
>  static noinline void test_run(struct svm_test *test)
>  {
> +	if (test->v2) {
> +		vmcb_ident(vmcb);
> +		v2_test = test;
> +		test->v2();
> +		return;
> +	}
> +
>  	cli();
>  	vmcb_ident(vmcb);
>  
> @@ -196,21 +203,19 @@ int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)
>  			continue;
>  		if (svm_tests[i].supported && !svm_tests[i].supported())
>  			continue;
> -		if (svm_tests[i].v2 == NULL) {
> -			if (svm_tests[i].on_vcpu) {
> -				if (cpu_count() <= svm_tests[i].on_vcpu)
> -					continue;
> -				on_cpu_async(svm_tests[i].on_vcpu, (void *)test_run, &svm_tests[i]);
> -				while (!svm_tests[i].on_vcpu_done)
> -					cpu_relax();
> -			}
> -			else
> -				test_run(&svm_tests[i]);
> -		} else {
> -			vmcb_ident(vmcb);
> -			v2_test = &(svm_tests[i]);
> -			svm_tests[i].v2();
> +
> +		if (!svm_tests[i].on_vcpu) {
> +			test_run(&svm_tests[i]);
> +			continue;
>  		}
> +
> +		if (cpu_count() <= svm_tests[i].on_vcpu)
> +			continue;
> +
> +		on_cpu_async(svm_tests[i].on_vcpu, (void *)test_run, &svm_tests[i]);
> +
> +		while (!svm_tests[i].on_vcpu_done)
> +			cpu_relax();
>  	}
>  
>  	if (!matched)
>
diff mbox series

Patch

diff --git a/x86/svm.c b/x86/svm.c
index 220bce66..2ab553a5 100644
--- a/x86/svm.c
+++ b/x86/svm.c
@@ -106,6 +106,13 @@  int svm_vmrun(void)
 
 static noinline void test_run(struct svm_test *test)
 {
+	if (test->v2) {
+		vmcb_ident(vmcb);
+		v2_test = test;
+		test->v2();
+		return;
+	}
+
 	cli();
 	vmcb_ident(vmcb);
 
@@ -196,21 +203,19 @@  int run_svm_tests(int ac, char **av, struct svm_test *svm_tests)
 			continue;
 		if (svm_tests[i].supported && !svm_tests[i].supported())
 			continue;
-		if (svm_tests[i].v2 == NULL) {
-			if (svm_tests[i].on_vcpu) {
-				if (cpu_count() <= svm_tests[i].on_vcpu)
-					continue;
-				on_cpu_async(svm_tests[i].on_vcpu, (void *)test_run, &svm_tests[i]);
-				while (!svm_tests[i].on_vcpu_done)
-					cpu_relax();
-			}
-			else
-				test_run(&svm_tests[i]);
-		} else {
-			vmcb_ident(vmcb);
-			v2_test = &(svm_tests[i]);
-			svm_tests[i].v2();
+
+		if (!svm_tests[i].on_vcpu) {
+			test_run(&svm_tests[i]);
+			continue;
 		}
+
+		if (cpu_count() <= svm_tests[i].on_vcpu)
+			continue;
+
+		on_cpu_async(svm_tests[i].on_vcpu, (void *)test_run, &svm_tests[i]);
+
+		while (!svm_tests[i].on_vcpu_done)
+			cpu_relax();
 	}
 
 	if (!matched)