2021-02-11 03:22:26

by Nick Desaulniers

[permalink] [raw]
Subject: [PATCH v5 1/2] ARM: kprobes: fix UNPREDICTABLE warnings

GNU as warns twice for this file:
Warning: using r15 results in unpredictable behaviour

via the Arm ARM:
K1.1.1 Overview of the constraints on Armv7 UNPREDICTABLE behaviors

The term UNPREDICTABLE describes a number of cases where the
architecture has a feature that software must not use.

Link: https://github.com/ClangBuiltLinux/linux/issues/1271
Link: https://reviews.llvm.org/D95586
Reported-by: kernelci.org bot <[email protected]>
Suggested-by: Peter Smith <[email protected]>
Suggested-by: Renato Golin <[email protected]>
Suggested-by: David Spickett <[email protected]>
Signed-off-by: Nick Desaulniers <[email protected]>
---
arch/arm/probes/kprobes/test-arm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/probes/kprobes/test-arm.c b/arch/arm/probes/kprobes/test-arm.c
index 977369f1aa48..2543106a203e 100644
--- a/arch/arm/probes/kprobes/test-arm.c
+++ b/arch/arm/probes/kprobes/test-arm.c
@@ -166,10 +166,10 @@ void kprobe_arm_test_cases(void)

/* Data-processing with PC as a target and status registers updated */
TEST_UNSUPPORTED("movs pc, r1")
- TEST_UNSUPPORTED("movs pc, r1, lsl r2")
+ TEST_UNSUPPORTED(__inst_arm(0xe1b0f211) " @movs pc, r1, lsl r2")
TEST_UNSUPPORTED("movs pc, #0x10000")
TEST_UNSUPPORTED("adds pc, lr, r1")
- TEST_UNSUPPORTED("adds pc, lr, r1, lsl r2")
+ TEST_UNSUPPORTED(__inst_arm(0xe09ef211) " @adds pc, lr, r1, lsl r2")
TEST_UNSUPPORTED("adds pc, lr, #4")

/* Data-processing with SP as target */
--
2.30.0.478.g8a0d178c01-goog


2021-02-11 08:18:24

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] ARM: kprobes: fix UNPREDICTABLE warnings

On Thu, 11 Feb 2021 at 03:52, Nick Desaulniers <[email protected]> wrote:
>
> GNU as warns twice for this file:
> Warning: using r15 results in unpredictable behaviour
>
> via the Arm ARM:
> K1.1.1 Overview of the constraints on Armv7 UNPREDICTABLE behaviors
>
> The term UNPREDICTABLE describes a number of cases where the
> architecture has a feature that software must not use.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1271
> Link: https://reviews.llvm.org/D95586
> Reported-by: kernelci.org bot <[email protected]>
> Suggested-by: Peter Smith <[email protected]>
> Suggested-by: Renato Golin <[email protected]>
> Suggested-by: David Spickett <[email protected]>
> Signed-off-by: Nick Desaulniers <[email protected]>

Acked-by: Ard Biesheuvel <[email protected]>

But can we add a bit more context to the commit log, please? It is not
obvious to the casual reader why it is OK to emit UNPREDICTABLE
opcodes, i.e., that these are selftests that aim to ensure that kprobe
never attempts to replace the opcodes in question with a probe, but
that they are not actually executed, or expected to occur in real
code.

