From: olof@lixom.net (Olof Johansson)
To: "Sachin P. Sant" <sachinp@in.ibm.com>
Cc: linuxppc-dev@ozlabs.org, ellerman@au1.ibm.com,
Milton Miller II <miltonm@us.ibm.com>
Subject: Re: [Patch 2/2] Kexec/Kdump support POWER6
Date: Tue, 22 May 2007 10:34:19 -0500 [thread overview]
Message-ID: <20070522153419.GA22047@lixom.net> (raw)
In-Reply-To: <4652E17C.7080607@in.ibm.com>
Hi,
On Tue, May 22, 2007 at 05:56:36PM +0530, Sachin P. Sant wrote:
> 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.
> 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();
> +
This will break kexec builds on non-pseries. It's referring to platform
code that might not be built.
> /* 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)
Does this function find the vrma, or save it away? Seems like the name
is misleading.
> +{
> + 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;
Is ppc64_vrma_page_size really the size, or the shift? Above would
indicate that it's really a shift value.
> +
> + 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);
Why is 16M hardcoded here, when you're taking such great care to read
out the pagesize earlier?
> + 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)) {
Indentation
> + /* store the hpte */
> + hpte_vrma_slots[num_hpte_vrma_slots++] = slot;
Here you rely on global exported state (num_hpte_vrma_slots), increasing it without
checking for limits. What happens if this function is ever called twice? Should you
set it to 0 in the beginning of the function and check it against the size of the
hpte_vrma_slots array instead?
> + 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);
> +
Same comment as above: This isn't a kexec function as much as a pseries function, so
it should be defined in some other header instead.
> /* 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
"MAGIC_SKIP_HPTE"? I'm sure there's a proper name for this field in the
PAPR, isn't there? Also, HPTE_V_RMA_NUM isn't a HPTE_V field, it shouldn't
have that prefix. It's not a property of the mmu in the first place.
These should maybe be local defines in the pseries lpar code instead, since it's
more of a lpar<->phyp interface than mmu programming interface.
-Olof
next prev parent reply other threads:[~2007-05-22 15:30 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 ` [Patch 2/2] " Sachin P. Sant
2007-05-22 15:34 ` Olof Johansson [this message]
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=20070522153419.GA22047@lixom.net \
--to=olof@lixom.net \
--cc=ellerman@au1.ibm.com \
--cc=linuxppc-dev@ozlabs.org \
--cc=miltonm@us.ibm.com \
--cc=sachinp@in.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.