Skip to contentSkip to conversation

scripts/decodecode: fix trapping instruction formatting

PATCH Applied Ivan Delalande 2 participants 2 messages Apr 19, 2020 – Apr 20, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scripts/decodecode: fix trapping instruction formatting

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")
---
 scripts/decodecode | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/decodecode +1 -1
index ba8b8d5834e6..fbdb325cdf4f 100755
@@ -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
Signature · 2 lines
Ivan Delalande
Arista Networks
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Ivan Delalande

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")
---
 scripts/decodecode | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/decodecode +0 -0
index ba8b8d5834e6..fbdb325cdf4f 100755

scripts/decodecode faultlinenum=$(( $(wc -l $T.oo | cut -d" " -f1) - \ · line 132

Quoted 8 lines
scripts/decodecode +1 -1
@@ -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.

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette