Commit 6faca2a5 authored by Krish Sadhukhan's avatar Krish Sadhukhan Committed by Paolo Bonzini
Browse files

nSVM: Add a test for NPF due to P=0 in NPT entry

If the P (present) bit in an NPT entry is cleared, accesses to the
corresponding guest physical address will fail and the guest will exit to
the host with an exit code of 0x400 (#NPF). The test checks for bits 2
and 32 to be set (respectively because all NPT accesses are considered
user accesses, and because the test encounters the P=0 entry while
translating the final guest physical address and not a guest page table.

Signed-off-by: default avatarKrish Sadhukhan <>
Message-Id: <>
Signed-off-by: default avatarPaolo Bonzini <>
parent 0079fe89
......@@ -720,6 +720,32 @@ static bool npt_nx_check(struct svm_test *test)
&& (vmcb->control.exit_info_1 == 0x100000015ULL);
static void npt_np_prepare(struct svm_test *test)
u64 *pte;
scratch_page = alloc_page();
pte = npt_get_pte((u64)scratch_page);
*pte &= ~1ULL;
static void npt_np_test(struct svm_test *test)
(void) *(volatile u64 *)scratch_page;
static bool npt_np_check(struct svm_test *test)
u64 *pte = npt_get_pte((u64)scratch_page);
*pte |= 1ULL;
return (vmcb->control.exit_code == SVM_EXIT_NPF)
&& (vmcb->control.exit_info_1 == 0x100000004ULL);
static void npt_us_prepare(struct svm_test *test)
u64 *pte;
......@@ -2119,6 +2145,9 @@ struct svm_test svm_tests[] = {
{ "npt_nx", npt_supported, npt_nx_prepare,
default_prepare_gif_clear, null_test,
default_finished, npt_nx_check },
{ "npt_np", npt_supported, npt_np_prepare,
default_prepare_gif_clear, npt_np_test,
default_finished, npt_np_check },
{ "npt_us", npt_supported, npt_us_prepare,
default_prepare_gif_clear, npt_us_test,
default_finished, npt_us_check },
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment