LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [patch 07/11] powerpc/dma: implement new dma_*map*_attrs() interfaces
From: Geoff Levand @ 2008-07-07 19:15 UTC (permalink / raw)
  To: benh; +Cc: Mark Nelson, linuxppc-dev, Paul Mackerras, cbe-oss-dev
In-Reply-To: <1215408473.8970.69.camel@pasglop>

Benjamin Herrenschmidt wrote:
> On Fri, 2008-07-04 at 21:05 +0200, arnd@arndb.de wrote:
>> plain text document attachment
>> (0007-powerpc-dma-implement-new-dma_-map-_attrs-interfa.patch)
>> Update powerpc to use the new dma_*map*_attrs() interfaces. In doing so
>> update struct dma_mapping_ops to accept a struct dma_attrs and propagate
>> these changes through to all users of the code (generic IOMMU and the
>> 64bit DMA code, and the iseries and ps3 platform code).
>> 
>> The old dma_*map_*() interfaces are reimplemented as calls to the
>> corresponding new interfaces.
> 
> Geoff, I think the PS3 bits in this patch are ok but I'd like
> you to double-check and send your ack if you think they are.


I tested on PS3 with ps3_defconfig, and it works OK.

Acked-by: Geoff Levand <geoffrey.levand@am.sony.com>


>> Signed-off-by: Mark Nelson <markn@au1.ibm.com>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> ---
>>  arch/powerpc/Kconfig                    |    1 +
>>  arch/powerpc/kernel/dma_64.c            |   34 ++++++---
>>  arch/powerpc/kernel/ibmebus.c           |   12 ++-
>>  arch/powerpc/kernel/iommu.c             |   11 ++-
>>  arch/powerpc/platforms/iseries/iommu.c  |    4 +-
>>  arch/powerpc/platforms/ps3/system-bus.c |   17 +++--
>>  include/asm-powerpc/dma-mapping.h       |  116 +++++++++++++++++++++++--------
>>  include/asm-powerpc/iommu.h             |   12 ++-
>>  8 files changed, 144 insertions(+), 63 deletions(-)

^ permalink raw reply

* indications for oprofile in compact mode
From: torez @ 2008-07-07 19:00 UTC (permalink / raw)
  To: linuxppc-dev

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



[-- Attachment #2: Indications oprofile in compact mode.txt --]
[-- Type: text/plain, Size: 2041 bytes --]

This patch allows Performance monitoring driver to detect when
operating in PowerPC compliance mode.

use patch -p0 to apply.

==========================================================================
diff -urN linux-2.6.26-rc7.orig/arch/powerpc/kernel/cputable.c linux-2.6.26-rc7/arch/powerpc/kernel/cputable.c
--- linux-2.6.26-rc7.orig/arch/powerpc/kernel/cputable.c	2008-07-07 11:37:40.000000000 -0500
+++ linux-2.6.26-rc7/arch/powerpc/kernel/cputable.c	2008-07-07 11:27:09.000000000 -0500
@@ -352,6 +352,7 @@
 		.icache_bsize		= 128,
 		.dcache_bsize		= 128,
 		.machine_check		= machine_check_generic,
+		.oprofile_cpu_type	= "ppc64/compat-power5+",
 		.platform		= "power5+",
 	},
 	{	/* Power6 */
@@ -383,6 +384,7 @@
 		.icache_bsize		= 128,
 		.dcache_bsize		= 128,
 		.machine_check		= machine_check_generic,
+		.oprofile_cpu_type	= "ppc64/compat-power6",
 		.platform		= "power6",
 	},
 	{	/* 2.06-compliant processor, i.e. Power7 "architected" mode */
@@ -394,6 +396,7 @@
 		.icache_bsize		= 128,
 		.dcache_bsize		= 128,
 		.machine_check		= machine_check_generic,
+		.oprofile_cpu_type	= "ppc64/compat-power7",
 		.platform		= "power7",
 	},
 	{	/* Power7 */
@@ -1593,6 +1596,12 @@
 			 * from the real PVR with a new value obtained
 			 * using a logical PVR value, don't modify the
 			 * performance monitor fields.
+			 * The performance monitor sub-system needs to have
+			 * access to the values from the real PVR, but, at 
+			 * the same time it needs to be aware it may be running
+			 * in compatibility mode. We we are changing the values
+			 * for the real PVR to those of the compatibility PVR,
+			 * change the oprofile_cpu_type field as well.
 			 */
 			if (t->num_pmcs && !s->num_pmcs) {
 				t->cpu_name = s->cpu_name;
@@ -1603,6 +1612,8 @@
 				t->cpu_setup = s->cpu_setup;
 				t->cpu_restore = s->cpu_restore;
 				t->platform = s->platform;
+				if (t->oprofile_cpu_type == NULL)
+					t->oprofile_cpu_type = s->oprofile_cpu_type;
 			} else
 				*t = *s;
 			*PTRRELOC(&cur_cpu_spec) = &the_cpu_spec;

^ permalink raw reply

* Re: [PATCH] Add MPC5200B base board mvBC-P
From: Jon Smirl @ 2008-07-07 18:51 UTC (permalink / raw)
  To: Grant Likely; +Cc: linux-ppc list, Andre Schwarz, David Gibson
In-Reply-To: <fa686aa40807070712x77ff7aben4cf51731bb4f5985@mail.gmail.com>

On 7/7/08, Grant Likely <grant.likely@secretlab.ca> wrote:
> On Mon, Jul 7, 2008 at 1:49 AM, Andre Schwarz
>  <andre.schwarz@matrix-vision.de> wrote:
>  > David,
>  >
>  > thanks - removed "device_type" from the DMA controller.
>  >
>  > Which nodes actually require "device_type" and which don't ?
>  >
>  > Is there some general rule ?
>
>
> Segher, David;
>
>  In OF, what is the purpose of device_type?  From what I understand
>  right now, each value of device_type claims a software interface that
>  the device supports.  So for example, device_type = "serial" means
>  that firmware supports using the device as a serial port, correct?
>  So, similarly, if OF did not have a driver for the device, then the
>  presence a device_type property would be a bug, right?
>
>  Does device_type indicated any other information other than firmware
>  driver interface?
>
>  I had an epiphany about device_type this weekend (and by epiphany, I
>  mean realizing my own stupidity).  If I'm correct about the above
>  questions, then that would mean it is *always* a bug to have a
>  device_type property in .dts file because there is no firmware
>  interface.  So, it seems to me that we shouldn't just be eliminating
>  undefined device_type values, but also eliminate the ones that are
>  defined in OF because .dts users do not support the firmware driver
>  interface.
>
>  Am I correct?
>
>  The only situation where I can see it being appropriate to specify
>  device_type is to work around older bindings that are ambiguous with
>  their other properties.

I experimented with this on my own trees.
			device_type = "serial";
Is current required on the boot console or it will disappear.


-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply

* Re: [Libhugetlbfs-devel] libbugetlbfs: Test case for powerpc huge_ptep_set_wrprotect() bug
From: Nishanth Aravamudan @ 2008-07-07 18:48 UTC (permalink / raw)
  To: libhugetlbfs-devel, linuxppc-dev
In-Reply-To: <20080707071955.GA27709@yookeroo.seuss>

On 07.07.2008 [17:19:55 +1000], David Gibson wrote:
> Until very recently (in fact, even now in mainline) powerpc kernels
> had a bug in huge_ptep_set_wrprotect() which meant the 'huge' flag was
> not passed down to pte_update() and hpte_need_flush().  This meant the
> hash ptes for hugepages would not be correctly flushed on fork(),
> allowing the parent to pollute the child's mapping after the fork().
> 
> This patch adds a testcase to libhugetlbfs for this behaviour, also
> doing some other checking of the COW semantics over a fork().
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Applied, thanks,
Nish
-- 
Nishanth Aravamudan <nacc@us.ibm.com>
IBM Linux Technology Center

^ permalink raw reply

* Re: [PATCH] [V3] powerpc: Xilinx: PS2: Added new XPS PS2 driver
From: Dmitry Torokhov @ 2008-07-07 18:45 UTC (permalink / raw)
  To: John Linn; +Cc: Sadanand Mutyala, linux-input, linuxppc-dev
In-Reply-To: <20080707182711.7F7E012D0061@mail133-dub.bigfish.com>

On Mon, Jul 07, 2008 at 12:27:09PM -0600, John Linn wrote:
> Thanks Dmitry, appreciate the help.
> 
> Powerpc dependencies in the Kconfig sound right.  Sorry for not thinking
> that thru well across all architectures. 
> 
> Do you want me to spin the patch again?
> 

Please send me incremental patch that implements proper Kconfig
dependencies and I will fold it all together on my side.

Thanks.

-- 
Dmitry

^ permalink raw reply

* [PATCH 4/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
From: Chandru @ 2008-07-07 18:44 UTC (permalink / raw)
  To: kexec, linuxppc-dev

Changes to kexec-ppc64.c in case of ibm,dynamic-reconfiguration-memory node 
of /proc/device-tree. 

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

diff -Naurp kexec-tools-testing-orig/kexec/arch/ppc64/kexec-ppc64.c 
kexec-tools-testing/kexec/arch/ppc64/kexec-ppc64.c
--- kexec-tools-testing-orig/kexec/arch/ppc64/kexec-ppc64.c	2008-07-07 
17:54:58.000000000 +0530
+++ kexec-tools-testing/kexec/arch/ppc64/kexec-ppc64.c	2008-07-07 
20:04:36.000000000 +0530
@@ -96,6 +96,49 @@ err1:
 
 }
 
+static int count_dyn_reconf_memory_ranges(void)
+{
+	char device_tree[] = "/proc/device-tree/";
+	char fname[128];
+	char buf[32];
+	FILE *file;
+
+	strcpy(fname, device_tree);
+	strcat(fname, "ibm,dynamic-reconfiguration-memory/ibm,lmb-size");
+	if ((file = fopen(fname, "r")) == NULL) {
+		perror(fname);
+		return -1;
+	}
+
+	if (fread(buf, 1, 8, file) < 0) {
+		perror(fname);
+		fclose(file);
+		return -1;
+	}
+
+	lmb_size = ((uint64_t *)buf)[0];
+	fclose(file);
+
+	/* Get number of lmbs from ibm,dynamic-memory */
+	strcpy(fname, device_tree);
+	strcat(fname, "ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory");
+	if ((file = fopen(fname, "r")) == NULL) {
+		perror(fname);
+		return -1;
+	}
+	/*
+	 * first 4 bytes provide number of entries(lmbs)
+	 */
+	if (fread(buf, 1, 4, file) < 0) {
+		perror(fname);
+		fclose(file);
+		return -1;
+	}
+	num_of_lmbs = ((unsigned int *)buf)[0];
+	max_memory_ranges += num_of_lmbs;
+	fclose(file);
+}
+
 /*
  * Count the memory nodes under /proc/device-tree and populate the
  * max_memory_ranges variable. This variable replaces MAX_MEMORY_RANGES
@@ -113,6 +156,12 @@ static int count_memory_ranges(void)
 	}
 
 	while ((dentry = readdir(dir)) != NULL) {
+		if (!strncmp(dentry->d_name,
+				"ibm,dynamic-reconfiguration-memory", 35)){
+			count_dyn_reconf_memory_ranges();
+			continue;
+		}
+
 		if (strncmp(dentry->d_name, "memory@", 7) &&
 			strcmp(dentry->d_name, "memory") &&
 			strncmp(dentry->d_name, "pci@", 4))
@@ -128,7 +177,52 @@ static int count_memory_ranges(void)
 
 	return 0;
 }
+static void add_base_memory_range(uint64_t start, uint64_t end)
+{
+	base_memory_range[nr_memory_ranges].start = start;
+	base_memory_range[nr_memory_ranges].end  = end;
+	base_memory_range[nr_memory_ranges].type = RANGE_RAM;
+	nr_memory_ranges++;
+
+	dbgprintf("%016llx-%016llx : %x\n",
+		base_memory_range[nr_memory_ranges-1].start,
+		base_memory_range[nr_memory_ranges-1].end,
+		base_memory_range[nr_memory_ranges-1].type);
+}
+
+static int get_dyn_reconf_base_ranges(void)
+{
+	uint64_t start, end;
+	char fname[128], buf[32];
+	FILE *file;
+	int i, n;
 
+
+	strcpy(fname, "/proc/device-tree/");
+	strcat(fname,
+		"ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory");
+	if ((file = fopen(fname, "r")) == NULL) {
+		perror(fname);
+		return -1;
+	}
+
+	fseek(file, 4, SEEK_SET);
+	for (i = 0; i < num_of_lmbs; i++) {
+		if ((n = fread(buf, 1, 24, file)) < 0) {
+			perror(fname);
+			fclose(file);
+			return -1;
+		}
+		if (nr_memory_ranges >= max_memory_ranges)
+			return -1;
+
+		start = ((uint64_t *)buf)[0];
+		end = start + lmb_size;
+		add_base_memory_range(start, end);
+	}
+	fclose(file);
+	return 0;
+}
 /* Sort the base ranges in memory - this is useful for ensuring that our
  * ranges are in ascending order, even if device-tree read of memory nodes
  * is done differently. Also, could be used for other range coalescing later
@@ -156,7 +250,7 @@ static int sort_base_ranges(void)
 /* Get base memory ranges */
 static int get_base_ranges(void)
 {
-	int local_memory_ranges = 0;
+	uint64_t start, end;
 	char device_tree[256] = "/proc/device-tree/";
 	char fname[256];
 	char buf[MAXBYTES];
@@ -170,6 +264,11 @@ static int get_base_ranges(void)
 		return -1;
 	}
 	while ((dentry = readdir(dir)) != NULL) {
+		if (!strncmp(dentry->d_name,
+				"ibm,dynamic-reconfiguration-memory", 35)) {
+			get_dyn_reconf_base_ranges();
+			continue;
+		}
 		if (strncmp(dentry->d_name, "memory@", 7) &&
 			strcmp(dentry->d_name, "memory"))
 			continue;
@@ -197,27 +296,18 @@ static int get_base_ranges(void)
 				closedir(dir);
 				return -1;
 			}
-			if (local_memory_ranges >= max_memory_ranges) {
+			if (nr_memory_ranges >= max_memory_ranges) {
 				fclose(file);
 				break;
 			}
-			base_memory_range[local_memory_ranges].start =
-				((uint64_t *)buf)[0];
-			base_memory_range[local_memory_ranges].end  =
-				base_memory_range[local_memory_ranges].start +
-				((uint64_t *)buf)[1];
-			base_memory_range[local_memory_ranges].type = RANGE_RAM;
-			local_memory_ranges++;
-			dbgprintf("%016llx-%016llx : %x\n",
-				base_memory_range[local_memory_ranges-1].start,
-				base_memory_range[local_memory_ranges-1].end,
-				base_memory_range[local_memory_ranges-1].type);
+			start = ((uint64_t *)buf)[0];
+			end = start + ((uint64_t *)buf)[1];
+			add_base_memory_range(start, end);
 			fclose(file);
 		}
 		closedir(dmem);
 	}
 	closedir(dir);
-	nr_memory_ranges = local_memory_ranges;
 	sort_base_ranges();
 	memory_max = base_memory_range[nr_memory_ranges - 1].end;
 #ifdef DEBUG
@@ -276,7 +366,9 @@ static int get_devtree_details(unsigned 
 			strncmp(dentry->d_name, "memory@", 7) &&
 			strcmp(dentry->d_name, "memory") &&
 			strncmp(dentry->d_name, "pci@", 4) &&
-			strncmp(dentry->d_name, "rtas", 4))
+			strncmp(dentry->d_name, "rtas", 4) &&
+			strncmp(dentry->d_name,
+				"ibm,dynamic-reconfiguration-memory", 35))
 			continue;
 		strcpy(fname, device_tree);
 		strcat(fname, dentry->d_name);
@@ -474,6 +566,29 @@ static int get_devtree_details(unsigned 
 			closedir(cdir);
 		} /* memory */
 
