* [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path
@ 2010-12-23 8:10 Xiao Guangrong
2010-12-23 8:11 ` [PATCH 2/2] KVM: test: dump page mapping if test fail Xiao Guangrong
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Xiao Guangrong @ 2010-12-23 8:10 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, KVM
Check page fault error code on prefetch pte path
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
x86/access.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 66 insertions(+), 8 deletions(-)
diff --git a/x86/access.c b/x86/access.c
index 067565b..f43f7f1 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -408,7 +408,9 @@ fault:
at->expected_error &= ~PFERR_FETCH_MASK;
}
-void ac_test_setup_pte(ac_test_t *at, ac_pool_t *pool)
+void __ac_setup_specific_pages(ac_test_t *at, ac_pool_t *pool, u64 pd_page,
+ u64 pt_page)
+
{
unsigned long root = read_cr3();
@@ -423,13 +425,12 @@ void ac_test_setup_pte(ac_test_t *at, ac_pool_t *pool)
switch (i) {
case 4:
case 3:
- pte = vroot[index];
- pte = ac_test_alloc_pt(pool) | PT_PRESENT_MASK;
- pte |= PT_WRITABLE_MASK | PT_USER_MASK;
+ pte = pd_page ? pd_page : ac_test_alloc_pt(pool);
+ pte |= PT_PRESENT_MASK | PT_WRITABLE_MASK | PT_USER_MASK;
break;
case 2:
if (!at->flags[AC_PDE_PSE])
- pte = ac_test_alloc_pt(pool);
+ pte = pt_page ? pt_page : ac_test_alloc_pt(pool);
else {
pte = at->phys & PT_PSE_BASE_ADDR_MASK;
pte |= PT_PSE_MASK;
@@ -475,6 +476,17 @@ void ac_test_setup_pte(ac_test_t *at, ac_pool_t *pool)
ac_set_expected_status(at);
}
+static void ac_test_setup_pte(ac_test_t *at, ac_pool_t *pool)
+{
+ __ac_setup_specific_pages(at, pool, 0, 0);
+}
+
+static void ac_setup_specific_pages(ac_test_t *at, ac_pool_t *pool,
+ u64 pd_page, u64 pt_page)
+{
+ return __ac_setup_specific_pages(at, pool, pd_page, pt_page);
+}
+
static void ac_test_check(ac_test_t *at, _Bool *success_ret, _Bool cond,
const char *fmt, ...)
{
@@ -663,6 +675,43 @@ err:
return 0;
}
+/*
+ * This test case is used to triger the bug which is fixed by
+ * commit 3ddf6c06e13e in the kvm tree
+ */
+static int check_pfec_on_prefetch_pte(ac_pool_t *pool)
+{
+ ac_test_t at1, at2;
+
+ ac_test_init(&at1, (void *)(0x123406001000));
+ ac_test_init(&at2, (void *)(0x123406003000));
+
+ at1.flags[AC_PDE_PRESENT] = 1;
+ at1.flags[AC_PTE_PRESENT] = 1;
+ ac_setup_specific_pages(&at1, pool, 30 * 1024 * 1024, 30 * 1024 * 1024);
+
+ at2.flags[AC_PDE_PRESENT] = 1;
+ at2.flags[AC_PTE_NX] = 1;
+ at2.flags[AC_PTE_PRESENT] = 1;
+ ac_setup_specific_pages(&at2, pool, 30 * 1024 * 1024, 30 * 1024 * 1024);
+
+ if (!ac_test_do_access(&at1)) {
+ printf("%s: prepare fail\n", __FUNCTION__);
+ goto err;
+ }
+
+ if (!ac_test_do_access(&at2)) {
+ printf("%s: check PFEC on prefetch pte path fail\n",
+ __FUNCTION__);
+ goto err;
+ }
+
+ return 1;
+
+err:
+ return 0;
+}
+
int ac_test_exec(ac_test_t *at, ac_pool_t *pool)
{
int r;
@@ -675,11 +724,18 @@ int ac_test_exec(ac_test_t *at, ac_pool_t *pool)
return r;
}
+typedef int (*ac_test_fn)(ac_pool_t *pool);
+const ac_test_fn ac_test_cases[] =
+{
+ corrupt_hugepage_triger,
+ check_pfec_on_prefetch_pte,
+};
+
int ac_test_run(void)
{
ac_test_t at;
ac_pool_t pool;
- int tests, successes;
+ int i, tests, successes;
printf("run\n");
tests = successes = 0;
@@ -690,8 +746,10 @@ int ac_test_run(void)
successes += ac_test_exec(&at, &pool);
} while (ac_test_bump(&at));
- ++tests;
- successes += corrupt_hugepage_triger(&pool);
+ for (i = 0; i < ARRAY_SIZE(ac_test_cases); i++) {
+ ++tests;
+ successes += ac_test_cases[i](&pool);
+ }
printf("\n%d tests, %d failures\n", tests, tests - successes);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] KVM: test: dump page mapping if test fail
2010-12-23 8:10 [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Xiao Guangrong
@ 2010-12-23 8:11 ` Xiao Guangrong
2010-12-29 9:32 ` [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Avi Kivity
2011-01-03 15:11 ` Avi Kivity
2 siblings, 0 replies; 5+ messages in thread
From: Xiao Guangrong @ 2010-12-23 8:11 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, KVM
It can help us to fix the bug
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
x86/access.c | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/x86/access.c b/x86/access.c
index f43f7f1..709d1a6 100644
--- a/x86/access.c
+++ b/x86/access.c
@@ -35,6 +35,9 @@ typedef unsigned long pt_element_t;
#define MSR_EFER 0xc0000080
#define EFER_NX_MASK (1ull << 11)
+#define PT_INDEX(address, level) \
+ ((address) >> (12 + ((level)-1) * 9)) & 511
+
/*
* page table access check tests
*/
@@ -420,7 +423,7 @@ void __ac_setup_specific_pages(ac_test_t *at, ac_pool_t *pool, u64 pd_page,
at->ptep = 0;
for (int i = 4; i >= 1 && (i >= 2 || !at->flags[AC_PDE_PSE]); --i) {
pt_element_t *vroot = va(root & PT_BASE_ADDR_MASK);
- unsigned index = ((unsigned long)at->virt >> (12 + (i-1) * 9)) & 511;
+ unsigned index = PT_INDEX((unsigned long)at->virt, i);
pt_element_t pte = 0;
switch (i) {
case 4:
@@ -487,6 +490,22 @@ static void ac_setup_specific_pages(ac_test_t *at, ac_pool_t *pool,
return __ac_setup_specific_pages(at, pool, pd_page, pt_page);
}
+static void dump_mapping(ac_test_t *at)
+{
+ unsigned long root = read_cr3();
+ int i;
+
+ printf("Dump mapping: address: %llx\n", at->virt);
+ for (i = 4; i >= 1 && (i >= 2 || !at->flags[AC_PDE_PSE]); --i) {
+ pt_element_t *vroot = va(root & PT_BASE_ADDR_MASK);
+ unsigned index = PT_INDEX((unsigned long)at->virt, i);
+ pt_element_t pte = vroot[index];
+
+ printf("------L%d: %llx\n", i, pte);
+ root = vroot[index];
+ }
+}
+
static void ac_test_check(ac_test_t *at, _Bool *success_ret, _Bool cond,
const char *fmt, ...)
{
@@ -511,6 +530,7 @@ static void ac_test_check(ac_test_t *at, _Bool *success_ret, _Bool cond,
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
printf("FAIL: %s\n", buf);
+ dump_mapping(at);
}
static int pt_match(pt_element_t pte1, pt_element_t pte2, pt_element_t ignore)
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path
2010-12-23 8:10 [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Xiao Guangrong
2010-12-23 8:11 ` [PATCH 2/2] KVM: test: dump page mapping if test fail Xiao Guangrong
@ 2010-12-29 9:32 ` Avi Kivity
2011-01-03 15:11 ` Avi Kivity
2 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2010-12-29 9:32 UTC (permalink / raw)
To: Xiao Guangrong; +Cc: Marcelo Tosatti, KVM
On 12/23/2010 10:10 AM, Xiao Guangrong wrote:
> Check page fault error code on prefetch pte path
Applied both, thanks.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path
2010-12-23 8:10 [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Xiao Guangrong
2010-12-23 8:11 ` [PATCH 2/2] KVM: test: dump page mapping if test fail Xiao Guangrong
2010-12-29 9:32 ` [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Avi Kivity
@ 2011-01-03 15:11 ` Avi Kivity
2011-01-05 2:48 ` Xiao Guangrong
2 siblings, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2011-01-03 15:11 UTC (permalink / raw)
To: Xiao Guangrong; +Cc: Marcelo Tosatti, KVM
On 12/23/2010 10:10 AM, Xiao Guangrong wrote:
> Check page fault error code on prefetch pte path
>
Can you point out the commit which fixed this failure? I'd like to
backport it if it's simple enough.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path
2011-01-03 15:11 ` Avi Kivity
@ 2011-01-05 2:48 ` Xiao Guangrong
0 siblings, 0 replies; 5+ messages in thread
From: Xiao Guangrong @ 2011-01-05 2:48 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, KVM
On 01/03/2011 11:11 PM, Avi Kivity wrote:
> On 12/23/2010 10:10 AM, Xiao Guangrong wrote:
>> Check page fault error code on prefetch pte path
>>
>
> Can you point out the commit which fixed this failure? I'd like to backport it if it's simple enough.
>
The commit is 3ddf6c06e13e:
commit 3ddf6c06e13ef7842e58815d28ec88faae19c8db
Author: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Date: Wed Nov 17 12:11:41 2010 +0800
KVM: MMU: don't mark spte notrap if reserved bit set
If reserved bit is set, we need inject the #PF with PFEC.RSVD=1,
but shadow_notrap_nonpresent_pte injects #PF with PFEC.RSVD=0 only
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-01-04 2:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-23 8:10 [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Xiao Guangrong
2010-12-23 8:11 ` [PATCH 2/2] KVM: test: dump page mapping if test fail Xiao Guangrong
2010-12-29 9:32 ` [PATCH 1/2] KVM: test: add the test case to check PFEC on prefetch pte path Avi Kivity
2011-01-03 15:11 ` Avi Kivity
2011-01-05 2:48 ` Xiao Guangrong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox