@@ -2807,34 +2807,18 @@ static void svm_nm_test_guest(struct svm_test *test)
asm volatile("fnop");
}
-/* This test checks that:
- *
- * (a) If CR0.TS is set in L2, #NM is handled by L2 when
- * just an L2 handler is registered.
- *
- * (b) If CR0.TS is cleared and CR0.EM is set, #NM is handled
- * by L2 when just an l2 handler is registered.
- *
- * (c) If CR0.TS and CR0.EM are cleared in L2, no exception
- * is generated.
+/*
+ * If CR0.TS and CR0.EM are cleared in L2, no exception
+ * is generated.
*/
-
static void svm_nm_test(void)
{
handle_exception(NM_VECTOR, guest_test_nm_handler);
write_cr0(read_cr0() & ~X86_CR0_TS);
test_set_guest(svm_nm_test_guest);
- vmcb->save.cr0 = vmcb->save.cr0 | X86_CR0_TS;
- report(svm_vmrun() == SVM_EXIT_VMMCALL && nm_test_counter == 1,
- "fnop with CR0.TS set in L2, #NM is triggered");
-
- vmcb->save.cr0 = (vmcb->save.cr0 & ~X86_CR0_TS) | X86_CR0_EM;
- report(svm_vmrun() == SVM_EXIT_VMMCALL && nm_test_counter == 2,
- "fnop with CR0.EM set in L2, #NM is triggered");
-
vmcb->save.cr0 = vmcb->save.cr0 & ~(X86_CR0_TS | X86_CR0_EM);
- report(svm_vmrun() == SVM_EXIT_VMMCALL && nm_test_counter == 2,
+ report(svm_vmrun() == SVM_EXIT_VMMCALL && nm_test_counter == 0,
"fnop with CR0.TS and CR0.EM unset no #NM excpetion");
}
@@ -3308,6 +3292,24 @@ static void svm_l2_ac_test(struct svm_test *test)
vmmcall();
}
+/*
+ * If CR0.TS is set in L2, #NM is generared
+ */
+static void svm_l2_nm_test(struct svm_test *svm)
+{
+ write_cr0(read_cr0() | X86_CR0_TS);
+ asm volatile("fnop");
+}
+
+/*
+ * If CR0.TS is cleared and CR0.EM is set, #NM is generated
+ */
+static void svm_l2_nm_test1(struct svm_test *svm)
+{
+ write_cr0((read_cr0() & ~X86_CR0_TS) | X86_CR0_EM);
+ asm volatile("fnop");
+}
+
struct svm_exception_test {
u8 vector;
void (*guest_code)(struct svm_test*);
@@ -3321,6 +3323,8 @@ struct svm_exception_test svm_exception_tests[] = {
{ AC_VECTOR, svm_l2_ac_test },
{ BP_VECTOR, svm_l2_bp_test },
{ OF_VECTOR, svm_l2_of_test },
+ { NM_VECTOR, svm_l2_nm_test },
+ { NM_VECTOR, svm_l2_nm_test1 },
};
static u8 svm_exception_test_vector;
Remove the boiler plate code for #NM test and move #NM exception test in exception test framework. Keep the test case for the condition where #NM exception is not generated as it is. Signed-off-by: Manali Shukla <manali.shukla@amd.com> --- x86/svm_tests.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-)