Thread (42 messages) 42 messages, 9 authors, 2016-11-01
STALE3506d REVIEWED: 3 (3M)
Revisions (15)
  1. v1 [diff vs current]
  2. v22 [diff vs current]
  3. v22 [diff vs current]
  4. v22 [diff vs current]
  5. v26 [diff vs current]
  6. v26 current
  7. v26 [diff vs current]
  8. v26 [diff vs current]
  9. v27 [diff vs current]
  10. v28 [diff vs current]
  11. v29 [diff vs current]
  12. v29 [diff vs current]
  13. v29 [diff vs current]
  14. v29 [diff vs current]
  15. v30 [diff vs current]

[PATCH v26 3/7] arm64: kdump: add kdump support

From: james.morse@arm.com (James Morse)
Date: 2016-09-16 14:50:24
Also in: kexec

On 07/09/16 05:29, AKASHI Takahiro wrote:
On crash dump kernel, all the information about primary kernel's system
memory (core image) is available in elf core header.
The primary kernel will set aside this header with reserve_elfcorehdr()
at boot time and inform crash dump kernel of its location via a new
device-tree property, "linux,elfcorehdr".

Please note that all other architectures use traditional "elfcorehdr="
kernel parameter for this purpose.

Then crash dump kernel will access the primary kernel's memory with
copy_oldmem_page(), which reads one page by ioremap'ing it since it does
not reside in linear mapping on crash dump kernel.

We also need our own elfcorehdr_read() here since the header is placed
within crash dump kernel's usable memory.
One nit below, looks good.

Reviewed-by: James Morse <james.morse@arm.com>


Thanks,

James

quoted hunk ↗ jump to hunk
diff --git a/arch/arm64/kernel/crash_dump.c b/arch/arm64/kernel/crash_dump.c
+/**
+ * copy_oldmem_page() - copy one page from old kernel memory
+ * @pfn: page frame number to be copied
+ * @buf: buffer where the copied page is placed
+ * @csize: number of bytes to copy
+ * @offset: offset in bytes into the page
+ * @userbuf: if set, @buf is in a user address space
+ *
+ * This function copies one page from old kernel memory into buffer pointed by
+ * @buf. If @buf is in userspace, set @userbuf to %1. Returns number of bytes
+ * copied or negative error in case of failure.
+ */
+ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
+			 size_t csize, unsigned long offset,
+			 int userbuf)
+{
+	void *vaddr;
+
+	if (!csize)
+		return 0;
+
+	vaddr = memremap(__pfn_to_phys(pfn), PAGE_SIZE, MEMREMAP_WB);
+	if (!vaddr)
+		return -ENOMEM;
+
+	if (userbuf) {
+		if (copy_to_user(buf, vaddr + offset, csize)) {
If you re-cast buf with (char __user *), it should stop sparse complaining:
../arch/arm64/kernel/crash_dump.c:45:34: warning: incorrect type in argument 1
(different address spaces)
../arch/arm64/kernel/crash_dump.c:45:34:    expected void [noderef] <asn:1>*to
../arch/arm64/kernel/crash_dump.c:45:34:    got char *buf
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help