+		if (!strncmp(dentry->d_name,
+				"ibm,dynamic-reconfiguration-memory", 35)) {
+			unsigned int k;
+			strcat(fname, "/ibm,dynamic-memory");
+			if ((file = fopen(fname, "r")) == NULL) {
+				perror(fname);
+				goto error_opencdir;
+			}
+			fseek(file, 4, SEEK_SET);
+			for (k = 0; k < num_of_lmbs; k++) {
+				if ((n = fread(buf, 1, 24, file)) < 0) {
+					perror(fname);
+					goto error_openfile;
+				}
+				rmo_base = ((uint64_t *)buf)[0];
+				rmo_top = rmo_base + lmb_size;
+				if (rmo_top > 0x30000000UL)
+					rmo_top = 0x30000000UL;
+			}
+			fclose(file);
+			closedir(cdir);
+		} /* ibm,dynamic-reconfiguration-memory */
+
 		if (strncmp(dentry->d_name, "pci@", 4) == 0) {
 			strcat(fname, "/linux,tce-base");
 			if ((file = fopen(fname, "r")) == NULL) {

^ permalink raw reply

* [PATCH 3/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
From: Chandru @ 2008-07-07 18:44 UTC (permalink / raw)
  To: kexec, linuxppc-dev

get crash memory ranges from ibm,dynamic-reconfiguration-memory node 
of /proc/device-tree. 


Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

diff -Naurp kexec-tools-testing-orig/kexec/arch/ppc64/crashdump-ppc64.c 
kexec-tools-testing/kexec/arch/ppc64/crashdump-ppc64.c
--- kexec-tools-testing-orig/kexec/arch/ppc64/crashdump-ppc64.c	2008-07-07 
17:54:58.000000000 +0530
+++ kexec-tools-testing/kexec/arch/ppc64/crashdump-ppc64.c	2008-07-07 
20:14:02.000000000 +0530
@@ -84,6 +84,82 @@ mem_rgns_t usablemem_rgns = {0, NULL};
  */
 uint64_t saved_max_mem = 0;
 
+static unsigned long long cstart, cend;
+static int memory_ranges;
+
+/*
+ * Exclude the region that lies within crashkernel
+ */
+static void exclude_crash_region(uint64_t start, uint64_t end)
+{
+	if (cstart < end && cend > start) {
+		if (start < cstart && end > cend) {
+			crash_memory_range[memory_ranges].start = start;
+			crash_memory_range[memory_ranges].end = cstart;
+			crash_memory_range[memory_ranges].type = RANGE_RAM;
+			memory_ranges++;
+			crash_memory_range[memory_ranges].start = cend;
+			crash_memory_range[memory_ranges].end = end;
+			crash_memory_range[memory_ranges].type = RANGE_RAM;
+			memory_ranges++;
+		} else if (start < cstart) {
+			crash_memory_range[memory_ranges].start = start;
+			crash_memory_range[memory_ranges].end = cstart;
+			crash_memory_range[memory_ranges].type = RANGE_RAM;
+			memory_ranges++;
+		} else if (end > cend) {
+			crash_memory_range[memory_ranges].start = cend;
+			crash_memory_range[memory_ranges].end = end;
+			crash_memory_range[memory_ranges].type = RANGE_RAM;
+			memory_ranges++;
+		}
+	} else {
+		crash_memory_range[memory_ranges].start = start;
+		crash_memory_range[memory_ranges].end  = end;
+		crash_memory_range[memory_ranges].type = RANGE_RAM;
+		memory_ranges++;
+	}
+}
+
+static int get_dyn_reconf_crash_memory_ranges()
+{
+	uint64_t start, end;
+	char fname[128], buf[32];
+	FILE *file;
+	int i, n;
+
+	strcpy(fname, "/proc/device-tree/");
+	strcat(fname, "ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory");
+	if ((file = fopen(fname, "r")) == NULL) {
+		perror(fname);
+		return -1;
+	}
+
+	fseek(file, 4, SEEK_SET);
+	for (i = 0; i < num_of_lmbs; i++) {
+		if ((n = fread(buf, 1, 24, file)) < 0) {
+			perror(fname);
+			fclose(file);
+			return -1;
+		}
+		if (memory_ranges >= (max_memory_ranges + 1)) {
+			/* No space to insert another element. */
+				fprintf(stderr,
+				"Error: Number of crash memory ranges"
+				" excedeed the max limit\n");
+			return -1;
+		}
+
+		start = ((uint64_t *)buf)[0];
+		end = start + lmb_size;
+		if (start == 0 && end >= (BACKUP_SRC_END + 1))
+			start = BACKUP_SRC_END + 1;
+		exclude_crash_region(start, end);
+	}
+	fclose(file);
+	return 0;
+}
+
 /* Reads the appropriate file and retrieves the SYSTEM RAM regions for whom 
to
  * create Elf headers. Keeping it separate from get_memory_ranges() as
  * requirements are different in the case of normal kexec and crashdumps.
@@ -98,7 +174,6 @@ uint64_t saved_max_mem = 0;
 static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
 {
 
-	int memory_ranges = 0;
 	char device_tree[256] = "/proc/device-tree/";
 	char fname[256];
 	char buf[MAXBYTES];
@@ -106,7 +181,7 @@ static int get_crash_memory_ranges(struc
 	FILE *file;
 	struct dirent *dentry, *mentry;
 	int i, n, crash_rng_len = 0;
-	unsigned long long start, end, cstart, cend;
+	unsigned long long start, end;
 	int page_size;
 
 	crash_max_memory_ranges = max_memory_ranges + 6;
@@ -129,7 +204,16 @@ static int get_crash_memory_ranges(struc
 		perror(device_tree);
 		goto err;
 	}
+
+	cstart = crash_base;
+	cend = crash_base + crash_size;
+
 	while ((dentry = readdir(dir)) != NULL) {
+		if (!strncmp(dentry->d_name,
+				"ibm,dynamic-reconfiguration-memory", 35)){
+			get_dyn_reconf_crash_memory_ranges();
+			continue;
+		}
 		if (strncmp(dentry->d_name, "memory@", 7) &&
 			strcmp(dentry->d_name, "memory"))
 			continue;
@@ -170,38 +254,7 @@ static int get_crash_memory_ranges(struc
 			if (start == 0 && end >= (BACKUP_SRC_END + 1))
 				start = BACKUP_SRC_END + 1;
 
-			cstart = crash_base;
-			cend = crash_base + crash_size;
-			/*
-			 * Exclude the region that lies within crashkernel
-			 */
-			if (cstart < end && cend > start) {
-				if (start < cstart && end > cend) {
-					crash_memory_range[memory_ranges].start = start;
-					crash_memory_range[memory_ranges].end = cstart;
-					crash_memory_range[memory_ranges].type = RANGE_RAM;
-					memory_ranges++;
-					crash_memory_range[memory_ranges].start = cend;
-					crash_memory_range[memory_ranges].end = end;
-					crash_memory_range[memory_ranges].type = RANGE_RAM;
-					memory_ranges++;
-				} else if (start < cstart) {
-					crash_memory_range[memory_ranges].start = start;
-					crash_memory_range[memory_ranges].end = cstart;
-					crash_memory_range[memory_ranges].type = RANGE_RAM;
-					memory_ranges++;
-				} else if (end > cend){
-					crash_memory_range[memory_ranges].start = cend;
-					crash_memory_range[memory_ranges].end = end;
-					crash_memory_range[memory_ranges].type = RANGE_RAM;
-					memory_ranges++;
-				}
-			} else {
-				crash_memory_range[memory_ranges].start = start;
-				crash_memory_range[memory_ranges].end  = end;
-				crash_memory_range[memory_ranges].type = RANGE_RAM;
-				memory_ranges++;
-			}
+			exclude_crash_region(start, end);
 			fclose(file);
 		}
 		closedir(dmem);
diff -Naurp kexec-tools-testing-orig/kexec/arch/ppc64/crashdump-ppc64.h 
kexec-tools-testing/kexec/arch/ppc64/crashdump-ppc64.h
--- kexec-tools-testing-orig/kexec/arch/ppc64/crashdump-ppc64.h	2008-07-07 
17:54:58.000000000 +0530
+++ kexec-tools-testing/kexec/arch/ppc64/crashdump-ppc64.h	2008-07-07 
20:03:45.000000000 +0530
@@ -28,4 +28,7 @@ extern uint64_t crash_size;
 extern unsigned int rtas_base;
 extern unsigned int rtas_size;
 
+uint64_t lmb_size;
+unsigned int num_of_lmbs;
+
 #endif /* CRASHDUMP_PPC64_H */

^ permalink raw reply

* [PATCH 2/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
From: Chandru @ 2008-07-07 18:44 UTC (permalink / raw)
  To: kexec, linuxppc-dev

Add linux,usable-memory properties into device tree in case of 
ibm,dynamic-reconfiguration-memory node of /proc/device-tree

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

diff -Naurp kexec-tools-testing-orig/kexec/arch/ppc64/fs2dt.c 
kexec-tools-testing/kexec/arch/ppc64/fs2dt.c
--- kexec-tools-testing-orig/kexec/arch/ppc64/fs2dt.c	2008-07-07 
17:54:58.000000000 +0530
+++ kexec-tools-testing/kexec/arch/ppc64/fs2dt.c	2008-07-07 20:08:53.000000000 
+0530
@@ -122,6 +122,80 @@ static unsigned propnum(const char *name
 	return offset;
 }
 
+static void add_dyn_reconf_usable_mem_property(int fd)
+{
+	char fname[MAXPATH], propname[64], t[8], *bname;
+	const char tbuf[32];
+	uint64_t buf[32];
+	uint64_t ranges[2*MAX_MEMORY_RANGES];
+	uint64_t base, end, loc_base, loc_end;
+	int range, rlen = 0, i;
+
+	strcpy(fname, pathname);
+	bname = strrchr(fname, '/');
+	bname[0] = '\0';
+	bname = strrchr(fname, '/');
+	if (strncmp(bname, "/ibm,dynamic-reconfiguration-memory", 36))
+		return;
+
+	if (lseek(fd, 4, SEEK_SET) < 0)
+		die("unrecoverable error: error seeking in \"%s\": %s\n",
+			pathname, strerror(errno));
+
+	/* kernel counts the lmb's from 1, hence use i=1 here */
+	for (i = 1; i <= num_of_lmbs; i++) {
+		rlen = 0;
+		if (read(fd, buf, 24) < 0)
+			die("unrecoverable error: error reading \"%s\": %s\n",
+				pathname, strerror(errno));
+
+		base = (uint64_t) buf[0];
+		end = base + lmb_size;
+		if (~0ULL - base < end)
+			die("unrecoverable error: mem property overflow\n");
+
+		for (range = 0; range < usablemem_rgns.size; range++) {
+			loc_base = usablemem_rgns.ranges[range].start;
+			loc_end = usablemem_rgns.ranges[range].end;
+			if (loc_base >= base && loc_end <= end) {
+				ranges[rlen++] = loc_base;
+				ranges[rlen++] = loc_end - loc_base;
+			} else if (base < loc_end && end > loc_base) {
+				if (loc_base < base)
+					loc_base = base;
+				if (loc_end > end)
+					loc_end = end;
+				ranges[rlen++] = loc_base;
+				ranges[rlen++] = loc_end - loc_base;
+			}
+		}
+		if (!rlen) {
+			/*
+			 * User did not pass any ranges for this region.
+			 * Hence, write (0,0) duple in linux,usable-memory
+			 * property such that this region will be ignored.
+			 */
+			ranges[rlen++] = 0;
+			ranges[rlen++] = 0;
+		}
+
+		rlen = rlen * sizeof(uint64_t);
+		/*
+		 * Add linux,usable-memory property.
+		 */
+		*dt++ = 3;
+		*dt++ = rlen;
+		strcpy(tbuf, "linux,usable-memory");
+		sprintf(t, "%d", i);
+		strcat(tbuf, t);
+		*dt++ = propnum((const char *)tbuf);
+		if ((rlen >= 8) && ((unsigned long)dt & 0x4))
+			dt++;
+		memcpy(dt, &ranges, rlen);
+		dt += (rlen + 3)/4;
+	}
+}
+
 static void add_usable_mem_property(int fd, int len)
 {
 	char fname[MAXPATH], *bname;
@@ -267,6 +341,10 @@ static void putprops(char *fn, struct di
 		dt += (len + 3)/4;
 		if (!strcmp(dp->d_name, "reg") && usablemem_rgns.size)
 			add_usable_mem_property(fd, len);
+		if (!strcmp(dp->d_name, "ibm,dynamic-memory") &&
+					usablemem_rgns.size)
+			add_dyn_reconf_usable_mem_property(fd);
+
 		close(fd);
 	}

^ permalink raw reply

* [PATCH 1/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
From: Chandru @ 2008-07-07 18:44 UTC (permalink / raw)
  To: kexec, linuxppc-dev

kexec-tools adds  crash, rtas, and tce memory regions as linux,usable-memory 
properties in device-tree.  Following changes are made in the kernel to 
recognize these special properties in case of 
ibm,dynamic-reconfiguration-memory node of device-tree.

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>
---

diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c 
linux-2.6.26-rc9/arch/powerpc/kernel/prom.c
--- linux-2.6.26-rc9-orig/arch/powerpc/kernel/prom.c	2008-07-06 
04:23:22.000000000 +0530
+++ linux-2.6.26-rc9/arch/powerpc/kernel/prom.c	2008-07-07 17:23:58.000000000 
+0530
@@ -884,9 +884,10 @@ static u64 __init dt_mem_next_cell(int s
  */
 static int __init early_init_dt_scan_drconf_memory(unsigned long node)
 {
-	cell_t *dm, *ls;
+	cell_t *dm, *ls, *endp, *usm;
 	unsigned long l, n, flags;
 	u64 base, size, lmb_size;
+	char buf[32], t[8];
 
 	ls = (cell_t *)of_get_flat_dt_prop(node, "ibm,lmb-size", &l);
 	if (ls == NULL || l < dt_root_size_cells * sizeof(cell_t))
@@ -917,7 +918,33 @@ static int __init early_init_dt_scan_drc
 			if ((base + size) > 0x80000000ul)
 				size = 0x80000000ul - base;
 		}
-		lmb_add(base, size);
+		strcpy(buf, "linux,usable-memory");
+		sprintf(t, "%d", (int)n);
+		strcat(buf, t);
+		usm = (cell_t *)of_get_flat_dt_prop(node,
+						 (const char *)buf, &l);
+		if (usm != NULL) {
+			endp = usm + (l / sizeof(cell_t));
+			while ((endp - usm) >= (dt_root_addr_cells +
+						 dt_root_size_cells)) {
+				base = dt_mem_next_cell(dt_root_addr_cells,
+								 &usm);
+				size = dt_mem_next_cell(dt_root_size_cells,
+								 &usm);
+				if (size == 0)
+					continue;
+				if (iommu_is_off) {
+					if ((base + size) > 0x80000000ul)
+						size = 0x80000000ul - base;
+				}
+				lmb_add(base, size);
+			}
+
+			/* Continue with next lmb entry */
+			continue;
+		} else {
+			lmb_add(base, size);
+		}
 	}
 	lmb_dump_all();
 	return 0;
diff -Naurp linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c 
linux-2.6.26-rc9/arch/powerpc/mm/numa.c
--- linux-2.6.26-rc9-orig/arch/powerpc/mm/numa.c	2008-07-06 04:23:22.000000000 
+0530
+++ linux-2.6.26-rc9/arch/powerpc/mm/numa.c	2008-07-07 17:50:35.000000000 
+0530
@@ -349,18 +349,33 @@ static unsigned long __init numa_enforce
 	return lmb_end_of_DRAM() - start;
 }
 
+static void set_nodeinfo(int nid, unsigned long start, unsigned long size)
+{
+	fake_numa_create_new_node(((start + size) >> PAGE_SHIFT),
+					&nid);
+	node_set_online(nid);
+
+	size = numa_enforce_memory_limit(start, size);
+	if (!size)
+		return;
+	add_active_range(nid, start >> PAGE_SHIFT,
+			(start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
+	return;
+}
+
 /*
  * Extract NUMA information from the ibm,dynamic-reconfiguration-memory
  * node.  This assumes n_mem_{addr,size}_cells have been set.
  */
 static void __init parse_drconf_memory(struct device_node *memory)
 {
-	const unsigned int *lm, *dm, *aa;
+	const unsigned int *lm, *dm, *aa, *usm;
 	unsigned int ls, ld, la;
 	unsigned int n, aam, aalen;
 	unsigned long lmb_size, size, start;
 	int nid, default_nid = 0;
-	unsigned int ai, flags;
+	unsigned int ai, flags, len, ranges;
+	char buf[32], t[8];
 
 	lm = of_get_property(memory, "ibm,lmb-size", &ls);
 	dm = of_get_property(memory, "ibm,dynamic-memory", &ld);
@@ -396,16 +411,27 @@ static void __init parse_drconf_memory(s
 				nid = default_nid;
 		}
 
-		fake_numa_create_new_node(((start + lmb_size) >> PAGE_SHIFT),
-						&nid);
-		node_set_online(nid);
+		strcpy(buf, "linux,usable-memory");
+		sprintf(t, "%d", (int)n);
+		strcat(buf, t);
+		usm = of_get_property(memory, (const char *)buf, &len);
+		if (usm != NULL) {
+			ranges = (len >> 2) / (n_mem_addr_cells +
+						 n_mem_size_cells);
+
+dr_new_range:		start = read_n_cells(n_mem_addr_cells, &usm);
+			size = read_n_cells(n_mem_size_cells, &usm);
+			if (size == 0)
+				continue;
 
-		size = numa_enforce_memory_limit(start, lmb_size);
-		if (!size)
-			continue;
+			set_nodeinfo(nid, start, size);
+			if (--ranges)
+				goto dr_new_range;
 
-		add_active_range(nid, start >> PAGE_SHIFT,
-				 (start >> PAGE_SHIFT) + (size >> PAGE_SHIFT));
+			continue;
+		} else {
+			set_nodeinfo(nid, start, lmb_size);
+		}
 	}
 }
 

^ permalink raw reply

* [PATCH 0/4] kdump : add support for ibm, dynamic-reconfiguration-memory for kexec/kdump
From: Chandru @ 2008-07-07 18:44 UTC (permalink / raw)
  To: kexec, linuxppc-dev

Following is a patch series that contains changes for kexec/kdump on Power6 
machines. Power6 machines have most of their memory represented 
in /proc/device-tree/ibm,dynamic-reconfiguration-memory node. kexec-tools 
currently read only memory@ nodes of device-tree.  Patch 1/4 contains changes 
in the kernel. Patch {2,3,4}/4 are changes for kexec-tools.  The kernel 
changes are similar to what was earlier present for memory@ nodes 
for 'linux,usable-memory' property.  Unlike memory@ nodes, since now there is 
one node under which most of the memory ranges are represented ( 
ibm,dynamic-memory) , I have appended the lmb entry number to 
the 'linux,usable-memory' string so as to identify usable-memory ranges in 
the device-tree. 

Signed-off-by: Chandru Siddalingappa <chandru@in.ibm.com>

^ permalink raw reply

* Re: [BUG] 2.6.26-rc8-git2 - powerpc - circular locking dependency detected with net/ehea driver
From: Kamalesh Babulal @ 2008-07-07 18:43 UTC (permalink / raw)
  To: Jan-Bernd Themann
  Cc: netdev, kernel list, linuxppc-dev, kernel-testers, jgarzik,
	Balbir Singh
In-Reply-To: <200807071108.09616.ossthema@de.ibm.com>

Jan-Bernd Themann wrote:
> Hi Kamalesh,
> 
> where you able to reproduce this problem with the patches applied
> we posted on friday?
> 
> Regards,
> Jan-Bernd
> 
> On Tuesday 01 July 2008 14:38, Kamalesh Babulal wrote:
>> Hi,
>>
>> circular locking dependency is detected, while booting the
>> powerpc box with the 2.6.26-rc8-git2 kernel.
>>
>> =======================================================
>> [ INFO: possible circular locking dependency detected ]
>> 2.6.26-rc8-git2 #1
>> -------------------------------------------------------
Hi Jan-Bernd,

Thanks for the patch. I tried your patch set over the 2.6.26-rc8-git2 kernel, 
the circular dependency is still begin detected :(.

Jul  7 09:12:42 : =======================================================
Jul  7 09:12:42 : [ INFO: possible circular locking dependency detected ]
Jul  7 09:12:42 : 2.6.26-rc8-git2 #2
Jul  7 09:12:42 : -------------------------------------------------------
Jul  7 09:12:42 : ip/2218 is trying to acquire lock:
Jul  7 09:12:42 :  (&ehea_fw_handles.lock){--..}, at: [<d0000000002740c4>] .ehea_up+0x6c/0x6f4 [ehea]
Jul  7 09:12:42 : 
Jul  7 09:12:42 : but task is already holding lock:
Jul  7 09:12:42 :  (&port->port_lock){--..}, at: [<d0000000002757dc>] .ehea_open+0x44/0xcc [ehea]
Jul  7 09:12:42 : 
Jul  7 09:12:42 : which lock already depends on the new lock.
Jul  7 09:12:42 : 
Jul  7 09:12:42 : 
Jul  7 09:12:42 : the existing dependency chain (in reverse order) is:
Jul  7 09:12:42 : 
Jul  7 09:12:42 : -> #2 (&port->port_lock){--..}:
Jul  7 09:12:42 :        [<c0000000000aa0e8>] .__lock_acquire+0xc84/0xee0
Jul  7 09:12:42 :        [<c0000000000aa41c>] .lock_acquire+0xd8/0x124
Jul  7 09:12:42 :        [<c000000000452008>] .mutex_lock_nested+0x168/0x420
Jul  7 09:12:42 :        [<d0000000002757dc>] .ehea_open+0x44/0xcc [ehea]
Jul  7 09:12:42 :        [<c0000000003b62b0>] .dev_open+0xec/0x160
Jul  7 09:12:42 :        [<c0000000003b46a4>] .dev_change_flags+0x10c/0x210
Jul  7 09:12:42 :        [<c0000000004162b0>] .devinet_ioctl+0x2cc/0x778
Jul  7 09:12:42 :        [<c0000000004173e0>] .inet_ioctl+0xdc/0x134
Jul  7 09:12:42 :        [<c0000000003a4464>] .sock_ioctl+0x2dc/0x338
Jul  7 09:12:42 :        [<c00000000012d12c>] .vfs_ioctl+0x64/0xfc
Jul  7 09:12:42 :        [<c00000000012d614>] .do_vfs_ioctl+0x450/0x494
Jul  7 09:12:42 :        [<c00000000012d6d0>] .sys_ioctl+0x78/0xc0
Jul  7 09:12:42 :        [<c00000000016413c>] .dev_ifsioc+0x1e8/0x450
Jul  7 09:12:42 :        [<c000000000163588>] .compat_sys_ioctl+0x3ec/0x484
Jul  7 09:12:42 :        [<c0000000000086dc>] syscall_exit+0x0/0x40
Jul  7 09:12:42 : 
Jul  7 09:12:42 : -> #1 (rtnl_mutex){--..}:
Jul  7 09:12:42 :        [<c0000000000aa0e8>] .__lock_acquire+0xc84/0xee0
Jul  7 09:12:42 :        [<c0000000000aa41c>] .lock_acquire+0xd8/0x124
Jul  7 09:12:42 :        [<c000000000452008>] .mutex_lock_nested+0x168/0x420
Jul  7 09:12:42 :        [<c0000000003c1ad0>] .rtnl_lock+0x28/0x44
Jul  7 09:12:42 :        [<c0000000003b5334>] .register_netdev+0x24/0x8c
Jul  7 09:12:42 :        [<d00000000027292c>] .ehea_setup_single_port+0x2d4/0x3e0 [ehea]
Jul  7 09:12:42 :        [<d00000000027a494>] .ehea_probe_adapter+0x290/0x3a0 [ehea]
Jul  7 09:12:42 :        [<c0000000003a0098>] .of_platform_device_probe+0x80/0x8c4
Jul  7 09:12:42 :        [<c000000000305ce4>] .driver_probe_device+0x144/0x20c
Jul  7 09:12:42 :        [<c000000000305e14>] .__driver_attach+0x68/0xb0
Jul  7 09:12:42 :        [<c000000000304ed4>] .bus_for_each_dev+0x88/0xe4
Jul  7 09:12:42 :        [<c000000000305a24>] .driver_attach+0x34/0x50
Jul  7 09:12:42 :        [<c000000000305524>] .bus_add_driver+0xe0/0x294
Jul  7 09:12:42 :        [<c000000000306178>] .driver_register+0xcc/0x1a4
Jul  7 09:12:42 :        [<c00000000039ff30>] .of_register_driver+0x54/0x6c
Jul  7 09:12:42 :        [<c0000000000256f4>] .ibmebus_register_driver+0x40/0x60
Jul  7 09:12:42 :        [<d00000000027a788>] .ehea_module_init+0x1e4/0x238c [ehea]
Jul  7 09:12:42 :        [<c0000000000b5294>] .sys_init_module+0x19a0/0x1b80
Jul  7 09:12:42 :        [<c0000000000086dc>] syscall_exit+0x0/0x40
Jul  7 09:12:42 : 
Jul  7 09:12:42 : -> #0 (&ehea_fw_handles.lock){--..}:
Jul  7 09:12:42 :        [<c0000000000a9fe4>] .__lock_acquire+0xb80/0xee0
Jul  7 09:12:42 :        [<c0000000000aa41c>] .lock_acquire+0xd8/0x124
Jul  7 09:12:42 :        [<c000000000452008>] .mutex_lock_nested+0x168/0x420
Jul  7 09:12:42 :        [<d0000000002740c4>] .ehea_up+0x6c/0x6f4 [ehea]
Jul  7 09:12:42 :        [<d000000000275804>] .ehea_open+0x6c/0xcc [ehea]
Jul  7 09:12:42 :        [<c0000000003b62b0>] .dev_open+0xec/0x160
Jul  7 09:12:42 :        [<c0000000003b46a4>] .dev_change_flags+0x10c/0x210
Jul  7 09:12:42 :        [<c0000000004162b0>] .devinet_ioctl+0x2cc/0x778
Jul  7 09:12:42 :        [<c0000000004173e0>] .inet_ioctl+0xdc/0x134
Jul  7 09:12:42 :        [<c0000000003a4464>] .sock_ioctl+0x2dc/0x338
Jul  7 09:12:42 :        [<c00000000012d12c>] .vfs_ioctl+0x64/0xfc
Jul  7 09:12:42 :        [<c00000000012d614>] .do_vfs_ioctl+0x450/0x494
Jul  7 09:12:42 :        [<c00000000012d6d0>] .sys_ioctl+0x78/0xc0
Jul  7 09:12:42 :        [<c00000000016413c>] .dev_ifsioc+0x1e8/0x450
Jul  7 09:12:42 :        [<c000000000163588>] .compat_sys_ioctl+0x3ec/0x484
Jul  7 09:12:42 :        [<c0000000000086dc>] syscall_exit+0x0/0x40
Jul  7 09:12:42 : 
Jul  7 09:12:42 : other info that might help us debug this:
Jul  7 09:12:42 : 
Jul  7 09:12:42 : 2 locks held by ip/2218:
Jul  7 09:12:42 :  #0:  (rtnl_mutex){--..}, at: [<c0000000003c1ad0>] .rtnl_lock+0x28/0x44
Jul  7 09:12:42 :  #1:  (&port->port_lock){--..}, at: [<d0000000002757dc>] .ehea_open+0x44/0xcc [ehea]
Jul  7 09:12:42 : 
Jul  7 09:12:42 : stack backtrace:
Jul  7 09:12:42 : Call Trace:
Jul  7 09:12:42 : [c0000000f7b6f030] [c000000000010b9c] .show_stack+0x78/0x1c8 (unreliable)
Jul  7 09:12:42 : [c0000000f7b6f0e0] [c000000000010d0c] .dump_stack+0x20/0x34
Jul  7 09:12:42 : [c0000000f7b6f160] [c0000000000a7644] .print_circular_bug_tail+0x84/0xa8
Jul  7 09:12:42 : [c0000000f7b6f230] [c0000000000a9fe4] .__lock_acquire+0xb80/0xee0
Jul  7 09:12:42 keechi-lp2 rmcctrl: 0513-059 The ctrmc Subsystem has been started. Subsystem PID is 2316.
Jul  7 09:12:42 : [c0000000f7b6f320] [c0000000000aa41c] .lock_acquire+0xd8/0x124
Jul  7 09:12:42 : [c0000000f7b6f3e0] [c000000000452008] .mutex_lock_nested+0x168/0x420
Jul  7 09:12:42 : [c0000000f7b6f4d0] [d0000000002740c4] .ehea_up+0x6c/0x6f4 [ehea]
Jul  7 09:12:42 : [c0000000f7b6f5e0] [d000000000275804] .ehea_open+0x6c/0xcc [ehea]
Jul  7 09:12:42 : [c0000000f7b6f680] [c0000000003b62b0] .dev_open+0xec/0x160
Jul  7 09:12:42 : [c0000000f7b6f710] [c0000000003b46a4] .dev_change_flags+0x10c/0x210
Jul  7 09:12:42 : [c0000000f7b6f7c0] [c0000000004162b0] .devinet_ioctl+0x2cc/0x778
Jul  7 09:12:42 : [c0000000f7b6f8d0] [c0000000004173e0] .inet_ioctl+0xdc/0x134
Jul  7 09:12:42 : [c0000000f7b6f950] [c0000000003a4464] .sock_ioctl+0x2dc/0x338
Jul  7 09:12:42 : [c0000000f7b6f9f0] [c00000000012d12c] .vfs_ioctl+0x64/0xfc
Jul  7 09:12:42 : [c0000000f7b6fa90] [c00000000012d614] .do_vfs_ioctl+0x450/0x494
Jul  7 09:12:42 : [c0000000f7b6fb50] [c00000000012d6d0] .sys_ioctl+0x78/0xc0
Jul  7 09:12:42 : [c0000000f7b6fc10] [c00000000016413c] .dev_ifsioc+0x1e8/0x450
Jul  7 09:12:42 : [c0000000f7b6fd30] [c000000000163588] .compat_sys_ioctl+0x3ec/0x484
Jul  7 09:12:42 : [c0000000f7b6fe30] [c0000000000086dc] syscall_exit+0x0/0x40
Jul  7 09:12:42 : ehea: eth0: Physical port up
Jul  7 09:12:42 : ehea: External switch port is backup port

0x40c4 is in ehea_up (drivers/net/ehea/ehea_main.c:2469).
2464            struct ehea_port *port = netdev_priv(dev);
2465
2466            if (port->state == EHEA_PORT_UP)
2467                    return 0;
2468
2469            mutex_lock(&ehea_fw_handles.lock);
2470
2471            ret = ehea_port_res_setup(port, port->num_def_qps,
2472                                      port->num_add_tx_qps);
2473            if (ret) {

0x57dc is in ehea_open (drivers/net/ehea/ehea_main.c:2559).
2554    static int ehea_open(struct net_device *dev)
2555    {
2556            int ret;
2557            struct ehea_port *port = netdev_priv(dev);
2558
2559            mutex_lock(&port->port_lock);
2560
2561            if (netif_msg_ifup(port))
2562                    ehea_info("enabling port %s", dev->name);
2563


-- 
Thanks & Regards,
Kamalesh Babulal,
Linux Technology Center,
IBM, ISTL.

^ permalink raw reply

* RE: [PATCH] [V3] powerpc: Xilinx: PS2: Added new XPS PS2 driver
From: John Linn @ 2008-07-07 18:27 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Sadanand Mutyala, linux-input, linuxppc-dev
In-Reply-To: <20080707141843.ZZRA012@mailhub.coreip.homeip.net>

Thanks Dmitry, appreciate the help.

Powerpc dependencies in the Kconfig sound right.  Sorry for not thinking
that thru well across all architectures. =


Do you want me to spin the patch again?

-- John

> -----Original Message-----
> From: linuxppc-dev-bounces+john.linn=3Dxilinx.com@ozlabs.org
[mailto:linuxppc-dev-
> bounces+john.linn=3Dxilinx.com@ozlabs.org] On Behalf Of Dmitry Torokhov
> Sent: Monday, July 07, 2008 12:20 PM
> To: John Linn
> Cc: Sadanand Mutyala; linuxppc-dev@ozlabs.org;
linux-input@vger.kernel.org
> Subject: Re: [PATCH] [V3] powerpc: Xilinx: PS2: Added new XPS PS2
driver
> =

> On Mon, Jul 07, 2008 at 08:38:45AM -0700, John Linn wrote:
> > Added a new driver for Xilinx XPS PS2 IP. This driver is
> > a flat driver to better match the Linux driver pattern.
> >
> > Signed-off-by: Sadanand <sadanan@xilinx.com>
> > Signed-off-by: John Linn <john.linn@xilinx.com>
> =

> Looks good and I am ready to apply with the exception that compile
> errors out when i try to build on x86 (asm/prom.h is missing). Do we
> need some Kconfig dependencies added?
> =

> --
> Dmitry
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev


This email and any attachments are intended for the sole use of the named r=
ecipient(s) and contain(s) confidential information that may be proprietary=
, privileged or copyrighted under applicable law. If you are not the intend=
ed recipient, do not read, copy, or forward this email message or any attac=
hments. Delete this email message and any attachments immediately.

^ permalink raw reply

* Re: [PATCH] [V3] powerpc: Xilinx: PS2: Added new XPS PS2 driver
From: Dmitry Torokhov @ 2008-07-07 18:19 UTC (permalink / raw)
  To: John Linn; +Cc: Sadanand, linuxppc-dev, linux-input
In-Reply-To: <20080707153850.4C83B128005C@mail53-wa4.bigfish.com>

On Mon, Jul 07, 2008 at 08:38:45AM -0700, John Linn wrote:
> Added a new driver for Xilinx XPS PS2 IP. This driver is
> a flat driver to better match the Linux driver pattern.
> 
> Signed-off-by: Sadanand <sadanan@xilinx.com>
> Signed-off-by: John Linn <john.linn@xilinx.com>

Looks good and I am ready to apply with the exception that compile
errors out when i try to build on x86 (asm/prom.h is missing). Do we
need some Kconfig dependencies added?

-- 
Dmitry

^ permalink raw reply

* [PATCH] [V2] powerpc: Xilinx: add dts file for ML507 board
From: John Linn @ 2008-07-07 18:04 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: John Linn

This new file adds support for the ML507 board which
has a Virtex 5 FXT FPGA with a 440.

Signed-off-by: John Linn <john.linn@xilinx.com>
---
V2
	Converted to dts-v1 format.
	Changed to match a newer reference design.

 arch/powerpc/boot/dts/virtex440-ml507.dts |  296 +++++++++++++++++++++++++++++
 1 files changed, 296 insertions(+), 0 deletions(-)
 create mode 100644 arch/powerpc/boot/dts/virtex440-ml507.dts

diff --git a/arch/powerpc/boot/dts/virtex440-ml507.dts b/arch/powerpc/boot/dts/virtex440-ml507.dts
new file mode 100644
index 0000000..d10a993
--- /dev/null
+++ b/arch/powerpc/boot/dts/virtex440-ml507.dts
@@ -0,0 +1,296 @@
+/*
+ * This file supports the Xilinx ML507 board with the 440 processor.
+ * A reference design for the FPGA is provided at http://git.xilinx.com.
+ *
+ * (C) Copyright 2008 Xilinx, Inc.
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "xlnx,virtex440";
+	dcr-parent = <&ppc440_0>;
+	model = "testing";
+	DDR2_SDRAM: memory@0 {
+		device_type = "memory";
+		reg = < 0 0x10000000 >;
+	} ;
+	chosen {
+		bootargs = "console=ttyS0 ip=on root=/dev/ram";
+		linux,stdout-path = "/plb@0/serial@83e00000";
+	} ;
+	cpus {
+		#address-cells = <1>;
+		#cpus = <1>;
+		#size-cells = <0>;
+		ppc440_0: cpu@0 {
+			clock-frequency = "";
+			compatible = "PowerPC,440", "ibm,ppc440";
+			d-cache-line-size = <0x20>;
+			d-cache-size = <0x8000>;
+			dcr-access-method = "native";
+			dcr-controller ;
+			device_type = "cpu";
+			i-cache-line-size = <0x20>;
+			i-cache-size = <0x8000>;
+			model = "PowerPC,440";
+			reg = <0>;
+			timebase-frequency = <0x17d78400>;
+			xlnx,apu-control = <1>;
+			xlnx,apu-udi-0 = <0>;
+			xlnx,apu-udi-1 = <0>;
+			xlnx,apu-udi-10 = <0>;
+			xlnx,apu-udi-11 = <0>;
+			xlnx,apu-udi-12 = <0>;
+			xlnx,apu-udi-13 = <0>;
+			xlnx,apu-udi-14 = <0>;
+			xlnx,apu-udi-15 = <0>;
+			xlnx,apu-udi-2 = <0>;
+			xlnx,apu-udi-3 = <0>;
+			xlnx,apu-udi-4 = <0>;
+			xlnx,apu-udi-5 = <0>;
+			xlnx,apu-udi-6 = <0>;
+			xlnx,apu-udi-7 = <0>;
+			xlnx,apu-udi-8 = <0>;
+			xlnx,apu-udi-9 = <0>;
+			xlnx,dcr-autolock-enable = <1>;
+			xlnx,dcu-rd-ld-cache-plb-prio = <0>;
+			xlnx,dcu-rd-noncache-plb-prio = <0>;
+			xlnx,dcu-rd-touch-plb-prio = <0>;
+			xlnx,dcu-rd-urgent-plb-prio = <0>;
+			xlnx,dcu-wr-flush-plb-prio = <0>;
+			xlnx,dcu-wr-store-plb-prio = <0>;
+			xlnx,dcu-wr-urgent-plb-prio = <0>;
+			xlnx,dma0-control = <0>;
+			xlnx,dma0-plb-prio = <0>;
+			xlnx,dma0-rxchannelctrl = <0x1010000>;
+			xlnx,dma0-rxirqtimer = <0x3ff>;
+			xlnx,dma0-txchannelctrl = <0x1010000>;
+			xlnx,dma0-txirqtimer = <0x3ff>;
+			xlnx,dma1-control = <0>;
+			xlnx,dma1-plb-prio = <0>;
+			xlnx,dma1-rxchannelctrl = <0x1010000>;
+			xlnx,dma1-rxirqtimer = <0x3ff>;
+			xlnx,dma1-txchannelctrl = <0x1010000>;
+			xlnx,dma1-txirqtimer = <0x3ff>;
+			xlnx,dma2-control = <0>;
+			xlnx,dma2-plb-prio = <0>;
+			xlnx,dma2-rxchannelctrl = <0x1010000>;
+			xlnx,dma2-rxirqtimer = <0x3ff>;
+			xlnx,dma2-txchannelctrl = <0x1010000>;
+			xlnx,dma2-txirqtimer = <0x3ff>;
+			xlnx,dma3-control = <0>;
+			xlnx,dma3-plb-prio = <0>;
+			xlnx,dma3-rxchannelctrl = <0x1010000>;
+			xlnx,dma3-rxirqtimer = <0x3ff>;
+			xlnx,dma3-txchannelctrl = <0x1010000>;
+			xlnx,dma3-txirqtimer = <0x3ff>;
+			xlnx,endian-reset = <0>;
+			xlnx,generate-plb-timespecs = <1>;
+			xlnx,icu-rd-fetch-plb-prio = <0>;
+			xlnx,icu-rd-spec-plb-prio = <0>;
+			xlnx,icu-rd-touch-plb-prio = <0>;
+			xlnx,interconnect-imask = <0xffffffff>;
+			xlnx,mplb-allow-lock-xfer = <1>;
+			xlnx,mplb-arb-mode = <0>;
+			xlnx,mplb-awidth = <0x20>;
+			xlnx,mplb-counter = <0x500>;
+			xlnx,mplb-dwidth = <0x80>;
+			xlnx,mplb-max-burst = <8>;
+			xlnx,mplb-native-dwidth = <0x80>;
+			xlnx,mplb-p2p = <0>;
+			xlnx,mplb-prio-dcur = <2>;
+			xlnx,mplb-prio-dcuw = <3>;
+			xlnx,mplb-prio-icu = <4>;
+			xlnx,mplb-prio-splb0 = <1>;
+			xlnx,mplb-prio-splb1 = <0>;
+			xlnx,mplb-read-pipe-enable = <1>;
+			xlnx,mplb-sync-tattribute = <0>;
+			xlnx,mplb-wdog-enable = <1>;
+			xlnx,mplb-write-pipe-enable = <1>;
+			xlnx,mplb-write-post-enable = <1>;
+			xlnx,num-dma = <1>;
+			xlnx,pir = <0xf>;
+			xlnx,ppc440mc-addr-base = <0>;
+			xlnx,ppc440mc-addr-high = <0xfffffff>;
+			xlnx,ppc440mc-arb-mode = <0>;
+			xlnx,ppc440mc-bank-conflict-mask = <0xc00000>;
+			xlnx,ppc440mc-control = <0xf810008f>;
+			xlnx,ppc440mc-max-burst = <8>;
+			xlnx,ppc440mc-prio-dcur = <2>;
+			xlnx,ppc440mc-prio-dcuw = <3>;
+			xlnx,ppc440mc-prio-icu = <4>;
+			xlnx,ppc440mc-prio-splb0 = <1>;
+			xlnx,ppc440mc-prio-splb1 = <0>;
+			xlnx,ppc440mc-row-conflict-mask = <0x3ffe00>;
+			xlnx,ppcdm-asyncmode = <0>;
+			xlnx,ppcds-asyncmode = <0>;
+			xlnx,user-reset = <0>;
+			DMA0: sdma@80 {
+				compatible = "xlnx,ll-dma-1.00.a";
+				dcr-reg = < 0x80 0x11 >;
+				interrupt-parent = <&xps_intc_0>;
+				interrupts = < 9 2 0xa 2 >;
+			} ;
+		} ;
+	} ;
+	plb_v46_0: plb@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "xlnx,plb-v46-1.02.a", "simple-bus";
+		ranges ;
+		DIP_Switches_8Bit: gpio@81460000 {
+			compatible = "xlnx,xps-gpio-1.00.a";
+			interrupt-parent = <&xps_intc_0>;
+			interrupts = < 6 2 >;
+			reg = < 0x81460000 0x10000 >;
+			xlnx,all-inputs = <1>;
+			xlnx,all-inputs-2 = <0>;
+			xlnx,dout-default = <0>;
+			xlnx,dout-default-2 = <0>;
+			xlnx,family = "virtex5";
+			xlnx,gpio-width = <8>;
+			xlnx,interrupt-present = <1>;
+			xlnx,is-bidir = <1>;
+			xlnx,is-bidir-2 = <1>;
+			xlnx,is-dual = <0>;
+			xlnx,tri-default = <0xffffffff>;
+			xlnx,tri-default-2 = <0xffffffff>;
+		} ;
+		Hard_Ethernet_MAC: xps-ll-temac@81c00000 {
+			#address-cells = <1>;
+			#size-cells = <1>;
+			compatible = "xlnx,compound";
+			ethernet@81c00000 {
+				compatible = "xlnx,xps-ll-temac-1.01.b";
+				device_type = "network";
+				interrupt-parent = <&xps_intc_0>;
+				interrupts = < 5 2 >;
+				llink-connected = <&DMA0>;
+				local-mac-address = [ 02 00 00 00 00 00 ];
+				reg = < 0x81c00000 0x40 >;
+				xlnx,bus2core-clk-ratio = <1>;
+				xlnx,phy-type = <1>;
+				xlnx,phyaddr = <1>;
+				xlnx,rxcsum = <1>;
+				xlnx,rxfifo = <0x1000>;
+				xlnx,temac-type = <0>;
+				xlnx,txcsum = <1>;
+				xlnx,txfifo = <0x1000>;
+			} ;
+		} ;
+		LEDs_8Bit: gpio@81400000 {
+			compatible = "xlnx,xps-gpio-1.00.a";
+			reg = < 0x81400000 0x10000 >;
+			xlnx,all-inputs = <0>;
+			xlnx,all-inputs-2 = <0>;
+			xlnx,dout-default = <0>;
+			xlnx,dout-default-2 = <0>;
+			xlnx,family = "virtex5";
+			xlnx,gpio-width = <8>;
+			xlnx,interrupt-present = <0>;
+			xlnx,is-bidir = <1>;
+			xlnx,is-bidir-2 = <1>;
+			xlnx,is-dual = <0>;
+			xlnx,tri-default = <0xffffffff>;
+			xlnx,tri-default-2 = <0xffffffff>;
+		} ;
+		LEDs_Positions: gpio@81420000 {
+			compatible = "xlnx,xps-gpio-1.00.a";
+			reg = < 0x81420000 0x10000 >;
+			xlnx,all-inputs = <0>;
+			xlnx,all-inputs-2 = <0>;
+			xlnx,dout-default = <0>;
+			xlnx,dout-default-2 = <0>;
+			xlnx,family = "virtex5";
+			xlnx,gpio-width = <5>;
+			xlnx,interrupt-present = <0>;
+			xlnx,is-bidir = <1>;
+			xlnx,is-bidir-2 = <1>;
+			xlnx,is-dual = <0>;
+			xlnx,tri-default = <0xffffffff>;
+			xlnx,tri-default-2 = <0xffffffff>;
+		} ;
+		Push_Buttons_5Bit: gpio@81440000 {
+			compatible = "xlnx,xps-gpio-1.00.a";
+			interrupt-parent = <&xps_intc_0>;
+			interrupts = < 7 2 >;
+			reg = < 0x81440000 0x10000 >;
+			xlnx,all-inputs = <1>;
+			xlnx,all-inputs-2 = <0>;
+			xlnx,dout-default = <0>;
+			xlnx,dout-default-2 = <0>;
+			xlnx,family = "virtex5";
+			xlnx,gpio-width = <5>;
+			xlnx,interrupt-present = <1>;
+			xlnx,is-bidir = <1>;
+			xlnx,is-bidir-2 = <1>;
+			xlnx,is-dual = <0>;
+			xlnx,tri-default = <0xffffffff>;
+			xlnx,tri-default-2 = <0xffffffff>;
+		} ;
+		RS232_Uart_1: serial@83e00000 {
+			clock-frequency = <0x5f5e100>;
+			compatible = "xlnx,xps-uart16550-2.00.a", "ns16550";
+			current-speed = <0x2580>;
+			device_type = "serial";
+			interrupt-parent = <&xps_intc_0>;
+			interrupts = < 8 2 >;
+			reg = < 0x83e00000 0x10000 >;
+			reg-offset = <3>;
+			reg-shift = <2>;
+			xlnx,family = "virtex5";
+			xlnx,has-external-rclk = <0>;
+			xlnx,has-external-xin = <0>;
+			xlnx,is-a-16550 = <1>;
+		} ;
+		SysACE_CompactFlash: sysace@83600000 {
+			compatible = "xlnx,xps-sysace-1.00.a";
+			interrupt-parent = <&xps_intc_0>;
+			interrupts = < 4 2 >;
+			reg = < 0x83600000 0x10000 >;
+			xlnx,family = "virtex5";
+			xlnx,mem-width = <0x10>;
+		} ;
+		xps_bram_if_cntlr_1: xps-bram-if-cntlr@ffff0000 {
+			compatible = "xlnx,xps-bram-if-cntlr-1.00.a";
+			reg = < 0xffff0000 0x10000 >;
+			xlnx,family = "virtex5";
+		} ;
+		xps_intc_0: interrupt-controller@81800000 {
+			#interrupt-cells = <2>;
+			compatible = "xlnx,xps-intc-1.00.a";
+			interrupt-controller ;
+			reg = < 0x81800000 0x10000 >;
+			xlnx,num-intr-inputs = <0xb>;
+		} ;
+		xps_timebase_wdt_1: xps-timebase-wdt@83a00000 {
+			compatible = "xlnx,xps-timebase-wdt-1.00.b";
+			interrupt-parent = <&xps_intc_0>;
+			interrupts = < 2 0 1 2 >;
+			reg = < 0x83a00000 0x10000 >;
+			xlnx,family = "virtex5";
+			xlnx,wdt-enable-once = <0>;
+			xlnx,wdt-interval = <0x1e>;
+		} ;
+		xps_timer_1: timer@83c00000 {
+			compatible = "xlnx,xps-timer-1.00.a";
+			interrupt-parent = <&xps_intc_0>;
+			interrupts = < 3 2 >;
+			reg = < 0x83c00000 0x10000 >;
+			xlnx,count-width = <0x20>;
+			xlnx,family = "virtex5";
+			xlnx,gen0-assert = <1>;
+			xlnx,gen1-assert = <1>;
+			xlnx,one-timer-only = <1>;
+			xlnx,trig0-assert = <1>;
+			xlnx,trig1-assert = <1>;
+		} ;
+	} ;
+}  ;
-- 
1.5.2.1



This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.

^ permalink raw reply related

* Re: e600 core power management
From: Matt Sealey @ 2008-07-07 18:04 UTC (permalink / raw)
  To: ppc-dev
In-Reply-To: <48720279.6010904@genesi-usa.com>

I think I'll reiterate here as it got lost in my rambling, that I am wondering
if NAP is enabled *by default* and if not, why not on processors that don't
doze? (powersave-nap is 0 here)

-- 
Matt Sealey <matt@genesi-usa.com>
Genesi, Manager, Developer Relations

Matt Sealey wrote:
> Hi guys,
> 
> Quick question, am I right (and looking at idle_6xx.S, I think I am) in 
> thinking that
> during the idle process, by default, an e600 core such as the 7448 or 
> MPC8610 will
> automatically transition to a NAP state, thus being as low power as 
> possible?

^ permalink raw reply

* [RFC v2 PATCH 4/4] Relocation support
From: Mohan Kumar M @ 2008-07-07 17:36 UTC (permalink / raw)
  To: ppcdev; +Cc: paulus, miltonm, michaele
In-Reply-To: <20080707172600.GE11470@in.ibm.com>

Relocation support

This patch changes all LOAD_REG_ADDR macro calls to LOAD_REG_IMMEDIATE
to make sure that we load the correct address. It also takes care of
when accessing absolute symbols in the code by adding the relocation
kernel base address.

Signed-off-by: Mohan Kumar M <mohan@in.ibm.com>
---
 arch/powerpc/kernel/crash_dump.c        |   22 +++++++++++
 arch/powerpc/kernel/entry_64.S          |    4 +-
 arch/powerpc/kernel/head_64.S           |   63 ++++++++++++++++++++++++++++----
 arch/powerpc/kernel/iommu.c             |    7 +++
 arch/powerpc/kernel/machine_kexec.c     |    5 ++
 arch/powerpc/kernel/machine_kexec_64.c  |    4 +-
 arch/powerpc/kernel/misc.S              |   40 ++++++++++++++++----
 arch/powerpc/kernel/prom.c              |   14 ++++++-
 arch/powerpc/kernel/prom_init.c         |   32 +++++++++++++---
 arch/powerpc/kernel/prom_init_check.sh  |    2 -
 arch/powerpc/kernel/setup_64.c          |    5 +-
 arch/powerpc/mm/hash_low_64.S           |    8 ++--
 arch/powerpc/mm/init_64.c               |    7 ++-
 arch/powerpc/mm/mem.c                   |    3 +
 arch/powerpc/mm/slb_low.S               |    2 -
 arch/powerpc/platforms/pseries/hvCall.S |    2 -
 arch/powerpc/platforms/pseries/iommu.c  |    5 ++
 include/asm-powerpc/exception.h         |    6 ---
 include/asm-powerpc/prom.h              |    2 +
 include/asm-powerpc/sections.h          |    4 +-
 include/asm-powerpc/system.h            |    5 ++
 21 files changed, 194 insertions(+), 48 deletions(-)

Index: linux-2.6.26-rc9/arch/powerpc/kernel/crash_dump.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/crash_dump.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/crash_dump.c
@@ -28,7 +28,15 @@
 
 void __init reserve_kdump_trampoline(void)
 {
+#ifdef CONFIG_RELOCATABLE_PPC64
+	if (RELOC(reloc_delta)) {
+		lmb_reserve(0, KDUMP_RESERVE_LIMIT);
+		printk("Reserving from 0 of size %lx\n", KDUMP_RESERVE_LIMIT);
+	}
+#else
 	lmb_reserve(0, KDUMP_RESERVE_LIMIT);
+	printk("Reserving from 0 of size %lx\n", KDUMP_RESERVE_LIMIT);
+#endif
 }
 
 static void __init create_trampoline(unsigned long addr)
@@ -42,7 +50,11 @@ static void __init create_trampoline(uns
 	 * two instructions it doesn't require any registers.
 	 */
 	create_instruction(addr, 0x60000000); /* nop */
+#ifndef CONFIG_RELOCATABLE_PPC64
 	create_branch(addr + 4, addr + PHYSICAL_START, 0);
+#else
+	create_branch(addr + 4, addr + RELOC(reloc_delta), 0);
+#endif
 }
 
 void __init setup_kdump_trampoline(void)
@@ -51,13 +63,23 @@ void __init setup_kdump_trampoline(void)
 
 	DBG(" -> setup_kdump_trampoline()\n");
 
+#ifdef CONFIG_RELOCATABLE_PPC64
+	if (!RELOC(reloc_delta))
+		return;
+#endif
+
 	for (i = KDUMP_TRAMPOLINE_START; i < KDUMP_TRAMPOLINE_END; i += 8) {
 		create_trampoline(i);
 	}
 
 #ifdef CONFIG_PPC_PSERIES
+#ifndef CONFIG_RELOCATABLE_PPC64
 	create_trampoline(__pa(system_reset_fwnmi) - PHYSICAL_START);
 	create_trampoline(__pa(machine_check_fwnmi) - PHYSICAL_START);
+#else
+	create_trampoline(__pa(system_reset_fwnmi) - RELOC(reloc_delta));
+	create_trampoline(__pa(machine_check_fwnmi) - RELOC(reloc_delta));
+#endif
 #endif /* CONFIG_PPC_PSERIES */
 
 	DBG(" <- setup_kdump_trampoline()\n");
Index: linux-2.6.26-rc9/arch/powerpc/kernel/entry_64.S
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/entry_64.S
+++ linux-2.6.26-rc9/arch/powerpc/kernel/entry_64.S
@@ -709,7 +709,7 @@ _GLOBAL(enter_rtas)
         std	r6,PACASAVEDMSR(r13)
 
 	/* Setup our real return addr */	
-	LOAD_REG_ADDR(r4,.rtas_return_loc)
+	LOAD_REG_IMMEDIATE(r4,.rtas_return_loc)
 	clrldi	r4,r4,2			/* convert to realmode address */
        	mtlr	r4
 
@@ -725,7 +725,7 @@ _GLOBAL(enter_rtas)
 	sync				/* disable interrupts so SRR0/1 */
 	mtmsrd	r0			/* don't get trashed */
 
-	LOAD_REG_ADDR(r4, rtas)
+	LOAD_REG_IMMEDIATE(r4, rtas)
 	ld	r5,RTASENTRY(r4)	/* get the rtas->entry value */
 	ld	r4,RTASBASE(r4)		/* get the rtas->base value */
 	
Index: linux-2.6.26-rc9/arch/powerpc/kernel/head_64.S
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/head_64.S
+++ linux-2.6.26-rc9/arch/powerpc/kernel/head_64.S
@@ -102,6 +102,12 @@ __secondary_hold_acknowledge:
 	.llong hvReleaseData-KERNELBASE
 #endif /* CONFIG_PPC_ISERIES */
 
+#ifdef CONFIG_RELOCATABLE_PPC64
+	/* Used as static variable to initialize the reloc_delta */
+__initialized:
+	.long 0x0
+#endif
+
 	. = 0x60
 /*
  * The following code is used to hold secondary processors
@@ -121,11 +127,13 @@ _GLOBAL(__secondary_hold)
 	/* Tell the master cpu we're here */
 	/* Relocation is off & we are located at an address less */
 	/* than 0x100, so only need to grab low order offset.    */
-	std	r24,__secondary_hold_acknowledge@l(0)
+	LOAD_REG_IMMEDIATE(r25, __secondary_hold_acknowledge)
+	std	r24,0(r25)
 	sync
 
 	/* All secondary cpus wait here until told to start. */
-100:	ld	r4,__secondary_hold_spinloop@l(0)
+	LOAD_REG_IMMEDIATE(r25, __secondary_hold_spinloop)
+100:	ld	r4,0(r25)
 	cmpdi	0,r4,1
 	bne	100b
 
@@ -1176,6 +1184,38 @@ _STATIC(__mmu_off)
  *
  */
 _GLOBAL(__start_initialization_multiplatform)
+#ifdef CONFIG_RELOCATABLE_PPC64
+	mr	r21,r3
+	mr	r22,r4
+	mr	r23,r5
+	bl	.reloc_offset
+	mr	r26,r3
+	mr	r3,r21
+	mr	r4,r22
+	mr	r5,r23
+
+	LOAD_REG_IMMEDIATE(r27, __initialized)
+	add	r27,r26,r27
+	ld	r7,0(r27)
+	cmpdi	r7,0
+	bne	4f
+
+	li	r7,1
+	stw	r7,0(r27)
+
+	cmpdi	r6,0
+	beq	4f
+	LOAD_REG_IMMEDIATE(r27, reloc_delta)
+	add	r27,r27,r26
+	std	r6,0(r27)
+
+	LOAD_REG_IMMEDIATE(r27, KERNELBASE)
+	add	r7,r6,r27
+	LOAD_REG_IMMEDIATE(r27, kernel_base)
+	add	r27,r27,r26
+	std	r7,0(r27)
+4:
+#endif
 	/*
 	 * Are we booted from a PROM Of-type client-interface ?
 	 */
@@ -1251,6 +1291,19 @@ _INIT_STATIC(__boot_from_prom)
 	trap
 
 _STATIC(__after_prom_start)
+	bl	.reloc_offset
+	mr	r26,r3
+#ifdef CONFIG_RELOCATABLE_PPC64
+	/*
+	 * If its a relocatable kernel, no need to copy the kernel
+	 * to PHYSICAL_START. Continue running from the same location
+	 */
+	LOAD_REG_IMMEDIATE(r27, reloc_delta)
+	add	r27,r27,r26
+	ld	r28,0(r27)
+	cmpdi	r28,0
+	bne	.start_here_multiplatform
+#endif
 
 /*
  * We need to run with __start at physical address PHYSICAL_START.
@@ -1264,8 +1317,6 @@ _STATIC(__after_prom_start)
  *	r26 == relocation offset
  *	r27 == KERNELBASE
  */
-	bl	.reloc_offset
-	mr	r26,r3
 	LOAD_REG_IMMEDIATE(r27, KERNELBASE)
 
 	LOAD_REG_IMMEDIATE(r3, PHYSICAL_START)	/* target addr */
@@ -1411,7 +1462,7 @@ __secondary_start:
 	bl	.early_setup_secondary
 
 	/* Initialize the kernel stack.  Just a repeat for iSeries.	 */
-	LOAD_REG_ADDR(r3, current_set)
+	LOAD_REG_IMMEDIATE(r3, current_set)
 	sldi	r28,r24,3		/* get current_set[cpu#]	 */
 	ldx	r1,r3,r28
 	addi	r1,r1,THREAD_SIZE-STACK_FRAME_OVERHEAD
@@ -1422,7 +1473,7 @@ __secondary_start:
 	mtlr	r7
 
 	/* enable MMU and jump to start_secondary */
-	LOAD_REG_ADDR(r3, .start_secondary_prolog)
+	LOAD_REG_IMMEDIATE(r3, .start_secondary_prolog)
 	LOAD_REG_IMMEDIATE(r4, MSR_KERNEL)
 #ifdef CONFIG_PPC_ISERIES
 BEGIN_FW_FTR_SECTION
Index: linux-2.6.26-rc9/arch/powerpc/kernel/machine_kexec.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/machine_kexec.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/machine_kexec.c
@@ -67,6 +67,11 @@ void __init reserve_crashkernel(void)
 	unsigned long long crash_size, crash_base;
 	int ret;
 
+#ifdef CONFIG_RELOCATABLE_PPC64
+	if (reloc_delta)
+		return;
+#endif
+
 	/* this is necessary because of lmb_phys_mem_size() */
 	lmb_analyze();
 
Index: linux-2.6.26-rc9/arch/powerpc/kernel/machine_kexec_64.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/machine_kexec_64.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/machine_kexec_64.c
@@ -43,7 +43,7 @@ int default_machine_kexec_prepare(struct
 	 * overlaps kernel static data or bss.
 	 */
 	for (i = 0; i < image->nr_segments; i++)
-		if (image->segment[i].mem < __pa(_end))
+		if (image->segment[i].mem < (__pa(_end) + kernel_base))
 			return -ETXTBSY;
 
 	/*
@@ -317,7 +317,7 @@ static void __init export_htab_values(vo
 	if (!node)
 		return;
 
-	kernel_end = __pa(_end);
+	kernel_end = __pa(_end) + kernel_base;
 	prom_add_property(node, &kernel_end_prop);
 
 	/* On machines with no htab htab_address is NULL */
Index: linux-2.6.26-rc9/arch/powerpc/kernel/misc.S
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/misc.S
+++ linux-2.6.26-rc9/arch/powerpc/kernel/misc.S
@@ -20,6 +20,8 @@
 #include <asm/asm-compat.h>
 #include <asm/asm-offsets.h>
 
+#define RELOC_DELTA 0x4000000002000000
+
 	.text
 
 /*
@@ -33,6 +35,17 @@ _GLOBAL(reloc_offset)
 1:	mflr	r3
 	LOAD_REG_IMMEDIATE(r4,1b)
 	subf	r3,r4,r3
+#ifdef CONFIG_RELOCATABLE_PPC64
+	LOAD_REG_IMMEDIATE(r5, RELOC_DELTA)
+	cmpd	r3,r5
+	bne	2f
+	/*
+	 * Don't return the offset if the difference is
+	 * RELOC_DELTA
+	 */
+	li	r3,0
+2:
+#endif
 	mtlr	r0
 	blr
 
@@ -40,14 +53,25 @@ _GLOBAL(reloc_offset)
  * add_reloc_offset(x) returns x + reloc_offset().
  */
 _GLOBAL(add_reloc_offset)
-	mflr	r0
-	bl	1f
-1:	mflr	r5
-	LOAD_REG_IMMEDIATE(r4,1b)
-	subf	r5,r4,r5
-	add	r3,r3,r5
-	mtlr	r0
-	blr
+        mflr    r0
+        bl      1f
+1:      mflr    r5
+        LOAD_REG_IMMEDIATE(r4,1b)
+        subf    r5,r4,r5
+#ifdef CONFIG_RELOCATABLE_PPC64
+	LOAD_REG_IMMEDIATE(r4, RELOC_DELTA)
+	cmpd	r5,r4
+	bne	2f
+	/*
+	 * Don't add the offset if the difference is
+	 * RELOC_DELTA
+	 */
+	li	r5,0
+2:
+#endif
+        add     r3,r3,r5
+        mtlr    r0
+        blr
 
 _GLOBAL(kernel_execve)
 	li	r0,__NR_execve
Index: linux-2.6.26-rc9/arch/powerpc/kernel/prom.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/prom.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/prom.c
@@ -65,6 +65,9 @@
 static int __initdata dt_root_addr_cells;
 static int __initdata dt_root_size_cells;
 
+unsigned long reloc_delta __attribute__ ((__section__ (".data")));
+unsigned long kernel_base __attribute__ ((__section__ (".data")));
+
 #ifdef CONFIG_PPC64
 int __initdata iommu_is_off;
 int __initdata iommu_force_on;
@@ -1125,7 +1128,6 @@ static void __init phyp_dump_reserve_mem
 static inline void __init phyp_dump_reserve_mem(void) {}
 #endif /* CONFIG_PHYP_DUMP  && CONFIG_PPC_RTAS */
 
-
 void __init early_init_devtree(void *params)
 {
 	DBG(" -> early_init_devtree(%p)\n", params);
@@ -1159,8 +1161,16 @@ void __init early_init_devtree(void *par
 	parse_early_param();
 
 	/* Reserve LMB regions used by kernel, initrd, dt, etc... */
-	lmb_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START);
 	reserve_kdump_trampoline();
+#ifdef CONFIG_RELOCATABLE_PPC64
+	if (RELOC(kernel_base)) {
+		lmb_reserve(0, KDUMP_RESERVE_LIMIT);
+		lmb_reserve(kernel_base, __pa(klimit) - PHYSICAL_START);
+	} else
+		lmb_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START);
+#else
+	lmb_reserve(PHYSICAL_START, __pa(klimit) - PHYSICAL_START);
+#endif
 	reserve_crashkernel();
 	early_reserve_mem();
 	phyp_dump_reserve_mem();
Index: linux-2.6.26-rc9/arch/powerpc/kernel/prom_init.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/prom_init.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/prom_init.c
@@ -91,11 +91,9 @@ extern const struct linux_logo logo_linu
  * fortunately don't get interpreted as two arguments).
  */
 #ifdef CONFIG_PPC64
-#define RELOC(x)        (*PTRRELOC(&(x)))
 #define ADDR(x)		(u32) add_reloc_offset((unsigned long)(x))
 #define OF_WORKAROUNDS	0
 #else
-#define RELOC(x)	(x)
 #define ADDR(x)		(u32) (x)
 #define OF_WORKAROUNDS	of_workarounds
 int of_workarounds;
@@ -110,6 +108,9 @@ int of_workarounds;
         __asm__ __volatile__(".long " BUG_ILLEGAL_INSTR);	\
 } while (0)
 
+
+#define DEBUG_PROM
+
 #ifdef DEBUG_PROM
 #define prom_debug(x...)	prom_printf(x)
 #else
@@ -1070,7 +1071,12 @@ static void __init prom_init_mem(void)
 		}
 	}
 
+#ifndef CONFIG_RELOCATABLE_PPC64
 	RELOC(alloc_bottom) = PAGE_ALIGN((unsigned long)&RELOC(_end) + 0x4000);
+#else
+	RELOC(alloc_bottom) = PAGE_ALIGN((unsigned long)&RELOC(_end) + 0x4000 +
+							RELOC(reloc_delta));
+#endif
 
 	/* Check if we have an initrd after the kernel, if we do move our bottom
 	 * point to after it
@@ -1321,7 +1327,7 @@ extern unsigned long __secondary_hold_ac
  * We want to reference the copy of __secondary_hold_* in the
  * 0 - 0x100 address range
  */
-#define LOW_ADDR(x)	(((unsigned long) &(x)) & 0xff)
+#define LOW_ADDR(x)    (((unsigned long) &(x)) & 0xff)
 
 static void __init prom_hold_cpus(void)
 {
@@ -1334,10 +1340,19 @@ static void __init prom_hold_cpus(void)
 	unsigned int cpu_threads, hw_cpu_num;
 	int propsize;
 	struct prom_t *_prom = &RELOC(prom);
+
+#ifndef CONFIG_RELOCATABLE_PPC64
 	unsigned long *spinloop
 		= (void *) LOW_ADDR(__secondary_hold_spinloop);
 	unsigned long *acknowledge
 		= (void *) LOW_ADDR(__secondary_hold_acknowledge);
+#else
+	unsigned long *spinloop
+		= (void *) &__secondary_hold_spinloop;
+	unsigned long *acknowledge
+		= (void *) &__secondary_hold_acknowledge;
+#endif
+
 #ifdef CONFIG_PPC64
 	/* __secondary_hold is actually a descriptor, not the text address */
 	unsigned long secondary_hold
@@ -2399,8 +2414,15 @@ unsigned long __init prom_init(unsigned 
 	/*
 	 * Copy the CPU hold code
 	 */
-	if (RELOC(of_platform) != PLATFORM_POWERMAC)
-		copy_and_flush(0, KERNELBASE + offset, 0x100, 0);
+	if (RELOC(of_platform) != PLATFORM_POWERMAC) {
+#ifdef CONFIG_RELOCATABLE_PPC64
+		if (RELOC(reloc_delta))
+			copy_and_flush(0, KERNELBASE + RELOC(reloc_delta),
+								0x100, 0);
+		else
+#endif
+			copy_and_flush(0, KERNELBASE + offset, 0x100, 0);
+	}
 
 	/*
 	 * Do early parsing of command line
Index: linux-2.6.26-rc9/arch/powerpc/kernel/prom_init_check.sh
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/prom_init_check.sh
+++ linux-2.6.26-rc9/arch/powerpc/kernel/prom_init_check.sh
@@ -20,7 +20,7 @@ WHITELIST="add_reloc_offset __bss_start 
 _end enter_prom memcpy memset reloc_offset __secondary_hold
 __secondary_hold_acknowledge __secondary_hold_spinloop __start
 strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224
-reloc_got2 kernstart_addr"
+reloc_got2 kernstart_addr reloc_delta"
 
 NM="$1"
 OBJ="$2"
Index: linux-2.6.26-rc9/arch/powerpc/kernel/setup_64.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/setup_64.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/setup_64.c
@@ -208,7 +208,6 @@ void __init early_setup(unsigned long dt
 
 	/* Probe the machine type */
 	probe_machine();
-
 	setup_kdump_trampoline();
 
 	DBG("Found, Initializing memory management...\n");
@@ -524,9 +523,9 @@ void __init setup_arch(char **cmdline_p)
 	if (ppc_md.panic)
 		setup_panic();
 
-	init_mm.start_code = (unsigned long)_stext;
+	init_mm.start_code = (unsigned long)_stext + kernel_base;
 	init_mm.end_code = (unsigned long) _etext;
-	init_mm.end_data = (unsigned long) _edata;
+	init_mm.end_data = (unsigned long) _edata + kernel_base;
 	init_mm.brk = klimit;
 	
 	irqstack_early_init();
Index: linux-2.6.26-rc9/arch/powerpc/mm/hash_low_64.S
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/mm/hash_low_64.S
+++ linux-2.6.26-rc9/arch/powerpc/mm/hash_low_64.S
@@ -83,7 +83,7 @@ _GLOBAL(__hash_page_4K)
 	std	r29,STK_REG(r29)(r1)
 	std	r30,STK_REG(r30)(r1)
 	std	r31,STK_REG(r31)(r1)
-	
+
 	/* Step 1:
 	 *
 	 * Check permissions, atomically mark the linux PTE busy
@@ -168,7 +168,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FT
 	std	r3,STK_PARM(r4)(r1)
 
 	/* Get htab_hash_mask */
-	ld	r4,htab_hash_mask@got(2)
+	LOAD_REG_IMMEDIATE(r4, htab_hash_mask)
 	ld	r27,0(r4)	/* htab_hash_mask -> r27 */
 
 	/* Check if we may already be in the hashtable, in this case, we
@@ -461,7 +461,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FT
 	std	r3,STK_PARM(r4)(r1)
 
 	/* Get htab_hash_mask */
-	ld	r4,htab_hash_mask@got(2)
+	LOAD_REG_IMMEDIATE(r4, htab_hash_mask)
 	ld	r27,0(r4)	/* htab_hash_mask -> r27 */
 
 	/* Check if we may already be in the hashtable, in this case, we
@@ -792,7 +792,7 @@ END_FTR_SECTION(CPU_FTR_NOEXECUTE|CPU_FT
 	std	r3,STK_PARM(r4)(r1)
 
 	/* Get htab_hash_mask */
-	ld	r4,htab_hash_mask@got(2)
+	LOAD_REG_IMMEDIATE(r4, htab_hash_mask)
 	ld	r27,0(r4)	/* htab_hash_mask -> r27 */
 
 	/* Check if we may already be in the hashtable, in this case, we
Index: linux-2.6.26-rc9/arch/powerpc/mm/init_64.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/mm/init_64.c
+++ linux-2.6.26-rc9/arch/powerpc/mm/init_64.c
@@ -79,10 +79,11 @@ phys_addr_t kernstart_addr;
 
 void free_initmem(void)
 {
-	unsigned long addr;
+	unsigned long long addr, eaddr;
 
-	addr = (unsigned long)__init_begin;
-	for (; addr < (unsigned long)__init_end; addr += PAGE_SIZE) {
+	addr = (unsigned long long )__init_begin + kernel_base;
+	eaddr = (unsigned long long ) __init_end + kernel_base;
+	for (; addr < eaddr; addr += PAGE_SIZE) {
 		memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
 		ClearPageReserved(virt_to_page(addr));
 		init_page_count(virt_to_page(addr));
Index: linux-2.6.26-rc9/arch/powerpc/mm/mem.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/mm/mem.c
+++ linux-2.6.26-rc9/arch/powerpc/mm/mem.c
@@ -400,7 +400,8 @@ void __init mem_init(void)
 		}
 	}
 
-	codesize = (unsigned long)&_sdata - (unsigned long)&_stext;
+	codesize = (unsigned long)&_sdata - (unsigned long)&_stext
+						+ kernel_base;
 	datasize = (unsigned long)&_edata - (unsigned long)&_sdata;
 	initsize = (unsigned long)&__init_end - (unsigned long)&__init_begin;
 	bsssize = (unsigned long)&__bss_stop - (unsigned long)&__bss_start;
Index: linux-2.6.26-rc9/arch/powerpc/mm/slb_low.S
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/mm/slb_low.S
+++ linux-2.6.26-rc9/arch/powerpc/mm/slb_low.S
@@ -128,7 +128,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_1T_SEGMENT
 	/* Now get to the array and obtain the sllp
 	 */
 	ld	r11,PACATOC(r13)
-	ld	r11,mmu_psize_defs@got(r11)
+	LOAD_REG_IMMEDIATE(r11, mmu_psize_defs)
 	add	r11,r11,r9
 	ld	r11,MMUPSIZESLLP(r11)
 	ori	r11,r11,SLB_VSID_USER
Index: linux-2.6.26-rc9/arch/powerpc/platforms/pseries/hvCall.S
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/platforms/pseries/hvCall.S
+++ linux-2.6.26-rc9/arch/powerpc/platforms/pseries/hvCall.S
@@ -55,7 +55,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_PURR);				
 	/* calculate address of stat structure r4 = opcode */	\
 	srdi	r4,r4,2;		/* index into array */	\
 	mulli	r4,r4,HCALL_STAT_SIZE;				\
-	LOAD_REG_ADDR(r7, per_cpu__hcall_stats);		\
+	LOAD_REG_IMMEDIATE(r7, per_cpu__hcall_stats);		\
 	add	r4,r4,r7;					\
 	ld	r7,PACA_DATA_OFFSET(r13); /* per cpu offset */	\
 	add	r4,r4,r7;					\
Index: linux-2.6.26-rc9/include/asm-powerpc/exception.h
===================================================================
--- linux-2.6.26-rc9.orig/include/asm-powerpc/exception.h
+++ linux-2.6.26-rc9/include/asm-powerpc/exception.h
@@ -47,12 +47,6 @@
 #define EX_R3		64
 #define EX_LR		72
 
-/*
- * We're short on space and time in the exception prolog, so we can't
- * use the normal SET_REG_IMMEDIATE macro. Normally we just need the
- * low halfword of the address, but for Kdump we need the whole low
- * word.
- */
 #ifdef CONFIG_CRASH_DUMP
 #define LOAD_HANDLER(reg, label)					\
 	oris	reg,reg,(label)@h;	/* virt addr of handler ... */	\
Index: linux-2.6.26-rc9/include/asm-powerpc/system.h
===================================================================
--- linux-2.6.26-rc9.orig/include/asm-powerpc/system.h
+++ linux-2.6.26-rc9/include/asm-powerpc/system.h
@@ -517,6 +517,11 @@ extern unsigned long add_reloc_offset(un
 extern void reloc_got2(unsigned long);
 
 #define PTRRELOC(x)	((typeof(x)) add_reloc_offset((unsigned long)(x)))
+#ifdef CONFIG_PPC64
+#define RELOC(x)        (*PTRRELOC(&(x)))
+#else
+#define RELOC(x)	(x)
+#endif
 
 static inline void create_instruction(unsigned long addr, unsigned int instr)
 {
Index: linux-2.6.26-rc9/include/asm-powerpc/sections.h
===================================================================
--- linux-2.6.26-rc9.orig/include/asm-powerpc/sections.h
+++ linux-2.6.26-rc9/include/asm-powerpc/sections.h
@@ -7,10 +7,12 @@
 #ifdef __powerpc64__
 
 extern char _end[];
+extern unsigned long kernel_base;
 
 static inline int in_kernel_text(unsigned long addr)
 {
-	if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end)
+	if (addr >= (unsigned long)_stext && addr < (unsigned long)__init_end
+								+ kernel_base)
 		return 1;
 
 	return 0;
Index: linux-2.6.26-rc9/include/asm-powerpc/prom.h
===================================================================
--- linux-2.6.26-rc9.orig/include/asm-powerpc/prom.h
+++ linux-2.6.26-rc9/include/asm-powerpc/prom.h
@@ -39,6 +39,8 @@
 
 #define OF_DT_VERSION		0x10
 
+extern unsigned long reloc_delta, kernel_base;
+
 /*
  * This is what gets passed to the kernel by prom_init or kexec
  *
Index: linux-2.6.26-rc9/arch/powerpc/kernel/iommu.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/kernel/iommu.c
+++ linux-2.6.26-rc9/arch/powerpc/kernel/iommu.c
@@ -473,7 +473,7 @@ struct iommu_table *iommu_init_table(str
 	spin_lock_init(&tbl->it_lock);
 
 #ifdef CONFIG_CRASH_DUMP
-	if (ppc_md.tce_get) {
+	if (reloc_delta && ppc_md.tce_get) {
 		unsigned long index;
 		unsigned long tceval;
 		unsigned long tcecount = 0;
@@ -499,6 +499,11 @@ struct iommu_table *iommu_init_table(str
 				index < tbl->it_size; index++)
 				__clear_bit(index, tbl->it_map);
 		}
+	} else {
+		/* Clear the hardware table in case firmware left allocations
+		   in it */
+		ppc_md.tce_free(tbl, tbl->it_offset, tbl->it_size);
+		printk("Called ppc_md.tce_free()\n");
 	}
 #else
 	/* Clear the hardware table in case firmware left allocations in it */
Index: linux-2.6.26-rc9/arch/powerpc/platforms/pseries/iommu.c
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/platforms/pseries/iommu.c
+++ linux-2.6.26-rc9/arch/powerpc/platforms/pseries/iommu.c
@@ -262,7 +262,10 @@ static void iommu_table_setparms(struct 
 
 	tbl->it_base = (unsigned long)__va(*basep);
 
-#ifndef CONFIG_CRASH_DUMP
+#ifdef CONFIG_CRASH_DUMP
+	if (!reloc_delta)
+		memset((void *)tbl->it_base, 0, *sizep);
+#else
 	memset((void *)tbl->it_base, 0, *sizep);
 #endif
 

^ permalink raw reply

* [RFC v2 PATCH 3/4] Apply relocation info to vmlinux
From: Mohan Kumar M @ 2008-07-07 17:35 UTC (permalink / raw)
  To: ppcdev; +Cc: paulus, miltonm, michaele
In-Reply-To: <20080707172600.GE11470@in.ibm.com>

Apply relocation

This code is a wrapper around regular kernel. This checks whether the
kernel is loaded at 32MB, if its not loaded at 32MB, its treated as a
regular kernel and the control is given to the kernel immediately. If
the kernel is loaded at 32MB, it applies relocation delta to each offset
in the list which was generated and appended by patch 1 and 2. After
updating all offsets, control is given to relocatable kernel.

Signed-off-by: Mohan Kumar M <mohan@in.ibm.com>
---
 arch/powerpc/kernel/reloc_apply.S |  229 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 229 insertions(+)

Index: linux-2.6.26-rc9/arch/powerpc/kernel/reloc_apply.S
===================================================================
--- /dev/null
+++ linux-2.6.26-rc9/arch/powerpc/kernel/reloc_apply.S
@@ -0,0 +1,229 @@
+#include <asm/ppc_asm.h>
+
+#define RELOC_DELTA 0x4000000002000000
+
+#define LOADADDR(rn,name) \
+	lis     rn,name##@highest;	\
+	ori     rn,rn,name##@higher;	\
+	rldicr  rn,rn,32,31;		\
+	oris    rn,rn,name##@h;		\
+	ori     rn,rn,name##@l
+
+
+/*
+ * Layout of vmlinux.reloc file
+ *	Minimal part of relocation applying code +
+ *	vmlinux +
+ *	Rest of the relocation applying code
+ */
+
+.section .text.head
+
+.globl start_wrap
+start_wrap:
+	/* Get relocation offset in r15 */
+	bl	1f
+1:	mflr	r15
+	LOAD_REG_IMMEDIATE(r16,1b)
+	subf	r15,r16,r15
+
+	LOAD_REG_IMMEDIATE(r17, _reloc)
+	add	r17,r17,r15
+	mtctr	r17
+	bctr		/* Jump to start_reloc in section ".text.reloc" */
+
+/* Secondary cpus spin code */
+. = 0x60
+	/* Get relocation offset in r15 */
+	bl	1f
+1:	mflr	r15
+	LOAD_REG_IMMEDIATE(r16,1b)
+	subf	r15,r16,r15
+
+	LOADADDR(r18, __spinloop)
+	add	r18,r18,r15
+100:	ld	r19,0(r18)
+	cmpwi	0,r19,1
+	bne	100b
+
+	LOAD_REG_IMMEDIATE(r17, _reloc)
+	add	r17,r17,r15
+	addi	r17,r17,0x60
+	mtctr	r17
+	/* Jump to start_reloc + 0x60 in section ".text.reloc" */
+	bctr
+
+/*
+ * Layout of vmlinux.reloc file
+ *	Minimal part of relocation applying code +
+ *	vmlinux +
+ *	Rest of the relocation applying code
+ */
+
+
+.section .text.reloc
+
+start_reloc:
+	b	master
+
+.org start_reloc + 0x60
+	LOADADDR(r18, __spinloop)
+	add	r18,r18,r15
+100:	ld	r19,0(r18)
+	cmpwi	0,r19,2
+	bne	100b
+
+	/* Now vmlinux is at _head */
+	LOAD_REG_IMMEDIATE(r17, _head)
+	add	r17,r17,r15
+	addi	r17,r17,0x60
+	mtctr	r17
+	bctr
+
+master:
+	LOAD_REG_IMMEDIATE(r16, output_len)
+	add	r16,r16,r15
+
+	/*
+	 * Load the delimiter to distinguish between different relocation
+	 * types
+	 */
+	LOAD_REG_IMMEDIATE(r24, __delimiter)
+	add	r24,r24,r15
+	ld	r24,0(r24)
+
+	LOAD_REG_IMMEDIATE(r17, _head)
+	LOAD_REG_IMMEDIATE(r21, _ehead)
+	sub	r21,r21,r17	/* Number of bytes in head section */
+
+	sub	r16,r16,r21	/* Original output_len */
+
+	/* Destination address */
+	LOAD_REG_IMMEDIATE(r17, _head) /* KERNELBASE */
+	add	r17,r17,r15
+
+	/* Source address */
+	LOAD_REG_IMMEDIATE(r18, _text) /* Regular vmlinux */
+	add	r18,r18,r15
+
+	/* Number of bytes to copy */
+	LOAD_REG_IMMEDIATE(r19, _etext)
+	add	r19,r19,r15
+	sub	r19,r19,r18
+
+	/* Move cpu spin code to "text.reloc" section */
+	LOADADDR(r23, __spinloop)
+	add	r23,r23,r15
+	li	r25,1
+	stw	r25,0(r23)
+
+	/* Copy vmlinux code to physical address 0 */
+	bl	.copy	/* copy(_head, _text, _etext-_text) */
+
+	/*
+	 * If its not running at 32MB, assume it to be a normal kernel.
+	 * Copy the vmlinux code to KERNELBASE and jump to KERNELBASE
+	 */
+	LOAD_REG_IMMEDIATE(r21, RELOC_DELTA)
+	cmpd	r15,r21
+	beq	apply_relocation
+	li	r6,0
+	b	skip_apply
+apply_relocation:
+
+	/* Kernel is running at 32MB */
+	mr	r22,r15
+	xor	r23,r23,r23
+	addi	r23,r23,16
+	srw	r22,r22,r23
+
+	li	r25,0
+
+	LOAD_REG_IMMEDIATE(r26, _head)
+
+	/*
+	 * Start reading the relocation offset list from end of file
+	 * Based on the relocation type either add the relocation delta
+	 * or do logical ORing the relocation delta
+	 */
+3:
+	addi	r16,r16,-8
+	ld	r18,0(r16)
+	cmpdi	r18,0		/* Processed all offsets */
+	beq	4f		/* Start vmlinux */
+	/* Are we processing reloction type R_PPC64_ADDR16_HI */
+	cmpdi	r25,1
+	beq	rel_hi
+	cmpd	r18,r24
+	beq	set_rel_hi
+	/* Process 64bit absolute relocation update */
+rel_addr64:
+	add	r18,r18,r15
+	ld	r28,0(r18)
+	cmpdi	r28,0
+	beq	next
+	add	r28,r28,r15	/* add relocation offset */
+	add	r28,r28,r26	/* add KERNELBASE */
+	std	r28,0(r18)
+	b	next
+set_rel_hi:			/* Enable R_PPC64_ADDR16_HI flag */
+	addi	r25,r25,1
+	b	3b
+rel_hi:
+	add	r18,r18,r15
+	lhz	r28,0(r18)
+	or	r28,r28,r22
+	sth	r28,0(r18)
+next:
+	b	3b
+4:
+	mr	r6,r15
+
+
+skip_apply:
+	isync
+	sync
+
+	/* Now vmlinux is at _head */
+	LOAD_REG_IMMEDIATE(r17, _head)
+	add	r17,r17,r15
+	mtctr	r17
+
+	/* Move cpu spin code to "text.reloc" section */
+	LOADADDR(r23, __spinloop)
+	add	r23,r23,r15
+	li	r25,2
+	stw	r25,0(r23)
+
+	bctr
+
+/* r17 destination, r18 source, r19 size */
+.copy:
+	addi	r19,r19,-8
+	li	r22,-8
+4:	li	r21,8			/* Use the smallest common	*/
+					/* denominator cache line	*/
+					/* size.  This results in	*/
+					/* extra cache line flushes	*/
+					/* but operation is correct.	*/
+					/* Can't get cache line size	*/
+					/* from NACA as it is being	*/
+					/* moved too.			*/
+
+	mtctr	r21			/* put # words/line in ctr	*/
+3:	addi	r22,r22,8		/* copy a cache line		*/
+	ldx	r21,r22,r18
+	stdx	r21,r22,r17
+	bdnz	3b
+	dcbst	r22,r17			/* write it to memory		*/
+	sync
+	icbi	r22,r17			/* flush the icache line	*/
+	cmpld	0,r22,r19
+	blt	4b
+	sync
+	blr
+
+__delimiter:
+	.llong 0xffffffffffffffff
+__spinloop:
+	.llong	0x0

^ permalink raw reply

* [RFC v2 PATCH 2/4] Build files needed for relocation support
From: Mohan Kumar M @ 2008-07-07 17:34 UTC (permalink / raw)
  To: ppcdev; +Cc: paulus, miltonm, michaele
In-Reply-To: <20080707172600.GE11470@in.ibm.com>

Build files needed for relocation

This patch builds vmlinux file with relocation sections and contents so
that relocs user space program can extract the required relocation
offsets. This packs final relocatable vmlinux kernel as following:
earlier part of relocation apply code, vmlinux, rest of relocation apply
code.

File make.reloc is used to build the relocatable kernel "vmlinux.reloc".

TODO:
I have not yet integrated building relocatable kernel with kernel
Makefile. I need help to integrate this into kernel build process.

Signed-off-by: Mohan Kumar M <mohan@in.ibm.com>
---
 arch/powerpc/Kconfig             |   15 ++++++++++++---
 arch/powerpc/Makefile            |    2 +-
 arch/powerpc/vmlinux.reloc.lds.S |   29 +++++++++++++++++++++++++++++
 arch/powerpc/vmlinux.reloc.scr   |    8 ++++++++
 make.reloc                       |   35 +++++++++++++++++++++++++++++++++++
 5 files changed, 85 insertions(+), 4 deletions(-)

Index: linux-2.6.26-rc9/arch/powerpc/Kconfig
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/Kconfig
+++ linux-2.6.26-rc9/arch/powerpc/Kconfig
@@ -317,6 +317,15 @@ config CRASH_DUMP
 
 	  Don't change this unless you know what you are doing.
 
+config RELOCATABLE_PPC64
+	bool "Build a relocatable kernel (EXPERIMENTAL)"
+	depends on PPC_MULTIPLATFORM && PPC64 && CRASH_DUMP && EXPERIMENTAL
+	help
+	  Build a kernel suitable for use as regular kernel and kdump capture
+	  kernel.
+
+	  Don't change this unless you know what you are doing.
+
 config PHYP_DUMP
 	bool "Hypervisor-assisted dump (EXPERIMENTAL)"
 	depends on PPC_PSERIES && EXPERIMENTAL
@@ -656,7 +665,7 @@ config LOWMEM_SIZE
 	default "0x30000000"
 
 config RELOCATABLE
-	bool "Build a relocatable kernel (EXPERIMENTAL)"
+	bool "Build relocatable kernel (EXPERIMENTAL)"
 	depends on EXPERIMENTAL && ADVANCED_OPTIONS && FLATMEM && FSL_BOOKE
 	help
 	  This builds a kernel image that is capable of running at the
@@ -776,11 +785,11 @@ config PAGE_OFFSET
 	default "0xc000000000000000"
 config KERNEL_START
 	hex
-	default "0xc000000002000000" if CRASH_DUMP
+	default "0xc000000002000000" if CRASH_DUMP && !RELOCATABLE_PPC64
 	default "0xc000000000000000"
 config PHYSICAL_START
 	hex
-	default "0x02000000" if CRASH_DUMP
+	default "0x02000000" if CRASH_DUMP && !RELOCATABLE_PPC64
 	default "0x00000000"
 endif
 
Index: linux-2.6.26-rc9/arch/powerpc/Makefile
===================================================================
--- linux-2.6.26-rc9.orig/arch/powerpc/Makefile
+++ linux-2.6.26-rc9/arch/powerpc/Makefile
@@ -69,7 +69,7 @@ override CC	+= -m$(CONFIG_WORD_SIZE)
 override AR	:= GNUTARGET=elf$(CONFIG_WORD_SIZE)-powerpc $(AR)
 endif
 
-LDFLAGS_vmlinux	:= -Bstatic
+LDFLAGS_vmlinux	:= --emit-relocs
 
 CFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc -mtraceback=none  -mcall-aixdesc
 CFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2 -mmultiple
Index: linux-2.6.26-rc9/arch/powerpc/vmlinux.reloc.lds.S
===================================================================
--- /dev/null
+++ linux-2.6.26-rc9/arch/powerpc/vmlinux.reloc.lds.S
@@ -0,0 +1,29 @@
+#include <asm/page.h>
+#include <asm-generic/vmlinux.lds.h>
+
+ENTRY(start_wrap)
+
+OUTPUT_ARCH(powerpc:common64)
+/* OUTPUT_ARCH(elf64ppc) */
+SECTIONS
+{
+	. = KERNELBASE;
+
+/*
+ * Text, read only data and other permanent read-only sections
+ */
+	/* Text and gots */
+	.text : {
+		_head = .;
+		*(.text.head)
+		_ehead = .;
+
+		_text = .;
+		*(.vmlinux)
+		_etext = .;
+
+		_reloc = .;
+		*(.text.reloc)
+		_ereloc = .;
+	}
+}
Index: linux-2.6.26-rc9/arch/powerpc/vmlinux.reloc.scr
===================================================================
--- /dev/null
+++ linux-2.6.26-rc9/arch/powerpc/vmlinux.reloc.scr
@@ -0,0 +1,8 @@
+SECTIONS
+{
+  .vmlinux : {
+	input_len = .;
+	*(.data)
+	output_len = . - 8;
+	}
+}
Index: linux-2.6.26-rc9/make.reloc
===================================================================
--- /dev/null
+++ linux-2.6.26-rc9/make.reloc
@@ -0,0 +1,35 @@
+#Makefile for building vmlinux with relocatable information and code.
+
+all: vmlinux.reloc
+
+obj 	:= arch/powerpc
+
+AS	= as
+LD	= ld
+CC	= gcc
+CPP	= $(CC) -E
+
+
+$(obj)/relocs : $(obj)/relocs.c
+	$(CC) $(obj)/relocs.c -o $(obj)/relocs
+
+$(obj)/vmlinux.reloc.bin : vmlinux $(obj)/relocs
+	$(obj)/relocs vmlinux > $(obj)/vmlinux.reloc.bin 2>/dev/null
+
+$(obj)/vmlinux.bin: vmlinux
+	objcopy -O binary -R .note -R .comment -S vmlinux $(obj)/vmlinux.bin
+
+$(obj)/vmlinux.bin.all : $(obj)/vmlinux.bin $(obj)/vmlinux.reloc.bin
+	cat $(obj)/vmlinux.bin $(obj)/vmlinux.reloc.bin > $(obj)/vmlinux.bin.all
+
+$(obj)/vmlinux.new : $(obj)/vmlinux.reloc.scr $(obj)/vmlinux.bin.all
+	$(LD) -m elf64ppc -r --format binary --oformat elf64-powerpc -T $(obj)/vmlinux.reloc.scr $(obj)/vmlinux.bin.all -o $(obj)/vmlinux.new
+
+$(obj)/kernel/reloc_apply.o : $(obj)/kernel/reloc_apply.S
+	$(CC) -m64 -Wp,-MD,arch/powerpc/kernel/.reloc_apply.o.d  -nostdinc -isystem /usr/lib/gcc/powerpc64-suse-linux/4.1.2/include -D__KERNEL__ -Iinclude  -include include/linux/autoconf.h  -D__ASSEMBLY__  -Wa,-maltivec     -c -o arch/powerpc/kernel/reloc_apply.o arch/powerpc/kernel/reloc_apply.S
+
+$(obj)/vmlinux.reloc.lds : $(obj)/vmlinux.reloc.lds.S
+	$(CC) -m64 -E -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Os -msoft-float -pipe -mminimal-toc -mtraceback=none  -mcall-aixdesc -mtune=power4 -mno-altivec -mno-spe -funit-at-a-time -mno-string -Wa,-maltivec -fomit-frame-pointer  -fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign -Wp,-MD,arch/powerpc/.vmlinux.reloc.lds.d  -nostdinc -isystem /usr/lib/gcc/powerpc64-suse-linux/4.1.2/include -D__KERNEL__ -Iinclude  -include include/linux/autoconf.h    -Upowerpc -P -C -Upowerpc -D__ASSEMBLY__ -o arch/powerpc/vmlinux.reloc.lds arch/powerpc/vmlinux.reloc.lds.S
+
+vmlinux.reloc : $(obj)/vmlinux.reloc.lds $(obj)/vmlinux.new $(obj)/kernel/reloc_apply.o
+	$(LD) -m elf64ppc -T $(obj)/vmlinux.reloc.lds $(obj)/vmlinux.new $(obj)/kernel/reloc_apply.o -o vmlinux.reloc

^ permalink raw reply

* [RFC v2 PATCH 1/4] Extract list of relocation offsets
From: Mohan Kumar M @ 2008-07-07 17:34 UTC (permalink / raw)
  To: ppcdev; +Cc: paulus, miltonm, michaele
In-Reply-To: <20080707172600.GE11470@in.ibm.com>

Extract list of relocation offsets

Extract list of offsets in the vmlinux file for which the relocation
delta has to be patched. Currently only following type of relocation
types are considered: R_PPC64_ADDR16_HI, R_PPC64_TOC and R_PPC64_ADDR64

The offsets are sorted according to the relocation type and this
information is appended to the normal vmlinux file by using the patch
relocation_build.patch

Signed-off-by: Mohan Kumar M <mohan@in.ibm.com>
---
 arch/powerpc/relocs.c |  865 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 865 insertions(+)

Index: linux-2.6.26-rc9/arch/powerpc/relocs.c
===================================================================
--- /dev/null
+++ linux-2.6.26-rc9/arch/powerpc/relocs.c
@@ -0,0 +1,865 @@
+#include <stdio.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <elf.h>
+#include <byteswap.h>
+#define USE_BSD
+#include <endian.h>
+
+#define MAX_SHDRS 100
+static Elf64_Ehdr ehdr;
+static Elf64_Shdr shdr[MAX_SHDRS];
+static Elf64_Sym  *symtab[MAX_SHDRS];
+static Elf64_Rel  *reltab[MAX_SHDRS];
+static Elf64_Rela  *reltaba[MAX_SHDRS];
+static char *strtab[MAX_SHDRS];
+static unsigned long reloc_count, reloc_idx;
+
+struct reloc_info {
+	unsigned int rel_type;
+	unsigned long long offset;
+};
+
+static struct reloc_info *relocs;
+
+/*
+ * Following symbols have been audited. There values are constant and do
+ * not change if bzImage is loaded at a different physical address than
+ * the address for which it has been compiled. Don't warn user about
+ * absolute relocations present w.r.t these symbols.
+ */
+static const char* safe_abs_relocs[] = {
+		"__kernel_vsyscall",
+		"__kernel_rt_sigreturn",
+		"__kernel_sigreturn",
+		"SYSENTER_RETURN",
+};
+
+static int is_safe_abs_reloc(const char* sym_name)
+{
+	int i, array_size;
+
+	array_size = sizeof(safe_abs_relocs)/sizeof(char*);
+
+	for(i = 0; i < array_size; i++) {
+		if (!strcmp(sym_name, safe_abs_relocs[i]))
+			/* Match found */
+			return 1;
+	}
+	if (strncmp(sym_name, "__crc_", 6) == 0)
+		return 1;
+	return 0;
+}
+
+static void die(char *fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	exit(1);
+}
+
+static const char *sym_type(unsigned type)
+{
+	static const char *type_name[] = {
+#define SYM_TYPE(X) [X] = #X
+		SYM_TYPE(STT_NOTYPE),
+		SYM_TYPE(STT_OBJECT),
+		SYM_TYPE(STT_FUNC),
+		SYM_TYPE(STT_SECTION),
+		SYM_TYPE(STT_FILE),
+		SYM_TYPE(STT_COMMON),
+		SYM_TYPE(STT_TLS),
+#undef SYM_TYPE
+	};
+	const char *s_type = "unknown sym type name";
+	if (type < sizeof(type_name)/sizeof(type_name[0])) {
+		s_type = type_name[type];
+	}
+	return s_type;
+}
+
+static const char *sym_bind(unsigned bind)
+{
+	static const char *bind_name[] = {
+#define SYM_BIND(X) [X] = #X
+		SYM_BIND(STB_LOCAL),
+		SYM_BIND(STB_GLOBAL),
+		SYM_BIND(STB_WEAK),
+#undef SYM_BIND
+	};
+	const char *s_bind = "unknown sym bind name";
+	if (bind < sizeof(bind_name)/sizeof(bind_name[0])) {
+		s_bind = bind_name[bind];
+	}
+	return s_bind;
+}
+
+static const char *sym_visibility(unsigned visibility)
+{
+	static const char *visibility_name[] = {
+#define SYM_VISIBILITY(X) [X] = #X
+		SYM_VISIBILITY(STV_DEFAULT),
+		SYM_VISIBILITY(STV_INTERNAL),
+		SYM_VISIBILITY(STV_HIDDEN),
+		SYM_VISIBILITY(STV_PROTECTED),
+#undef SYM_VISIBILITY
+	};
+	const char *name = "unknown sym visibility name";
+	if (visibility < sizeof(visibility_name)/sizeof(visibility_name[0])) {
+		name = visibility_name[visibility];
+	}
+	return name;
+}
+
+static const char *rel_type(unsigned type)
+{
+	static const char *type_name[] = {
+#define REL_TYPE(X) [X] = #X
+		REL_TYPE(R_PPC64_NONE),
+		REL_TYPE(R_PPC64_ADDR32),
+		REL_TYPE(R_PPC64_ADDR24),
+		REL_TYPE(R_PPC64_ADDR16),
+		REL_TYPE(R_PPC64_ADDR16_LO),
+		REL_TYPE(R_PPC64_ADDR16_HI),
+		REL_TYPE(R_PPC64_ADDR16_HA),
+		REL_TYPE(R_PPC64_ADDR14	),
+		REL_TYPE(R_PPC64_ADDR14_BRTAKEN),
+		REL_TYPE(R_PPC64_ADDR14_BRNTAKEN),
+		REL_TYPE(R_PPC64_REL24),
+		REL_TYPE(R_PPC64_REL14),
+		REL_TYPE(R_PPC64_REL14_BRTAKEN),
+		REL_TYPE(R_PPC64_REL14_BRNTAKEN),
+		REL_TYPE(R_PPC64_GOT16),
+		REL_TYPE(R_PPC64_GOT16_LO),
+		REL_TYPE(R_PPC64_GOT16_HI),
+		REL_TYPE(R_PPC64_GOT16_HA),
+		REL_TYPE(R_PPC64_COPY),
+		REL_TYPE(R_PPC64_GLOB_DAT),
+		REL_TYPE(R_PPC64_JMP_SLOT),
+		REL_TYPE(R_PPC64_RELATIVE),
+		REL_TYPE(R_PPC64_UADDR32),
+		REL_TYPE(R_PPC64_UADDR16),
+		REL_TYPE(R_PPC64_REL32),
+		REL_TYPE(R_PPC64_PLT32),
+		REL_TYPE(R_PPC64_PLTREL32),
+		REL_TYPE(R_PPC64_PLT16_LO),
+		REL_TYPE(R_PPC64_PLT16_HI),
+		REL_TYPE(R_PPC64_PLT16_HA),
+		REL_TYPE(R_PPC64_SECTOFF),
+		REL_TYPE(R_PPC64_SECTOFF_LO),
+		REL_TYPE(R_PPC64_SECTOFF_HI),
+		REL_TYPE(R_PPC64_SECTOFF_HA),
+		REL_TYPE(R_PPC64_ADDR30),
+		REL_TYPE(R_PPC64_ADDR64),
+		REL_TYPE(R_PPC64_ADDR16_HIGHER),
+		REL_TYPE(R_PPC64_ADDR16_HIGHERA),
+		REL_TYPE(R_PPC64_ADDR16_HIGHEST),
+		REL_TYPE(R_PPC64_ADDR16_HIGHESTA),
+		REL_TYPE(R_PPC64_UADDR64),
+		REL_TYPE(R_PPC64_REL64),
+		REL_TYPE(R_PPC64_PLT64),
+		REL_TYPE(R_PPC64_PLTREL64),
+		REL_TYPE(R_PPC64_TOC16),
+		REL_TYPE(R_PPC64_TOC16_LO),
+		REL_TYPE(R_PPC64_TOC16_HI),
+		REL_TYPE(R_PPC64_TOC16_HA),
+		REL_TYPE(R_PPC64_TOC),
+		REL_TYPE(R_PPC64_PLTGOT16),
+		REL_TYPE(R_PPC64_PLTGOT16_LO),
+		REL_TYPE(R_PPC64_PLTGOT16_HI),
+		REL_TYPE(R_PPC64_PLTGOT16_HA),
+		REL_TYPE(R_PPC64_ADDR16_DS),
+		REL_TYPE(R_PPC64_ADDR16_LO_DS),
+		REL_TYPE(R_PPC64_GOT16_DS),
+		REL_TYPE(R_PPC64_GOT16_LO_DS),
+		REL_TYPE(R_PPC64_PLT16_LO_DS),
+		REL_TYPE(R_PPC64_SECTOFF_DS),
+		REL_TYPE(R_PPC64_SECTOFF_LO_DS),
+		REL_TYPE(R_PPC64_TOC16_DS),
+		REL_TYPE(R_PPC64_TOC16_LO_DS),
+		REL_TYPE(R_PPC64_PLTGOT16_DS),
+		REL_TYPE(R_PPC64_PLTGOT16_LO_DS),
+		REL_TYPE(R_PPC64_TLS),
+		REL_TYPE(R_PPC64_DTPMOD64),
+		REL_TYPE(R_PPC64_TPREL16),
+		REL_TYPE(R_PPC64_TPREL16_LO),
+		REL_TYPE(R_PPC64_TPREL16_HI),
+		REL_TYPE(R_PPC64_TPREL16_HA),
+		REL_TYPE(R_PPC64_TPREL64),
+		REL_TYPE(R_PPC64_DTPREL16),
+		REL_TYPE(R_PPC64_DTPREL16_LO),
+		REL_TYPE(R_PPC64_DTPREL16_HI),
+		REL_TYPE(R_PPC64_DTPREL16_HA),
+		REL_TYPE(R_PPC64_DTPREL64),
+		REL_TYPE(R_PPC64_GOT_TLSGD16),
+		REL_TYPE(R_PPC64_GOT_TLSGD16_LO),
+		REL_TYPE(R_PPC64_GOT_TLSGD16_HI),
+		REL_TYPE(R_PPC64_GOT_TLSGD16_HA),
+		REL_TYPE(R_PPC64_GOT_TLSLD16),
+		REL_TYPE(R_PPC64_GOT_TLSLD16_LO),
+		REL_TYPE(R_PPC64_GOT_TLSLD16_HI),
+		REL_TYPE(R_PPC64_GOT_TLSLD16_HA),
+		REL_TYPE(R_PPC64_GOT_TPREL16_DS),
+		REL_TYPE(R_PPC64_GOT_TPREL16_LO_DS),
+		REL_TYPE(R_PPC64_GOT_TPREL16_HI),
+		REL_TYPE(R_PPC64_GOT_TPREL16_HA),
+		REL_TYPE(R_PPC64_GOT_DTPREL16_DS),
+		REL_TYPE(R_PPC64_GOT_DTPREL16_LO_DS),
+		REL_TYPE(R_PPC64_GOT_DTPREL16_HI),
+		REL_TYPE(R_PPC64_GOT_DTPREL16_HA),
+		REL_TYPE(R_PPC64_TPREL16_DS),
+		REL_TYPE(R_PPC64_TPREL16_LO_DS),
+		REL_TYPE(R_PPC64_TPREL16_HIGHER),
+		REL_TYPE(R_PPC64_TPREL16_HIGHERA),
+		REL_TYPE(R_PPC64_TPREL16_HIGHEST),
+		REL_TYPE(R_PPC64_TPREL16_HIGHESTA),
+		REL_TYPE(R_PPC64_DTPREL16_DS),
+		REL_TYPE(R_PPC64_DTPREL16_LO_DS),
+		REL_TYPE(R_PPC64_DTPREL16_HIGHER),
+		REL_TYPE(R_PPC64_DTPREL16_HIGHERA),
+		REL_TYPE(R_PPC64_DTPREL16_HIGHEST),
+		REL_TYPE(R_PPC64_DTPREL16_HIGHESTA),
+#undef REL_TYPE
+	};
+	const char *name = "unknown type rel type name";
+	if (type < sizeof(type_name)/sizeof(type_name[0])) {
+		name = type_name[type];
+	}
+	return name;
+}
+
+static const char *sec_name(unsigned shndx)
+{
+	const char *sec_strtab;
+	const char *name;
+	sec_strtab = strtab[ehdr.e_shstrndx];
+	name = "<noname>";
+	if (shndx < ehdr.e_shnum) {
+		name = sec_strtab + shdr[shndx].sh_name;
+	}
+	else if (shndx == SHN_ABS) {
+		name = "ABSOLUTE";
+	}
+	else if (shndx == SHN_COMMON) {
+		name = "COMMON";
+	}
+	return name;
+}
+
+static const char *sym_name(const char *sym_strtab, Elf64_Sym *sym)
+{
+	const char *name;
+	name = "<noname>";
+	if (sym->st_name) {
+		name = sym_strtab + sym->st_name;
+	}
+	else {
+		name = sec_name(shdr[sym->st_shndx].sh_name);
+	}
+	return name;
+}
+
+
+
+#if BYTE_ORDER == BIG_ENDIAN
+#define be16_to_cpu(val) (val)
+#define be32_to_cpu(val) (val)
+#define be64_to_cpu(val) (val)
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define be16_to_cpu(val) bswap_16(val)
+#define be32_to_cpu(val) bswap_32(val)
+#define be64_to_cpu(val) bswap_64(val)
+#endif
+
+static uint16_t elf16_to_cpu(uint16_t val)
+{
+	return be16_to_cpu(val);
+}
+
+static uint32_t elf32_to_cpu(uint32_t val)
+{
+	return be32_to_cpu(val);
+}
+
+static uint64_t elf64_to_cpu(uint64_t val)
+{
+	return be64_to_cpu(val);
+}
+
+static void read_ehdr(FILE *fp)
+{
+	if (fread(&ehdr, sizeof(ehdr), 1, fp) != 1) {
+		die("Cannot read ELF header: %s\n",
+			strerror(errno));
+	}
+	if (memcmp(ehdr.e_ident, ELFMAG, 4) != 0) {
+		die("No ELF magic\n");
+	}
+	if (ehdr.e_ident[EI_CLASS] != ELFCLASS64) {
+		die("Not a 64 bit executable\n");
+	}
+	if (ehdr.e_ident[EI_DATA] != ELFDATA2MSB) {
+		die("Not a MSB ELF executable\n");
+	}
+	if (ehdr.e_ident[EI_VERSION] != EV_CURRENT) {
+		die("Unknown ELF version\n");
+	}
+	/* Convert the fields to native endian */
+	ehdr.e_type      = elf16_to_cpu(ehdr.e_type);
+	ehdr.e_machine   = elf16_to_cpu(ehdr.e_machine);
+	ehdr.e_version   = elf32_to_cpu(ehdr.e_version);
+	ehdr.e_entry     = elf64_to_cpu(ehdr.e_entry);
+	ehdr.e_phoff     = elf64_to_cpu(ehdr.e_phoff);
+	ehdr.e_shoff     = elf64_to_cpu(ehdr.e_shoff);
+	ehdr.e_flags     = elf32_to_cpu(ehdr.e_flags);
+	ehdr.e_ehsize    = elf16_to_cpu(ehdr.e_ehsize);
+	ehdr.e_phentsize = elf16_to_cpu(ehdr.e_phentsize);
+	ehdr.e_phnum     = elf16_to_cpu(ehdr.e_phnum);
+	ehdr.e_shentsize = elf16_to_cpu(ehdr.e_shentsize);
+	ehdr.e_shnum     = elf16_to_cpu(ehdr.e_shnum);
+	ehdr.e_shstrndx  = elf16_to_cpu(ehdr.e_shstrndx);
+
+	if ((ehdr.e_type != ET_EXEC) && (ehdr.e_type != ET_DYN)) {
+		die("Unsupported ELF header type\n");
+	}
+	if (ehdr.e_machine != EM_PPC64) {
+		die("Not for PPC64\n");
+	}
+	if (ehdr.e_version != EV_CURRENT) {
+		die("Unknown ELF version\n");
+	}
+	if (ehdr.e_ehsize != sizeof(Elf64_Ehdr)) {
+		die("Bad Elf header size\n");
+	}
+	if (ehdr.e_phentsize != sizeof(Elf64_Phdr)) {
+		die("Bad program header entry\n");
+	}
+	if (ehdr.e_shentsize != sizeof(Elf64_Shdr)) {
+		die("Bad section header entry\n");
+	}
+	if (ehdr.e_shstrndx >= ehdr.e_shnum) {
+		die("String table index out of bounds\n");
+	}
+}
+
+static void read_shdrs(FILE *fp)
+{
+	int i;
+	if (ehdr.e_shnum > MAX_SHDRS) {
+		die("%d section headers supported: %d\n",
+			ehdr.e_shnum, MAX_SHDRS);
+	}
+	if (fseek(fp, ehdr.e_shoff, SEEK_SET) < 0) {
+		die("Seek to %d failed: %s\n",
+			ehdr.e_shoff, strerror(errno));
+	}
+	if (fread(&shdr, sizeof(shdr[0]), ehdr.e_shnum, fp) != ehdr.e_shnum) {
+		die("Cannot read ELF section headers: %s\n",
+			strerror(errno));
+	}
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		shdr[i].sh_name      = elf32_to_cpu(shdr[i].sh_name);
+		shdr[i].sh_type      = elf32_to_cpu(shdr[i].sh_type);
+		shdr[i].sh_flags     = elf64_to_cpu(shdr[i].sh_flags);
+		shdr[i].sh_addr      = elf64_to_cpu(shdr[i].sh_addr);
+		shdr[i].sh_offset    = elf64_to_cpu(shdr[i].sh_offset);
+		shdr[i].sh_size      = elf64_to_cpu(shdr[i].sh_size);
+		shdr[i].sh_link      = elf32_to_cpu(shdr[i].sh_link);
+		shdr[i].sh_info      = elf32_to_cpu(shdr[i].sh_info);
+		shdr[i].sh_addralign = elf64_to_cpu(shdr[i].sh_addralign);
+		shdr[i].sh_entsize   = elf64_to_cpu(shdr[i].sh_entsize);
+	}
+
+}
+
+static void read_strtabs(FILE *fp)
+{
+	int i;
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		if (shdr[i].sh_type != SHT_STRTAB) {
+			continue;
+		}
+		strtab[i] = malloc(shdr[i].sh_size);
+		if (!strtab[i]) {
+			die("malloc of %d bytes for strtab failed\n",
+				shdr[i].sh_size);
+		}
+		if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
+			die("Seek to %d failed: %s\n",
+				shdr[i].sh_offset, strerror(errno));
+		}
+		if (fread(strtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
+			die("Cannot read symbol table: %s\n",
+				strerror(errno));
+		}
+	}
+}
+
+static void read_symtabs(FILE *fp)
+{
+	int i,j;
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		if (shdr[i].sh_type != SHT_SYMTAB) {
+			continue;
+		}
+		symtab[i] = malloc(shdr[i].sh_size);
+		if (!symtab[i]) {
+			die("malloc of %d bytes for symtab failed\n",
+				shdr[i].sh_size);
+		}
+		if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
+			die("Seek to %d failed: %s\n",
+				shdr[i].sh_offset, strerror(errno));
+		}
+		if (fread(symtab[i], 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
+			die("Cannot read symbol table: %s\n",
+				strerror(errno));
+		}
+		for(j = 0; j < shdr[i].sh_size/sizeof(symtab[i][0]); j++) {
+			symtab[i][j].st_name  = elf32_to_cpu(symtab[i][j].st_name);
+			symtab[i][j].st_value = elf64_to_cpu(symtab[i][j].st_value);
+			symtab[i][j].st_size  = elf64_to_cpu(symtab[i][j].st_size);
+			symtab[i][j].st_shndx = elf16_to_cpu(symtab[i][j].st_shndx);
+		}
+	}
+}
+
+
+static void read_relocs(FILE *fp)
+{
+	int i,j;
+	void *relp;
+
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		if (shdr[i].sh_type != SHT_REL && shdr[i].sh_type != SHT_RELA)
+			continue;
+
+		if (shdr[i].sh_type == SHT_REL) {
+			reltab[i] = malloc(shdr[i].sh_size);
+			if (!reltab[i]) {
+				die("malloc of %d bytes for relocs failed\n",
+					shdr[i].sh_size);
+			}
+			relp = reltab[i];
+		} else {
+			reltaba[i] = malloc(shdr[i].sh_size);
+			if (!reltaba[i]) {
+				die("malloc of %d bytes for relocs failed\n",
+					shdr[i].sh_size);
+			}
+			relp = reltaba[i];
+		}
+
+		if (fseek(fp, shdr[i].sh_offset, SEEK_SET) < 0) {
+			die("Seek to %d failed: %s\n",
+				shdr[i].sh_offset, strerror(errno));
+		}
+		if (fread(relp, 1, shdr[i].sh_size, fp) != shdr[i].sh_size) {
+			die("Cannot read symbol table: %s\n",
+				strerror(errno));
+		}
+
+		if (shdr[i].sh_type == SHT_REL)
+			for(j = 0; j < shdr[i].sh_size/sizeof(reltab[0][0]); j++) {
+				reltab[i][j].r_offset = elf64_to_cpu(reltab[i][j].r_offset);
+				reltab[i][j].r_info   = elf64_to_cpu(reltab[i][j].r_info);
+			}
+		else
+			for(j = 0; j < shdr[i].sh_size/sizeof(reltaba[0][0]); j++) {
+				reltaba[i][j].r_offset = elf64_to_cpu(reltaba[i][j].r_offset);
+				reltaba[i][j].r_info   = elf64_to_cpu(reltaba[i][j].r_info);
+				reltaba[i][j].r_addend   = elf64_to_cpu(reltaba[i][j].r_addend);
+			}
+	}
+}
+
+
+static void print_absolute_symbols(void)
+{
+	int i;
+	printf("Absolute symbols\n");
+	printf(" Num:  Value            Size  Type       Bind        Visibility  Name\n");
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		char *sym_strtab;
+		Elf64_Sym *sh_symtab;
+		int j;
+		if (shdr[i].sh_type != SHT_SYMTAB) {
+			continue;
+		}
+		sh_symtab = symtab[i];
+		sym_strtab = strtab[shdr[i].sh_link];
+		for(j = 0; j < shdr[i].sh_size/sizeof(symtab[0][0]); j++) {
+			Elf64_Sym *sym;
+			const char *name;
+			sym = &symtab[i][j];
+			name = sym_name(sym_strtab, sym);
+			if (sym->st_shndx != SHN_ABS) {
+				continue;
+			}
+			printf("type:[%s]\n",
+				sym_type(ELF64_ST_TYPE(sym->st_info)));
+			printf("%5d %016llx %5d type:%s bind:%10s %12s %s %s\n", \
+				j, sym->st_value, sym->st_size, \
+				sym_type(ELF64_ST_TYPE(sym->st_info)), \
+				sym_bind(ELF64_ST_BIND(sym->st_info)), \
+				sym_visibility(ELF64_ST_VISIBILITY(sym->st_other)), \
+				name);
+		}
+	}
+	printf("\n");
+}
+
+static void print_absolute_relocs(void)
+{
+	int i, printed = 0;
+	int nr, sh_type;
+
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		char *sym_strtab;
+		Elf64_Sym *sh_symtab;
+		unsigned sec_applies, sec_symtab;
+		int j;
+		if (shdr[i].sh_type != SHT_REL && shdr[i].sh_type != SHT_RELA) {
+			continue;
+		}
+		sec_symtab  = shdr[i].sh_link;
+		sec_applies = shdr[i].sh_info;
+		if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
+			continue;
+		}
+		if (shdr[i].sh_type == SHT_REL) {
+			sh_type = SHT_REL;
+			nr = shdr[i].sh_size/sizeof(reltab[0][0]);
+		} else {
+			sh_type = SHT_RELA;
+			nr = shdr[i].sh_size/sizeof(reltaba[0][0]);
+		}
+
+		sh_symtab = symtab[sec_symtab];
+		sym_strtab = strtab[shdr[sec_symtab].sh_link];
+
+		for(j = 0; j < nr; j++) {
+			Elf64_Rel *rel;
+			Elf64_Rela *rela;
+			Elf64_Sym *sym;
+			const char *name;
+
+			if (sh_type == SHT_REL) {
+				rel = &reltab[i][j];
+				sym = &sh_symtab[ELF64_R_SYM(rel->r_info)];
+			} else {
+				rela = &reltaba[i][j];
+				sym = &sh_symtab[ELF64_R_SYM(rela->r_info)];
+			}
+
+			name = sym_name(sym_strtab, sym);
+			if (sym->st_shndx != SHN_ABS) {
+				continue;
+			}
+
+			/* Absolute symbols are not relocated if vmlinux is
+			 * loaded at a non-compiled address. Display a warning
+			 * to user at compile time about the absolute
+			 * relocations present.
+			 *
+			 * User need to audit the code to make sure
+			 * some symbols which should have been section
+			 * relative have not become absolute because of some
+			 * linker optimization or wrong programming usage.
+			 *
+			 * Before warning check if this absolute symbol
+			 * relocation is harmless.
+			 */
+			if (is_safe_abs_reloc(name))
+				continue;
+
+			if (!printed) {
+				printf("WARNING: Absolute relocations"
+					" present\n");
+				printf("Offset           Info             Type           Sym.Value        "
+					"Sym.Name\n");
+				printed = 1;
+			}
+
+			if (sh_type == SHT_REL)
+				printf("%016llx %016llx %10s %016llx  %s\n",
+					rel->r_offset,
+					rel->r_info,
+					rel_type(ELF64_R_TYPE(rel->r_info)),
+					sym->st_value,
+					name);
+			else
+				printf("%016llx %016llx %10s %016llx  %s\n",
+					rela->r_offset,
+					rela->r_info,
+					rel_type(ELF64_R_TYPE(rela->r_info)),
+					sym->st_value,
+					name);
+		}
+	}
+
+	if (printed)
+		printf("\n");
+}
+
+static void walk_relocs(void (*visit)(void *relp, Elf64_Sym *sym, int sh_type))
+{
+	int i;
+	/* Walk through the relocations */
+	for(i = 0; i < ehdr.e_shnum; i++) {
+		char *sym_strtab;
+		Elf64_Sym *sh_symtab;
+		unsigned sec_applies, sec_symtab;
+		int j, nr_entries, sh_type;
+		if (shdr[i].sh_type != SHT_REL && shdr[i].sh_type != SHT_RELA) {
+			continue;
+		}
+		sec_symtab  = shdr[i].sh_link;
+		sec_applies = shdr[i].sh_info;
+		if (!(shdr[sec_applies].sh_flags & SHF_ALLOC)) {
+			continue;
+		}
+		sh_symtab = symtab[sec_symtab];
+		sym_strtab = strtab[shdr[sec_symtab].sh_link];
+		if (shdr[i].sh_type == SHT_REL) {
+			sh_type = SHT_REL;
+			nr_entries = shdr[i].sh_size/sizeof(reltab[0][0]);
+		} else {
+			sh_type = SHT_RELA;
+			nr_entries = shdr[i].sh_size/sizeof(reltaba[0][0]);
+		}
+
+		for(j = 0; j < nr_entries; j++) {
+			Elf64_Rel *rel;
+			Elf64_Rela *rela;
+			Elf64_Sym *sym;
+			void *relp;
+			unsigned r_type;
+
+			if (sh_type == SHT_REL) {
+				rel = &reltab[i][j];
+				sym = &sh_symtab[ELF64_R_SYM(rel->r_info)];
+				r_type = ELF64_R_TYPE(rel->r_info);
+				relp = rel;
+			} else {
+				rela = &reltaba[i][j];
+				sym = &sh_symtab[ELF64_R_SYM(rela->r_info)];
+				r_type = ELF64_R_TYPE(rela->r_info);
+				relp = rela;
+			}
+			/* Don't visit relocations to absolute symbols */
+			if (sym->st_shndx == SHN_ABS) {
+				continue;
+			}
+			/* PC relative relocations don't need to be adjusted */
+			switch (r_type) {
+				case R_PPC64_ADDR32:
+				case R_PPC64_ADDR16:
+				case R_PPC64_ADDR16_HI:
+				case R_PPC64_ADDR24:
+				case R_PPC64_ADDR64:
+				case R_PPC64_TOC:
+					/* Visit relocations that need to be adjusted */
+					visit(relp, sym, sh_type);
+					break;
+				case R_PPC64_ADDR16_LO:
+				case R_PPC64_REL24:
+				case R_PPC64_REL64:
+				case R_PPC64_TOC16:
+				case R_PPC64_ADDR16_LO_DS:
+				case R_PPC64_ADDR16_HIGHEST:
+				case R_PPC64_ADDR16_HIGHER:
+				case R_PPC64_GOT16_DS:
+				case R_PPC64_TOC16_DS:
+				case R_PPC64_REL14:
+				default:
+					break;
+			}
+		}
+	}
+}
+
+static void count_reloc(void *relp, Elf64_Sym *sym, int sh_type)
+{
+	reloc_count += 1;
+}
+
+static void collect_reloc(void *relp, Elf64_Sym *sym, int sh_type)
+{
+	Elf64_Rel *rel;
+	Elf64_Rela *rela;
+
+	/* Remember the address that needs to be adjusted. */
+	if (sh_type == SHT_REL) {
+		rel = (Elf64_Rel *)relp;
+		relocs[reloc_idx].offset = rel->r_offset;
+		relocs[reloc_idx++].rel_type = ELF64_R_TYPE(rel->r_info);
+	} else {
+		rela = (Elf64_Rela *)relp;
+		relocs[reloc_idx].offset = rela->r_offset;
+		relocs[reloc_idx++].rel_type = ELF64_R_TYPE(rela->r_info);
+	}
+}
+
+static int cmp_relocs(const void *va, const void *vb)
+{
+	const struct reloc_info *a, *b;
+	a = va; b = vb;
+	return (a->rel_type == b->rel_type)? 0 : (a->rel_type > b->rel_type)? 1 : -1;
+}
+
+static void emit_relocs(int as_text)
+{
+	int i;
+	int prev_r_type;
+	/* Count how many relocations I have and allocate space for them. */
+	reloc_count = 0;
+	walk_relocs(count_reloc);
+	relocs = malloc(reloc_count * sizeof(relocs[0]));
+	if (!relocs) {
+		die("malloc of %d entries for relocs failed\n",
+			reloc_count);
+	}
+	/* Collect up the relocations */
+	reloc_idx = 0;
+	walk_relocs(collect_reloc);
+
+	/* Order the relocations for more efficient processing */
+	qsort(relocs, reloc_count, sizeof(relocs[0]), cmp_relocs);
+
+	/* Print the relocations */
+	if (as_text) {
+		/* Print the relocations in a form suitable that
+		 * gas will like.
+		 */
+		printf(".section \".data.reloc\",\"a\"\n");
+		printf(".balign 4\n");
+
+		printf("\t .long 0x%016llx\n", relocs[0].offset);
+		prev_r_type = relocs[0].rel_type;
+
+		for(i = 1; i < reloc_count; i++) {
+			if (prev_r_type != relocs[i].rel_type && prev_r_type == R_PPC64_ADDR16_HI) {
+				printf("\t .long 0xffffffffffffffff\n");
+				prev_r_type = relocs[i].rel_type;
+			}
+			printf("\t .long 0x%016llx\n", relocs[i].offset);
+		}
+		printf("\n");
+	}
+	else {
+		unsigned char buf[8];
+		buf[0] = buf[1] = buf[2] = buf[3] = 0;
+		buf[4] = buf[5] = buf[6] = buf[7] = 0;
+
+		/* Print a stop */
+		printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+		printf("%c%c%c%c", buf[4], buf[5], buf[6], buf[7]);
+
+		buf[7] = (relocs[0].offset >>  0) & 0xff;
+		buf[6] = (relocs[0].offset >>  8) & 0xff;
+		buf[5] = (relocs[0].offset >> 16) & 0xff;
+		buf[4] = (relocs[0].offset >> 24) & 0xff;
+		buf[3] = (relocs[0].offset >> 32) & 0xff;
+		buf[2] = (relocs[0].offset >> 40) & 0xff;
+		buf[1] = (relocs[0].offset >> 48) & 0xff;
+		buf[0] = (relocs[0].offset >> 56) & 0xff;
+		printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+		printf("%c%c%c%c", buf[4], buf[5], buf[6], buf[7]);
+
+		prev_r_type = relocs[0].rel_type;
+
+		/* Now print each relocation */
+		for(i = 1; i < reloc_count; i++) {
+			if (prev_r_type != relocs[i].rel_type && prev_r_type == R_PPC64_ADDR16_HI) {
+				printf("%c%c%c%c", 0xff, 0xff, 0xff, 0xff);
+				printf("%c%c%c%c", 0xff, 0xff, 0xff, 0xff);
+				prev_r_type = relocs[i].rel_type;
+			}
+			buf[7] = (relocs[i].offset >>  0) & 0xff;
+			buf[6] = (relocs[i].offset >>  8) & 0xff;
+			buf[5] = (relocs[i].offset >> 16) & 0xff;
+			buf[4] = (relocs[i].offset >> 24) & 0xff;
+			buf[3] = (relocs[i].offset >> 32) & 0xff;
+			buf[2] = (relocs[i].offset >> 40) & 0xff;
+			buf[1] = (relocs[i].offset >> 48) & 0xff;
+			buf[0] = (relocs[i].offset >> 56) & 0xff;
+			printf("%c%c%c%c", buf[0], buf[1], buf[2], buf[3]);
+			printf("%c%c%c%c", buf[4], buf[5], buf[6], buf[7]);
+		}
+		buf[0] = buf[1] = buf[2] = buf[3] = 0;
+		buf[4] = buf[5] = buf[6] = buf[7] = 0;
+	}
+}
+
+static void usage(void)
+{
+	die("relocs [--abs-syms |--abs-relocs | --text] vmlinux\n");
+}
+
+int main(int argc, char **argv)
+{
+	int show_absolute_syms, show_absolute_relocs;
+	int as_text;
+	const char *fname;
+	FILE *fp;
+	int i;
+
+	show_absolute_syms = 0;
+	show_absolute_relocs = 0;
+	as_text = 0;
+	fname = NULL;
+	for(i = 1; i < argc; i++) {
+		char *arg = argv[i];
+		if (*arg == '-') {
+			if (strcmp(argv[1], "--abs-syms") == 0) {
+				show_absolute_syms = 1;
+				continue;
+			}
+
+			if (strcmp(argv[1], "--abs-relocs") == 0) {
+				show_absolute_relocs = 1;
+				continue;
+			}
+			else if (strcmp(argv[1], "--text") == 0) {
+				as_text = 1;
+				continue;
+			}
+		}
+		else if (!fname) {
+			fname = arg;
+			continue;
+		}
+		usage();
+	}
+	if (!fname) {
+		usage();
+	}
+	fp = fopen(fname, "r");
+	if (!fp) {
+		die("Cannot open %s: %s\n",
+			fname, strerror(errno));
+	}
+	read_ehdr(fp);
+	read_shdrs(fp);
+	read_strtabs(fp);
+	read_symtabs(fp);
+	read_relocs(fp);
+	if (show_absolute_syms) {
+		print_absolute_symbols();
+		return 0;
+	}
+	if (show_absolute_relocs) {
+		print_absolute_relocs();
+		return 0;
+	}
+	emit_relocs(as_text);
+	return 0;
+}

^ permalink raw reply

* Re: [PATCH] Add PPC_FEATURE_PMU_COMPAT
From: Nathan Lynch @ 2008-07-07 17:29 UTC (permalink / raw)
  To: Kumar Gala; +Cc: linuxppc-dev, Paul Mackerras, Maynard
In-Reply-To: <A2A80C78-AF10-4FC0-A7E7-CDCACA9AD7E3@kernel.crashing.org>

Kumar Gala wrote:
>
> On Jul 3, 2008, at 6:20 PM, Nathan Lynch wrote:
>
>> Beginning with Power6, there is a set of 32 PMU events which is
>> compatible across POWER processor lines.  PPC_FEATURE_PMU_COMPAT
>> indicates support for this subset.
>>
>> Signed-off-by: Nathan Lynch <ntl@pobox.com>
>> ---
>> arch/powerpc/kernel/cputable.c |    4 ++--
>> include/asm-powerpc/cputable.h |    1 +
>> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> Can you explain what these PMU events are a bit further?

Maynard, can you help out here...?  :)

