All of lore.kernel.org
 help / color / mirror / Atom feed
From: Malcolm Crossley <malcolm.crossley@citrix.com>
To: xen-devel@lists.xensource.com
Cc: tim@xen.org
Subject: [PATCH] [RFC] xen: Fix memory hotplug end limit test for updating compat M2P table
Date: Mon, 23 Apr 2012 19:07:23 +0100	[thread overview]
Message-ID: <8470671d407f4f74b499.1335204443@malcolmc-Precision-WorkStation-T3500> (raw)

The memory hotplug code was masking the hotplugged memory start address and comparing to a shifted version of COMPAT MPT size but not doing the same for the end address.
This patch applies the same shifting and masking to the end address and reapplies the mask if the end address has been clamped.

diff -r 274e5accd62d -r 8470671d407f xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c
+++ b/xen/arch/x86/x86_64/mm.c
@@ -446,6 +446,8 @@ static int setup_compat_m2p_table(struct
     int err = 0;
 
     smap = info->spfn & (~((1UL << (L2_PAGETABLE_SHIFT - 2)) -1));
+    emap = ( (epfn + ((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1 )) &
+                ~((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1) );
 
     /*
      * Notice: For hot-added memory, only range below m2p_compat_vstart
@@ -454,11 +456,11 @@ static int setup_compat_m2p_table(struct
     if   ((smap > ((RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2)) )
         return 0;
 
-    if (epfn > (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START))
-        epfn = (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2;
-
-    emap = ( (epfn + ((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1 )) &
-                ~((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1) );
+    if (emap > ((RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2))
+    {
+        emap = (RDWR_COMPAT_MPT_VIRT_END - RDWR_COMPAT_MPT_VIRT_START) >> 2;
+    	emap = emap & ~((1UL << (L2_PAGETABLE_SHIFT - 2)) - 1);
+    }
 
     va = HIRO_COMPAT_MPT_VIRT_START +
          smap * sizeof(*compat_machine_to_phys_mapping);

             reply	other threads:[~2012-04-23 18:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-23 18:07 Malcolm Crossley [this message]
2012-04-24  7:21 ` [PATCH] [RFC] xen: Fix memory hotplug end limit test for updating compat M2P table Jan Beulich
2012-04-24 16:02   ` Malcolm Crossley
2012-04-24 16:11     ` 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=8470671d407f4f74b499.1335204443@malcolmc-Precision-WorkStation-T3500 \
    --to=malcolm.crossley@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.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 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.