public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 2.6.12-rc5] Module gp must point to valid memory
@ 2005-06-06  9:04 Keith Owens
  2005-06-06 17:06 ` David Mosberger
  0 siblings, 1 reply; 2+ messages in thread
From: Keith Owens @ 2005-06-06  9:04 UTC (permalink / raw)
  To: linux-ia64

Some bits of the kernel assume that gp always points to valid memory,
in particular PHYSICAL_MODE_ENTER() assumes that both gp and sp are
valid virtual addresses with associated physical pages.  The IA64
module loader puts gp well past the end of the module, with no physical
backing.  Offsets on gp are still valid, but physical mode addressing
breaks for modules.  Ensure that gp always falls within the module
body.  Also ensure that gp is 8 byte aligned.

Signed-off-by: Keith Owens <kaos@sgi.com>

Index: linux/arch/ia64/kernel/module.c
=================================--- linux.orig/arch/ia64/kernel/module.c	2005-03-02 18:38:07.000000000 +1100
+++ linux/arch/ia64/kernel/module.c	2005-06-06 18:42:47.883261093 +1000
@@ -825,14 +825,16 @@ apply_relocate_add (Elf64_Shdr *sechdrs,
 		 * XXX Should have an arch-hook for running this after final section
 		 *     addresses have been selected...
 		 */
-		/* See if gp can cover the entire core module:  */
-		uint64_t gp = (uint64_t) mod->module_core + MAX_LTOFF / 2;
-		if (mod->core_size >= MAX_LTOFF)
+		uint64_t gp;
+		if (mod->core_size > MAX_LTOFF)
 			/*
 			 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
 			 * at the end of the module.
 			 */
-			gp = (uint64_t) mod->module_core + mod->core_size - MAX_LTOFF / 2;
+			gp = mod->core_size - MAX_LTOFF / 2;
+		else
+			gp = mod->core_size / 2;
+		gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
 		mod->arch.gp = gp;
 		DEBUGP("%s: placing gp at 0x%lx\n", __FUNCTION__, gp);
 	}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch 2.6.12-rc5] Module gp must point to valid memory
  2005-06-06  9:04 [patch 2.6.12-rc5] Module gp must point to valid memory Keith Owens
@ 2005-06-06 17:06 ` David Mosberger
  0 siblings, 0 replies; 2+ messages in thread
From: David Mosberger @ 2005-06-06 17:06 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Mon, 06 Jun 2005 19:04:28 +1000, Keith Owens <kaos@sgi.com> said:

  Keith> Some bits of the kernel assume that gp always points to valid memory,
  Keith> in particular PHYSICAL_MODE_ENTER() assumes that both gp and sp are
  Keith> valid virtual addresses with associated physical pages.

Ah, another "fun" issue caused by putting the text in region 5...

I think the real issue are the "tpa" instructions.  For those to work,
there must be a valid va -> pa translation.  It's not like the memory
that gp points to is every accessed.

The patch looks fine to me.

	--david

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-06-06 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06  9:04 [patch 2.6.12-rc5] Module gp must point to valid memory Keith Owens
2005-06-06 17:06 ` David Mosberger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox