public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hariprasad Nellitheertha <hari@in.ibm.com>
To: linux-kernel@vger.kernel.org, fastboot@osdl.org
Cc: akpm@osdl.org, Suparna Bhattacharya <suparna@in.ibm.com>,
	mbligh@aracnet.com, litke@us.ibm.com, ebiederm@xmission.com
Subject: Re: [PATCH][3/6]Interface for copying the dump pages
Date: Tue, 17 Aug 2004 17:38:09 +0530	[thread overview]
Message-ID: <20040817120809.GD3916@in.ibm.com> (raw)
In-Reply-To: <20040817120717.GC3916@in.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 108 bytes --]

Regards, Hari
-- 
Hariprasad Nellitheertha
Linux Technology Center
India Software Labs
IBM India, Bangalore

[-- Attachment #2: kd-copy-268.patch --]
[-- Type: text/plain, Size: 4338 bytes --]



This patch provides the interfaces necessary to read the dump contents,
treating it as a high memory device.

Signed off by Hariprasad Nellitheertha <hari@in.ibm.com>


---

 linux-2.6.8.1-hari/arch/i386/mm/highmem.c     |   18 ++++++++++
 linux-2.6.8.1-hari/drivers/char/mem.c         |   44 ++++++++++++++++++++++++++
 linux-2.6.8.1-hari/include/asm-i386/highmem.h |    1 
 linux-2.6.8.1-hari/include/linux/highmem.h    |    1 
 4 files changed, 64 insertions(+)

diff -puN arch/i386/mm/highmem.c~kd-copy-268 arch/i386/mm/highmem.c
--- linux-2.6.8.1/arch/i386/mm/highmem.c~kd-copy-268	2004-08-17 17:06:21.000000000 +0530
+++ linux-2.6.8.1-hari/arch/i386/mm/highmem.c	2004-08-17 17:06:27.000000000 +0530
@@ -74,6 +74,24 @@ void kunmap_atomic(void *kvaddr, enum km
 	preempt_check_resched();
 }
 
+/* This is the same as kmap_atomic but takes in a pfn instead of a
+ * struct page.
+ */
+void *kmap_atomic_pfn(unsigned long pfn, enum km_type type)
+{
+        enum fixed_addresses idx;
+        unsigned long vaddr;
+
+        inc_preempt_count();
+
+        idx = type + KM_TYPE_NR*smp_processor_id();
+        vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
+        set_pte(kmap_pte-idx, pfn_pte(pfn, kmap_prot));
+        __flush_tlb_one(vaddr);
+
+        return (void*) vaddr;
+}
+
 struct page *kmap_atomic_to_page(void *ptr)
 {
 	unsigned long idx, vaddr = (unsigned long)ptr;
diff -puN drivers/char/mem.c~kd-copy-268 drivers/char/mem.c
--- linux-2.6.8.1/drivers/char/mem.c~kd-copy-268	2004-08-17 17:06:21.000000000 +0530
+++ linux-2.6.8.1-hari/drivers/char/mem.c	2004-08-17 17:06:27.000000000 +0530
@@ -23,9 +23,13 @@
 #include <linux/devfs_fs_kernel.h>
 #include <linux/ptrace.h>
 #include <linux/device.h>
+#include <linux/bootmem.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
+#include <asm/tlbflush.h>
+#include <asm/crash_dump.h>
+#include <asm/highmem.h>
 
 #ifdef CONFIG_IA64
 # include <linux/efi.h>
@@ -38,6 +42,8 @@ extern void fbmem_init(void);
 extern void tapechar_init(void);
 #endif
 
+ssize_t copy_hmem_page(unsigned long, char *, size_t, int);
+
 /*
  * Architectures vary in how they handle caching for addresses
  * outside of main memory.
@@ -219,6 +225,44 @@ static int mmap_mem(struct file * file, 
 	return 0;
 }
 
+/*
+ * Copy a page from "highmem". For this page, there is no pte mapped
+ * in the current kernel. We stitch up a pte, similar to kmap_atomic.
+ */
+ssize_t copy_hmem_page(unsigned long pfn, char *buf, size_t csize, int userbuf)
+{
+	void *page, *vaddr;
+
+	if (!csize)
+		return 0;
+
+	if (pfn == -1) {
+		/* Give them a zeroed page */
+		if (userbuf) {
+			if (clear_user(buf, csize))
+				return -EFAULT;
+		} else
+			memset(buf, 0, csize);
+	} else {
+		page = kmalloc(PAGE_SIZE, GFP_KERNEL);
+
+		vaddr = kmap_atomic_pfn(pfn, KM_PTE0);
+		copy_page(page, vaddr);
+		kunmap_atomic(vaddr, KM_PTE0);
+
+		if (userbuf) {
+			if (copy_to_user(buf, page, csize)) {
+				kfree(page);
+				return -EFAULT;
+			}
+		} else
+			memcpy(buf, page, csize);
+		kfree(page);
+	}
+
+	return 0;
+}
+
 extern long vread(char *buf, char *addr, unsigned long count);
 extern long vwrite(char *buf, char *addr, unsigned long count);
 
diff -puN include/asm-i386/highmem.h~kd-copy-268 include/asm-i386/highmem.h
--- linux-2.6.8.1/include/asm-i386/highmem.h~kd-copy-268	2004-08-17 17:06:21.000000000 +0530
+++ linux-2.6.8.1-hari/include/asm-i386/highmem.h	2004-08-17 17:06:27.000000000 +0530
@@ -61,6 +61,7 @@ void *kmap(struct page *page);
 void kunmap(struct page *page);
 void *kmap_atomic(struct page *page, enum km_type type);
 void kunmap_atomic(void *kvaddr, enum km_type type);
+void *kmap_atomic_pfn(unsigned long pfn, enum km_type type);
 struct page *kmap_atomic_to_page(void *ptr);
 
 #define flush_cache_kmaps()	do { } while (0)
diff -puN include/linux/highmem.h~kd-copy-268 include/linux/highmem.h
--- linux-2.6.8.1/include/linux/highmem.h~kd-copy-268	2004-08-17 17:06:21.000000000 +0530
+++ linux-2.6.8.1-hari/include/linux/highmem.h	2004-08-17 17:06:27.000000000 +0530
@@ -30,6 +30,7 @@ static inline void *kmap(struct page *pa
 
 #define kmap_atomic(page, idx)		page_address(page)
 #define kunmap_atomic(addr, idx)	do { } while (0)
+#define kmap_atomic_pfn(pfn, idx)	page_address(pfn_to_page(pfn))
 #define kmap_atomic_to_page(ptr)	virt_to_page(ptr)
 
 #endif /* CONFIG_HIGHMEM */

_

  reply	other threads:[~2004-08-17 12:09 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-17 12:04 [RFC]Kexec based crash dumping Hariprasad Nellitheertha
2004-08-17 12:05 ` [PATCH][1/6]Documentation Hariprasad Nellitheertha
2004-08-17 12:07   ` [PATCH][2/6]Memory preserving reboot using kexec Hariprasad Nellitheertha
2004-08-17 12:08     ` Hariprasad Nellitheertha [this message]
2004-08-17 12:09       ` [PATCH][4/6]Register snapshotting before kexec-boot Hariprasad Nellitheertha
2004-08-17 12:10         ` [PATCH][5/6]ELF format interface for the dump Hariprasad Nellitheertha
2004-08-17 12:13           ` [PATCH][6/6]Device abstraction for linear/raw view of " Hariprasad Nellitheertha
2004-08-17 22:53             ` Martin J. Bligh
2004-08-18 12:29               ` Hariprasad Nellitheertha
2004-08-17 16:27         ` [PATCH][4/6]Register snapshotting before kexec-boot Dave Hansen
2004-08-18 13:43         ` Theodore Ts'o
2004-08-19 11:59           ` Hariprasad Nellitheertha
2004-08-17 16:17       ` [PATCH][3/6]Interface for copying the dump pages Dave Hansen
2004-08-17 16:01     ` [PATCH][2/6]Memory preserving reboot using kexec Dave Hansen
2004-08-17 22:44 ` [RFC]Kexec based crash dumping Andrew Morton
2004-08-18 12:28   ` Hariprasad Nellitheertha
2004-08-20  8:17   ` [Fastboot] " Eric W. Biederman
2004-08-20  8:05 ` [Fastboot] " Eric W. Biederman
2004-08-20  8:27   ` Hariprasad Nellitheertha

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=20040817120809.GD3916@in.ibm.com \
    --to=hari@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=fastboot@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=litke@us.ibm.com \
    --cc=mbligh@aracnet.com \
    --cc=suparna@in.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox