linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: "Sachin P. Sant" <sachinp@in.ibm.com>
To: Olof Johansson <olof@lixom.net>, Paul Mackerras <paulus@samba.org>
Cc: linuxppc-dev@ozlabs.org, ellerman@au1.ibm.com,
	Milton Miller II <miltonm@us.ibm.com>
Subject: [Patch 2/2] Kexec/Kdump support - POWER6
Date: Wed, 23 May 2007 15:07:51 +0530	[thread overview]
Message-ID: <46540B6F.6030300@in.ibm.com> (raw)
In-Reply-To: <20070522153419.GA22047@lixom.net>

[-- Attachment #1: Type: text/plain, Size: 287 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.

This patch also adds plpar_pte_read_raw() on the lines of 
plpar_pte_remove_raw().

Thanks
-Sachin





[-- Attachment #2: kexec-kdump-support-on-POWER6 --]
[-- Type: text/plain, Size: 3525 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/platforms/pseries/lpar.c linux-2.6.22-rc2-kexec/arch/powerpc/platforms/pseries/lpar.c
--- linux-2.6.22-rc2-vrma/arch/powerpc/platforms/pseries/lpar.c	2007-05-19 09:36:17.000000000 +0530
+++ linux-2.6.22-rc2-kexec/arch/powerpc/platforms/pseries/lpar.c	2007-05-23 13:47:54.000000000 +0530
@@ -369,6 +369,62 @@ static long pSeries_lpar_hpte_remove(uns
 	return -1;
 }
 
+#define VRMA_VPN        ASM_CONST(0x001FFFFFF0000000)
+#define VRMA_MASK       ASM_CONST(0xc000000000000000)
+#define VRMA_HPTE_B_1TB ASM_CONST(0x4000000000000000)
+#define VRMA_NUM        16
+
+unsigned long hpte_vrma_slots[VRMA_NUM];
+unsigned int num_hpte_vrma_slots = 0;
+
+static void pSeries_save_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_shift;
+
+	vaddr = VRMA_VPN + rma_size;
+
+	/* Find hpte's with VRMA mappings */
+	for (; vaddr >= VRMA_VPN; vaddr -= step) {
+		hash = hpt_hash(vaddr, ppc64_vrma_page_shift);
+		slot = ((hash & htab_hash_mask) * HPTES_PER_GROUP);	
+
+		for (i = 0; i < HPTES_PER_GROUP; i++) {
+			lpar_rc = plpar_pte_read_raw(0, slot, 
+						&dword0, &dummy1);
+			if (!lpar_rc && dword0 &&
+				((dword0 & VRMA_MASK) == VRMA_HPTE_B_1TB) &&
+				(num_hpte_vrma_slots < VRMA_NUM)) {
+				/* 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;
@@ -376,9 +432,16 @@ static void pSeries_lpar_hptab_clear(voi
 	unsigned long dummy1, dummy2;
 	int i;
 
+	if (have_vrma)
+		pSeries_save_hpte_vrma();
+
 	/* 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/arch/powerpc/platforms/pseries/plpar_wrappers.h linux-2.6.22-rc2-kexec/arch/powerpc/platforms/pseries/plpar_wrappers.h
--- linux-2.6.22-rc2-vrma/arch/powerpc/platforms/pseries/plpar_wrappers.h	2007-05-19 09:36:17.000000000 +0530
+++ linux-2.6.22-rc2-kexec/arch/powerpc/platforms/pseries/plpar_wrappers.h	2007-05-23 11:38:12.000000000 +0530
@@ -108,6 +108,21 @@ static inline long plpar_pte_read(unsign
 	return rc;
 }
 
+/* plpar_pte_read_raw can be called in real mode. It calls plpar_hcall_raw */
+static inline long plpar_pte_read_raw(unsigned long flags, unsigned long ptex,
+		unsigned long *old_pteh_ret, unsigned long *old_ptel_ret)
+{
+	long rc;
+	unsigned long retbuf[PLPAR_HCALL_BUFSIZE];
+
+	rc = plpar_hcall_raw(H_READ, retbuf, flags, ptex);
+
+	*old_pteh_ret = retbuf[0];
+	*old_ptel_ret = retbuf[1];
+
+	return rc;
+}
+
 static inline long plpar_pte_protect(unsigned long flags, unsigned long ptex,
 		unsigned long avpn)
 {

  parent reply	other threads:[~2007-05-23  9:37 UTC|newest]

Thread overview: 18+ 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   ` [Patch 2/2] " Sachin P. Sant
2007-05-22 15:34     ` Olof Johansson
2007-05-23  5:13       ` Sachin P. Sant
2007-05-23  5:14       ` Sachin P. Sant
2007-05-23  9:37       ` Sachin P. Sant [this message]
2007-05-23 10:55         ` [Patch 2/2] Kexec/Kdump support - POWER6 Paul Mackerras
2007-05-24 12:17           ` Mohan Kumar M
2007-05-24 14:21             ` Olof Johansson
2007-05-25  8:55               ` [Patch ] " Sachin P. Sant
2007-05-25 22:43                 ` Benjamin Herrenschmidt
2007-05-28 11:40                   ` Sachin P. Sant
2007-05-28 21:31                     ` Benjamin Herrenschmidt
2007-05-29  6:18                       ` Sachin P. Sant
2007-05-29  6:58                         ` Benjamin Herrenschmidt
2007-05-29 10:14                     ` Michael Ellerman
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=46540B6F.6030300@in.ibm.com \
    --to=sachinp@in.ibm.com \
    --cc=ellerman@au1.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miltonm@us.ibm.com \
    --cc=olof@lixom.net \
    --cc=paulus@samba.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).