From: Tim Deegan <tim@xen.org>
To: xen-devel@lists.xen.org
Cc: Aravindh Puthiyaparambil <aravindh@virtuata.com>
Subject: [PATCH 5/5] x86/mem_access: check for errors in p2m->set_entry().
Date: Thu, 7 Mar 2013 14:53:03 +0000 [thread overview]
Message-ID: <1362667983-24938-6-git-send-email-tim@xen.org> (raw)
In-Reply-To: <1362667983-24938-1-git-send-email-tim@xen.org>
These calls ought always to succeed. Assert that they do rather than
ignoring the return value.
Signed-off-by: Tim Deegan <tim@xen.org>
Cc: Aravindh Puthiyaparambil <aravindh@virtuata.com>
---
xen/arch/x86/mm/p2m.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 4837de3..f5ddd20 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1262,21 +1262,27 @@ bool_t p2m_mem_access_check(paddr_t gpa, bool_t gla_valid, unsigned long gla,
p2m_type_t p2mt;
p2m_access_t p2ma;
mem_event_request_t *req;
+ int rc;
- /* First, handle rx2rw conversion automatically */
+ /* First, handle rx2rw conversion automatically.
+ * These calls to p2m->set_entry() must succeed: we have the gfn
+ * locked and just did a successful get_entry(). */
gfn_lock(p2m, gfn, 0);
mfn = p2m->get_entry(p2m, gfn, &p2mt, &p2ma, 0, NULL);
if ( access_w && p2ma == p2m_access_rx2rw )
{
- p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2mt, p2m_access_rw);
+ rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2mt, p2m_access_rw);
+ ASSERT(rc);
gfn_unlock(p2m, gfn, 0);
return 1;
}
else if ( p2ma == p2m_access_n2rwx )
{
ASSERT(access_w || access_r || access_x);
- p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2mt, p2m_access_rwx);
+ rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K,
+ p2mt, p2m_access_rwx);
+ ASSERT(rc);
}
gfn_unlock(p2m, gfn, 0);
@@ -1294,13 +1300,18 @@ bool_t p2m_mem_access_check(paddr_t gpa, bool_t gla_valid, unsigned long gla,
}
else
{
+ gfn_lock(p2m, gfn, 0);
+ mfn = p2m->get_entry(p2m, gfn, &p2mt, &p2ma, 0, NULL);
if ( p2ma != p2m_access_n2rwx )
{
- /* A listener is not required, so clear the access restrictions */
- gfn_lock(p2m, gfn, 0);
- p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2mt, p2m_access_rwx);
- gfn_unlock(p2m, gfn, 0);
+ /* A listener is not required, so clear the access
+ * restrictions. This set must succeed: we have the
+ * gfn locked and just did a successful get_entry(). */
+ rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K,
+ p2mt, p2m_access_rwx);
+ ASSERT(rc);
}
+ gfn_unlock(p2m, gfn, 0);
return 1;
}
}
--
1.7.10.4
next prev parent reply other threads:[~2013-03-07 14:53 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 14:52 [PATCH 0/5] x86/mm: out-of-memory errors in p2m ops Tim Deegan
2013-03-07 14:52 ` [PATCH 1/5] x86/mm: use bool_t for flags in shadow-pagetable structs Tim Deegan
2013-03-07 14:53 ` [PATCH 2/5] x86/mm: warn if we ever run out of shadow/hap pool for p2m/lgd ops Tim Deegan
2013-03-07 15:22 ` Andrew Cooper
2013-03-07 15:34 ` Jan Beulich
2013-03-07 14:53 ` [PATCH 3/5] x86/ept: check for errors in a few callers of ept_set_entry Tim Deegan
2013-03-07 14:53 ` [PATCH 4/5] x86/mem_sharing: check for errors in p2m->set_entry() Tim Deegan
2013-03-07 15:07 ` Andres Lagar-Cavilla
2013-03-07 16:10 ` Tim Deegan
2013-03-07 16:49 ` Andres Lagar-Cavilla
2013-03-07 14:53 ` Tim Deegan [this message]
2013-03-07 21:50 ` [PATCH 5/5] x86/mem_access: " Aravindh Puthiyaparambil
2013-03-07 15:38 ` [PATCH 0/5] x86/mm: out-of-memory errors in p2m ops Jan Beulich
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=1362667983-24938-6-git-send-email-tim@xen.org \
--to=tim@xen.org \
--cc=aravindh@virtuata.com \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.