[RFC] SLW: check endianess in stop api

Message ID 1498172260-18886-1-git-send-email-akshay.adiga@linux.vnet.ibm.com
State Rejected
Headers show

Commit Message

Akshay Adiga June 22, 2017, 10:57 p.m.
Patch adds a fake stop api call in libpore directory which prints the
endianess detected. This uses a HAVE_{LITTLE,BIG}_ENDIAN and converts
into __{BIG,LITTLE}_ENDIAN and prints it.

Following is the output as seen in the opal logs.

# cat /sys/firmware/opal/msglog |grep -i slw |tail -n1
[    2.297621840,6] SLW: is __LITTLE_ENDIAN

Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
---
 hw/slw.c              |  2 ++
 include/p9_stop_api.H |  3 +++
 libpore/Makefile.inc  |  2 +-
 libpore/endian.h      | 15 +++++++++++++++
 libpore/p9_stop_api.C | 17 +++++++++++++++++
 libpore/p9_stop_api.H |  3 +++
 6 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 include/p9_stop_api.H
 create mode 100644 libpore/endian.h
 create mode 100644 libpore/p9_stop_api.C
 create mode 100644 libpore/p9_stop_api.H

Comments

Akshay Adiga June 22, 2017, 11:11 p.m. | #1
I see CPPFLAGS defining BIG ENDIAN in Makefile.main and HOSTFLAGS 
setting things based on the build machine.

Makefile.main :
...
HOSTEND=$(shell uname -m | sed -e 's/^i.*86$$/LITTLE/' -e 
's/^x86.*/LITTLE/' -e 's/^ppc64le/LITTLE/' -e 's/^ppc.*/BIG/')
HOSTCFLAGS=-O1 $(CWARNS) -DHAVE_$(HOSTEND)_ENDIAN -MMD
....
CPPFLAGS += -DBITS_PER_LONG=64 -DHAVE_BIG_ENDIAN

Suspecting HOSTCFLAGS are coming in the way.


On 06/23/2017 04:27 AM, Akshay Adiga wrote:
> Patch adds a fake stop api call in libpore directory which prints the
> endianess detected. This uses a HAVE_{LITTLE,BIG}_ENDIAN and converts
> into __{BIG,LITTLE}_ENDIAN and prints it.
>
> Following is the output as seen in the opal logs.
>
> # cat /sys/firmware/opal/msglog |grep -i slw |tail -n1
> [    2.297621840,6] SLW: is __LITTLE_ENDIAN
Shouldn't this be detected as BIG_ENDIAN ?
Any ideas ?

