mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: <linux-kernel@vger.kernel.org>
Cc: Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH] xen/p2m: fix extra memory regions accounting
Date: Thu, 3 Sep 2015 14:03:55 +0200	[thread overview]
Message-ID: <1441281835-38238-1-git-send-email-roger.pau@citrix.com> (raw)

On systems with memory maps with ranges that don't end at page boundaries,
like:

[...]
(XEN)  0000000000100000 - 00000000dfdf9c00 (usable)
(XEN)  00000000dfdf9c00 - 00000000dfe4bc00 (ACPI NVS)
[...]

xen_add_extra_mem will create a protected range that ends up at 0xdfdf9c00,
but the function used to check if a memory address is inside of a protected
range works with pfns, which means that an attempt to map 0xdfdf9c00 will be
refused because the check is performed against 0xdfdf9000 instead of
0xdfdf9c00.

In order to fix this, make sure that the ranges that are added to the
xen_extra_mem array are aligned to page boundaries.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
AFAICT this patch needs to be backported to 3.19, 4.0, 4.1 and 4.2.
---
 arch/x86/xen/setup.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index 55f388e..dcf5865 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -68,6 +68,9 @@ static void __init xen_add_extra_mem(phys_addr_t start, phys_addr_t size)
 {
 	int i;
 
+	start = PAGE_ALIGN(start);
+	size &= PAGE_MASK;
+
 	for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
 		/* Add new region. */
 		if (xen_extra_mem[i].size == 0) {
@@ -92,6 +95,9 @@ static void __init xen_del_extra_mem(phys_addr_t start, phys_addr_t size)
 	int i;
 	phys_addr_t start_r, size_r;
 
+	start = PAGE_ALIGN(start);
+	size &= PAGE_MASK;
+
 	for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) {
 		start_r = xen_extra_mem[i].start;
 		size_r = xen_extra_mem[i].size;
-- 
1.9.5 (Apple Git-50.3)


             reply	other threads:[~2015-09-03 12:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-03 12:03 Roger Pau Monne [this message]
2015-09-03 12:05 Roger Pau Monne
2015-09-03 12:15 ` Roger Pau Monné
2015-09-03 12:26   ` Juergen Gross
2015-09-03 12:25 ` Juergen Gross
2015-09-03 14:38   ` Roger Pau Monné
2015-09-03 14:45     ` David Vrabel
2015-09-03 14:50     ` Juergen Gross

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=1441281835-38238-1-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=linux-kernel@vger.kernel.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®