> ---
> arch/arm/probes/kprobes/test-arm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/probes/kprobes/test-arm.c b/arch/arm/probes/kprobes/test-arm.c
> index 977369f1aa48..2543106a203e 100644
> --- a/arch/arm/probes/kprobes/test-arm.c
> +++ b/arch/arm/probes/kprobes/test-arm.c
> @@ -166,10 +166,10 @@ void kprobe_arm_test_cases(void)
>
> /* Data-processing with PC as a target and status registers updated */
> TEST_UNSUPPORTED("movs pc, r1")
> - TEST_UNSUPPORTED("movs pc, r1, lsl r2")
> + TEST_UNSUPPORTED(__inst_arm(0xe1b0f211) " @movs pc, r1, lsl r2")
> TEST_UNSUPPORTED("movs pc, #0x10000")
> TEST_UNSUPPORTED("adds pc, lr, r1")
> - TEST_UNSUPPORTED("adds pc, lr, r1, lsl r2")
> + TEST_UNSUPPORTED(__inst_arm(0xe09ef211) " @adds pc, lr, r1, lsl r2")
> TEST_UNSUPPORTED("adds pc, lr, #4")
>
> /* Data-processing with SP as target */
> --
> 2.30.0.478.g8a0d178c01-goog
>

2021-02-11 19:09:34

by Nick Desaulniers

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] ARM: kprobes: fix UNPREDICTABLE warnings

On Thu, Feb 11, 2021 at 12:15 AM Ard Biesheuvel <[email protected]> wrote:
>
> On Thu, 11 Feb 2021 at 03:52, Nick Desaulniers <[email protected]> wrote:
> >
> > GNU as warns twice for this file:
> > Warning: using r15 results in unpredictable behaviour
> >
> > via the Arm ARM:
> > K1.1.1 Overview of the constraints on Armv7 UNPREDICTABLE behaviors
> >
> > The term UNPREDICTABLE describes a number of cases where the
> > architecture has a feature that software must not use.
> >
> > Link: https://github.com/ClangBuiltLinux/linux/issues/1271
> > Link: https://reviews.llvm.org/D95586
> > Reported-by: kernelci.org bot <[email protected]>
> > Suggested-by: Peter Smith <[email protected]>
> > Suggested-by: Renato Golin <[email protected]>
> > Suggested-by: David Spickett <[email protected]>
> > Signed-off-by: Nick Desaulniers <[email protected]>
>
> Acked-by: Ard Biesheuvel <[email protected]>
>
> But can we add a bit more context to the commit log, please? It is not

Sure, that's a good idea.

> obvious to the casual reader why it is OK to emit UNPREDICTABLE
> opcodes, i.e., that these are selftests that aim to ensure that kprobe
> never attempts to replace the opcodes in question with a probe, but
> that they are not actually executed, or expected to occur in real
> code.

I'll add:

Ard notes:
These are selftests that aim to ensure that kprobe
never attempts to replace the opcodes in question with a probe, but
they are not actually executed, or expected to occur in real
code.

to the commit message, when submitting to RMK's queue.

Thanks for taking a look and the feedback.

>
> > ---
> > arch/arm/probes/kprobes/test-arm.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/arch/arm/probes/kprobes/test-arm.c b/arch/arm/probes/kprobes/test-arm.c
> > index 977369f1aa48..2543106a203e 100644
> > --- a/arch/arm/probes/kprobes/test-arm.c
> > +++ b/arch/arm/probes/kprobes/test-arm.c
> > @@ -166,10 +166,10 @@ void kprobe_arm_test_cases(void)
> >
> > /* Data-processing with PC as a target and status registers updated */
> > TEST_UNSUPPORTED("movs pc, r1")
> > - TEST_UNSUPPORTED("movs pc, r1, lsl r2")
> > + TEST_UNSUPPORTED(__inst_arm(0xe1b0f211) " @movs pc, r1, lsl r2")
> > TEST_UNSUPPORTED("movs pc, #0x10000")
> > TEST_UNSUPPORTED("adds pc, lr, r1")
> > - TEST_UNSUPPORTED("adds pc, lr, r1, lsl r2")
> > + TEST_UNSUPPORTED(__inst_arm(0xe09ef211) " @adds pc, lr, r1, lsl r2")
> > TEST_UNSUPPORTED("adds pc, lr, #4")
> >
> > /* Data-processing with SP as target */
> > --
> > 2.30.0.478.g8a0d178c01-goog
> >



--
Thanks,
~Nick Desaulniers