^ permalink raw reply

* [RFC v2 PATCH 0/4] Relocatable kernel support for PPC64
From: Mohan Kumar M @ 2008-07-07 17:26 UTC (permalink / raw)
  To: ppcdev; +Cc: paulus, michaele, miltonm

Hi,

Following four patches enable the "relocatable kernel" feature for
PPC64 kernels.
        1. extract_relocation_info.patch
        2. relocation_build.patch
        3. apply_relocation.patch
        4. relocation_support.patch

With the patchset, vmcore image of a crashed system can be captured
using the same kernel binary.

Still the kernel is not a fully relocatable kernel. It can either run at
0 or 32MB based on which address its loaded. If its loaded by 'kexec
-p',
it behaves as a relocatable kernel and runs at 32MB(even though its
compiled for 0). If the same kernel is loaded by yaboot or kexec -l, it
will behave as a normal kernel and will run at the compiled address.

Issues:
* During kdump kernel boot, all secondary processors are stuck up. But
  during yaboot all secondary processors are brought online.
* Relocatable kernel build process is not yet integrated with the kernel
  build.
* Kdump kernel boot fails on some specific systems because exception vectors
  are overwritten (When I tested the same kernel binary on an another
  machine kdump kernel boots). No issues in OpenPower and Power6 machines. I
  have faced exception overwritten problem in one Power5 lpar.

