* [PATCH] scripts/decodecode: fix trapping instruction formatting
@ 2020-04-19 22:36 Ivan Delalande
2020-04-20 8:59 ` Borislav Petkov
0 siblings, 1 reply; 2+ messages in thread
From: Ivan Delalande @ 2020-04-19 22:36 UTC (permalink / raw)
To: Andrew Morton; +Cc: Borislav Petkov, linux-kernel
If the trapping instruction contains a ':', for a memory access through
segment registers for example, the sed substitution will insert the '*'
marker in the middle of the instruction instead of the line address:
2b: 65 48 0f c7 0f cmpxchg16b %gs:*(%rdi) <-- trapping instruction
I started to think I had forgotten some quirk of the assembly syntax
before noticing that it was actually coming from the script. Fix it to
add the address marker at the right place for these instructions:
28: 49 8b 06 mov (%r14),%rax
2b:* 65 48 0f c7 0f cmpxchg16b %gs:(%rdi) <-- trapping instruction
30: 0f 94 c0 sete %al
Fixes: 18ff44b189e2 ("scripts/decodecode: make faulting insn ptr more robust")
Signed-off-by: Ivan Delalande <colona@arista.com>
---
scripts/decodecode | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/decodecode b/scripts/decodecode
index ba8b8d5834e6..fbdb325cdf4f 100755
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -126,7 +126,7 @@ faultlinenum=$(( $(wc -l $T.oo | cut -d" " -f1) - \
faultline=`cat $T.dis | head -1 | cut -d":" -f2-`
faultline=`echo "$faultline" | sed -e 's/\[/\\\[/g; s/\]/\\\]/g'`
-cat $T.oo | sed -e "${faultlinenum}s/^\(.*:\)\(.*\)/\1\*\2\t\t<-- trapping instruction/"
+cat $T.oo | sed -e "${faultlinenum}s/^\([^:]*:\)\(.*\)/\1\*\2\t\t<-- trapping instruction/"
echo
cat $T.aa
cleanup
--
Ivan Delalande
Arista Networks
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] scripts/decodecode: fix trapping instruction formatting
2020-04-19 22:36 [PATCH] scripts/decodecode: fix trapping instruction formatting Ivan Delalande
@ 2020-04-20 8:59 ` Borislav Petkov
0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2020-04-20 8:59 UTC (permalink / raw)
To: Ivan Delalande; +Cc: Andrew Morton, linux-kernel
On Sun, Apr 19, 2020 at 03:36:53PM -0700, Ivan Delalande wrote:
> If the trapping instruction contains a ':', for a memory access through
> segment registers for example, the sed substitution will insert the '*'
> marker in the middle of the instruction instead of the line address:
>
> 2b: 65 48 0f c7 0f cmpxchg16b %gs:*(%rdi) <-- trapping instruction
>
> I started to think I had forgotten some quirk of the assembly syntax
> before noticing that it was actually coming from the script. Fix it to
> add the address marker at the right place for these instructions:
>
> 28: 49 8b 06 mov (%r14),%rax
> 2b:* 65 48 0f c7 0f cmpxchg16b %gs:(%rdi) <-- trapping instruction
> 30: 0f 94 c0 sete %al
>
> Fixes: 18ff44b189e2 ("scripts/decodecode: make faulting insn ptr more robust")
> Signed-off-by: Ivan Delalande <colona@arista.com>
> ---
> scripts/decodecode | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/decodecode b/scripts/decodecode
> index ba8b8d5834e6..fbdb325cdf4f 100755
> --- a/scripts/decodecode
> +++ b/scripts/decodecode
> @@ -126,7 +126,7 @@ faultlinenum=$(( $(wc -l $T.oo | cut -d" " -f1) - \
> faultline=`cat $T.dis | head -1 | cut -d":" -f2-`
> faultline=`echo "$faultline" | sed -e 's/\[/\\\[/g; s/\]/\\\]/g'`
>
> -cat $T.oo | sed -e "${faultlinenum}s/^\(.*:\)\(.*\)/\1\*\2\t\t<-- trapping instruction/"
> +cat $T.oo | sed -e "${faultlinenum}s/^\([^:]*:\)\(.*\)/\1\*\2\t\t<-- trapping instruction/"
> echo
> cat $T.aa
> cleanup
> --
Nice catch, thanks.
Reviewed-by: Borislav Petkov <bp@suse.de>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-20 9:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-19 22:36 [PATCH] scripts/decodecode: fix trapping instruction formatting Ivan Delalande
2020-04-20 8:59 ` Borislav Petkov
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).