linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64
@ 2021-03-05 18:39 Andy Shevchenko
  2021-03-05 22:19 ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-03-05 18:39 UTC (permalink / raw)
  To: Borislav Petkov, linux-kernel; +Cc: Andrew Morton, Andy Shevchenko

On x86_64 host the objdump uses current architecture which is 64-bit
and hence decodecode shows wrong instructions.

Fix it by supplying '-M i386' in case of ARCH i?86 or x86.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 scripts/decodecode | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/scripts/decodecode b/scripts/decodecode
index 31d884e35f2f..020a84982249 100755
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -75,21 +75,25 @@ disas() {
 
 	${CROSS_COMPILE}as $AFLAGS -o $t.o $t.s > /dev/null 2>&1
 
-	if [ "$ARCH" = "arm" ]; then
+	case "$ARCH" in
+	arm)
 		if [ $width -eq 2 ]; then
 			OBJDUMPFLAGS="-M force-thumb"
 		fi
 
 		${CROSS_COMPILE}strip $t.o
-	fi
-
-	if [ "$ARCH" = "arm64" ]; then
+		;;
+	arm64)
 		if [ $width -eq 4 ]; then
 			type=inst
 		fi
 
 		${CROSS_COMPILE}strip $t.o
-	fi
+		;;
+	i?86|x86)
+			OBJDUMPFLAGS="-M i386"
+		;;
+	esac
 
 	if [ $pc_sub -ne 0 ]; then
 		if [ $PC ]; then
-- 
2.30.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64
  2021-03-05 18:39 [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64 Andy Shevchenko
@ 2021-03-05 22:19 ` Borislav Petkov
  2021-03-08  9:59   ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2021-03-05 22:19 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Andrew Morton

On Fri, Mar 05, 2021 at 08:39:48PM +0200, Andy Shevchenko wrote:
> On x86_64 host the objdump uses current architecture which is 64-bit
> and hence decodecode shows wrong instructions.
> 
> Fix it by supplying '-M i386' in case of ARCH i?86 or x86.

At the beginning of the script says:

# e.g., to decode an i386 oops on an x86_64 system, use:
# AFLAGS=--32 decodecode < 386.oops

What kind of oops are you decoding such that that doesn't work for you?

Thx.

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64
  2021-03-05 22:19 ` Borislav Petkov
@ 2021-03-08  9:59   ` Andy Shevchenko
  2021-03-08 10:17     ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-03-08  9:59 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Andy Shevchenko, Linux Kernel Mailing List, Andrew Morton

On Sat, Mar 6, 2021 at 12:25 AM Borislav Petkov <bp@suse.de> wrote:
>
> On Fri, Mar 05, 2021 at 08:39:48PM +0200, Andy Shevchenko wrote:
> > On x86_64 host the objdump uses current architecture which is 64-bit
> > and hence decodecode shows wrong instructions.
> >
> > Fix it by supplying '-M i386' in case of ARCH i?86 or x86.
>
> At the beginning of the script says:
>
> # e.g., to decode an i386 oops on an x86_64 system, use:
> # AFLAGS=--32 decodecode < 386.oops
>
> What kind of oops are you decoding such that that doesn't work for you?

It works, but... The question here is why the script behaviour depends
so much on the architecture in question (by environment). ARM stuff is
using traditional ARCH (and that's what I have expected to work),
while x86 has a set of other variables.
So, I have to rephrase the commit message then and do actually an
alias when ARCH is set in a certain way, Would it be better?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64
  2021-03-08  9:59   ` Andy Shevchenko
@ 2021-03-08 10:17     ` Borislav Petkov
  2021-03-08 10:22       ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2021-03-08 10:17 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andy Shevchenko, Linux Kernel Mailing List, Andrew Morton

On Mon, Mar 08, 2021 at 11:59:34AM +0200, Andy Shevchenko wrote:
> It works, but... The question here is why the script behaviour depends
> so much on the architecture in question (by environment). ARM stuff is
> using traditional ARCH (and that's what I have expected to work),
> while x86 has a set of other variables.
> So, I have to rephrase the commit message then and do actually an
> alias when ARCH is set in a certain way, Would it be better?

No, I have no clue what you're trying to accomplish. You wanted to
supply ARCH when decoding a 32-bit oops because you expected ARCH to
work...?

AFLAGS has always been there, ARM folks added ARCH AFAIR. Also, you need
AFLAGS to compile the snippet in the correct bitsize.

And there's a usage note at the beginning of the script and I always
read it to make sure I'm using it right.

So what's the problem again?

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64
  2021-03-08 10:17     ` Borislav Petkov
@ 2021-03-08 10:22       ` Andy Shevchenko
  2021-03-08 11:12         ` Borislav Petkov
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2021-03-08 10:22 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Andy Shevchenko, Linux Kernel Mailing List, Andrew Morton

On Mon, Mar 8, 2021 at 12:17 PM Borislav Petkov <bp@suse.de> wrote:
>
> On Mon, Mar 08, 2021 at 11:59:34AM +0200, Andy Shevchenko wrote:
> > It works, but... The question here is why the script behaviour depends
> > so much on the architecture in question (by environment). ARM stuff is
> > using traditional ARCH (and that's what I have expected to work),
> > while x86 has a set of other variables.
> > So, I have to rephrase the commit message then and do actually an
> > alias when ARCH is set in a certain way, Would it be better?
>
> No, I have no clue what you're trying to accomplish. You wanted to
> supply ARCH when decoding a 32-bit oops because you expected ARCH to
> work...?

Yes.

> AFLAGS has always been there, ARM folks added ARCH AFAIR. Also, you need
> AFLAGS to compile the snippet in the correct bitsize.
>
> And there's a usage note at the beginning of the script and I always
> read it to make sure I'm using it right.
>
> So what's the problem again?

Inconsistency.
For the ARM we have to provide ARCH, for x86 a variety of all the flags.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64
  2021-03-08 10:22       ` Andy Shevchenko
@ 2021-03-08 11:12         ` Borislav Petkov
  0 siblings, 0 replies; 6+ messages in thread
From: Borislav Petkov @ 2021-03-08 11:12 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Andy Shevchenko, Linux Kernel Mailing List, Andrew Morton

On Mon, Mar 08, 2021 at 12:22:34PM +0200, Andy Shevchenko wrote:
> For the ARM we have to provide ARCH, for x86 a variety of all the flags.

For x86 you have to provide only AFLAGS.

If you want to make this script parse proper cmdline options like
--arch, --width and --help along with keeping the old methods
functional, I guess that would be ok.

-- 
Regards/Gruss,
    Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-08 11:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 18:39 [PATCH v1 1/1] scripts/decodecode: Decode 32-bit code correctly on x86_64 Andy Shevchenko
2021-03-05 22:19 ` Borislav Petkov
2021-03-08  9:59   ` Andy Shevchenko
2021-03-08 10:17     ` Borislav Petkov
2021-03-08 10:22       ` Andy Shevchenko
2021-03-08 11:12         ` 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).