Building relocatable kernel support:
Enable "Build a kdump crash kernel" option and "Build relocatable
kernel"
options to build the kernel as relocatable.

After the kernel build, build the relocatable kernel by running
        make -f make.reloc

Copy the vmlinux.reloc to /boot, build initrd and update yaboot.conf to
include the entry for 'vmlinux.reloc' and corresponding initrd

Please give me your comments and suggestions to fix the above issues and
improve this feature.

Regards,
Mohan.

^ permalink raw reply

* Re: [PATCH] Add PPC_FEATURE_PMU_COMPAT
From: Nathan Lynch @ 2008-07-07 17:17 UTC (permalink / raw)
  To: Olof Johansson; +Cc: linuxppc-dev, Paul Mackerras
In-Reply-To: <9C67179C-12C2-430C-B3FB-07A80DBB7324@lixom.net>

Olof Johansson wrote:
> On Jul 3, 2008, at 6:20 PM, Nathan Lynch wrote:
>
>> Beginning with Power6, there is a set of 32 PMU events which is
>> compatible across POWER processor lines.  PPC_FEATURE_PMU_COMPAT
>> indicates support for this subset.
>
> The PMU isn't, as far as I know, part of the architecture, it's up to  
> each implementation to do as it pleases. Right? So this should probably 
> be named less generic.

