powerpc fixes for 5.16 #4
Fix a recently introduced oops at boot on 85xx in some configurations. Fix crashes when loading some livepatch modules with STRICT_MODULE_RWX. Thanks to: Joe Lawrence, Russell Currey, Xiaoming Ni. -----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmG+q+UTHG1wZUBlbGxl cm1hbi5pZC5hdQAKCRBR6+o8yOGlgG5sEACVsb39+Q8w0GKJxUGR0Wri1InJTkLC UWpd9PVzG6n8+Epl0f+H5cMlv5V6xaDzTsNXEf27xIACMlPSVHVLDW8u/RFPizdp fUDUweGUvK/M0GQW89nRV29DjdNjMmUq1KQFM6eEgYN/0nS3HqF27jamiaFhiZ+e pJl1g2dy/DTWrFz3V/8b0nv6kyJE8GlpnCmTchDsPNDbzWQVJXVfM7IB/9N+EVna MQAZCyKSOafTgNRPOW+Sm4oF64z+Yn4cxURVKfzbM+0Cd8pNIcGZ7McXrnp0DR4t bLGeYEzyR1bPc3VTt7b+jafDP41AakRllKAFz65+pdYOcV1hTRM4inbLVPT5Bmz6 7ANlX/w4BwYWFk3mWW14BoxU02FlRKRddXhusq7x2wIqvtn1KI8Qm1xpneiGpcW+ GEe+k9ONGowXp/bc47/Co6dPSHKRRHUC3MsgbDv2Y7M5G9vsetckdQzA2bIqYSx8 r1ZXNiMwQarPeB6FrGvNbekyCsIhJkk6chhtL0k27BVOFqYiHZtaqBs+RCQYPdC8 Aih8WOEqdldbItFI3MihyKULucgkVpdnm80Ja67qRthuJICF9OML3mdrt83bxEIp fu4Bsw8dygVKJWScZj8AUC/ZBxOrrTGyZR1RvsHpaAiEfinMkxxTnXjqNDiSZWXt DKKLx6pfSFrokw== =Nmp5 -----END PGP SIGNATURE----- Merge tag 'powerpc-5.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux Pull powerpc fixes from Michael Ellerman: "Fix a recently introduced oops at boot on 85xx in some configurations. Fix crashes when loading some livepatch modules with STRICT_MODULE_RWX. Thanks to Joe Lawrence, Russell Currey, and Xiaoming Ni" * tag 'powerpc-5.16-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/module_64: Fix livepatching for RO modules powerpc/85xx: Fix oops when CONFIG_FSL_PMC=n
This commit is contained in:
commit
713ab911f2
|
@ -422,11 +422,17 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
|
|||
const char *name)
|
||||
{
|
||||
long reladdr;
|
||||
func_desc_t desc;
|
||||
int i;
|
||||
|
||||
if (is_mprofile_ftrace_call(name))
|
||||
return create_ftrace_stub(entry, addr, me);
|
||||
|
||||
memcpy(entry->jump, ppc64_stub_insns, sizeof(ppc64_stub_insns));
|
||||
for (i = 0; i < sizeof(ppc64_stub_insns) / sizeof(u32); i++) {
|
||||
if (patch_instruction(&entry->jump[i],
|
||||
ppc_inst(ppc64_stub_insns[i])))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Stub uses address relative to r2. */
|
||||
reladdr = (unsigned long)entry - my_r2(sechdrs, me);
|
||||
|
@ -437,10 +443,24 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
|
|||
}
|
||||
pr_debug("Stub %p get data from reladdr %li\n", entry, reladdr);
|
||||
|
||||
entry->jump[0] |= PPC_HA(reladdr);
|
||||
entry->jump[1] |= PPC_LO(reladdr);
|
||||
entry->funcdata = func_desc(addr);
|
||||
entry->magic = STUB_MAGIC;
|
||||
if (patch_instruction(&entry->jump[0],
|
||||
ppc_inst(entry->jump[0] | PPC_HA(reladdr))))
|
||||
return 0;
|
||||
|
||||
if (patch_instruction(&entry->jump[1],
|
||||
ppc_inst(entry->jump[1] | PPC_LO(reladdr))))
|
||||
return 0;
|
||||
|
||||
// func_desc_t is 8 bytes if ABIv2, else 16 bytes
|
||||
desc = func_desc(addr);
|
||||
for (i = 0; i < sizeof(func_desc_t) / sizeof(u32); i++) {
|
||||
if (patch_instruction(((u32 *)&entry->funcdata) + i,
|
||||
ppc_inst(((u32 *)(&desc))[i])))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (patch_instruction(&entry->magic, ppc_inst(STUB_MAGIC)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -495,8 +515,11 @@ static int restore_r2(const char *name, u32 *instruction, struct module *me)
|
|||
me->name, *instruction, instruction);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ld r2,R2_STACK_OFFSET(r1) */
|
||||
*instruction = PPC_INST_LD_TOC;
|
||||
if (patch_instruction(instruction, ppc_inst(PPC_INST_LD_TOC)))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -636,9 +659,12 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
|
|||
}
|
||||
|
||||
/* Only replace bits 2 through 26 */
|
||||
*(uint32_t *)location
|
||||
= (*(uint32_t *)location & ~0x03fffffc)
|
||||
value = (*(uint32_t *)location & ~0x03fffffc)
|
||||
| (value & 0x03fffffc);
|
||||
|
||||
if (patch_instruction((u32 *)location, ppc_inst(value)))
|
||||
return -EFAULT;
|
||||
|
||||
break;
|
||||
|
||||
case R_PPC64_REL64:
|
||||
|
|
|
@ -220,7 +220,7 @@ static int smp_85xx_start_cpu(int cpu)
|
|||
local_irq_save(flags);
|
||||
hard_irq_disable();
|
||||
|
||||
if (qoriq_pm_ops)
|
||||
if (qoriq_pm_ops && qoriq_pm_ops->cpu_up_prepare)
|
||||
qoriq_pm_ops->cpu_up_prepare(cpu);
|
||||
|
||||
/* if cpu is not spinning, reset it */
|
||||
|
@ -292,7 +292,7 @@ static int smp_85xx_kick_cpu(int nr)
|
|||
booting_thread_hwid = cpu_thread_in_core(nr);
|
||||
primary = cpu_first_thread_sibling(nr);
|
||||
|
||||
if (qoriq_pm_ops)
|
||||
if (qoriq_pm_ops && qoriq_pm_ops->cpu_up_prepare)
|
||||
qoriq_pm_ops->cpu_up_prepare(nr);
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue