Subject: Re: [PATCH] powerpc: fix xmon disassembler for little-endian

From: Tom Musta <[email-masked]>
Date: Mon, 02 Dec 2013 08:05:11 -0600

On 12/2/2013 3:10 AM, Philippe Bergheaud wrote:
> This patch fixes the disassembler of the powerpc kernel debugger xmon,
> for little-endian.
> 
> Signed-off-by: Philippe Bergheaud <[email-masked]>
> ---
>  arch/powerpc/xmon/xmon.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
> index af9d346..6c27804 100644
> --- a/arch/powerpc/xmon/xmon.c
> +++ b/arch/powerpc/xmon/xmon.c
> @@ -171,7 +171,11 @@ extern void xmon_leave(void);
>  #define REG		"%.8lx"
>  #endif
>  
> +#ifdef __LITTLE_ENDIAN__
> +#define GETWORD(v)	(((v)[3] << 24) + ((v)[2] << 16) + ((v)[1] << 8) + (v)[0])
> +#else
>  #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3])
> +#endif
>  
>  #define isxdigit(c)	(('0' <= (c) && (c) <= '9') \
>  			 || ('a' <= (c) && (c) <= 'f') \
> 

Philippe:  Wouldn't it be better to just do a 32-bit load and let the endianness be worked out
by the hardware?  i.e.

#define GETWORD(v) (*(u32 *)v)

Tom