Hi Again,
On 05/22/2019 06:14 AM, Christophe Leroy wrote:
Hi Aero,
Le 22/05/2019 à 00:18, Aaro Koskinen a écrit :
Hi,
I was trying to upgrade from v5.0 -> v5.1 on PowerBook G4, but when
trying
to kexec a kernel the system gets stuck (no errors seen on the console).
Do you mean you are trying to kexec a v5.1 kernel from a v5.0 kernel, or
do you have a working v5.1 kernel, but kexec doesn't work with it ?
Bisected to: 93c4a162b014 ("powerpc/6xx: Store PGDIR physical address
in a SPRG"). This commit doesn't revert cleanly anymore but I tested
that the one before works OK.
Not sure that's the problem. There was a problem with that commit, but
it was fixed by 4622a2d43101 ("powerpc/6xx: fix setup and use of
SPRN_SPRG_PGDIR for hash32").
You probably hit some commit between those two during bisect, that's
likely the reason why you ended here.
Can you restart your bisect from 4622a2d43101 ?
If you have CONFIG_SMP, maybe you should also consider taking
397d2300b08c ("powerpc/32s: fix flush_hash_pages() on SMP"). Stable
5.1.4 includes it.
With current Linus HEAD (9c7db5004280), it gets a bit further but still
doesn't work: now I get an error on the console after kexec "Starting
new kernel! ... Bye!":
kernel tried to execute exec-protected page (...) - exploit attempt?
Interesting.
Do you have CONFIG_STRICT_KERNEL_RWX=y in your .config ? If so, can you
retry without it ?
After looking at the code, I don't thing CONFIG_STRICT_KERNEL_RWX will
make any difference. Can you try the patch below ?
From 8c1039da0d0f26cdf995156a905fc97fe7bda36c Mon Sep 17 00:00:00 2001
From: Christophe Leroy <christophe.le...@c-s.fr>
Date: Wed, 22 May 2019 07:28:42 +0000
Subject: [PATCH] Fix Kexec
---
arch/powerpc/include/asm/pgtable.h | 2 ++
arch/powerpc/kernel/machine_kexec_32.c | 4 ++++
arch/powerpc/mm/pgtable_32.c | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/pgtable.h
b/arch/powerpc/include/asm/pgtable.h
index 3f53be60fb01..642eea937229 100644
--- a/arch/powerpc/include/asm/pgtable.h
+++ b/arch/powerpc/include/asm/pgtable.h
@@ -140,6 +140,8 @@ static inline void pte_frag_set(mm_context_t *ctx,
void *p)
}
#endif
+int change_page_attr(struct page *page, int numpages, pgprot_t prot);
+
#endif /* __ASSEMBLY__ */
#endif /* _ASM_POWERPC_PGTABLE_H */
diff --git a/arch/powerpc/kernel/machine_kexec_32.c
b/arch/powerpc/kernel/machine_kexec_32.c
index affe5dcce7f4..4f719501e6ae 100644
--- a/arch/powerpc/kernel/machine_kexec_32.c
+++ b/arch/powerpc/kernel/machine_kexec_32.c
@@ -54,6 +54,10 @@ void default_machine_kexec(struct kimage *image)
memcpy((void *)reboot_code_buffer, relocate_new_kernel,
relocate_new_kernel_size);
+ change_page_attr(image->control_code_page,
+ ALIGN(KEXEC_CONTROL_PAGE_SIZE, PAGE_SIZE) >>
PAGE_SHIFT,
+ PAGE_KERNEL_TEXT);
+
flush_icache_range(reboot_code_buffer,
reboot_code_buffer + KEXEC_CONTROL_PAGE_SIZE);
printk(KERN_INFO "Bye!\n");
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 16ada373b32b..0e4651d803fc 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -340,7 +340,7 @@ static int __change_page_attr_noflush(struct page
*page, pgprot_t prot)
*
* THIS DOES NOTHING WITH BAT MAPPINGS, DEBUG USE ONLY
*/
-static int change_page_attr(struct page *page, int numpages, pgprot_t prot)
+int change_page_attr(struct page *page, int numpages, pgprot_t prot)
{
int i, err = 0;
unsigned long flags;
--
2.13.3