All of lore.kernel.org
 help / color / mirror / Atom feed
* RFC: /proc/kcore
@ 2002-03-11 20:00 Russell King
  0 siblings, 0 replies; only message in thread
From: Russell King @ 2002-03-11 20:00 UTC (permalink / raw)
  To: linux-kernel

A short while ago, I cooked up the following for the ARM architecture
to allow /proc/kcore to work.  I suspect it needs to be extended to all
architectures however; comments from all other architecture maintainers
are welcome.

In the ELF headers, we supply the following information for the kernels
memory space:

        phdr->p_type    = PT_LOAD;
        phdr->p_flags   = PF_R|PF_W|PF_X;
        phdr->p_offset  = dataoff;
        phdr->p_vaddr   = PAGE_OFFSET;
        phdr->p_paddr   = __pa(PAGE_OFFSET);
        phdr->p_filesz  = phdr->p_memsz = ((unsigned long)high_memory - PAGE_OFFSET);
        phdr->p_align   = PAGE_SIZE;

So, when we access file offset 'dataoff' we expect the bytes starting
at virtual memory address 'PAGE_OFFSET' (or physical address
__pa(PAGE_OFFSET)).

'dataoff' comes from get_kcore_size, and is the same as the elf_buflen
you see in the patch below, and is the first byte of non-header
information.

With a file offset of 'elf_buflen', the original code does:

	start = __va(0)

and the only way this will return the byte at PAGE_OFFSET is if __va
is defined as (PAGE_OFFSET + (x)).  However, a machine where the RAM
does not start at physical address zero, this will not be the case.

I therefore expect that the code I have below for ARM should be used
for all architectures.

I'd like other people to confirm.  If I don't hear anything, I'll
generate such a patch, and forward it to Linus, Marcelo and LKML for
inclusion in the next kernel releases.

--- orig/fs/proc/kcore.c	Mon Oct  1 23:11:24 2001
+++ linux/fs/proc/kcore.c	Tue Jan 29 20:57:03 2002
@@ -382,7 +382,17 @@
 	}
 #endif
 	/* fill the remainder of the buffer from kernel VM space */
+#ifndef __arm__
 	start = (unsigned long)__va(*fpos - elf_buflen);
+#else
+	/*
+	 * this would appear to be more correct than the above.
+	 * We said in the ELF header that the data which starts
+	 * at 'elf_buflen' is virtual address PAGE_OFFSET.  This
+	 * is not what the above does.
+	 */
+	start = PAGE_OFFSET + (*fpos - elf_buflen);
+#endif
 	if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
 		tsz = buflen;
 		

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-03-11 20:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-03-11 20:00 RFC: /proc/kcore Russell King

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.