* [PATCH] arm64: fix endianness annotation for 'struct jit_ctx' and friends
@ 2017-06-28 14:58 Luc Van Oostenryck
2017-06-29 10:08 ` Will Deacon
0 siblings, 1 reply; 3+ messages in thread
From: Luc Van Oostenryck @ 2017-06-28 14:58 UTC (permalink / raw)
To: linux-arm-kernel
struct jit_ctx::image is used the store a pointer to the jitted
intructions, which are always little-endian. These instructions
are thus correctly converted from native order to little-endian
before being stored but the pointer 'image' is declared as for
native order values.
Fix this by declaring the field as __le32* instead of u32*.
Same for the pointer used in jit_fill_hole() to initialize
the image.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
arch/arm64/net/bpf_jit_comp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index c870d6f01..8860bb9c3 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -70,7 +70,7 @@ struct jit_ctx {
int idx;
int epilogue_offset;
int *offset;
- u32 *image;
+ __le32 *image;
};
static inline void emit(const u32 insn, struct jit_ctx *ctx)
@@ -130,7 +130,7 @@ static inline int bpf2a64_offset(int bpf_to, int bpf_from,
static void jit_fill_hole(void *area, unsigned int size)
{
- u32 *ptr;
+ __le32 *ptr;
/* We are guaranteed to have aligned memory. */
for (ptr = area; size >= sizeof(u32); size -= sizeof(u32))
*ptr++ = cpu_to_le32(AARCH64_BREAK_FAULT);
@@ -874,7 +874,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
/* 2. Now, the actual pass. */
- ctx.image = (u32 *)image_ptr;
+ ctx.image = (__le32 *)image_ptr;
ctx.idx = 0;
build_prologue(&ctx);
--
2.13.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] arm64: fix endianness annotation for 'struct jit_ctx' and friends
2017-06-28 14:58 [PATCH] arm64: fix endianness annotation for 'struct jit_ctx' and friends Luc Van Oostenryck
@ 2017-06-29 10:08 ` Will Deacon
2017-06-29 14:55 ` Luc Van Oostenryck
0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2017-06-29 10:08 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Jun 28, 2017 at 04:58:03PM +0200, Luc Van Oostenryck wrote:
> struct jit_ctx::image is used the store a pointer to the jitted
> intructions, which are always little-endian. These instructions
> are thus correctly converted from native order to little-endian
> before being stored but the pointer 'image' is declared as for
> native order values.
>
> Fix this by declaring the field as __le32* instead of u32*.
> Same for the pointer used in jit_fill_hole() to initialize
> the image.
>
> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
> ---
> arch/arm64/net/bpf_jit_comp.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Happy to take this via the arm64 tree, along with the other sparse fixes
(modulo review comments).
Ok with you, David?
Will
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] arm64: fix endianness annotation for 'struct jit_ctx' and friends
2017-06-29 10:08 ` Will Deacon
@ 2017-06-29 14:55 ` Luc Van Oostenryck
0 siblings, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2017-06-29 14:55 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jun 29, 2017 at 11:08:36AM +0100, Will Deacon wrote:
> Happy to take this via the arm64 tree, along with the other sparse fixes
> (modulo review comments).
For info, together with the other endianness fixes I sent, this
fixes all the 'easy to fix' endianness annotations.
It remains:
- 2 or 3 small issues, just needing a cast, maybe with __force.
- Problems with probes. Those could probably be fixed
by redefining [k]probe_opcode_t as __le32 instead of u32
but I didn't looked at the consequences.
- 3 or 4 'impossible to solve properly by design' where things
like the following is done:
if (kvm_vcpu_is_be(vcpu)) {
switch (len) {
case 1:
return data & 0xff;
case 2:
return be16_to_cpu(data & 0xffff);
case 4:
return be32_to_cpu(data & 0xffffffff);
default:
return be64_to_cpu(data);
}
} else {
...
This is done for kvm emulate & the kvm vgics
Cheers,
-- Luc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-29 14:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-28 14:58 [PATCH] arm64: fix endianness annotation for 'struct jit_ctx' and friends Luc Van Oostenryck
2017-06-29 10:08 ` Will Deacon
2017-06-29 14:55 ` Luc Van Oostenryck
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).