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>,
	Manali Shukla <manali.shukla@amd.com>
Subject: [kvm-unit-tests PATCH v3 7/9] x86: nSVM: Move #OF test to exception test framework
Date: Wed,  5 Oct 2022 23:52:10 +0000	[thread overview]
Message-ID: <20221005235212.57836-8-seanjc@google.com> (raw)
In-Reply-To: <20221005235212.57836-1-seanjc@google.com>

From: Manali Shukla <manali.shukla@amd.com>

Remove the boiler plate code for #OF test and move #OF exception test in
exception test framework.

Signed-off-by: Manali Shukla <manali.shukla@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
 x86/svm_tests.c | 50 +------------------------------------------------
 1 file changed, 1 insertion(+), 49 deletions(-)

diff --git a/x86/svm_tests.c b/x86/svm_tests.c
index 1285f98..0870cc5 100644
--- a/x86/svm_tests.c
+++ b/x86/svm_tests.c
@@ -2756,54 +2756,6 @@ static void pause_filter_test(void)
 	}
 }
 
-
-static int of_test_counter;
-
-static void guest_test_of_handler(struct ex_regs *r)
-{
-	of_test_counter++;
-}
-
-static void svm_of_test_guest(struct svm_test *test)
-{
-	struct far_pointer32 fp = {
-		.offset = (uintptr_t)&&into,
-		.selector = KERNEL_CS32,
-	};
-	uintptr_t rsp;
-
-	asm volatile ("mov %%rsp, %0" : "=r"(rsp));
-
-	if (fp.offset != (uintptr_t)&&into) {
-		printf("Codee address too high.\n");
-		return;
-	}
-
-	if ((u32)rsp != rsp) {
-		printf("Stack address too high.\n");
-	}
-
-	asm goto("lcall *%0" : : "m" (fp) : "rax" : into);
-	return;
-into:
-
-	asm volatile (".code32;"
-		      "movl $0x7fffffff, %eax;"
-		      "addl %eax, %eax;"
-		      "into;"
-		      "lret;"
-		      ".code64");
-	__builtin_unreachable();
-}
-
-static void svm_into_test(void)
-{
-	handle_exception(OF_VECTOR, guest_test_of_handler);
-	test_set_guest(svm_of_test_guest);
-	report(svm_vmrun() == SVM_EXIT_VMMCALL && of_test_counter == 1,
-	       "#OF is generated in L2 exception handler");
-}
-
 static int nm_test_counter;
 
 static void guest_test_nm_handler(struct ex_regs *r)
@@ -3294,6 +3246,7 @@ struct svm_exception_test svm_exception_tests[] = {
 	{ DB_VECTOR, generate_single_step_db },
 	{ BP_VECTOR, generate_bp },
 	{ AC_VECTOR, svm_l2_ac_test },
+	{ OF_VECTOR, generate_of },
 };
 
 static u8 svm_exception_test_vector;
@@ -3444,7 +3397,6 @@ struct svm_test svm_tests[] = {
 	TEST(svm_vmload_vmsave),
 	TEST(svm_test_singlestep),
 	TEST(svm_nm_test),
-	TEST(svm_into_test),
 	TEST(svm_exception_test),
 	TEST(svm_lbrv_test0),
 	TEST(svm_lbrv_test1),
-- 
2.38.0.rc1.362.ged0d419d3c-goog


  parent reply	other threads:[~2022-10-05 23:52 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-05 23:52 [kvm-unit-tests PATCH v3 0/9] x86: n{VMX,SVM} exception tests Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 1/9] nVMX: Add "nop" after setting EFLAGS.TF to guarantee single-step #DB Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 2/9] x86: Move helpers to generate misc exceptions to processor.h Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 3/9] nVMX: Move #OF test to generic exceptions test Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 4/9] nVMX: Drop one-off INT3=>#BP test Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 5/9] x86: nSVM: Add an exception test framework and tests Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 6/9] x86: nSVM: Move #BP test to exception test framework Sean Christopherson
2022-10-05 23:52 ` Sean Christopherson [this message]
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 8/9] x86: nSVM: Move part of #NM " Sean Christopherson
2022-10-05 23:52 ` [kvm-unit-tests PATCH v3 9/9] nVMX: Move #NM test to generic " Sean Christopherson
2022-10-12  4:17 ` [kvm-unit-tests PATCH v3 0/9] x86: n{VMX,SVM} exception tests Manali Shukla

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=20221005235212.57836-8-seanjc@google.com \
    --to=seanjc@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=manali.shukla@amd.com \
    --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.