All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: xen-devel@lists.xen.org
Cc: Eddie Dong <eddie.dong@intel.com>, Jun Nakajima <jun.nakajima@intel.com>
Subject: [PATCH 3/5] x86/ept: check for errors in a few callers of ept_set_entry.
Date: Thu, 7 Mar 2013 14:53:01 +0000	[thread overview]
Message-ID: <1362667983-24938-4-git-send-email-tim@xen.org> (raw)
In-Reply-To: <1362667983-24938-1-git-send-email-tim@xen.org>

AFAICT in all these cases we have the p2m lock and have just checked
that the p2m trie is populated so the call should succeed.  Make it
explicit with ASSERT() rather than just ignoring the result.

Signed-off-by: Tim Deegan <tim@xen.org>
Cc: Jun Nakajima <jun.nakajima@intel.com>
Cc: Eddie Dong <eddie.dong@intel.com>
---
 xen/arch/x86/mm/p2m-ept.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index a2d1591..595c6e7 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -401,8 +401,9 @@ ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn,
 
         /* then move to the level we want to make real changes */
         for ( ; i > target; i-- )
-            ept_next_level(p2m, 0, &table, &gfn_remainder, i);
-
+            if ( !ept_next_level(p2m, 0, &table, &gfn_remainder, i) )
+                break;
+        /* We just installed the pages we need. */
         ASSERT(i == target);
 
         index = gfn_remainder >> (i * EPT_TABLE_ORDER);
@@ -704,6 +705,7 @@ void ept_change_entry_emt_with_range(struct domain *d,
     mfn_t mfn;
     int order = 0;
     struct p2m_domain *p2m = p2m_get_hostp2m(d);
+    int rc;
 
     p2m_lock(p2m);
     for ( gfn = start_gfn; gfn <= end_gfn; gfn++ )
@@ -732,7 +734,11 @@ void ept_change_entry_emt_with_range(struct domain *d,
                     order = level * EPT_TABLE_ORDER;
                     if ( need_modify_ept_entry(p2m, gfn, mfn, 
                           e.ipat, e.emt, e.sa_p2mt) )
-                        ept_set_entry(p2m, gfn, mfn, order, e.sa_p2mt, e.access);
+                    {
+                        rc = ept_set_entry(p2m, gfn, mfn, order,
+                                           e.sa_p2mt, e.access);
+                        ASSERT(rc);
+                    }
                     gfn += trunk;
                     break;
                 }
@@ -741,8 +747,12 @@ void ept_change_entry_emt_with_range(struct domain *d,
         }
         else /* gfn assigned with 4k */
         {
-            if ( need_modify_ept_entry(p2m, gfn, mfn, e.ipat, e.emt, e.sa_p2mt) )
-                ept_set_entry(p2m, gfn, mfn, order, e.sa_p2mt, e.access);
+            if ( need_modify_ept_entry(p2m, gfn, mfn,
+                                       e.ipat, e.emt, e.sa_p2mt) )
+            {
+                rc = ept_set_entry(p2m, gfn, mfn, order, e.sa_p2mt, e.access);
+                ASSERT(rc);
+            }
         }
     }
     p2m_unlock(p2m);
-- 
1.7.10.4

  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 ` Tim Deegan [this message]
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 ` [PATCH 5/5] x86/mem_access: " Tim Deegan
2013-03-07 21:50   ` 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-4-git-send-email-tim@xen.org \
    --to=tim@xen.org \
    --cc=eddie.dong@intel.com \
    --cc=jun.nakajima@intel.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.