All of lore.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][6/6]Device abstraction for linear/raw view of the dump
Date: Tue, 17 Aug 2004 17:43:32 +0530	[thread overview]
Message-ID: <20040817121332.GG3916@in.ibm.com> (raw)
In-Reply-To: <20040817121017.GF3916@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-hmem-268.patch --]
[-- Type: text/plain, Size: 4534 bytes --]



This patch contains the code that enables us to access the previous kernel's
memory as /dev/hmem.

Signed off by Hariprasad Nellitheertha <hari@in.ibm.com>
Signed off by Adam Litke <litke@us.ibm.com>


---

 linux-2.6.8.1-hari/Documentation/devices.txt |    1 
 linux-2.6.8.1-hari/drivers/char/mem.c        |   72 +++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)

diff -puN Documentation/devices.txt~kd-hmem-268 Documentation/devices.txt
--- linux-2.6.8.1/Documentation/devices.txt~kd-hmem-268	2004-08-17 17:11:26.000000000 +0530
+++ linux-2.6.8.1-hari/Documentation/devices.txt	2004-08-17 17:11:32.000000000 +0530
@@ -100,6 +100,7 @@ Your cooperation is appreciated.
 		  9 = /dev/urandom	Faster, less secure random number gen.
 		 10 = /dev/aio		Asyncronous I/O notification interface
 		 11 = /dev/kmsg		Writes to this come out as printk's
+		 12 = /dev/hmem		Access to kexec-ed crash dump
   1 block	RAM disk
 		  0 = /dev/ram0		First RAM disk
 		  1 = /dev/ram1		Second RAM disk
diff -puN drivers/char/mem.c~kd-hmem-268 drivers/char/mem.c
--- linux-2.6.8.1/drivers/char/mem.c~kd-hmem-268	2004-08-17 17:11:26.000000000 +0530
+++ linux-2.6.8.1-hari/drivers/char/mem.c	2004-08-17 17:11:32.000000000 +0530
@@ -263,6 +263,68 @@ ssize_t copy_hmem_page(unsigned long pfn
 	return 0;
 }
 
+/*
+ * After a crash-induced kexec, our physical memory layout
+ * looks like the following:
+ *
+ *        max_pfn                           End of memory\
+ * /---------|--------------------------------------------\
+ * | Section | Section | Section | Section                |
+ * |    K    |    B    |    A    |    C                   |
+ * \------------------------------------------------------/
+ *
+ * Section K: System memory.  The system is fooled to think it
+ *            can only use memory in this area.
+ * Section A: Backup of 0 - CRASH_BACKUP_SIZE kB from
+ *            the crashed kernel.
+ * Section B: Untouched memory from last kernel.
+ * Section C: Untouched memory from last kernel.
+ *
+ * In order to present a properly-ordered dump via this device,
+ * we must reorder the sections per the following:
+ *
+ * /---------|--------------------------------------------\
+ * | Section | Section |  Empty  | Section                |
+ * |    A    |    B    | Section |    C                   |
+ * \------------------------------------------------------/
+ *
+ */
+static ssize_t read_hmem(struct file * file, char * buf,
+                        size_t count, loff_t *ppos)
+{
+	unsigned long pfn;
+	unsigned curmem_end, backup_start, backup_end;
+	size_t read=0, csize;
+
+	backup_start = CRASH_BACKUP_BASE / PAGE_SIZE;
+	backup_end = backup_start + (CRASH_BACKUP_SIZE / PAGE_SIZE);
+	curmem_end = max_pfn;
+
+	while(count) {
+		pfn = *ppos / PAGE_SIZE;
+
+		/* Perform translation (see comment above) */
+		if (pfn < curmem_end)
+			pfn += backup_start;
+		else if ((pfn >= backup_start) && (pfn < backup_end))
+			pfn = -1; /* Placeholder so we know to zero page later */
+
+		if ((pfn != -1) && (pfn > saved_max_pfn))
+			return 0; /* EOF */
+
+		csize = (count > PAGE_SIZE) ? PAGE_SIZE : count;
+
+		if (copy_hmem_page(pfn, buf, csize, 1))
+			return -EFAULT;
+
+		buf += csize;
+		*ppos += csize;
+		read += csize;
+		count -= csize;
+	}
+	return read;
+}
+
 extern long vread(char *buf, char *addr, unsigned long count);
 extern long vwrite(char *buf, char *addr, unsigned long count);
 
@@ -626,6 +688,7 @@ static int open_port(struct inode * inod
 #define read_full       read_zero
 #define open_mem	open_port
 #define open_kmem	open_mem
+#define open_hmem	open_mem
 
 static struct file_operations mem_fops = {
 	.llseek		= memory_lseek,
@@ -671,6 +734,11 @@ static struct file_operations full_fops 
 	.write		= write_full,
 };
 
+static struct file_operations hmem_fops = {
+        .read           = read_hmem,
+        .open           = open_hmem,
+};
+
 static ssize_t kmsg_write(struct file * file, const char __user * buf,
 			  size_t count, loff_t *ppos)
 {
@@ -725,6 +793,9 @@ static int memory_open(struct inode * in
 		case 11:
 			filp->f_op = &kmsg_fops;
 			break;
+		case 12:
+			filp->f_op = &hmem_fops;
+			break;
 		default:
 			return -ENXIO;
 	}
@@ -754,6 +825,7 @@ static const struct {
 	{8, "random",  S_IRUGO | S_IWUSR,           &random_fops},
 	{9, "urandom", S_IRUGO | S_IWUSR,           &urandom_fops},
 	{11,"kmsg",    S_IRUGO | S_IWUSR,           &kmsg_fops},
+	{12,"hmem",    S_IRUSR | S_IWUSR | S_IRGRP, &hmem_fops},
 };
 
 static struct class_simple *mem_class;

_

  reply	other threads:[~2004-08-17 12:20 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     ` [PATCH][3/6]Interface for copying the dump pages Hariprasad Nellitheertha
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           ` Hariprasad Nellitheertha [this message]
2004-08-17 22:53             ` [PATCH][6/6]Device abstraction for linear/raw view of " 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=20040817121332.GG3916@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 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.