* MIPS: KDUMP: fix for crashkernel to load from non-sectioned memory.
@ 2013-10-03 7:46 Prem Mallappa
2013-10-03 7:46 ` [PATCH] MIPS: KDUMP: Fix to access " Prem Mallappa
0 siblings, 1 reply; 5+ messages in thread
From: Prem Mallappa @ 2013-10-03 7:46 UTC (permalink / raw)
To: linux-mips
This only happens with kernels having initramfs builtin.
W.R.T following memory map, first kernel ends up in creating per-cpu crash notes (ELF PT_NOTE) in the higher memory area.
When a initramfs image is used, most often the crash_note ends up in "pfn's" belonging to 0x2000.0000
When crashkernel tries to access the PT_NOTEs (crash_notes per cpu variable) via __pfn_to_section <= pfn_to_page <= kmap, we end up in crash, as the sections belong to pfn 0x20006c00 (mem_section[2][0]) for a crash kernel is not populated.
Creating new mappings using ioremap solves the problem, which is pretty much what the patch does.
Determined physical RAM map:
memory: 0000000004eff000 @ 0000000000100000 (usable)
memory: 000000000a000000 @ 0000000005000000 (usable) <<<< Crashkernel reserved area
memory: 0000000030000000 @ 0000000020000000 (usable)
------------
mem_section[0][0]:0x8000000004180003
mem_section[1][0]:0x0
mem_section[2][0]:0x8000000003e00003
mem_section[3][0]:0x8000000003e00003
mem_section[4][0]:0x8000000003e00003
mem_section[5][0]:0x0
mem_section[6][0]:0x0 << Repeats rest of 1024 times >>
get_crash_notes_per_cpu: crash_notes addr = 20006c00
<<32 entries>>
get_crash_notes_per_cpu: crash_notes addr = 2013cc00
Crash Kernel
============
Determined physical RAM map:
memory: 000000000a000000 @ 0000000005000000 (usable)
memory: 0000000020000000 @ 0000000050000000 (usable)
------
mem_section[0][0]:0x8000000008184003
mem_section[1][0]:0x0
mem_section[2][0]:0x0
mem_section[3][0]:0x0
mem_section[4][0]:0x0
mem_section[5][0]:0x8000000007384003
mem_section[6][0]:0x8000000007384003
mem_section[7][0]:0x0 << Repeats rest of 1024 times >>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] MIPS: KDUMP: Fix to access non-sectioned memory
2013-10-03 7:46 MIPS: KDUMP: fix for crashkernel to load from non-sectioned memory Prem Mallappa
@ 2013-10-03 7:46 ` Prem Mallappa
2013-10-03 18:29 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: Prem Mallappa @ 2013-10-03 7:46 UTC (permalink / raw)
To: linux-mips; +Cc: Prem Mallappa
When booted with initramfs, percpu crash_notes ends up in memory that is not accessible by crashkernel
Signed-off-by: Prem Mallappa <pmallappa@caviumnetworks.com>
---
arch/mips/kernel/crash_dump.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/arch/mips/kernel/crash_dump.c b/arch/mips/kernel/crash_dump.c
index 3be9e7b..f9886437 100644
--- a/arch/mips/kernel/crash_dump.c
+++ b/arch/mips/kernel/crash_dump.c
@@ -3,6 +3,8 @@
#include <linux/crash_dump.h>
#include <asm/uaccess.h>
#include <linux/slab.h>
+#include <linux/errno.h>
+#include <linux/io.h>
static int __init parse_savemaxmem(char *p)
{
@@ -13,7 +15,6 @@ static int __init parse_savemaxmem(char *p)
}
__setup("savemaxmem=", parse_savemaxmem);
-
static void *kdump_buf_page;
/**
@@ -41,19 +42,20 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
if (!csize)
return 0;
- vaddr = kmap_atomic_pfn(pfn);
+ vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
if (!userbuf) {
memcpy(buf, (vaddr + offset), csize);
- kunmap_atomic(vaddr);
+ iounmap(vaddr);
} else {
if (!kdump_buf_page) {
pr_warning("Kdump: Kdump buffer page not allocated\n");
return -EFAULT;
}
+
copy_page(kdump_buf_page, vaddr);
- kunmap_atomic(vaddr);
+ iounmap(vaddr);
if (copy_to_user(buf, (kdump_buf_page + offset), csize))
return -EFAULT;
}
--
1.8.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: KDUMP: Fix to access non-sectioned memory
2013-10-03 7:46 ` [PATCH] MIPS: KDUMP: Fix to access " Prem Mallappa
@ 2013-10-03 18:29 ` Ralf Baechle
2013-10-03 18:48 ` David Daney
0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2013-10-03 18:29 UTC (permalink / raw)
To: Prem Mallappa; +Cc: linux-mips, Prem Mallappa
On Thu, Oct 03, 2013 at 01:16:55PM +0530, Prem Mallappa wrote:
> @@ -41,19 +42,20 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
> if (!csize)
> return 0;
>
> - vaddr = kmap_atomic_pfn(pfn);
> + vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
This is not portable, I'm afraid.
Ioremap on MIPS is creating uncached mappings - on most systems, that is.
However there is no guarantee that the data accessed through this mapping
does not reside in a cache on another CPU or another virtual address
which would make the operation undefined.
On SGI IP27 and IP35 ioremap is not even able to create RAM mappings at
all. If you're lucky this would result in a bus error; if you're unlucky
it'll make the SCSI controller scribble the answer to the universe, life
and everything on the disk drive only to corrupt it again before you have
a chance to read it ;-)
I think this is bulletproof on Octeon so until there's a better patch you
may want to keep this around for the SDK.
I wonder, does commit 5395d97b675986e7e8f3140f9e0819d20b1d22cd
in upstream-sfr.git fix your issue?
Cheers,
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: KDUMP: Fix to access non-sectioned memory
2013-10-03 18:29 ` Ralf Baechle
@ 2013-10-03 18:48 ` David Daney
2013-10-03 20:16 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: David Daney @ 2013-10-03 18:48 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Prem Mallappa, linux-mips, Prem Mallappa
On 10/03/2013 11:29 AM, Ralf Baechle wrote:
> On Thu, Oct 03, 2013 at 01:16:55PM +0530, Prem Mallappa wrote:
>
>> @@ -41,19 +42,20 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
>> if (!csize)
>> return 0;
>>
>> - vaddr = kmap_atomic_pfn(pfn);
>> + vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE);
>
> This is not portable, I'm afraid.
It raised a red flag for me too.
I wonder, how does /dev/mem handle it? We should probably do what the
mem driver does for this.
David Daney
>
> Ioremap on MIPS is creating uncached mappings - on most systems, that is.
> However there is no guarantee that the data accessed through this mapping
> does not reside in a cache on another CPU or another virtual address
> which would make the operation undefined.
>
> On SGI IP27 and IP35 ioremap is not even able to create RAM mappings at
> all. If you're lucky this would result in a bus error; if you're unlucky
> it'll make the SCSI controller scribble the answer to the universe, life
> and everything on the disk drive only to corrupt it again before you have
> a chance to read it ;-)
>
> I think this is bulletproof on Octeon so until there's a better patch you
> may want to keep this around for the SDK.
>
> I wonder, does commit 5395d97b675986e7e8f3140f9e0819d20b1d22cd
> in upstream-sfr.git fix your issue?
>
> Cheers,
>
> Ralf
>
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: KDUMP: Fix to access non-sectioned memory
2013-10-03 18:48 ` David Daney
@ 2013-10-03 20:16 ` Ralf Baechle
0 siblings, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2013-10-03 20:16 UTC (permalink / raw)
To: David Daney; +Cc: Prem Mallappa, linux-mips, Prem Mallappa
On Thu, Oct 03, 2013 at 11:48:34AM -0700, David Daney wrote:
> I wonder, how does /dev/mem handle it? We should probably do what
> the mem driver does for this.
/dev/mem is converting physical address to virtual addresses using
xlate_dev_mem_ptr() which is defined as:
#define xlate_dev_mem_ptr(p) __va(p)
which obviously is suffering from similar problems as Prem's suggested
patch.
Fortunately /dev/(k)mem have pretty much gotten out of fashion ;-)
The x86 implementation of xlate_dev_mem_ptr() is based on ioremap_cache()
which may be x86-specific - but very handy in situations like this and
there might also be devices which want to be mapped cached.
I'm considering to implement it since ages. I just don't want a whole
flood of new cache modes like ioremap_uncached_accelerated() or maybe
ioremap_writeback_on_sunday_afternoons_only() ;-)
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-10-03 20:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 7:46 MIPS: KDUMP: fix for crashkernel to load from non-sectioned memory Prem Mallappa
2013-10-03 7:46 ` [PATCH] MIPS: KDUMP: Fix to access " Prem Mallappa
2013-10-03 18:29 ` Ralf Baechle
2013-10-03 18:48 ` David Daney
2013-10-03 20:16 ` Ralf Baechle
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.