From: Pekka Paalanen <pq@iki.fi>
To: Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@elte.hu>
Cc: Pekka Paalanen <pq@iki.fi>,
Stuart Bennett <stuart@freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH 3/7] x86 mmiotrace: WARN_ONCE if dis/arming a page fails
Date: Sun, 1 Mar 2009 16:11:07 +0200 [thread overview]
Message-ID: <20090301161107.21d82c10@daedalus.pq.iki.fi> (raw)
In-Reply-To: <20090301160643.05a2219b@daedalus.pq.iki.fi>
>From 2f1f600e019955a0485452e4da676837bc8c91bd Mon Sep 17 00:00:00 2001
From: Stuart Bennett <stuart@freedesktop.org>
Date: Fri, 30 Jan 2009 17:38:59 +0000
Subject: [PATCH] x86 mmiotrace: WARN_ONCE if dis/arming a page fails
Print a full warning once, if arming or disarming a page fails.
Also, if initial arming fails, do not handle the page further. This
avoids the possibility of a page failing to arm and then later claiming
to have handled any fault on that page.
WARN_ONCE added by Pekka Paalanen.
Signed-off-by: Stuart Bennett <stuart@freedesktop.org>
Signed-off-by: Pekka Paalanen <pq@iki.fi>
---
arch/x86/mm/kmmio.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/arch/x86/mm/kmmio.c b/arch/x86/mm/kmmio.c
index 93d8203..fb1f115 100644
--- a/arch/x86/mm/kmmio.c
+++ b/arch/x86/mm/kmmio.c
@@ -105,7 +105,7 @@ static struct kmmio_fault_page *get_kmmio_fault_page(unsigned long page)
return NULL;
}
-static void set_page_present(unsigned long addr, bool present,
+static int set_page_present(unsigned long addr, bool present,
unsigned int *pglevel)
{
pteval_t pteval;
@@ -116,7 +116,7 @@ static void set_page_present(unsigned long addr, bool present,
if (!pte) {
pr_err("kmmio: no pte for page 0x%08lx\n", addr);
- return;
+ return -1;
}
if (pglevel)
@@ -140,22 +140,27 @@ static void set_page_present(unsigned long addr, bool present,
default:
pr_err("kmmio: unexpected page level 0x%x.\n", level);
- return;
+ return -1;
}
__flush_tlb_one(addr);
+
+ return 0;
}
/** Mark the given page as not present. Access to it will trigger a fault. */
-static void arm_kmmio_fault_page(unsigned long page, unsigned int *pglevel)
+static int arm_kmmio_fault_page(unsigned long page, unsigned int *pglevel)
{
- set_page_present(page & PAGE_MASK, false, pglevel);
+ int ret = set_page_present(page & PAGE_MASK, false, pglevel);
+ WARN_ONCE(ret < 0, KERN_ERR "kmmio arming 0x%08lx failed.\n", page);
+ return ret;
}
/** Mark the given page as present. */
static void disarm_kmmio_fault_page(unsigned long page, unsigned int *pglevel)
{
- set_page_present(page & PAGE_MASK, true, pglevel);
+ int ret = set_page_present(page & PAGE_MASK, true, pglevel);
+ WARN_ONCE(ret < 0, KERN_ERR "kmmio disarming 0x%08lx failed.\n", page);
}
/*
@@ -326,9 +331,13 @@ static int add_kmmio_fault_page(unsigned long page)
f->count = 1;
f->page = page;
- list_add_rcu(&f->list, kmmio_page_list(f->page));
- arm_kmmio_fault_page(f->page, NULL);
+ if (arm_kmmio_fault_page(f->page, NULL)) {
+ kfree(f);
+ return -1;
+ }
+
+ list_add_rcu(&f->list, kmmio_page_list(f->page));
return 0;
}
--
1.6.0.6
next prev parent reply other threads:[~2009-03-01 14:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090301160643.05a2219b@daedalus.pq.iki.fi>
2009-03-01 14:09 ` [PATCH 1/7] x86: count errors in testmmiotrace.ko Pekka Paalanen
2009-03-01 14:10 ` [PATCH 2/7] x86: add far read test to testmmiotrace Pekka Paalanen
2009-03-01 14:11 ` Pekka Paalanen [this message]
2009-03-01 14:11 ` [PATCH 4/7] x86 mmiotrace: fix save/restore page table state Pekka Paalanen
2009-03-01 14:12 ` [PATCH 5/7] x86 mmiotrace: split set_page_presence() Pekka Paalanen
2009-03-01 14:13 ` [PATCH 6/7] x86 mmiotrace: improve handling of secondary faults Pekka Paalanen
2009-03-01 14:14 ` [PATCH 7/7] x86 mmiotrace: fix race with release_kmmio_fault_page() Pekka Paalanen
2009-03-02 9:23 ` [PATCH 0/7] mmiotrace: enhance01 Ingo Molnar
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=20090301161107.21d82c10@daedalus.pq.iki.fi \
--to=pq@iki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=stuart@freedesktop.org \
/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
all inboxes | Powered by JetHome®