From: horms@verge.net.au (Simon Horman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: conditional ioremap() fix for copy_oldmem_page()
Date: Wed, 22 Jun 2011 18:55:32 +0900 [thread overview]
Message-ID: <20110622095525.GC9215@verge.net.au> (raw)
In-Reply-To: <20110622034445.1936.16176.sendpatchset@t400s>
On Wed, Jun 22, 2011 at 12:44:45PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
>
> Update the copy_oldmem_page() function to ioremap() only
> when accessing memory that is outside the regular range
> of system memory that is managed by the kernel.
>
> Without this patch a warning is triggered in the ARM-specific
> ioremap implementation, see WARN_ON(pfn_valid()) in ioremap.c
>
> The copy_oldmem_page() function is used by the secondary crash
> kernel to access memory using the /proc/vmcore code implemented
> in fs/proc/vmcore.c. To pass information from the first kernel
> to the secondary crash kernel a kernel command line option is
> used to point out where the elf core hdr is located.
>
> The crash kernel is loaded through kexec-tools which also contains
> code that reserves memory for the elfcorehdr= option. This memory
> block is reserved _inside_ the main system memory of the secondary
> kernel. The /proc/vmcore code in the secondary kernel is however
> using copy_oldmem_page() to access both this elfcorehdr area and
> the rest of the memory used by the the first kernel.
>
> So the copy_oldmem_page() function is used to access data that
> may be located in system memory, or it may be outside. Always
> using ioremap will not work, so this patch makes it conditional
> based on pfn_valid().
>
> For more details please look at the sh7372-based example here:
> http://permalink.gmane.org/gmane.linux.ports.sh.devel/11502
>
> Signed-off-by: Magnus Damm <damm@opensource.se>
Reviewed-by: Simon Horman <horms@verge.net.au>
> ---
>
> arch/arm/kernel/crash_dump.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> --- 0001/arch/arm/kernel/crash_dump.c
> +++ work/arch/arm/kernel/crash_dump.c 2011-06-18 20:59:49.000000000 +0900
> @@ -39,9 +39,13 @@ ssize_t copy_oldmem_page(unsigned long p
> if (!csize)
> return 0;
>
> - vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
> - if (!vaddr)
> - return -ENOMEM;
> + if (pfn_valid(pfn)) {
> + vaddr = phys_to_virt(pfn << PAGE_SHIFT);
> + } else {
> + vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
> + if (!vaddr)
> + return -ENOMEM;
> + }
>
> if (userbuf) {
> if (copy_to_user(buf, vaddr + offset, csize)) {
> @@ -52,6 +56,8 @@ ssize_t copy_oldmem_page(unsigned long p
> memcpy(buf, vaddr + offset, csize);
> }
>
> - iounmap(vaddr);
> + if (!pfn_valid(pfn))
> + iounmap(vaddr);
> +
> return csize;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
prev parent reply other threads:[~2011-06-22 9:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-22 3:44 [PATCH] ARM: conditional ioremap() fix for copy_oldmem_page() Magnus Damm
2011-06-22 9:55 ` Simon Horman [this message]
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=20110622095525.GC9215@verge.net.au \
--to=horms@verge.net.au \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).