Yeah, you're right.  Will change it to PSERIES_PMU_COMPAT or similar.

^ permalink raw reply

* Re: [Cbe-oss-dev] powerpc/cell/cpufreq: add spu aware cpufreq governor
From: Eric Blossom @ 2008-07-07 17:17 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Dave Jones, Stephen Rothwell, cpufreq, linuxppc-dev, Jeremy Kerr,
	cbe-oss-dev
In-Reply-To: <200807071702.31240.arnd@arndb.de>

On Mon, Jul 07, 2008 at 05:02:30PM +0200, Arnd Bergmann wrote:
> From: Christian Krafft <krafft@de.ibm.com>
> 
> This patch adds a cpufreq governor that takes the number of running spus
> into account. It's very similar to the ondemand governor, but not as complex.
> Instead of hacking spu load into the ondemand governor it might be easier to
> have cpufreq accepting multiple governors per cpu in future.
> Don't know if this is the right way, but it would keep the governors simple.

I've got a basic question about this idea:

Does it throttle only idle spus or is there a single control for
the entire PPE + SPE complex?

I can think of many situations in our code where at certain times we
may only be able to keep N out of M spes occupied (because of how
we've expressed our task-specific parallelism), but we're counting on
the ones we're using running at full speed so that we can maintain our
real-time throughput.  (Our application does real-time signal
processing of continuously streaming data)

Is there a way to disable the "throttling SPEs" feature short of
configuring it out of the kernel?

Eric

^ permalink raw reply

* Re: [PATCH] powerpc: Use new printk extension %pS to print symbols on oops
From: Linus Torvalds @ 2008-07-07 17:08 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev
In-Reply-To: <20080707034436.BEA2DDDF35@ozlabs.org>



On Mon, 7 Jul 2008, Benjamin Herrenschmidt wrote:
>
> This changes the oops and backtrace code to use the new %pS
> printk extension to print out symbols rather than manually
> calling print_symbol.

Ok, I ended up committing the suppor for '%pS' early (as a series of 
smaller patches to make it clearer), just because it makes it easier for 
different people to start converthing things with the infrastructure in 
place.

But I wasn't planning on actually merging any of the conversions until 
after 2.6.26 (ie there will be no actual _users_ of '%pS' in 2.6.26)

		Linus

^ permalink raw reply

* Re: [Cbe-oss-dev] [patch 02/02] powerpc/cell: add support for power button of future IBM cell blades
From: Christian Krafft @ 2008-07-07 16:56 UTC (permalink / raw)
  To: Christian Krafft; +Cc: cbe-oss-dev, arnd, linuxppc-dev
In-Reply-To: <20080707184756.16e52677@linux.ibm.com>

From: Christian Krafft <krafft@de.ibm.com>

This patch adds support for the power button on future IBM cell blades.
It actually doesn't shut down the machine. Instead it exposes an
input device /dev/input/event0 to userspace which sends KEY_POWER
if power button has been pressed.
haldaemon actually recognizes the button, so a plattform independent acpid
replacement should handle it correctly.

Signed-off-by: Christian Krafft <krafft@de.ibm.com>

Index: linux.git/arch/powerpc/platforms/cell/Kconfig
===================================================================
--- linux.git.orig/arch/powerpc/platforms/cell/Kconfig
+++ linux.git/arch/powerpc/platforms/cell/Kconfig
@@ -87,9 +87,12 @@ config PPC_IBM_CELL_BLADE_BUTTONS
 	bool "IBM Cell Blade Buttons"
 	depends on CBE_RAS && PPC_IBM_CELL_BLADE
 	default y
+	select INPUT
+	select INPUT_EVDEV
 	help
 	  Support Buttons on IBM Cell blades. This adds a method to
-	  trigger system reset via front panel pinhole button.
+	  trigger system reset via front panel pinhole button and
+	  an input device for the power button.
 
 config CBE_THERM
 	tristate "CBE thermal support"
Index: linux.git/arch/powerpc/platforms/cell/ras.c
===================================================================
--- linux.git.orig/arch/powerpc/platforms/cell/ras.c
+++ linux.git/arch/powerpc/platforms/cell/ras.c
@@ -14,6 +14,11 @@
 #include <linux/smp.h>
 #include <linux/reboot.h>
 
+#ifdef CONFIG_PPC_IBM_CELL_BLADE_BUTTONS
+#include <linux/input.h>
+#include <linux/platform_device.h>
+#endif /* CONFIG_PPC_IBM_CELL_BLADE_BUTTONS */
+
 #include <asm/reg.h>
 #include <asm/io.h>
 #include <asm/prom.h>
@@ -232,31 +237,76 @@ static struct notifier_block cbe_ptcal_r
 
 #ifdef CONFIG_PPC_IBM_CELL_BLADE_BUTTONS
 static int sysreset_hack;
+static struct input_dev *button_dev;
+static struct platform_device *button_pdev;
 
 static int __init cbe_sysreset_init(void)
 {
+	int ret = 0;
+	struct input_dev *dev;
 	struct cbe_pmd_regs __iomem *regs;
 
 	sysreset_hack = machine_is_compatible("IBM,CBPLUS-1.0");
 	if (!sysreset_hack)
-		return 0;
+		goto out;
 
 	regs = cbe_get_cpu_pmd_regs(0);
 	if (!regs)
-		return 0;
+		goto out;
 
 	/* Enable JTAG system-reset hack */
 	out_be32(&regs->fir_mode_reg,
 		in_be32(&regs->fir_mode_reg) |
 		CBE_PMD_FIR_MODE_M8);
 
-	return 0;
+	dev = input_allocate_device();
+	if (!dev) {
+		ret = -ENOMEM;
+		printk(KERN_ERR "%s: Not enough memory\n", __func__);
+		goto out;
+	}
+
+	set_bit(EV_KEY, dev->evbit);
+	set_bit(KEY_POWER, dev->keybit);
+
+	dev->name = "Power Button";
+	dev->id.bustype = BUS_HOST;
+
+	/* this makes the button look like an acpi power button
+	 * no clue whether anyone relies on that though */
+	dev->id.product = 0x02;
+	dev->phys = "LNXPWRBN/button/input0";
+
+	button_pdev = platform_device_register_simple("power_button", 0, NULL, 0);
+	if (IS_ERR(button_pdev)) {
+		ret = PTR_ERR(button_pdev);
+		goto out_free_input;
+	}
+
+	dev->dev.parent = &button_pdev->dev;
+ 	ret = input_register_device(dev);
+
+	if (ret) {
+		printk(KERN_ERR "%s: Failed to register device\n", __func__);
+		goto out_free_pdev;
+	}
+
+	button_dev = dev;
+	goto out;
+
+out_free_pdev:
+	platform_device_unregister(button_pdev);
+out_free_input:
+	input_free_device(dev);
+out:
+	return ret;
 }
 device_initcall(cbe_sysreset_init);
 
 int cbe_sysreset_hack(void)
 {
 	struct cbe_pmd_regs __iomem *regs;
+	u64 status;
 
 	/*
 	 * The BMC can inject user triggered system reset exceptions,
@@ -267,10 +317,20 @@ int cbe_sysreset_hack(void)
 		regs = cbe_get_cpu_pmd_regs(0);
 		if (!regs)
 			return 0;
-		if (in_be64(&regs->ras_esc_0) & 0x0000ffff) {
+		status = in_be64(&regs->ras_esc_0);
+		if (status & 0x0000ffff) {
 			out_be64(&regs->ras_esc_0, 0);
 			return 0;
 		}
+		if (status & 0x00010000) {
+			out_be64(&regs->ras_esc_0, 0);
+			if (!button_dev)
+				return 0;
+			input_report_key(button_dev, KEY_POWER, 1);
+			input_sync(button_dev);
+			input_report_key(button_dev, KEY_POWER, 0);
+			input_sync(button_dev);
+		}
 	}
 	return 1;
 }

-- 
Mit freundlichen Gruessen,
kind regards,

Christian Krafft
Linux Kernel Development
IBM Systems & Technology Group
Phone: +49-07031-16-2032

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats:	Martin Jetter
Geschaetsfuehung:		Herbert Kircher
Sitz der Gesellschaft:		Boelingen
Registergericht:		Amtsgericht Stuttgart, HRB 243294

^ permalink raw reply


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