Skip to content

Commit

Permalink
x86: nSVM: Add nested shutdown interception test
Browse files Browse the repository at this point in the history
Add a simple test that a shutdown in L2 is correctly routed to L1 when L1
wants to intercept shutdown.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Link: https://lore.kernel.org/r/20221122161152.293072-10-mlevitsk@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
  • Loading branch information
Maxim Levitsky authored and sean-jc committed Jun 7, 2023
1 parent 2e4e8a4 commit e5bedc8
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions x86/svm_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "delay.h"
#include "util.h"
#include "x86/usermode.h"
#include "vmalloc.h"

#define SVM_EXIT_MAX_DR_INTERCEPT 0x3f

Expand Down Expand Up @@ -3256,6 +3257,22 @@ static void svm_exception_test(void)
}
}

static void shutdown_intercept_test_guest(struct svm_test *test)
{
asm volatile ("ud2");
report_fail("should not reach here\n");

}

static void svm_shutdown_intercept_test(void)
{
test_set_guest(shutdown_intercept_test_guest);
vmcb->save.idtr.base = (u64)alloc_vpage();
vmcb->control.intercept |= (1ULL << INTERCEPT_SHUTDOWN);
svm_vmrun();
report(vmcb->control.exit_code == SVM_EXIT_SHUTDOWN, "shutdown test passed");
}

struct svm_test svm_tests[] = {
{ "null", default_supported, default_prepare,
default_prepare_gif_clear, null_test,
Expand Down Expand Up @@ -3370,6 +3387,7 @@ struct svm_test svm_tests[] = {
TEST(svm_intr_intercept_mix_smi),
TEST(svm_tsc_scale_test),
TEST(pause_filter_test),
TEST(svm_shutdown_intercept_test),
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};

Expand Down

0 comments on commit e5bedc8

Please sign in to comment.