This patch adds writing support for /dev/oldmem. This is used to
restore the memory contents of hibernated system.
Signed-off-by: Huang Ying <ying.huang@intel.com>
---
arch/i386/kernel/crash_dump.c | 27 +++++++++++++++++++++++++++
drivers/char/mem.c | 32 ++++++++++++++++++++++++++++++++
include/linux/crash_dump.h | 2 ++
3 files changed, 61 insertions(+)
Index: linux-2.6.23-rc4/arch/i386/kernel/crash_dump.c
===================================================================
--- linux-2.6.23-rc4.orig/arch/i386/kernel/crash_dump.c 2007-09-11 16:52:14.000000000 +0800
+++ linux-2.6.23-rc4/arch/i386/kernel/crash_dump.c 2007-09-20 09:48:10.000000000 +0800
@@ -58,6 +58,33 @@
return csize;
}
+ssize_t write_oldmem_page(unsigned long pfn, const char *buf,
+ size_t csize, unsigned long offset, int userbuf)
+{
+ void *vaddr;
+
+ if (!csize)
+ return 0;
+
+ if (!userbuf) {
+ vaddr = kmap_atomic_pfn(pfn, KM_PTE0);
+ memcpy(vaddr + offset, buf, csize);
+ } else {
+ if (!kdump_buf_page) {
+ printk(KERN_WARNING "Kdump: Kdump buffer page not"
+ " allocated\n");
+ return -EFAULT;
+ }
+ if (copy_from_user(kdump_buf_page, buf, csize))
+ return -EFAULT;
+ vaddr = kmap_atomic_pfn(pfn, KM_PTE0);
+ memcpy(vaddr + offset, kdump_buf_page, csize);
+ }
+ kunmap_atomic(vaddr, KM_PTE0);
+
+ return csize;
+}
+
static int __init kdump_buf_page_init(void)
{
int ret = 0;
Index: linux-2.6.23-rc4/include/linux/crash_dump.h
===================================================================
--- linux-2.6.23-rc4.orig/include/linux/crash_dump.h 2007-09-11 16:52:14.000000000 +0800
+++ linux-2.6.23-rc4/include/linux/crash_dump.h 2007-09-20 09:48:10.000000000 +0800
@@ -11,6 +11,8 @@
extern unsigned long long elfcorehdr_addr;
extern ssize_t copy_oldmem_page(unsigned long, char *, size_t,
unsigned long, int);
+extern ssize_t write_oldmem_page(unsigned long, const char *, size_t,
+ unsigned long, int);
extern const struct...