* [PATCH 1/2] powerpc: make kernel module helper endian-safe.
@ 2013-09-20 18:42 Eugene Surovegin
2013-09-20 18:42 ` [PATCH 2/2] powerpc: make ftrace endian-safe Eugene Surovegin
2013-09-23 8:34 ` [PATCH 1/2] powerpc: make kernel module helper endian-safe David Laight
0 siblings, 2 replies; 4+ messages in thread
From: Eugene Surovegin @ 2013-09-20 18:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Anton Blanchard
Signed-off-by: Eugene Surovegin <surovegin@google.com>
---
arch/powerpc/kernel/module_64.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 6ee59a0..a102f44 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -62,6 +62,16 @@ struct ppc64_stub_entry
r2) into the stub. */
static struct ppc64_stub_entry ppc64_stub =
{ .jump = {
+#ifdef __LITTLE_ENDIAN__
+ 0x00, 0x00, 0x82, 0x3d, /* addis r12,r2, <high> */
+ 0x00, 0x00, 0x8c, 0x39, /* addi r12,r12, <low> */
+ /* Save current r2 value in magic place on the stack. */
+ 0x28, 0x00, 0x41, 0xf8, /* std r2,40(r1) */
+ 0x20, 0x00, 0x6c, 0xe9, /* ld r11,32(r12) */
+ 0x28, 0x00, 0x4c, 0xe8, /* ld r2,40(r12) */
+ 0xa6, 0x03, 0x69, 0x7d, /* mtctr r11 */
+ 0x20, 0x04, 0x80, 0x4e /* bctr */
+#else
0x3d, 0x82, 0x00, 0x00, /* addis r12,r2, <high> */
0x39, 0x8c, 0x00, 0x00, /* addi r12,r12, <low> */
/* Save current r2 value in magic place on the stack. */
@@ -70,6 +80,7 @@ static struct ppc64_stub_entry ppc64_stub =
0xe8, 0x4c, 0x00, 0x28, /* ld r2,40(r12) */
0x7d, 0x69, 0x03, 0xa6, /* mtctr r11 */
0x4e, 0x80, 0x04, 0x20 /* bctr */
+#endif
} };
/* Count how many different 24-bit relocations (different symbol,
@@ -269,8 +280,13 @@ static inline int create_stub(Elf64_Shdr *sechdrs,
*entry = ppc64_stub;
+#ifdef __LITTLE_ENDIAN__
+ loc1 = (Elf64_Half *)&entry->jump[0];
+ loc2 = (Elf64_Half *)&entry->jump[4];
+#else
loc1 = (Elf64_Half *)&entry->jump[2];
loc2 = (Elf64_Half *)&entry->jump[6];
+#endif
/* Stub uses address relative to r2. */
reladdr = (unsigned long)entry - my_r2(sechdrs, me);
--
1.8.1.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] powerpc: make ftrace endian-safe.
2013-09-20 18:42 [PATCH 1/2] powerpc: make kernel module helper endian-safe Eugene Surovegin
@ 2013-09-20 18:42 ` Eugene Surovegin
2013-09-23 8:33 ` David Laight
2013-09-23 8:34 ` [PATCH 1/2] powerpc: make kernel module helper endian-safe David Laight
1 sibling, 1 reply; 4+ messages in thread
From: Eugene Surovegin @ 2013-09-20 18:42 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Anton Blanchard
Signed-off-by: Eugene Surovegin <surovegin@google.com>
---
arch/powerpc/kernel/ftrace.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 1fb7856..9b27b29 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -174,7 +174,11 @@ __ftrace_make_nop(struct module *mod,
pr_devel(" %08x %08x\n", jmp[0], jmp[1]);
+#ifdef __LITTLE_ENDIAN__
+ ptr = ((unsigned long)jmp[1] << 32) + jmp[0];
+#else
ptr = ((unsigned long)jmp[0] << 32) + jmp[1];
+#endif
/* This should match what was called */
if (ptr != ppc_function_entry((void *)addr)) {
--
1.8.1.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH 2/2] powerpc: make ftrace endian-safe.
2013-09-20 18:42 ` [PATCH 2/2] powerpc: make ftrace endian-safe Eugene Surovegin
@ 2013-09-23 8:33 ` David Laight
0 siblings, 0 replies; 4+ messages in thread
From: David Laight @ 2013-09-23 8:33 UTC (permalink / raw)
To: Eugene Surovegin, linuxppc-dev; +Cc: Anton Blanchard
> --- a/arch/powerpc/kernel/ftrace.c
> +++ b/arch/powerpc/kernel/ftrace.c
> @@ -174,7 +174,11 @@ __ftrace_make_nop(struct module *mod,
>=20
> pr_devel(" %08x %08x\n", jmp[0], jmp[1]);
>=20
> +#ifdef __LITTLE_ENDIAN__
> + ptr =3D ((unsigned long)jmp[1] << 32) + jmp[0];
> +#else
> ptr =3D ((unsigned long)jmp[0] << 32) + jmp[1];
> +#endif
>=20
Why not just:
ptr =3D *(__u64 *)jmp;
Or, if alignment isn't guaranteed, something that is
equivalent to:
ptr =3D *(__u64 __attribute__((aligned(4))) *)jmp;
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 1/2] powerpc: make kernel module helper endian-safe.
2013-09-20 18:42 [PATCH 1/2] powerpc: make kernel module helper endian-safe Eugene Surovegin
2013-09-20 18:42 ` [PATCH 2/2] powerpc: make ftrace endian-safe Eugene Surovegin
@ 2013-09-23 8:34 ` David Laight
1 sibling, 0 replies; 4+ messages in thread
From: David Laight @ 2013-09-23 8:34 UTC (permalink / raw)
To: Eugene Surovegin, linuxppc-dev; +Cc: Anton Blanchard
> --- a/arch/powerpc/kernel/module_64.c
> +++ b/arch/powerpc/kernel/module_64.c
> @@ -62,6 +62,16 @@ struct ppc64_stub_entry
> r2) into the stub. */
> static struct ppc64_stub_entry ppc64_stub =3D
> { .jump =3D {
> +#ifdef __LITTLE_ENDIAN__
> + 0x00, 0x00, 0x82, 0x3d, /* addis r12,r2, <high> */
> + 0x00, 0x00, 0x8c, 0x39, /* addi r12,r12, <low> */
> + /* Save current r2 value in magic place on the stack. */
> + 0x28, 0x00, 0x41, 0xf8, /* std r2,40(r1) */
> + 0x20, 0x00, 0x6c, 0xe9, /* ld r11,32(r12) */
> + 0x28, 0x00, 0x4c, 0xe8, /* ld r2,40(r12) */
> + 0xa6, 0x03, 0x69, 0x7d, /* mtctr r11 */
> + 0x20, 0x04, 0x80, 0x4e /* bctr */
> +#else
> 0x3d, 0x82, 0x00, 0x00, /* addis r12,r2, <high> */
> 0x39, 0x8c, 0x00, 0x00, /* addi r12,r12, <low> */
> /* Save current r2 value in magic place on the stack. */
> @@ -70,6 +80,7 @@ static struct ppc64_stub_entry ppc64_stub =3D
> 0xe8, 0x4c, 0x00, 0x28, /* ld r2,40(r12) */
> 0x7d, 0x69, 0x03, 0xa6, /* mtctr r11 */
> 0x4e, 0x80, 0x04, 0x20 /* bctr */
> +#endif
Seems to me that should be a list of 32bit constants.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-09-23 8:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-20 18:42 [PATCH 1/2] powerpc: make kernel module helper endian-safe Eugene Surovegin
2013-09-20 18:42 ` [PATCH 2/2] powerpc: make ftrace endian-safe Eugene Surovegin
2013-09-23 8:33 ` David Laight
2013-09-23 8:34 ` [PATCH 1/2] powerpc: make kernel module helper endian-safe David Laight
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).