>
> Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
> ---
>  hw/slw.c              |  2 ++
>  include/p9_stop_api.H |  3 +++
>  libpore/Makefile.inc  |  2 +-
>  libpore/endian.h      | 15 +++++++++++++++
>  libpore/p9_stop_api.C | 17 +++++++++++++++++
>  libpore/p9_stop_api.H |  3 +++
>  6 files changed, 41 insertions(+), 1 deletion(-)
>  create mode 100644 include/p9_stop_api.H
>  create mode 100644 libpore/endian.h
>  create mode 100644 libpore/p9_stop_api.C
>  create mode 100644 libpore/p9_stop_api.H
>
> diff --git a/hw/slw.c b/hw/slw.c
> index ce409f9..bd17b6a 100644
> --- a/hw/slw.c
> +++ b/hw/slw.c
> @@ -31,6 +31,7 @@
>  #include <opal-api.h>
>
>  #include <p8_pore_table_gen_api.H>
> +#include <p9_stop_api.H>
>  #include <sbe_xip_image.h>
>
>  #define MAX_RESET_PATCH_SIZE	64
> @@ -1150,6 +1151,7 @@ static void slw_init_chip_p9(struct proc_chip *chip)
>  	/* At power ON setup inits for power-mgt */
>  	for_each_available_core_in_chip(c, chip->id)
>  		slw_set_overrides_p9(chip, c);
> +	p9_stop_save_cpureg();
>  }
>  static void slw_init_chip(struct proc_chip *chip)
>  {
> diff --git a/include/p9_stop_api.H b/include/p9_stop_api.H
> new file mode 100644
> index 0000000..80f3529
> --- /dev/null
> +++ b/include/p9_stop_api.H
> @@ -0,0 +1,3 @@
> +
> +int p9_stop_save_cpureg( void);
> +
> diff --git a/libpore/Makefile.inc b/libpore/Makefile.inc
> index 2eac595..0d35661 100644
> --- a/libpore/Makefile.inc
> +++ b/libpore/Makefile.inc
> @@ -1,4 +1,4 @@
> -LIBPORE_SRCS = p8_pore_table_gen_api_fixed.C
> +LIBPORE_SRCS = p8_pore_table_gen_api_fixed.C p9_stop_api.C
>  LIBPORE_SRCS += p8_pore_table_static_data.c sbe_xip_image.c pore_inline_assembler.c
>  LIBPORE_OBJS_1 = $(LIBPORE_SRCS:%.c=%.o)
>  LIBPORE_OBJS = $(LIBPORE_OBJS_1:%.C=%.o)
> diff --git a/libpore/endian.h b/libpore/endian.h
> new file mode 100644
> index 0000000..f7e0960
> --- /dev/null
> +++ b/libpore/endian.h
> @@ -0,0 +1,15 @@
> +#include <ccan/endian/endian.h>
> +
> +#ifndef __BYTE_ORDER
> +#define	__LITTLE_ENDIAN	1234
> +#define	__BIG_ENDIAN	4321
> +
> +/* Support Glibc style endianness check */
> +#ifdef HAVE_LITTLE_ENDIAN
> +	#define __BYTE_ORDER __LITTLE_ENDIAN
> +#elif HAVE_BIG_ENDIAN
> +	#define __BYTE_ORDER __BIG_ENDIAN
> +#else
> +	#error
> +#endif
> +#endif /* __BYTE_ORDER */
> diff --git a/libpore/p9_stop_api.C b/libpore/p9_stop_api.C
> new file mode 100644
> index 0000000..4b5d749
> --- /dev/null
> +++ b/libpore/p9_stop_api.C
> @@ -0,0 +1,17 @@
> +
> +#include "endian.h"
> +#include <skiboot.h>
> +#include "p9_stop_api.H"
> +//-----------------------------------------------------------------------------
> +
> +int p9_stop_save_cpureg( )
> +{
> +
> +    if (__BYTE_ORDER == __BIG_ENDIAN)
> +	     _prlog(PR_INFO , "SLW: is __BIG_ENDIAN\n");
> +    if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +	     _prlog(PR_INFO , "SLW: is __LITTLE_ENDIAN\n");
> +
> +    return 0;
> +}
> +
> diff --git a/libpore/p9_stop_api.H b/libpore/p9_stop_api.H
> new file mode 100644
> index 0000000..80f3529
> --- /dev/null
> +++ b/libpore/p9_stop_api.H
> @@ -0,0 +1,3 @@
> +
> +int p9_stop_save_cpureg( void);
> +
>

Regards
Akshay Adiga
Michael Neuling June 24, 2017, 7:33 p.m. | #2
On Fri, 2017-06-23 at 04:27 +0530, Akshay Adiga wrote:
> Patch adds a fake stop api call in libpore directory which prints the
> endianess detected. This uses a HAVE_{LITTLE,BIG}_ENDIAN and converts
> into __{BIG,LITTLE}_ENDIAN and prints it.
> 
> Following is the output as seen in the opal logs.
> 
> # cat /sys/firmware/opal/msglog |grep -i slw |tail -n1
> [    2.297621840,6] SLW: is __LITTLE_ENDIAN

What are you trying to do here?  All the code below does is check the endian you
compiled in.

What is the point of this?  I assume the SLW has an endian and you're trying to
check that.  Why not just do that, rather than this bogus check.

Mikey

> 
> Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
> ---
>  hw/slw.c              |  2 ++
>  include/p9_stop_api.H |  3 +++
>  libpore/Makefile.inc  |  2 +-
>  libpore/endian.h      | 15 +++++++++++++++
>  libpore/p9_stop_api.C | 17 +++++++++++++++++
>  libpore/p9_stop_api.H |  3 +++
>  6 files changed, 41 insertions(+), 1 deletion(-)
>  create mode 100644 include/p9_stop_api.H
>  create mode 100644 libpore/endian.h
>  create mode 100644 libpore/p9_stop_api.C
>  create mode 100644 libpore/p9_stop_api.H
> 
> diff --git a/hw/slw.c b/hw/slw.c
> index ce409f9..bd17b6a 100644
> --- a/hw/slw.c
> +++ b/hw/slw.c
> @@ -31,6 +31,7 @@
>  #include <opal-api.h>
>  
>  #include <p8_pore_table_gen_api.H>
> +#include <p9_stop_api.H>
>  #include <sbe_xip_image.h>
>  
>  #define MAX_RESET_PATCH_SIZE	64
> @@ -1150,6 +1151,7 @@ static void slw_init_chip_p9(struct proc_chip *chip)
>  	/* At power ON setup inits for power-mgt */
>  	for_each_available_core_in_chip(c, chip->id)
>  		slw_set_overrides_p9(chip, c);
> +	p9_stop_save_cpureg();
>  }
>  static void slw_init_chip(struct proc_chip *chip)
>  {
> diff --git a/include/p9_stop_api.H b/include/p9_stop_api.H
> new file mode 100644
> index 0000000..80f3529
> --- /dev/null
> +++ b/include/p9_stop_api.H
> @@ -0,0 +1,3 @@
> +
> +int p9_stop_save_cpureg( void);
> +
> diff --git a/libpore/Makefile.inc b/libpore/Makefile.inc
> index 2eac595..0d35661 100644
> --- a/libpore/Makefile.inc
> +++ b/libpore/Makefile.inc
> @@ -1,4 +1,4 @@
> -LIBPORE_SRCS = p8_pore_table_gen_api_fixed.C
> +LIBPORE_SRCS = p8_pore_table_gen_api_fixed.C p9_stop_api.C
>  LIBPORE_SRCS += p8_pore_table_static_data.c sbe_xip_image.c
> pore_inline_assembler.c
>  LIBPORE_OBJS_1 = $(LIBPORE_SRCS:%.c=%.o)
>  LIBPORE_OBJS = $(LIBPORE_OBJS_1:%.C=%.o)
> diff --git a/libpore/endian.h b/libpore/endian.h
> new file mode 100644
> index 0000000..f7e0960
> --- /dev/null
> +++ b/libpore/endian.h
> @@ -0,0 +1,15 @@
> +#include <ccan/endian/endian.h>
> +
> +#ifndef __BYTE_ORDER
> +#define	__LITTLE_ENDIAN	1234
> +#define	__BIG_ENDIAN	4321
> +
> +/* Support Glibc style endianness check */
> +#ifdef HAVE_LITTLE_ENDIAN
> +	#define __BYTE_ORDER __LITTLE_ENDIAN
> +#elif HAVE_BIG_ENDIAN
> +	#define __BYTE_ORDER __BIG_ENDIAN
> +#else
> +	#error
> +#endif
> +#endif /* __BYTE_ORDER */
> diff --git a/libpore/p9_stop_api.C b/libpore/p9_stop_api.C
> new file mode 100644
> index 0000000..4b5d749
> --- /dev/null
> +++ b/libpore/p9_stop_api.C
> @@ -0,0 +1,17 @@
> +
> +#include "endian.h"
> +#include <skiboot.h>
> +#include "p9_stop_api.H"
> +//---------------------------------------------------------------------------
> --
> +
> +int p9_stop_save_cpureg( )
> +{
> +
> +    if (__BYTE_ORDER == __BIG_ENDIAN)
> +	     _prlog(PR_INFO , "SLW: is __BIG_ENDIAN\n");
> +    if (__BYTE_ORDER == __LITTLE_ENDIAN)
> +	     _prlog(PR_INFO , "SLW: is __LITTLE_ENDIAN\n");
> +
> +    return 0;
> +}
> +
> diff --git a/libpore/p9_stop_api.H b/libpore/p9_stop_api.H
> new file mode 100644
> index 0000000..80f3529
> --- /dev/null
> +++ b/libpore/p9_stop_api.H
> @@ -0,0 +1,3 @@
> +
> +int p9_stop_save_cpureg( void);
> +

Patch

diff --git a/hw/slw.c b/hw/slw.c
index ce409f9..bd17b6a 100644
--- a/hw/slw.c
+++ b/hw/slw.c
@@ -31,6 +31,7 @@ 
 #include <opal-api.h>
 
 #include <p8_pore_table_gen_api.H>
+#include <p9_stop_api.H>
 #include <sbe_xip_image.h>
 
 #define MAX_RESET_PATCH_SIZE	64
@@ -1150,6 +1151,7 @@  static void slw_init_chip_p9(struct proc_chip *chip)
 	/* At power ON setup inits for power-mgt */
 	for_each_available_core_in_chip(c, chip->id)
 		slw_set_overrides_p9(chip, c);
+	p9_stop_save_cpureg();
 }
 static void slw_init_chip(struct proc_chip *chip)
 {
diff --git a/include/p9_stop_api.H b/include/p9_stop_api.H
new file mode 100644
index 0000000..80f3529
--- /dev/null
+++ b/include/p9_stop_api.H
@@ -0,0 +1,3 @@ 
+
+int p9_stop_save_cpureg( void);
+
diff --git a/libpore/Makefile.inc b/libpore/Makefile.inc
index 2eac595..0d35661 100644
--- a/libpore/Makefile.inc
+++ b/libpore/Makefile.inc
@@ -1,4 +1,4 @@ 
-LIBPORE_SRCS = p8_pore_table_gen_api_fixed.C
+LIBPORE_SRCS = p8_pore_table_gen_api_fixed.C p9_stop_api.C
 LIBPORE_SRCS += p8_pore_table_static_data.c sbe_xip_image.c pore_inline_assembler.c
 LIBPORE_OBJS_1 = $(LIBPORE_SRCS:%.c=%.o)
 LIBPORE_OBJS = $(LIBPORE_OBJS_1:%.C=%.o)
diff --git a/libpore/endian.h b/libpore/endian.h
new file mode 100644
index 0000000..f7e0960
--- /dev/null
+++ b/libpore/endian.h
@@ -0,0 +1,15 @@ 
+#include <ccan/endian/endian.h>
+
+#ifndef __BYTE_ORDER
+#define	__LITTLE_ENDIAN	1234
+#define	__BIG_ENDIAN	4321
+
+/* Support Glibc style endianness check */
+#ifdef HAVE_LITTLE_ENDIAN
+	#define __BYTE_ORDER __LITTLE_ENDIAN
+#elif HAVE_BIG_ENDIAN
+	#define __BYTE_ORDER __BIG_ENDIAN
+#else
+	#error
+#endif
+#endif /* __BYTE_ORDER */
diff --git a/libpore/p9_stop_api.C b/libpore/p9_stop_api.C
new file mode 100644
index 0000000..4b5d749
--- /dev/null
+++ b/libpore/p9_stop_api.C
@@ -0,0 +1,17 @@ 
+
+#include "endian.h"
+#include <skiboot.h>
+#include "p9_stop_api.H"
+//-----------------------------------------------------------------------------
+
+int p9_stop_save_cpureg( )
+{
+
+    if (__BYTE_ORDER == __BIG_ENDIAN)
+	     _prlog(PR_INFO , "SLW: is __BIG_ENDIAN\n");
+    if (__BYTE_ORDER == __LITTLE_ENDIAN)
+	     _prlog(PR_INFO , "SLW: is __LITTLE_ENDIAN\n");
+
+    return 0;
+}
+
diff --git a/libpore/p9_stop_api.H b/libpore/p9_stop_api.H
new file mode 100644
index 0000000..80f3529
--- /dev/null
+++ b/libpore/p9_stop_api.H
@@ -0,0 +1,3 @@ 
+
+int p9_stop_save_cpureg( void);
+