All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eugene Surovegin <ebs@ebshome.net>
To: tj@kernel.org
Cc: ptesarik@suse.cz, xiyou.wangcong@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, vgoyal@redhat.com
Subject: [PATCH] percpu: fix per_cpu_ptr_to_phys() handling of non-page-aligned addresses.
Date: Thu, 15 Dec 2011 11:25:59 -0800	[thread overview]
Message-ID: <20111215192559.GA28283@gate.ebshome.net> (raw)

per_cpu_ptr_to_phys() incorrectly rounds up its result for non-kmalloc case
to the page boundary, which is bogus for any non-page-aligned address.

This fixes the only in-tree user of this function - sysfs handler for
per-cpu 'crash_notes' physical address. The manifestation of this bug is
missing 'CORE' ELF notes in kdump.

Signed-off-by: Eugene Surovegin <ebs@ebshome.net>
---
 mm/percpu.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 3bb810a..716eb4a 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1023,9 +1023,11 @@ phys_addr_t per_cpu_ptr_to_phys(void *addr)
 		if (!is_vmalloc_addr(addr))
 			return __pa(addr);
 		else
-			return page_to_phys(vmalloc_to_page(addr));
+			return page_to_phys(vmalloc_to_page(addr)) +
+			       offset_in_page(addr);
 	} else
-		return page_to_phys(pcpu_addr_to_page(addr));
+		return page_to_phys(pcpu_addr_to_page(addr)) +
+		       offset_in_page(addr);
 }
 
 /**
-- 
1.7.5.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Eugene Surovegin <ebs@ebshome.net>
To: tj@kernel.org
Cc: ptesarik@suse.cz, xiyou.wangcong@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, vgoyal@redhat.com
Subject: [PATCH] percpu: fix per_cpu_ptr_to_phys() handling of non-page-aligned addresses.
Date: Thu, 15 Dec 2011 11:25:59 -0800	[thread overview]
Message-ID: <20111215192559.GA28283@gate.ebshome.net> (raw)

per_cpu_ptr_to_phys() incorrectly rounds up its result for non-kmalloc case
to the page boundary, which is bogus for any non-page-aligned address.

This fixes the only in-tree user of this function - sysfs handler for
per-cpu 'crash_notes' physical address. The manifestation of this bug is
missing 'CORE' ELF notes in kdump.

Signed-off-by: Eugene Surovegin <ebs@ebshome.net>
---
 mm/percpu.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index 3bb810a..716eb4a 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1023,9 +1023,11 @@ phys_addr_t per_cpu_ptr_to_phys(void *addr)
 		if (!is_vmalloc_addr(addr))
 			return __pa(addr);
 		else
-			return page_to_phys(vmalloc_to_page(addr));
+			return page_to_phys(vmalloc_to_page(addr)) +
+			       offset_in_page(addr);
 	} else
-		return page_to_phys(pcpu_addr_to_page(addr));
+		return page_to_phys(pcpu_addr_to_page(addr)) +
+		       offset_in_page(addr);
 }
 
 /**
-- 
1.7.5.1


             reply	other threads:[~2011-12-15 19:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-15 19:25 Eugene Surovegin [this message]
2011-12-15 19:25 ` [PATCH] percpu: fix per_cpu_ptr_to_phys() handling of non-page-aligned addresses Eugene Surovegin
2011-12-15 19:43 ` Tejun Heo
2011-12-15 19:43   ` Tejun Heo

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=20111215192559.GA28283@gate.ebshome.net \
    --to=ebs@ebshome.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ptesarik@suse.cz \
    --cc=tj@kernel.org \
    --cc=vgoyal@redhat.com \
    --cc=xiyou.wangcong@gmail.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.