From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
To: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>, KVM <kvm@vger.kernel.org>
Subject: [PATCH 2/2] KVM: test: dump page mapping if test fail
Date: Thu, 23 Dec 2010 16:11:39 +0800 [thread overview]
Message-ID: <4D13043B.1040904@cn.fujitsu.com> (raw)
In-Reply-To: <4D1303FC.9070404@cn.fujitsu.com>
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
next prev parent reply other threads:[~2010-12-23 8:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2010-12-29 9:32 ` Avi Kivity
2011-01-03 15:11 ` Avi Kivity
2011-01-05 2:48 ` Xiao Guangrong
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=4D13043B.1040904@cn.fujitsu.com \
--to=xiaoguangrong@cn.fujitsu.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox