* 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 Signed-off-by : Mohan Kumar M --- 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) {