All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sachin P. Sant" <sachinp@in.ibm.com>
To: linuxppc-dev@ozlabs.org
Cc: Milton Miller II <miltonm@us.ibm.com>, ellerman@au1.ibm.com
Subject: [Patch 2/2] Kexec/Kdump support POWER6
Date: Tue, 22 May 2007 17:56:36 +0530	[thread overview]
Message-ID: <4652E17C.7080607@in.ibm.com> (raw)
In-Reply-To: <4652E109.4020204@in.ibm.com>

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

On Power machines supporting VRMA, Kexec/Kdump does not work.
Hypervisor stores VRMA mapping used by the OS, in the hpte hash
tables. Make sure these hpte entries are left untouched.

Thanks
-Sachin



[-- Attachment #2: kexec-kdump-support-for-POWRE6 --]
[-- Type: text/plain, Size: 4218 bytes --]

* On Power machines supporting VRMA, Kexec/Kdump does not work.
* Hypervisor stores VRMA mapping used by the OS, in the hpte hash tables.
* Make sure these hpte entries are left untouched.

Signed-off-by : Sachin Sant <sachinp@in.ibm.com>
Signed-off-by : Mohan Kumar M <mohan@in.ibm.com>
---

diff -Naurp linux-2.6.22-rc2-vrma/arch/powerpc/kernel/machine_kexec_64.c linux-2.6.22-rc2-p6/arch/powerpc/kernel/machine_kexec_64.c
--- linux-2.6.22-rc2-vrma/arch/powerpc/kernel/machine_kexec_64.c	2007-05-21 15:14:58.000000000 +0530
+++ linux-2.6.22-rc2-p6/arch/powerpc/kernel/machine_kexec_64.c	2007-05-21 15:19:14.000000000 +0530
@@ -279,6 +279,9 @@ void default_machine_kexec(struct kimage
 	kexec_stack.thread_info.task = current_thread_info()->task;
 	kexec_stack.thread_info.flags = 0;
 
+	if (have_vrma)
+		pSeries_find_hpte_vrma();
+
 	/* Some things are best done in assembly.  Finding globals with
 	 * a toc is easier in C, so pass in what we can.
 	 */
diff -Naurp linux-2.6.22-rc2-vrma/arch/powerpc/platforms/pseries/lpar.c linux-2.6.22-rc2-p6/arch/powerpc/platforms/pseries/lpar.c
--- linux-2.6.22-rc2-vrma/arch/powerpc/platforms/pseries/lpar.c	2007-05-21 15:14:57.000000000 +0530
+++ linux-2.6.22-rc2-p6/arch/powerpc/platforms/pseries/lpar.c	2007-05-22 15:53:11.000000000 +0530
@@ -369,6 +369,56 @@ static long pSeries_lpar_hpte_remove(uns
 	return -1;
 }
 
+unsigned long hpte_vrma_slots[HPTE_V_RMA_NUM];
+unsigned int num_hpte_vrma_slots = 0;
+
+void pSeries_find_hpte_vrma(void)
+{
+	unsigned int step;
+	unsigned long hash, slot, vaddr;
+	unsigned long dword0, dummy1, rma_size;
+	long lpar_rc;
+	int i;
+	
+	/* Get the RMA size */
+	rma_size = lmb.rmo_size;
+	
+	/* Get the VRMA page size */	
+	step = 1 << ppc64_vrma_page_size;
+
+	vaddr = HPTE_V_RMA_VPN + rma_size;
+
+	/* Find hpte's with VRMA mappings */
+	for (; vaddr >= HPTE_V_RMA_VPN; vaddr -= step) {
+		hash = hpt_hash(vaddr, mmu_psize_defs[MMU_PAGE_16M].shift);
+		slot = ((hash & htab_hash_mask) * HPTES_PER_GROUP);	
+
+		for (i = 0; i < HPTES_PER_GROUP; i++) {
+			lpar_rc = plpar_pte_read(0, slot, 
+						&dword0, &dummy1);
+			if (!lpar_rc && dword0 &&
+			((dword0 & HPTE_V_MASK) == MAGIC_SKIP_HPTE)) {
+				/* store the hpte */
+				hpte_vrma_slots[num_hpte_vrma_slots++] = slot;
+				break;
+			}
+			slot++;
+		}
+	}
+}
+
+static inline int check_vrma_slot(int slot)
+{
+	int j;
+
+	for (j = 0; j < num_hpte_vrma_slots; j++)
+		if (hpte_vrma_slots[j] == slot) 
+			return 1;
+
+	return 0;
+
+}
+
 static void pSeries_lpar_hptab_clear(void)
 {
 	unsigned long size_bytes = 1UL << ppc64_pft_size;
@@ -377,8 +427,12 @@ static void pSeries_lpar_hptab_clear(voi
 	int i;
 
 	/* TODO: Use bulk call */
-	for (i = 0; i < hpte_count; i++)
+	for (i = 0; i < hpte_count; i++) {
+		if (have_vrma && check_vrma_slot(i))
+			/* You don't want to remove this hpte */
+			continue;
 		plpar_pte_remove_raw(0, i, 0, &dummy1, &dummy2);
+	}
 }
 
 /*
diff -Naurp linux-2.6.22-rc2-vrma/include/asm-powerpc/kexec.h linux-2.6.22-rc2-p6/include/asm-powerpc/kexec.h
--- linux-2.6.22-rc2-vrma/include/asm-powerpc/kexec.h	2007-05-21 15:14:55.000000000 +0530
+++ linux-2.6.22-rc2-p6/include/asm-powerpc/kexec.h	2007-05-21 15:19:14.000000000 +0530
@@ -24,6 +24,8 @@
 
 #define KEXEC_CONTROL_CODE_SIZE 4096
 
+extern void pSeries_find_hpte_vrma(void);
+
 /* The native architecture */
 #ifdef __powerpc64__
 #define KEXEC_ARCH KEXEC_ARCH_PPC64
diff -Naurp linux-2.6.22-rc2-vrma/include/asm-powerpc/mmu-hash64.h linux-2.6.22-rc2-p6/include/asm-powerpc/mmu-hash64.h
--- linux-2.6.22-rc2-vrma/include/asm-powerpc/mmu-hash64.h	2007-05-21 15:14:55.000000000 +0530
+++ linux-2.6.22-rc2-p6/include/asm-powerpc/mmu-hash64.h	2007-05-21 15:23:31.000000000 +0530
@@ -94,6 +94,11 @@ extern char initial_stab[];
 #define HPTE_R_C		ASM_CONST(0x0000000000000080)
 #define HPTE_R_R		ASM_CONST(0x0000000000000100)
 
+#define HPTE_V_RMA_VPN         ASM_CONST(0x001FFFFFF0000000)
+#define HPTE_V_MASK            ASM_CONST(0xc000000000000000)
+#define MAGIC_SKIP_HPTE        ASM_CONST(0x4000000000000000)
+#define HPTE_V_RMA_NUM         16
+
 /* Values for PP (assumes Ks=0, Kp=1) */
 /* pp0 will always be 0 for linux     */
 #define PP_RWXX	0	/* Supervisor read/write, User none */

  reply	other threads:[~2007-05-22 12:26 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-22 12:22 [Patch 0/2] Kexec/Kdump support POWER6 Sachin P. Sant
2007-05-22 12:24 ` [Patch 1/2] " Sachin P. Sant
2007-05-22 12:26   ` Sachin P. Sant [this message]
2007-05-22 15:34     ` [Patch 2/2] " Olof Johansson
2007-05-23  5:13       ` Sachin P. Sant
2007-05-23  5:14       ` Sachin P. Sant
2007-05-23  9:37       ` [Patch 2/2] Kexec/Kdump support - POWER6 Sachin P. Sant
2007-05-23 10:55         ` Paul Mackerras
2007-05-24 12:17           ` Mohan Kumar M
2007-05-24 12:17             ` Mohan Kumar M
2007-05-24 14:21             ` Olof Johansson
2007-05-24 14:21               ` Olof Johansson
2007-05-25  8:55               ` [Patch ] " Sachin P. Sant
2007-05-25  8:55                 ` Sachin P. Sant
2007-05-25 22:43                 ` Benjamin Herrenschmidt
2007-05-25 22:43                   ` Benjamin Herrenschmidt
2007-05-28 11:40                   ` Sachin P. Sant
2007-05-28 11:40                     ` Sachin P. Sant
2007-05-28 21:31                     ` Benjamin Herrenschmidt
2007-05-28 21:31                       ` Benjamin Herrenschmidt
2007-05-29  6:18                       ` Sachin P. Sant
2007-05-29  6:18                         ` Sachin P. Sant
2007-05-29  6:58                         ` Benjamin Herrenschmidt
2007-05-29  6:58                           ` Benjamin Herrenschmidt
2007-05-29 10:14                     ` Michael Ellerman
2007-05-29 10:14                       ` Michael Ellerman
2007-05-29 11:06                       ` Stephen Rothwell
2007-05-29 11:06                         ` Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4652E17C.7080607@in.ibm.com \
    --to=sachinp@in.ibm.com \
    --cc=ellerman@au1.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@us.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.