All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/23] grub 64bit little-endian on power
@ 2014-02-26 18:30 Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 01/23] Add a new architecture to the build process Ram Pai
                   ` (22 more replies)
  0 siblings, 23 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:30 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

The following patches enable grub to support
64bit Little Endian Power architecture.

Anton Blanchard (12):
  Add IEEE1275_ADDR helper
  Fix some more warnings when casting.
  Add powerpc64 types
  Fix warnings when building powerpc linux loader 64bit
  Fix powerpc setjmp/longjmp 64bit issues
  Add powerpc64 ieee1275 trampoline
  Add 64bit support to powerpc startup code
  Add grub_dl_find_section_addr
  Add ppc64 relocations
  ppc64 doesn't need libgcc routines
  Use FUNC_START/FUNC_END for powerpc function definitions
  powerpc64 is not necessarily BigEndian anymore! :)

Ram Pai (11):
  Add a new architecture to the build process
  Build grub as O1 until we add savegpr and restgpr routines
  powerpc64 LE's linker knows how to handle the undefined symbol .TOC.  
      in grub modules. So just ignore that symbol during build.
  grub-install can now recognize and install a LE grub boot loader
  set the ABI version to 0x02 in the e_flag of the PPC64LE ELF image.
  GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader.
  .TOC. symbol is special in ppc64le . It maps to the address of the
    .toc     section.
  the .toc section in powerpc64le modules are sometimes not aligned on a
    four     byte boundary. This fails the module linker especially when
    processing     R_PPC64_TOC16_LO_DS, since the addresses are expected
    to be aligned on 4byte     boundary.
  all parameter to firmware calls should to be BigEndian and the results
        should be CPU endian.
  grub segfaults if initrd is specified before specifying the kernel.   
     The problem is the initrd module sees that kernel is not specified 
       and takes the fail path. In the fail path it checks if anything
    has     be malloc'ed. Unfortunately the variable that it looks to
    check for     is a uninitialized stack variable. The stack variable
    can incorrectly     indicate something is malloced, which leads the
    module to free some     unallocated memory. This patch fixes the
    problem by initializing the     stack variable.
  Power7 cannot handle VSX instructions correctly. It segfaults.    
    This patch is applicable only for power7 systems.

Thomas Falcon (1):
  Add a new architecture to the build process

Tomohiro B Berry (1):
  Add a new architecture to the build process

 Makefile.am                               |   4 +
 config.h.in                               |   4 +
 configure.ac                              |  17 ++-
 gentpl.py                                 |   7 +-
 grub-core/Makefile.am                     |   7 ++
 grub-core/Makefile.core.def               |  20 ++++
 grub-core/disk/ieee1275/nand.c            |  41 +++----
 grub-core/disk/ieee1275/ofdisk.c          |  28 +++--
 grub-core/fs/fshelp.c                     |  10 ++
 grub-core/gensyminfo.sh.in                |   7 +-
 grub-core/kern/dl.c                       |  66 +++++++++++-
 grub-core/kern/ieee1275/ieee1275.c        | 162 ++++++++++++++++------------
 grub-core/kern/ieee1275/openfw.c          |  25 ++---
 grub-core/kern/powerpc/cache.S            |   6 +-
 grub-core/kern/powerpc/dl.c               | 172 +++++++++++++++++++++++++++++-
 grub-core/kern/powerpc/ieee1275/entry.S   | 150 ++++++++++++++++++++++++++
 grub-core/kern/powerpc/ieee1275/startup.S |  30 +++++-
 grub-core/kern/term.c                     |  11 ++
 grub-core/lib/ieee1275/datetime.c         |  36 +++----
 grub-core/lib/powerpc/relocator.c         |   8 +-
 grub-core/lib/powerpc/setjmp.S            | 102 ++++++++++--------
 grub-core/loader/powerpc/ieee1275/linux.c |  10 +-
 grub-core/net/drivers/ieee1275/ofnet.c    |   8 +-
 grub-core/normal/term.c                   |  42 ++++++++
 include/grub/dl.h                         |   2 +
 include/grub/elf.h                        |   4 +
 include/grub/ieee1275/ieee1275.h          |   8 +-
 include/grub/libgcc.h                     |   2 +-
 include/grub/offsets.h                    |   5 +
 include/grub/powerpc/ieee1275/ieee1275.h  |   6 ++
 include/grub/powerpc/types.h              |  16 ++-
 include/grub/powerpc64le                  |   1 +
 include/grub/util/install.h               |   1 +
 util/grub-install-common.c                |   1 +
 util/grub-install.c                       |  15 ++-
 util/grub-mkimagexx.c                     |   4 +
 util/mkimage.c                            |  19 ++++
 37 files changed, 843 insertions(+), 214 deletions(-)
 create mode 100644 grub-core/kern/powerpc/ieee1275/entry.S
 create mode 120000 include/grub/powerpc64le

-- 
1.8.5.3



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

* [RFC PATCH 01/23] Add a new architecture to the build process
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 02/23] Build LE grub as O1 Ram Pai
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

Add a new architecture to the build process

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
Signed-off-by: Tomohiro B Berry <tbberry@us.ibm.com>
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 Makefile.am                 |  4 ++++
 config.h.in                 |  4 ++++
 configure.ac                | 10 +++++++---
 gentpl.py                   |  7 ++++---
 grub-core/Makefile.am       |  7 +++++++
 grub-core/Makefile.core.def | 18 ++++++++++++++++++
 include/grub/powerpc64le    |  1 +
 7 files changed, 45 insertions(+), 6 deletions(-)
 create mode 120000 include/grub/powerpc64le

diff --git a/Makefile.am b/Makefile.am
index f02ae0a..8aad803 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -383,6 +383,10 @@ if COND_powerpc_ieee1275
 BOOTCHECKS = bootcheck-linux-ppc
 endif
 
+if COND_powerpc64le_ieee1275
+BOOTCHECKS = bootcheck-linux-ppc
+endif
+
 EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S
 
 .PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \
diff --git a/config.h.in b/config.h.in
index 4b63014..1d71e35 100644
--- a/config.h.in
+++ b/config.h.in
@@ -6,6 +6,10 @@
 #define __powerpc__ 1
 #endif
 
+#if defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
+#define __powerpc64le__ 1
+#endif
+
 #define GCRYPT_NO_DEPRECATED 1
 
 /* Define to 1 to enable disk cache statistics.  */
diff --git a/configure.ac b/configure.ac
index 8888c2f..09e9dfb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,6 +119,7 @@ if test "x$with_platform" = x; then
     x86_64-*) platform=pc ;;
     powerpc-*) platform=ieee1275 ;;
     powerpc64-*) platform=ieee1275 ;;
+    powerpc64le-*) platform=ieee1275 ;;
     sparc64-*) platform=ieee1275 ;;
     mipsel-*) platform=loongson ;;
     mips-*) platform=arc ;;
@@ -137,6 +138,7 @@ case "$target_cpu"-"$platform" in
   x86_64-xen) ;;
   x86_64-*) target_cpu=i386 ;;
   powerpc64-ieee1275) target_cpu=powerpc ;;
+  powerpc64le-ieee1275) target_cpu=powerpc64le ;;
 esac
 
 # Check if the platform is supported, make final adjustments.
@@ -152,6 +154,7 @@ case "$target_cpu"-"$platform" in
   i386-ieee1275) ;;
   i386-qemu) ;;
   powerpc-ieee1275) ;;
+  powerpc64le-ieee1275) ;;
   sparc64-ieee1275) ;;
   ia64-efi) ;;
   mips-qemu_mips) ;;
@@ -173,7 +176,7 @@ esac
 if test x$platform != xemu ; then
    case "$target_cpu" in
 	i386 | powerpc) target_m32=1 ;;
-	x86_64 | sparc64) target_m64=1 ;;
+	x86_64 | sparc64 | powerpc64le) target_m64=1 ;;
    esac
 fi
 
@@ -557,7 +560,7 @@ if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \
    TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as"
 fi
 
-if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then
+if test "x$grub_cv_cc_target_clang" = xyes && (test "x$target_cpu" = xpowerpc || test "x$target_cpu" = xpowerpc64le ); then
 AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame]
 [
 CFLAGS="$TARGET_CFLAGS"
@@ -1428,7 +1431,7 @@ if test x"$enable_build_grub_mkfont" = xno ; then
   FONT_SOURCE=
 fi
 
-if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then
+if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$target_cpu"-"$platform" = xpowerpc64le-ieee1275 || test "x$platform" = xcoreboot ); then
   if test x"$grub_build_mkfont_excuse" = x ; then
     AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont])
   else
@@ -1671,6 +1674,7 @@ AM_CONDITIONAL([COND_mips_arc], [test "(" x$target_cpu = xmips -o x$target_cpu =
 AM_CONDITIONAL([COND_sparc64_ieee1275], [test x$target_cpu = xsparc64 -a x$platform = xieee1275])
 AM_CONDITIONAL([COND_sparc64_emu], [test x$target_cpu = xsparc64 -a x$platform = xemu])
 AM_CONDITIONAL([COND_powerpc_ieee1275], [test x$target_cpu = xpowerpc -a x$platform = xieee1275])
+AM_CONDITIONAL([COND_powerpc64le_ieee1275], [test x$target_cpu = xpowerpc64le -a x$platform = xieee1275])
 AM_CONDITIONAL([COND_mips], [test x$target_cpu = xmips -o x$target_cpu = xmipsel])
 AM_CONDITIONAL([COND_mipsel], [test x$target_cpu = xmipsel])
 AM_CONDITIONAL([COND_mipseb], [test x$target_cpu = xmips])
diff --git a/gentpl.py b/gentpl.py
index bdcae1a..744bed0 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -30,7 +30,7 @@ GRUB_PLATFORMS = [ "emu", "i386_pc", "i386_efi", "i386_qemu", "i386_coreboot",
                    "i386_multiboot", "i386_ieee1275", "x86_64_efi",
                    "i386_xen", "x86_64_xen",
                    "mips_loongson", "sparc64_ieee1275",
-                   "powerpc_ieee1275", "mips_arc", "ia64_efi",
+                   "powerpc_ieee1275", "powerpc64le_ieee1275", "mips_arc", "ia64_efi",
                    "mips_qemu_mips", "arm_uboot", "arm_efi", "arm64_efi" ]
 
 GROUPS = {}
@@ -44,12 +44,13 @@ GROUPS["x86"]      = GROUPS["i386"] + GROUPS["x86_64"]
 GROUPS["mips"]     = [ "mips_loongson", "mips_qemu_mips", "mips_arc" ]
 GROUPS["sparc64"]  = [ "sparc64_ieee1275" ]
 GROUPS["powerpc"]  = [ "powerpc_ieee1275" ]
+GROUPS["powerpc64le"]  = [ "powerpc64le_ieee1275" ]
 GROUPS["arm"]      = [ "arm_uboot", "arm_efi" ]
 GROUPS["arm64"]    = [ "arm64_efi" ]
 
 # Groups based on firmware
 GROUPS["efi"]  = [ "i386_efi", "x86_64_efi", "ia64_efi", "arm_efi", "arm64_efi" ]
-GROUPS["ieee1275"]   = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]
+GROUPS["ieee1275"]   = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275", "powerpc64le_ieee1275" ]
 GROUPS["uboot"] = [ "arm_uboot" ]
 GROUPS["xen"]  = [ "i386_xen", "x86_64_xen" ]
 
@@ -58,7 +59,7 @@ GROUPS["noemu"]   = GRUB_PLATFORMS[:]; GROUPS["noemu"].remove("emu")
 
 # Groups based on hardware features
 GROUPS["cmos"] = GROUPS["x86"][:] + ["mips_loongson", "mips_qemu_mips",
-                                     "sparc64_ieee1275", "powerpc_ieee1275"]
+                                     "sparc64_ieee1275", "powerpc_ieee1275", "powerpc64le_ieee1275" ]
 GROUPS["cmos"].remove("i386_efi"); GROUPS["cmos"].remove("x86_64_efi");
 GROUPS["pci"]      = GROUPS["x86"] + ["mips_loongson"]
 GROUPS["usb"]      = GROUPS["pci"]
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index 5c087c8..d9034c1 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -210,6 +210,13 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
 endif
 
+if COND_powerpc64le_ieee1275
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/terminfo.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h
+KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/lib/arg.h
+endif
+
 if COND_sparc64_ieee1275
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/ieee1275/ieee1275.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sparc64/ieee1275/ieee1275.h
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index 42443bc..c6e70bb 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -35,6 +35,7 @@ script = {
   name = grub.chrp;
   common = boot/powerpc/grub.chrp.in;
   enable = powerpc_ieee1275;
+  enable = powerpc64le_ieee1275;
 };
 
 script = {
@@ -42,6 +43,7 @@ script = {
   name = bootinfo.txt;
   common = boot/powerpc/bootinfo.txt.in;
   enable = powerpc_ieee1275;
+  enable = powerpc64le_ieee1275;
 };
 
 kernel = {
@@ -87,6 +89,7 @@ kernel = {
 
   mips_loongson_ldflags    = '-Wl,-Ttext,0x80200000';
   powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
+  powerpc64le_ieee1275_ldflags = '-Wl,-Ttext,0x200000';
   sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400';
   mips_arc_ldflags    = '-Wl,-Ttext,$(TARGET_LINK_ADDR)';
   mips_qemu_mips_ldflags    = '-Wl,-Ttext,0x80200000';
@@ -110,6 +113,7 @@ kernel = {
   mips_startup = kern/mips/startup.S;
   sparc64_ieee1275_startup = kern/sparc64/ieee1275/crt0.S;
   powerpc_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
+  powerpc64le_ieee1275_startup = kern/powerpc/ieee1275/startup.S;
   arm_uboot_startup = kern/arm/uboot/startup.S;
   arm_efi_startup = kern/arm/efi/startup.S;
   arm64_efi_startup = kern/arm64/efi/startup.S;
@@ -253,6 +257,9 @@ kernel = {
   powerpc_ieee1275 = kern/powerpc/cache.S;
   powerpc_ieee1275 = kern/powerpc/dl.c;
 
+  powerpc64le_ieee1275 = kern/powerpc/cache.S;
+  powerpc64le_ieee1275 = kern/powerpc/dl.c;
+
   sparc64_ieee1275 = kern/sparc64/cache.S;
   sparc64_ieee1275 = kern/sparc64/dl.c;
   sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c;
@@ -754,6 +761,7 @@ module = {
   enable = emu;
   enable = sparc64_ieee1275;
   enable = powerpc_ieee1275;
+  enable = powerpc64le_ieee1275;
   enable = mips_arc;
   enable = ia64_efi;
   enable = arm_efi;
@@ -855,6 +863,7 @@ module = {
   arm_efi = lib/efi/reboot.c;
   arm64_efi = lib/efi/reboot.c;
   powerpc_ieee1275 = lib/ieee1275/reboot.c;
+  powerpc64le_ieee1275 = lib/ieee1275/reboot.c;
   sparc64_ieee1275 = lib/ieee1275/reboot.c;
   mips_arc = lib/mips/arc/reboot.c;
   mips_loongson = lib/mips/loongson/reboot.c;
@@ -1027,12 +1036,14 @@ module = {
   ieee1275 = commands/ieee1275/suspend.c;
   enable = i386_ieee1275;
   enable = powerpc_ieee1275;
+  enable = powerpc64le_ieee1275;
 };
 
 module = {
   name = escc;
   ieee1275 = term/ieee1275/escc.c;
   enable = powerpc_ieee1275;
+  enable = powerpc64le_ieee1275;
 };
 
 module = {
@@ -1537,6 +1548,8 @@ module = {
   mips = lib/mips/relocator.c;
   powerpc = lib/powerpc/relocator_asm.S;
   powerpc = lib/powerpc/relocator.c;
+  powerpc64le = lib/powerpc/relocator_asm.S;
+  powerpc64le = lib/powerpc/relocator.c;
   xen = lib/xen/relocator.c;
   i386_xen = lib/i386/xen/relocator.S;
   x86_64_xen = lib/x86_64/xen/relocator.S;
@@ -1548,6 +1561,7 @@ module = {
 
   enable = mips;
   enable = powerpc;
+  enable = powerpc64le;
   enable = x86;
   enable = xen;
 };
@@ -1559,8 +1573,10 @@ module = {
   uboot = lib/uboot/datetime.c;
   sparc64_ieee1275 = lib/ieee1275/datetime.c;
   powerpc_ieee1275 = lib/ieee1275/datetime.c;
+  powerpc64le_ieee1275 = lib/ieee1275/datetime.c;
   sparc64_ieee1275 = lib/ieee1275/cmos.c;
   powerpc_ieee1275 = lib/ieee1275/cmos.c;
+  powerpc64le_ieee1275 = lib/ieee1275/cmos.c;
   xen = lib/xen/datetime.c;
   xen_cppflags = '$(CPPFLAGS_XEN)';
 
@@ -1669,6 +1685,7 @@ module = {
   i386_pc = lib/i386/pc/vesa_modes_table.c;
   mips = loader/mips/linux.c;
   powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
+  powerpc64le_ieee1275 = loader/powerpc/ieee1275/linux.c;
   sparc64_ieee1275 = loader/sparc64/ieee1275/linux.c;
   ia64_efi = loader/ia64/efi/linux.c;
   arm = loader/arm/linux.c;
@@ -2057,6 +2074,7 @@ module = {
   name = ieee1275_fb;
   ieee1275 = video/ieee1275.c;
   enable = powerpc_ieee1275;
+  enable = powerpc64le_ieee1275;
 };
 
 module = {
diff --git a/include/grub/powerpc64le b/include/grub/powerpc64le
new file mode 120000
index 0000000..9a47ca9
--- /dev/null
+++ b/include/grub/powerpc64le
@@ -0,0 +1 @@
+powerpc
\ No newline at end of file
-- 
1.8.5.3



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

* [RFC PATCH 02/23] Build LE grub as O1
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 01/23] Add a new architecture to the build process Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 03/23] ignore .TOC. symbol Ram Pai
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

Build LE grub as O1 until we add savegpr and restgpr

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From:  Anton Blanchard <anton@samba.org>
---
 configure.ac | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 09e9dfb..10856be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,12 @@ grub_TRANSFORM([grub-file])
 
 # Optimization flag.  Allow user to override.
 if test "x$TARGET_CFLAGS" = x; then
-  TARGET_CFLAGS="$TARGET_CFLAGS -Os"
+  if test "x$target_cpu" = xpowerpc64le; then
+     #HACK till savegpr/addgpr is supported
+     TARGET_CFLAGS="$TARGET_CFLAGS -O1"
+  else
+     TARGET_CFLAGS="$TARGET_CFLAGS -Os"
+  fi
 fi
 
 # Default HOST_CPPFLAGS
-- 
1.8.5.3



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

* [RFC PATCH 03/23] ignore .TOC. symbol
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 01/23] Add a new architecture to the build process Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 02/23] Build LE grub as O1 Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 16:52   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 04/23] grub-install can now recognize and install a LE grub boot loader Ram Pai
                   ` (19 subsequent siblings)
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

powerpc64 LE's linker knows how to handle the undefined
symbol .TOC. in grub modules. So just ignore that symbol during build.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/gensyminfo.sh.in | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/grub-core/gensyminfo.sh.in b/grub-core/gensyminfo.sh.in
index 2e8716b..cad5af3 100644
--- a/grub-core/gensyminfo.sh.in
+++ b/grub-core/gensyminfo.sh.in
@@ -34,4 +34,9 @@ else
 fi
 
 # Print all undefined symbols used by module
-@TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | sed "s@^\([^ ]*\).*@undefined $modname \1@g"
+if test x"@GRUB_TARGET_CPU@" = xpowerpc64le; then
+    #ignore the special .TOC. symbol on powerpc64le
+    @TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | grep -w -v '.TOC.' 
+else
+    @TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module
+fi  | sed "s@^\([^ ]*\).*@undefined $modname \1@g"
-- 
1.8.5.3



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

* [RFC PATCH 04/23] grub-install can now recognize and install a LE grub boot loader
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (2 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 03/23] ignore .TOC. symbol Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 05/23] set ABI version in e_flag of the PPC64LE ELF image Ram Pai
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

grub-install can now recognize and install a LE grub boot loader

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 include/grub/offsets.h      |  5 +++++
 include/grub/util/install.h |  1 +
 util/grub-install-common.c  |  1 +
 util/grub-install.c         | 15 +++++++++++++--
 util/mkimage.c              | 19 +++++++++++++++++++
 5 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/include/grub/offsets.h b/include/grub/offsets.h
index 85e7401..b6acd02 100644
--- a/include/grub/offsets.h
+++ b/include/grub/offsets.h
@@ -63,6 +63,9 @@
 #define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ALIGN 4
 #define GRUB_KERNEL_POWERPC_IEEE1275_LINK_ADDR 0x200000
 
+#define GRUB_KERNEL_POWERPC64LE_IEEE1275_LINK_ALIGN 4
+#define GRUB_KERNEL_POWERPC64LE_IEEE1275_LINK_ADDR 0x200000
+
 #define GRUB_KERNEL_MIPS_LOONGSON_LINK_ADDR         0x80200000
 
 #define GRUB_KERNEL_MIPS_LOONGSON_LINK_ALIGN  32
@@ -111,6 +114,7 @@
 #define GRUB_KERNEL_ARM_UBOOT_MOD_GAP 0x0
 
 #define GRUB_KERNEL_POWERPC_IEEE1275_MOD_ALIGN 0x1000
+#define GRUB_KERNEL_POWERPC64LE_IEEE1275_MOD_ALIGN 0x1000
 #define GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN 3
 #define GRUB_KERNEL_SPARC64_IEEE1275_MOD_ALIGN (1 << GRUB_KERNEL_SPARC64_IEEE1275_LOG_MOD_ALIGN)
 
@@ -126,6 +130,7 @@
    for PowerMac to prevent "CLAIM failed" error.  The real fix is to
    rewrite grub-mkimage to generate valid ELF files.  */
 #define GRUB_KERNEL_POWERPC_IEEE1275_MOD_GAP 0x8000
+#define GRUB_KERNEL_POWERPC64LE_IEEE1275_MOD_GAP 0x8000
 
 #ifdef GRUB_MACHINE
 #define GRUB_OFFSETS_CONCAT_(a,b,c) a ## b ## c
diff --git a/include/grub/util/install.h b/include/grub/util/install.h
index aedcd29..3f32cd3 100644
--- a/include/grub/util/install.h
+++ b/include/grub/util/install.h
@@ -89,6 +89,7 @@ enum grub_install_plat
     GRUB_INSTALL_PLATFORM_MIPSEL_LOONGSON,
     GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275,
     GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275,
+    GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275,
     GRUB_INSTALL_PLATFORM_MIPSEL_ARC,
     GRUB_INSTALL_PLATFORM_MIPS_ARC,
     GRUB_INSTALL_PLATFORM_IA64_EFI,
diff --git a/util/grub-install-common.c b/util/grub-install-common.c
index c8bedcb..a1f18fc 100644
--- a/util/grub-install-common.c
+++ b/util/grub-install-common.c
@@ -661,6 +661,7 @@ static struct
     [GRUB_INSTALL_PLATFORM_MIPS_ARC] =         { "mips",    "arc"       },
     [GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275] = { "sparc64", "ieee1275"  },
     [GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275] = { "powerpc", "ieee1275"  },
+    [GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275] = { "powerpc64le", "ieee1275"  },
     [GRUB_INSTALL_PLATFORM_IA64_EFI] =         { "ia64",    "efi"       },
     [GRUB_INSTALL_PLATFORM_ARM_EFI] =          { "arm",     "efi"       },
     [GRUB_INSTALL_PLATFORM_ARM64_EFI] =        { "arm64",   "efi"       },
diff --git a/util/grub-install.c b/util/grub-install.c
index 2e6226a..994af24 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -311,6 +311,8 @@ get_default_platform (void)
 {
 #ifdef __powerpc__
    return "powerpc-ieee1275";
+#elif __powerpc64le__
+   return "powerpc64le-ieee1275";
 #elif defined (__sparc__) || defined (__sparc64__)
    return "sparc64-ieee1275";
 #elif defined (__MIPSEL__)
@@ -475,6 +477,7 @@ have_bootdev (enum grub_install_plat pl)
     case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
     case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275:
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
     case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
     case GRUB_INSTALL_PLATFORM_MIPS_ARC:
       return 1;
@@ -897,6 +900,7 @@ main (int argc, char *argv[])
     case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
     case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275:
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
     case GRUB_INSTALL_PLATFORM_MIPSEL_ARC:
     case GRUB_INSTALL_PLATFORM_MIPS_ARC:
     case GRUB_INSTALL_PLATFORM_ARM_UBOOT:
@@ -926,6 +930,7 @@ main (int argc, char *argv[])
 	grub_util_error ("%s", _("install device isn't specified"));
       break;
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
       if (install_device)
 	is_prep = 1;
       break;
@@ -1138,7 +1143,8 @@ main (int argc, char *argv[])
       grub_install_mkdir_p (efidir);
     }
 
-  if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
+  if (platform == GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275 ||
+      platform ==  GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275)
     {
       int is_guess = 0;
       if (!macppcdir)
@@ -1340,7 +1346,8 @@ main (int argc, char *argv[])
       if ((disk_module && grub_strcmp (disk_module, "biosdisk") != 0)
 	  || grub_drives[1]
 	  || (!install_drive
-	      && platform != GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275)
+	      && platform != GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275
+	      && platform != GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275)
 	  || (install_drive && !is_same_disk (grub_drives[0], install_drive))
 	  || !have_bootdev (platform))
 	{
@@ -1433,6 +1440,7 @@ main (int argc, char *argv[])
 		    break;
 		  case GRUB_INSTALL_PLATFORM_SPARC64_IEEE1275:
 		  case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+		  case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
 		  case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
 		    {
 		      const char * ofpath = grub_util_devname_to_ofpath (*curdev);
@@ -1539,6 +1547,7 @@ main (int argc, char *argv[])
     case GRUB_INSTALL_PLATFORM_I386_MULTIBOOT:
     case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
     case GRUB_INSTALL_PLATFORM_I386_XEN:
     case GRUB_INSTALL_PLATFORM_X86_64_XEN:
       core_name = "core.elf";
@@ -1598,6 +1607,7 @@ main (int argc, char *argv[])
 
     case GRUB_INSTALL_PLATFORM_I386_IEEE1275:
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
       {
 	char *dst = grub_util_path_concat (2, grubdir, "grub");
 	grub_install_copy_file (imgfile, dst, 1);
@@ -1700,6 +1710,7 @@ main (int argc, char *argv[])
       }
 
     case GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275:
+    case GRUB_INSTALL_PLATFORM_POWERPC64LE_IEEE1275:
       if (macppcdir)
 	{
 	  char *core_services = grub_util_path_concat (4, macppcdir,
diff --git a/util/mkimage.c b/util/mkimage.c
index 26d9816..baf5fdc 100644
--- a/util/mkimage.c
+++ b/util/mkimage.c
@@ -371,6 +371,25 @@ static const struct grub_install_image_target_desc image_targets[] =
       .link_align = 4
     },
     {
+      .dirname = "powerpc64le-ieee1275",
+      .names = { "powerpc64le-ieee1275", NULL },
+      .voidp_sizeof = 8,
+      .bigendian = 0,
+      .id = IMAGE_PPC, 
+      .flags = PLATFORM_FLAGS_NONE,
+      .total_module_size = TARGET_NO_FIELD,
+      .decompressor_compressed_size = TARGET_NO_FIELD,
+      .decompressor_uncompressed_size = TARGET_NO_FIELD,
+      .decompressor_uncompressed_addr = TARGET_NO_FIELD,
+      .section_align = 1,
+      .vaddr_offset = 0,
+      .link_addr = GRUB_KERNEL_POWERPC64LE_IEEE1275_LINK_ADDR,
+      .elf_target = EM_PPC64,
+      .mod_gap = GRUB_KERNEL_POWERPC64LE_IEEE1275_MOD_GAP,
+      .mod_align = GRUB_KERNEL_POWERPC64LE_IEEE1275_MOD_ALIGN,
+      .link_align = 4
+    },
+    {
       .dirname = "sparc64-ieee1275",
       .names = { "sparc64-ieee1275-raw", NULL },
       .voidp_sizeof = 8,
-- 
1.8.5.3



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

* [RFC PATCH 05/23] set ABI version in e_flag of the PPC64LE ELF image.
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (3 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 04/23] grub-install can now recognize and install a LE grub boot loader Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 06/23] Add IEEE1275_ADDR helper Ram Pai
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

set the ABI version to 0x02 in the e_flag of the PPC64LE ELF image.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 include/grub/elf.h    | 1 +
 util/grub-mkimagexx.c | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/include/grub/elf.h b/include/grub/elf.h
index caa7963..bee7583 100644
--- a/include/grub/elf.h
+++ b/include/grub/elf.h
@@ -1851,6 +1851,7 @@ typedef Elf32_Addr Elf32_Conflict;
 
 /* Values for Elf32/64_Ehdr.e_flags.  */
 #define EF_PPC_EMB		0x80000000	/* PowerPC embedded flag */
+#define EF_PPC64LE_ABIV2	0x00000002	/* PowerPC 64 LE flag */
 
 /* Cygnus local bits below */
 #define EF_PPC_RELOCATABLE	0x00010000	/* PowerPC -mrelocatable flag*/
diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c
index 0a1ac9e..b1833a1 100644
--- a/util/grub-mkimagexx.c
+++ b/util/grub-mkimagexx.c
@@ -141,11 +141,15 @@ SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target
   phdr->p_vaddr = grub_host_to_target32 (target_addr);
   phdr->p_paddr = grub_host_to_target32 (target_addr);
   phdr->p_align = grub_host_to_target32 (align > image_target->link_align ? align : image_target->link_align);
+
   if (image_target->id == IMAGE_LOONGSON_ELF)
     ehdr->e_flags = grub_host_to_target32 (0x1000 | EF_MIPS_NOREORDER 
 					   | EF_MIPS_PIC | EF_MIPS_CPIC);
+  else if (image_target->id == IMAGE_PPC && image_target->bigendian == 0)
+    ehdr->e_flags = grub_host_to_target32 (EF_PPC64LE_ABIV2);
   else
     ehdr->e_flags = 0;
+
   if (image_target->id == IMAGE_LOONGSON_ELF)
     {
       phdr->p_filesz = grub_host_to_target32 (*core_size);
-- 
1.8.5.3



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

* [RFC PATCH 06/23] Add IEEE1275_ADDR helper
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (4 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 05/23] set ABI version in e_flag of the PPC64LE ELF image Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 17:11   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 07/23] Fix some more warnings when casting Ram Pai
                   ` (16 subsequent siblings)
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

If the target pointer size doesn't match the IEEE1275 cell size, we
need to cast twice to avoid a warning.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 grub-core/disk/ieee1275/ofdisk.c       |  4 ++--
 grub-core/kern/ieee1275/ieee1275.c     | 30 +++++++++++++++---------------
 grub-core/kern/ieee1275/openfw.c       |  6 +++---
 grub-core/lib/ieee1275/datetime.c      |  4 ++--
 grub-core/net/drivers/ieee1275/ofnet.c |  2 +-
 include/grub/ieee1275/ieee1275.h       |  4 +++-
 6 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index 6870b39..1b72f06 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -224,7 +224,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	return;
     
       INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
-      args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
+      args.method = IEEE1275_ADDR("vscsi-report-luns");
       args.ihandle = ihandle;
       args.table = 0;
       args.nentries = 0;
@@ -613,7 +613,7 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
     return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device");
 
   INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
-  args_ieee1275.method = (grub_ieee1275_cell_t) "block-size";
+  args_ieee1275.method = IEEE1275_ADDR("block-size");
   args_ieee1275.ihandle = last_ihandle;
   args_ieee1275.result = 1;
 
diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index 9821702..f933c89 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -38,7 +38,7 @@ grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep)
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "finddevice", 1, 1);
-  args.device = (grub_ieee1275_cell_t) name;
+  args.device = IEEE1275_ADDR(name);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
@@ -66,8 +66,8 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
 
   INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1);
   args.phandle = phandle;
-  args.prop = (grub_ieee1275_cell_t) property;
-  args.buf = (grub_ieee1275_cell_t) buf;
+  args.prop = IEEE1275_ADDR(property);
+  args.buf = IEEE1275_ADDR(buf);
   args.buflen = (grub_ieee1275_cell_t) size;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -115,8 +115,8 @@ grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
 
   INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1);
   args.phandle = phandle;
-  args.prev_prop = (grub_ieee1275_cell_t) prev_prop;
-  args.next_prop = (grub_ieee1275_cell_t) prop;
+  args.prev_prop = IEEE1275_ADDR(prev_prop);
+  args.next_prop = IEEE1275_ADDR(prop);
   args.flags = (grub_ieee1275_cell_t) -1;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -139,7 +139,7 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
 
   INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
   args.phandle = phandle;
-  args.prop = (grub_ieee1275_cell_t) prop;
+  args.prop = IEEE1275_ADDR(prop);
   args.length = (grub_ieee1275_cell_t) -1;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -190,7 +190,7 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
 
   INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1);
   args.phandle = phandle;
-  args.buf = (grub_ieee1275_cell_t) path;
+  args.buf = IEEE1275_ADDR(path);
   args.buflen = (grub_ieee1275_cell_t) len;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -219,7 +219,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
 
   INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1);
   args.ihandle = ihandle;
-  args.buf = (grub_ieee1275_cell_t) path;
+  args.buf = IEEE1275_ADDR(path);
   args.buflen = (grub_ieee1275_cell_t) len;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -247,7 +247,7 @@ grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
 
   INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
   args.ihandle = ihandle;
-  args.buf = (grub_ieee1275_cell_t) buffer;
+  args.buf = IEEE1275_ADDR(buffer);
   args.len = (grub_ieee1275_cell_t) len;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -273,7 +273,7 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
 
   INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
   args.ihandle = ihandle;
-  args.buf = (grub_ieee1275_cell_t) buffer;
+  args.buf = IEEE1275_ADDR(buffer);
   args.len = (grub_ieee1275_cell_t) len;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -401,7 +401,7 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
     return -1;
 
   INIT_IEEE1275_COMMON (&args.common, "interpret", 1, 1);
-  args.command = (grub_ieee1275_cell_t) command;
+  args.command = IEEE1275_ADDR(command);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
@@ -453,7 +453,7 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "open", 1, 1);
-  args.path = (grub_ieee1275_cell_t) path;
+  args.path = IEEE1275_ADDR(path);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
@@ -548,8 +548,8 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
 
   INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
   args.size = (grub_ieee1275_cell_t) size;
-  args.buf = (grub_ieee1275_cell_t) buf;
-  args.propname = (grub_ieee1275_cell_t) propname;
+  args.buf = IEEE1275_ADDR(buf);
+  args.propname = IEEE1275_ADDR(propname);
   args.phandle = (grub_ieee1275_cell_t) phandle;
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
@@ -578,7 +578,7 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
-  args.method = (grub_ieee1275_cell_t) "color!";
+  args.method = IEEE1275_ADDR("color!");
   args.ihandle = ihandle;
   args.index = index;
   args.r = r;
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
index ddb7783..a8bbc71 100644
--- a/grub-core/kern/ieee1275/openfw.c
+++ b/grub-core/kern/ieee1275/openfw.c
@@ -285,7 +285,7 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
 			6,
 #endif
 			1);
-  args.method = (grub_ieee1275_cell_t) "map";
+  args.method = IEEE1275_ADDR("map");
   args.ihandle = grub_ieee1275_mmu;
 #ifdef __sparc__
   args.phys_high = 0;
@@ -543,8 +543,8 @@ grub_ieee1275_canonicalise_devname (const char *path)
 	return NULL;
 
       INIT_IEEE1275_COMMON (&args.common, "canon", 3, 1);
-      args.path = (grub_ieee1275_cell_t) path;
-      args.buf = (grub_ieee1275_cell_t) buf;
+      args.path = IEEE1275_ADDR(path);
+      args.buf = IEEE1275_ADDR(buf);
       args.inlen = (grub_ieee1275_cell_t) (bufsize - 1);
 
       if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
index 74578f1..fa0d3b6 100644
--- a/grub-core/lib/ieee1275/datetime.c
+++ b/grub-core/lib/ieee1275/datetime.c
@@ -84,7 +84,7 @@ grub_get_datetime (struct grub_datetime *datetime)
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7);
   args.device = (grub_ieee1275_cell_t) ihandle;
-  args.method = (grub_ieee1275_cell_t) "get-time";
+  args.method = IEEE1275_ADDR("get-time");
 
   status = IEEE1275_CALL_ENTRY_FN (&args);
 
@@ -136,7 +136,7 @@ grub_set_datetime (struct grub_datetime *datetime)
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1);
   args.device = (grub_ieee1275_cell_t) ihandle;
-  args.method = (grub_ieee1275_cell_t) "set-time";
+  args.method = IEEE1275_ADDR("set-time");
 
   args.year = datetime->year;
   args.month = datetime->month;
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index eea8e71..ea6456f 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -386,7 +386,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
       args;
       INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2);
       args.len = card->txbufsize;
-      args.method = (grub_ieee1275_cell_t) "alloc-mem";
+      args.method = IEEE1275_ADDR("alloc-mem");
 
       if (IEEE1275_CALL_ENTRY_FN (&args) == -1
 	  || args.catch)
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 8e42513..2e5270c 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -49,8 +49,10 @@ struct grub_ieee1275_common_hdr
   grub_ieee1275_cell_t nr_outs;
 };
 
+#define IEEE1275_ADDR(x)         (grub_uint32_t)(grub_addr_t)(x)
+
 #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
-  (p)->name = (grub_ieee1275_cell_t) xname; \
+  (p)->name = (grub_ieee1275_cell_t) IEEE1275_ADDR(xname); \
   (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
   (p)->nr_outs = (grub_ieee1275_cell_t) xouts
 
-- 
1.8.5.3



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

* [RFC PATCH 07/23] Fix some more warnings when casting.
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (5 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 06/23] Add IEEE1275_ADDR helper Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 08/23] Add powerpc64 types Ram Pai
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

Fix some more warnings when casting.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 grub-core/disk/ieee1275/ofdisk.c       | 2 +-
 grub-core/lib/powerpc/relocator.c      | 8 ++++----
 grub-core/net/drivers/ieee1275/ofnet.c | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index 1b72f06..d785d6a 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -244,7 +244,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	{
 	  grub_uint64_t *ptr;
 
-	  ptr = *(grub_uint64_t **) (args.table + 4 + 8 * i);
+	  ptr = *(grub_uint64_t **) ((grub_addr_t)args.table + 4 + 8 * i);
 	  while (*ptr)
 	    {
 	      grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
diff --git a/grub-core/lib/powerpc/relocator.c b/grub-core/lib/powerpc/relocator.c
index bdf2b11..4bac96f 100644
--- a/grub-core/lib/powerpc/relocator.c
+++ b/grub-core/lib/powerpc/relocator.c
@@ -84,8 +84,8 @@ grub_cpu_relocator_backward (void *ptr0, void *src, void *dest,
 			     grub_size_t size)
 {
   void *ptr = ptr0;
-  write_reg (8, (grub_uint32_t) src, &ptr);
-  write_reg (9, (grub_uint32_t) dest, &ptr);
+  write_reg (8, (grub_uint32_t) (grub_addr_t) src, &ptr);
+  write_reg (9, (grub_uint32_t) (grub_addr_t) dest, &ptr);
   write_reg (10, (grub_uint32_t) size, &ptr);
   grub_memcpy (ptr, &grub_relocator_backward_start,
 	       RELOCATOR_SRC_SIZEOF (backward));
@@ -96,8 +96,8 @@ grub_cpu_relocator_forward (void *ptr0, void *src, void *dest,
 			     grub_size_t size)
 {
   void *ptr = ptr0;
-  write_reg (8, (grub_uint32_t) src, &ptr);
-  write_reg (9, (grub_uint32_t) dest, &ptr);
+  write_reg (8, (grub_uint32_t) (grub_addr_t) src, &ptr);
+  write_reg (9, (grub_uint32_t) (grub_addr_t) dest, &ptr);
   write_reg (10, (grub_uint32_t) size, &ptr);
   grub_memcpy (ptr, &grub_relocator_forward_start, 
 	       RELOCATOR_SRC_SIZEOF (forward));
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index ea6456f..07c8446 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -395,7 +395,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
 	  grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
 	}
       else
-	card->txbuf = (void *) args.result;
+	card->txbuf = (void *) (grub_addr_t) args.result;
     }
   else
     card->txbuf = grub_zalloc (card->txbufsize);
-- 
1.8.5.3



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

* [RFC PATCH 08/23] Add powerpc64 types
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (6 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 07/23] Fix some more warnings when casting Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 17:15   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit Ram Pai
                   ` (14 subsequent siblings)
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 Add powerpc64 types

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 include/grub/powerpc/types.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
index a098ae6..7a2fc6b 100644
--- a/include/grub/powerpc/types.h
+++ b/include/grub/powerpc/types.h
@@ -19,11 +19,19 @@
 #ifndef GRUB_TYPES_CPU_HEADER
 #define GRUB_TYPES_CPU_HEADER	1
 
+#ifdef __powerpc64le__
+/* The size of void *.  */
+#define GRUB_TARGET_SIZEOF_VOID_P	8
+
+/* The size of long.  */
+#define GRUB_TARGET_SIZEOF_LONG		8
+#else
 /* The size of void *.  */
 #define GRUB_TARGET_SIZEOF_VOID_P	4
 
 /* The size of long.  */
 #define GRUB_TARGET_SIZEOF_LONG		4
+#endif
 
 /* powerpc is big-endian.  */
 #define GRUB_TARGET_WORDS_BIGENDIAN	1
-- 
1.8.5.3



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

* [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (7 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 08/23] Add powerpc64 types Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 17:21   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 10/23] GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader Ram Pai
                   ` (13 subsequent siblings)
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

Fix warnings when building powerpc linux loader 64bit

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 grub-core/loader/powerpc/ieee1275/linux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
index 4a14f66..3d6a61e 100644
--- a/grub-core/loader/powerpc/ieee1275/linux.c
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
@@ -141,8 +141,8 @@ grub_linux_boot (void)
   grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args,
 			      grub_strlen (linux_args) + 1, &actual);
 
-  grub_dprintf ("loader", "Entry point: 0x%x\n", linux_entry);
-  grub_dprintf ("loader", "Initrd at: 0x%x, size 0x%x\n", initrd_addr,
+  grub_dprintf ("loader", "Entry point: 0x%lx\n", linux_entry);
+  grub_dprintf ("loader", "Initrd at: 0x%lx, size 0x%lx\n", initrd_addr,
 		initrd_size);
   grub_dprintf ("loader", "Boot arguments: %s\n", linux_args);
   grub_dprintf ("loader", "Jumping to Linux...\n");
@@ -360,7 +360,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
   if (addr == (grub_addr_t) -1)
      goto fail;
 
-  grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
+  grub_dprintf ("loader", "Loading initrd at 0x%lx, size 0x%lx\n", addr, size);
 
   if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
     goto fail;
-- 
1.8.5.3



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

* [RFC PATCH 10/23] GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader.
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (8 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues Ram Pai
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/kern/powerpc/dl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c
index 3a7fa3e..7677e5a 100644
--- a/grub-core/kern/powerpc/dl.c
+++ b/grub-core/kern/powerpc/dl.c
@@ -94,6 +94,7 @@ grub_err_t
 grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
 			       Elf_Shdr *s, grub_dl_segment_t seg)
 {
+#ifdef powerpc
   Elf_Rela *rel, *max;
 
   for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
@@ -155,7 +156,6 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
 	case GRUB_ELF_R_PPC_REL32:
 	  *addr = value - (Elf_Word) addr;
 	  break;
-
 	default:
 	  return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
 			     N_("relocation 0x%x is not implemented yet"),
@@ -164,4 +164,9 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
     }
 
   return GRUB_ERR_NONE;
+#else
+  return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+     N_("relocation is not implemented yet for module=%llx ehdr=%llx Elf_Shdr=%llx seg=%llx"), 
+     mod, ehdr, s, seg);
+#endif
 }
-- 
1.8.5.3



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

* [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (9 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 10/23] GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 17:27   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 12/23] Add powerpc64 ieee1275 trampoline Ram Pai
                   ` (11 subsequent siblings)
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 Fix powerpc setjmp/longjmp 64bit issues

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From:  Anton Blanchard <anton@samba.org>
---
 grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
 1 file changed, 52 insertions(+), 42 deletions(-)

diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
index 716b563..51fcae9 100644
--- a/grub-core/lib/powerpc/setjmp.S
+++ b/grub-core/lib/powerpc/setjmp.S
@@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
 
 	.text
 
+#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
+#define LOAD	ld
+#define STORE	std
+#define SZ_LONG	8
+#else
+#define LOAD	lwz
+#define STORE	stw
+#define SZ_LONG	4
+#endif
+
 /*
  * int grub_setjmp (grub_jmp_buf env)
  */
 FUNCTION(grub_setjmp)
-	stw	1, 0(3)
-	stw	14, 4(3)
-	stw	15, 8(3)
-	stw	16, 12(3)
-	stw	17, 16(3)
-	stw	18, 20(3)
-	stw	19, 24(3)
-	stw	20, 28(3)
-	stw	21, 32(3)
-	stw	22, 36(3)
-	stw	23, 40(3)
-	stw	24, 44(3)
-	stw	25, 48(3)
-	stw	26, 52(3)
-	stw	27, 56(3)
-	stw	28, 60(3)
-	stw	29, 64(3)
-	stw	30, 68(3)
-	stw	31, 72(3)
+	STORE	1, 0(3)
+	STORE	14, 1*SZ_LONG(3)
+	STORE	15, 2*SZ_LONG(3)
+	STORE	16, 3*SZ_LONG(3)
+	STORE	17, 4*SZ_LONG(3)
+	STORE	18, 5*SZ_LONG(3)
+	STORE	19, 6*SZ_LONG(3)
+	STORE	20, 7*SZ_LONG(3)
+	STORE	21, 8*SZ_LONG(3)
+	STORE	22, 9*SZ_LONG(3)
+	STORE	23, 10*SZ_LONG(3)
+	STORE	24, 11*SZ_LONG(3)
+	STORE	25, 12*SZ_LONG(3)
+	STORE	26, 13*SZ_LONG(3)
+	STORE	27, 14*SZ_LONG(3)
+	STORE	28, 15*SZ_LONG(3)
+	STORE	29, 16*SZ_LONG(3)
+	STORE	30, 17*SZ_LONG(3)
+	STORE	31, 18*SZ_LONG(3)
 	mflr	4
-	stw	4, 76(3)
+	STORE	4, 19*SZ_LONG(3)
 	mfcr	4
-	stw	4, 80(3)
+	STORE	4, 20*SZ_LONG(3)
 	li	3, 0
 	blr
 
@@ -59,28 +69,28 @@ FUNCTION(grub_setjmp)
  * int grub_longjmp (grub_jmp_buf env, int val)
  */
 FUNCTION(grub_longjmp)
-	lwz	1, 0(3)
-	lwz	14, 4(3)
-	lwz	15, 8(3)
-	lwz	16, 12(3)
-	lwz	17, 16(3)
-	lwz	18, 20(3)
-	lwz	19, 24(3)
-	lwz	20, 28(3)
-	lwz	21, 32(3)
-	lwz	22, 36(3)
-	lwz	23, 40(3)
-	lwz	24, 44(3)
-	lwz	25, 48(3)
-	lwz	26, 52(3)
-	lwz	27, 56(3)
-	lwz	28, 60(3)
-	lwz	29, 64(3)
-	lwz	30, 68(3)
-	lwz	31, 72(3)
-	lwz	5, 76(3)
+	LOAD	1, 0(3)
+	LOAD	14, 1*SZ_LONG(3)
+	LOAD	15, 2*SZ_LONG(3)
+	LOAD	16, 3*SZ_LONG(3)
+	LOAD	17, 4*SZ_LONG(3)
+	LOAD	18, 5*SZ_LONG(3)
+	LOAD	19, 6*SZ_LONG(3)
+	LOAD	20, 7*SZ_LONG(3)
+	LOAD	21, 8*SZ_LONG(3)
+	LOAD	22, 9*SZ_LONG(3)
+	LOAD	23, 10*SZ_LONG(3)
+	LOAD	24, 11*SZ_LONG(3)
+	LOAD	25, 12*SZ_LONG(3)
+	LOAD	26, 13*SZ_LONG(3)
+	LOAD	27, 14*SZ_LONG(3)
+	LOAD	28, 15*SZ_LONG(3)
+	LOAD	29, 16*SZ_LONG(3)
+	LOAD	30, 17*SZ_LONG(3)
+	LOAD	31, 18*SZ_LONG(3)
+	LOAD	5, 19*SZ_LONG(3)
 	mtlr	5
-	lwz	5, 80(3)
+	LOAD	5, 20*SZ_LONG(3)
 	mtcr	5
 	mr.	3, 4
 	bne	1f
-- 
1.8.5.3



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

* [RFC PATCH 12/23] Add powerpc64 ieee1275 trampoline
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (10 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 13/23] Add 64bit support to powerpc startup code Ram Pai
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

Add a trampoline so a 64bit grub can call a 32 bit OF

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 grub-core/Makefile.core.def              |   2 +
 grub-core/kern/powerpc/ieee1275/entry.S  | 150 +++++++++++++++++++++++++++++++
 include/grub/powerpc/ieee1275/ieee1275.h |   6 ++
 3 files changed, 158 insertions(+)
 create mode 100644 grub-core/kern/powerpc/ieee1275/entry.S

diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index c6e70bb..0c80fe4 100644
--- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def
@@ -256,9 +256,11 @@ kernel = {
 
   powerpc_ieee1275 = kern/powerpc/cache.S;
   powerpc_ieee1275 = kern/powerpc/dl.c;
+  powerpc_ieee1275 = kern/powerpc/ieee1275/entry.S;
 
   powerpc64le_ieee1275 = kern/powerpc/cache.S;
   powerpc64le_ieee1275 = kern/powerpc/dl.c;
+  powerpc64le_ieee1275 = kern/powerpc/ieee1275/entry.S;
 
   sparc64_ieee1275 = kern/sparc64/cache.S;
   sparc64_ieee1275 = kern/sparc64/dl.c;
diff --git a/grub-core/kern/powerpc/ieee1275/entry.S b/grub-core/kern/powerpc/ieee1275/entry.S
new file mode 100644
index 0000000..5d58149
--- /dev/null
+++ b/grub-core/kern/powerpc/ieee1275/entry.S
@@ -0,0 +1,150 @@
+/* entry.S - open firmware call entry and return  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2004,2007,2010,2014  Free Software Foundation, Inc.
+ *
+ *  GRUB is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation, either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <ppc-asm.h>
+
+#define STACK_FRAME_SIZE	(48 + 64 + 16 + 144)
+#define MSR_OFFSET		(48 + 64)
+#define R13_OFFSET		(MSR_OFFSET + 8)
+#define NVREG_OFFSET(i)		(STACK_FRAME_SIZE - (32-(i))*8)
+#define SAVE_NVGPR(A)	std	(A),NVREG_OFFSET(A)(r1)
+#define REST_NVGPR(A)	ld	(A),NVREG_OFFSET(A)(r1)
+#define SPRN_SRR0	0x01A
+#define SPRN_SRR1	0x01B
+#define r1	sp
+
+
+#if defined(_CALL_ELF) && _CALL_ELF == 1  /* BIG ENDIAN */
+#define TOC_OFFSET		40
+#define r2	toc
+#endif
+
+/*
+ * OF runs in 32 bit mode so it clobbers the high 32 bits of all registers
+ * it saves. We save and restore all the non volatile registers to avoid
+ * this issue.
+ *
+ * unsigned int ieee1275_call_entry_fn(void *args, unsigned long entry);
+ */
+FUNC_START(ieee1275_call_entry_fn)
+	mflr	r0
+	std	r0,16(r1)
+	stdu	r1,-STACK_FRAME_SIZE(r1)
+
+#if defined(_CALL_ELF) && _CALL_ELF == 1  /* BIG ENDIAN */
+	std	r2,TOC_OFFSET(r1)
+#endif
+	std	r13,R13_OFFSET(r1)
+
+	SAVE_NVGPR(r14)
+	SAVE_NVGPR(r15)
+	SAVE_NVGPR(r16)
+	SAVE_NVGPR(r17)
+	SAVE_NVGPR(r18)
+	SAVE_NVGPR(r19)
+	SAVE_NVGPR(r20)
+	SAVE_NVGPR(r21)
+	SAVE_NVGPR(r22)
+	SAVE_NVGPR(r23)
+	SAVE_NVGPR(r24)
+	SAVE_NVGPR(r25)
+	SAVE_NVGPR(r26)
+	SAVE_NVGPR(r27)
+	SAVE_NVGPR(r28)
+	SAVE_NVGPR(r29)
+	SAVE_NVGPR(r30)
+	SAVE_NVGPR(r31)
+
+	mfmsr	r31
+	std	r31, MSR_OFFSET(r1)
+
+	/* Clear 64bit mode */
+	rldicl r31,r31,0,1
+
+#if defined(_CALL_ELF) && _CALL_ELF == 2  /* LITTLE ENDIAN */
+	/* Clear LE mode */
+	rldicr r31,r31,0,62
+#endif
+
+	mtspr	SPRN_SRR0,r4
+	mtspr	SPRN_SRR1,r31
+
+	/* Point the LR at our return code */
+	bl	1f
+1:	mflr	r30
+	addi	r30,r30,(2f - 1b)
+	mtlr	r30
+
+	/* Call OF */
+	rfid
+
+#if defined(_CALL_ELF) && _CALL_ELF == 2  /* LITTLE ENDIAN */
+2:     .long 0x05009f42        /* bcl     20,31,$+4 */
+       .long 0xa602487d        /* mflr    r10 */
+       .long 0x1c004a39        /* addi    r10,r10,28 */
+       .long 0xa6035a7d        /* mtsrr0  r10 */
+       .long 0xa600407d        /* mfmsr   r10 */
+       .long 0x01004a69        /* xori    r10,r10,1 */
+       .long 0xa6035b7d        /* mtsrr1  r10 */
+       .long 0x2400004c        /* rfid */
+#endif
+
+	/* Clear the top 32 bits of r1, just in case */
+2:	rldicl	r1,r1,0,32
+
+	/* Reset our MSR */
+	ld	r31,MSR_OFFSET(r1)
+	mtspr	SPRN_SRR1,r31
+
+	bl	3f
+3:	mflr	r30
+	addi	r30,r30,(4f - 3b)
+	mtspr	SPRN_SRR0,r30
+
+	rfid
+
+#if defined(_CALL_ELF) && _CALL_ELF == 1  /* BIG ENDIAN */
+4:	ld	r2,TOC_OFFSET(r1)
+#endif
+4:	ld	r13,R13_OFFSET(r1)
+
+	REST_NVGPR(r14)
+	REST_NVGPR(r15)
+	REST_NVGPR(r16)
+	REST_NVGPR(r17)
+	REST_NVGPR(r18)
+	REST_NVGPR(r19)
+	REST_NVGPR(r20)
+	REST_NVGPR(r21)
+	REST_NVGPR(r22)
+	REST_NVGPR(r23)
+	REST_NVGPR(r24)
+	REST_NVGPR(r25)
+	REST_NVGPR(r26)
+	REST_NVGPR(r27)
+	REST_NVGPR(r28)
+	REST_NVGPR(r29)
+	REST_NVGPR(r30)
+	REST_NVGPR(r31)
+
+	addi	r1,r1,STACK_FRAME_SIZE
+	ld	r0,16(r1)
+	mtlr	r0
+	blr
+FUNC_END(ieee1275_call_entry_fn)
diff --git a/include/grub/powerpc/ieee1275/ieee1275.h b/include/grub/powerpc/ieee1275/ieee1275.h
index 3c7683f..14bdc43 100644
--- a/include/grub/powerpc/ieee1275/ieee1275.h
+++ b/include/grub/powerpc/ieee1275/ieee1275.h
@@ -25,4 +25,10 @@
 #define GRUB_IEEE1275_CELL_SIZEOF 4
 typedef grub_uint32_t grub_ieee1275_cell_t;
 
+#ifdef __powerpc64__
+int EXPORT_FUNC(ieee1275_call_entry_fn)(void *args, void *entry);
+#define	IEEE1275_CALL_ENTRY_FN(args)	\
+		ieee1275_call_entry_fn((args), grub_ieee1275_entry_fn)
+#endif
+
 #endif /* ! GRUB_IEEE1275_MACHINE_HEADER */
-- 
1.8.5.3



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

* [RFC PATCH 13/23] Add 64bit support to powerpc startup code
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (11 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 12/23] Add powerpc64 ieee1275 trampoline Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 14/23] Add grub_dl_find_section_addr Ram Pai
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 Add 64bit support to powerpc startup code

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 grub-core/kern/powerpc/ieee1275/startup.S | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/grub-core/kern/powerpc/ieee1275/startup.S b/grub-core/kern/powerpc/ieee1275/startup.S
index 21c884b..d93682e 100644
--- a/grub-core/kern/powerpc/ieee1275/startup.S
+++ b/grub-core/kern/powerpc/ieee1275/startup.S
@@ -19,15 +19,26 @@
 
 #include <grub/symbol.h>
 #include <grub/offsets.h>
+#include <ppc-asm.h>
 
 .extern __bss_start
 .extern _end
 
 	.text
-	.align	2
-	.globl	start, _start
-start:
-_start:
+
+FUNC_START(_start)
+
+#if defined(_CALL_ELF) && _CALL_ELF == 2 /* Little endian */
+        .long 0x05009f42            /* bcl 20,31,$+4                      */
+        .long 0xa602487d            /* mflr r10                           */
+        .long 0x1c004a39            /* addi r10,r10,28                    */
+        .long 0xa600607d            /* mfmsr r11                          */
+        .long 0x01006b69            /* xori r11,r11,1                     */
+        .long 0xa6035a7d            /* mtsrr0 r10                         */
+        .long 0xa6037b7d            /* mtsrr1 r11                         */
+        .long 0x2400004c            /* rfid                               */
+#endif
+
 	li      2, 0
 	li      13, 0
 
@@ -61,7 +72,18 @@ _start:
 
 	/* Store r5 in grub_ieee1275_entry_fn.  */
 	lis	9, grub_ieee1275_entry_fn@ha
+
+#if defined( __powerpc64__ ) || defined ( __powerpc64le__ )
+	std	5, grub_ieee1275_entry_fn@l(9)
+	/* Set up the TOC */
+	bl	3f
+3:	mflr	9
+	addis	2,9,.TOC.-3b@ha
+	addi	2,2,.TOC.-3b@l
+#else
 	stw	5, grub_ieee1275_entry_fn@l(9)
+#endif
 
 	bl	grub_main
 1:	b	1b
+FUNC_END(_start)
-- 
1.8.5.3



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

* [RFC PATCH 14/23] Add grub_dl_find_section_addr
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (12 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 13/23] Add 64bit support to powerpc startup code Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 15/23] Add ppc64 relocations Ram Pai
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

ppc64 needs to find the address of the toc and opd sections.
Create grub_dl_find_section_addr to do this.

We also need grub_dl_find_section, so make it global.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 grub-core/kern/dl.c | 27 ++++++++++++++++++++++++++-
 include/grub/dl.h   |  2 ++
 2 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index 6850e04..de2d0ed 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -191,6 +191,31 @@ grub_dl_get_section_addr (grub_dl_t mod, unsigned n)
   return 0;
 }
 
+void *grub_dl_find_section_addr (grub_dl_t mod, Elf_Ehdr *e, const char *name)
+{
+  Elf_Shdr *s;
+  const char *str;
+  unsigned i;
+  grub_dl_segment_t seg;
+
+  s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
+  str = (char *) e + s->sh_offset;
+
+  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+       i < e->e_shnum;
+       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+    {
+      if (grub_strcmp (str + s->sh_name, name) == 0)
+	{
+	  for (seg = mod->segment; seg; seg = seg->next)
+	    if (seg->section == i)
+	      return seg->addr;
+	}
+    }
+
+  return 0;
+}
+
 /* Check if EHDR is a valid ELF header.  */
 static grub_err_t
 grub_dl_check_header (void *ehdr, grub_size_t size)
@@ -427,7 +452,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
   return GRUB_ERR_NONE;
 }
 
-static Elf_Shdr *
+Elf_Shdr *
 grub_dl_find_section (Elf_Ehdr *e, const char *name)
 {
   Elf_Shdr *s;
diff --git a/include/grub/dl.h b/include/grub/dl.h
index 9562fa6..39c73a7 100644
--- a/include/grub/dl.h
+++ b/include/grub/dl.h
@@ -250,6 +250,8 @@ grub_err_t grub_arch_dl_check_header (void *ehdr);
 grub_err_t
 grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
 			       Elf_Shdr *s, grub_dl_segment_t seg);
+Elf_Shdr * grub_dl_find_section (Elf_Ehdr *e, const char *name);
+void *grub_dl_find_section_addr (grub_dl_t mod, Elf_Ehdr *e, const char *name);
 #endif
 
 #if defined (_mips)
-- 
1.8.5.3



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

* [RFC PATCH 15/23] Add ppc64 relocations
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (13 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 14/23] Add grub_dl_find_section_addr Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 16/23] ppc64 doesn't need libgcc routines Ram Pai
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 Add ppc64 relocations

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From:    Anton Blanchard <anton@samba.org>
---
 grub-core/kern/powerpc/dl.c | 179 +++++++++++++++++++++++++++++++++++++++++---
 include/grub/elf.h          |   3 +
 2 files changed, 172 insertions(+), 10 deletions(-)

diff --git a/grub-core/kern/powerpc/dl.c b/grub-core/kern/powerpc/dl.c
index 7677e5a..2a3b022 100644
--- a/grub-core/kern/powerpc/dl.c
+++ b/grub-core/kern/powerpc/dl.c
@@ -23,6 +23,20 @@
 #include <grub/err.h>
 #include <grub/i18n.h>
 
+#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
+#define ELFCLASSXX ELFCLASS64
+#define ELFMACHINEXX EM_PPC64
+#else
+#define ELFCLASSXX ELFCLASS32
+#define ELFMACHINEXX EM_PPC32
+#endif
+
+#if defined( __powerpc64le__ )
+#define ELFDATA2XSB ELFDATA2LSB
+#else
+#define ELFDATA2XSB ELFDATA2MSB
+#endif
+
 /* Check if EHDR is a valid ELF header.  */
 grub_err_t
 grub_arch_dl_check_header (void *ehdr)
@@ -30,14 +44,77 @@ grub_arch_dl_check_header (void *ehdr)
   Elf_Ehdr *e = ehdr;
 
   /* Check the magic numbers.  */
-  if (e->e_ident[EI_CLASS] != ELFCLASS32
-      || e->e_ident[EI_DATA] != ELFDATA2MSB
-      || e->e_machine != EM_PPC)
+  if (e->e_ident[EI_CLASS] != ELFCLASSXX
+      || e->e_ident[EI_DATA] != ELFDATA2XSB
+      || e->e_machine != ELFMACHINEXX)
     return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic"));
 
   return GRUB_ERR_NONE;
 }
 
+
+
+
+#if defined( __powerpc64le__ )
+struct trampoline
+{
+  grub_uint32_t std;
+  grub_uint32_t addis;
+  grub_uint32_t addi; 
+  grub_uint32_t mtctr;
+  grub_uint32_t bctr;
+};
+
+static const struct trampoline trampoline_template = 
+  {
+       0xf8410018,       /* std     r2,24(r1) */
+       0x3d800000,       /* addis   r12,0,0 */
+       0x398c0000,       /* addi    r12,r12,0 */
+       0x7d8903a6,       /* mtctr   r12 */
+       0x4e800420,       /* bctr */
+  };
+
+#define PPC_NOP 0x60000000
+#define	RESTORE_TOC 0xe8410018       /* ld      r2,24(r1) */
+
+#define STO_PPC64_LOCAL_BIT             5
+#define STO_PPC64_LOCAL_MASK            (7 << STO_PPC64_LOCAL_BIT)
+
+static inline unsigned int
+ppc64_decode_local_entry(unsigned int other)
+{
+  return ((1 << other) >> 2) << 2;
+}
+
+#define PPC64_LOCAL_ENTRY_OFFSET(other)                         \
+  ppc64_decode_local_entry (((other) & STO_PPC64_LOCAL_MASK)    \
+                            >> STO_PPC64_LOCAL_BIT)
+
+
+
+#elif defined( __powerpc64__ )
+
+#error "NOT SUPPORTED YET"
+
+static int grub_arch_dl_is_in_opd (grub_dl_t mod, void *ehdr, unsigned long addr)
+{
+  unsigned long start, end;
+  Elf_Shdr *s = grub_dl_find_section(ehdr, ".opd");
+
+  if (!s)
+	return 0;
+
+  start = (unsigned long)grub_dl_find_section_addr(mod, ehdr, ".opd");
+  end = start + s->sh_size;
+
+  if ((start <= addr) && (addr < end))
+    return 1;
+  else
+    return 0;
+}
+
+#else
+
 /* For low-endian reverse lis and addr_high as well as ori and addr_low. */
 struct trampoline
 {
@@ -55,8 +132,20 @@ static const struct trampoline trampoline_template =
     0x4e800420,
   };
 
+#endif
+
 #pragma GCC diagnostic ignored "-Wcast-align"
 
+static unsigned long grub_arch_dl_get_toc (grub_dl_t mod, void *ehdr)
+{
+  unsigned long i = (unsigned long)grub_dl_find_section_addr(mod, ehdr, ".toc");
+  if (!i)
+    return 0;
+
+  return i;
+}
+
+
 grub_err_t
 grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
 				 grub_size_t *got)
@@ -89,12 +178,15 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp,
   return GRUB_ERR_NONE;
 }
 
+#define PPC_LO(v) ((v) & 0xffff)
+#define PPC_HI(v) (((v) >> 16) & 0xffff)
+#define PPC_HA(v) PPC_HI ((v) + 0x8000)
+
 /* Relocate symbols.  */
 grub_err_t
 grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
 			       Elf_Shdr *s, grub_dl_segment_t seg)
 {
-#ifdef powerpc
   Elf_Rela *rel, *max;
 
   for (rel = (Elf_Rela *) ((char *) ehdr + s->sh_offset),
@@ -104,7 +196,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
     {
       Elf_Word *addr;
       Elf_Sym *sym;
-      grub_uint32_t value;
+      Elf_Addr value;
 
       if (seg->size < rel->r_offset)
 	return grub_error (GRUB_ERR_BAD_MODULE,
@@ -119,6 +211,76 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
       value = sym->st_value + rel->r_addend;
       switch (ELF_R_TYPE (rel->r_info))
 	{
+#ifdef __powerpc64le__
+	case GRUB_ELF_R_PPC_REL24:
+	  {
+	    struct trampoline *tptr = mod->trampptr;
+	    Elf_Sword delta;
+	    if (sym->st_shndx == SHN_UNDEF)
+	    {
+	      	grub_memcpy (tptr, &trampoline_template, sizeof (*tptr));
+
+		tptr->addis |= PPC_HA(value);
+		tptr->addi |= PPC_LO(value);
+
+	        mod->trampptr = tptr + 1;
+	        delta = (grub_uint8_t *) tptr - (grub_uint8_t *) addr;
+
+	        if (*(addr+1) != PPC_NOP)
+	               return grub_error (GRUB_ERR_BAD_MODULE,
+			     "Missing NOP after PPC_REL24 got %x", *(addr+1));
+	        *(addr+1) = RESTORE_TOC;
+	    } else
+	        delta = (grub_uint8_t *)value - (grub_uint8_t *) addr + 
+                     PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
+
+
+            if (delta << 6 >> 6 != delta)
+		      return grub_error (GRUB_ERR_BAD_MODULE,
+					 "relocation overflow");
+
+	    *(Elf_Word *) (addr) = (*addr & ~0x03fffffc) | (delta & 0x03fffffc);
+	  }
+	  break;
+
+	case GRUB_ELF_R_PPC64_ADDR64:
+	  *(Elf_Xword *) addr = value;
+	  break;
+
+	case GRUB_ELF_R_PPC64_TOC:
+	  *(Elf_Xword *) addr = grub_arch_dl_get_toc(mod, ehdr);
+	  break;
+
+	case GRUB_ELF_R_PPC64_TOC16_HA:
+          value -= grub_arch_dl_get_toc(mod, ehdr);
+          *(Elf_Half *) addr = PPC_HA(value);
+	  break;
+
+	case GRUB_ELF_R_PPC64_TOC16_LO:
+          value -= grub_arch_dl_get_toc(mod, ehdr);
+	  *(Elf_Half *) addr = PPC_LO(value);
+	  break;
+
+	case GRUB_ELF_R_PPC64_TOC16_LO_DS:
+	   value -= grub_arch_dl_get_toc(mod, ehdr);
+	   if (value & 3)
+	    return grub_error (GRUB_ERR_BAD_MODULE,
+			       "bad TOC16_LO_DS relocation");
+	
+	  *(Elf_Half *) addr = ((*(Elf_Half *) addr) & ~0xfffc) | (value & 0xfffc);
+	  break;
+
+	case GRUB_ELF_R_PPC64_REL16_HA:
+	  value -=  (unsigned long) addr;
+	  *(Elf_Half *) addr = PPC_HA(value);
+	  break;
+
+	case GRUB_ELF_R_PPC64_REL16_LO:
+	  value -=  (unsigned long) addr;
+	  *(Elf_Half *) addr = PPC_LO(value);
+	  break;
+#else
+
 	case GRUB_ELF_R_PPC_ADDR16_LO:
 	  *(Elf_Half *) addr = value;
 	  break;
@@ -156,6 +318,8 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
 	case GRUB_ELF_R_PPC_REL32:
 	  *addr = value - (Elf_Word) addr;
 	  break;
+#endif
+
 	default:
 	  return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
 			     N_("relocation 0x%x is not implemented yet"),
@@ -164,9 +328,4 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
     }
 
   return GRUB_ERR_NONE;
-#else
-  return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
-     N_("relocation is not implemented yet for module=%llx ehdr=%llx Elf_Shdr=%llx seg=%llx"), 
-     mod, ehdr, s, seg);
-#endif
 }
diff --git a/include/grub/elf.h b/include/grub/elf.h
index bee7583..224d164 100644
--- a/include/grub/elf.h
+++ b/include/grub/elf.h
@@ -1998,6 +1998,9 @@ typedef Elf32_Addr Elf32_Conflict;
 #define GRUB_ELF_R_PPC_DIAB_RELSDA_HI	184	/* like EMB_RELSDA, but high 16 bit */
 #define GRUB_ELF_R_PPC_DIAB_RELSDA_HA	185	/* like EMB_RELSDA, adjusted high 16 */
 
+#define GRUB_ELF_R_PPC64_REL16_LO       250
+#define GRUB_ELF_R_PPC64_REL16_HA       252
+
 /* This is a phony reloc to handle any old fashioned TOC16 references
    that may still be in object files.  */
 #define GRUB_ELF_R_PPC_TOC16		255
-- 
1.8.5.3



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

* [RFC PATCH 16/23] ppc64 doesn't need libgcc routines
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (14 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 15/23] Add ppc64 relocations Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 17/23] Use FUNC_START/FUNC_END for powerpc function definitions Ram Pai
                   ` (6 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 ppc64 doesn't need libgcc routines

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From: Anton Blanchard <anton@samba.org>
---
 include/grub/libgcc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h
index fdc6611..69a95bc 100644
--- a/include/grub/libgcc.h
+++ b/include/grub/libgcc.h
@@ -23,7 +23,7 @@
 #include <config-util.h>
 
 /* On x86 these functions aren't really needed. Save some space.  */
-#if !defined (__i386__) && !defined (__x86_64__)
+#if !defined (__i386__) && !defined (__x86_64__) && !defined (__powerpc64le__)
 # ifdef HAVE___ASHLDI3
 void EXPORT_FUNC (__ashldi3) (void);
 # endif
-- 
1.8.5.3



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

* [RFC PATCH 17/23] Use FUNC_START/FUNC_END for powerpc function definitions
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (15 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 16/23] ppc64 doesn't need libgcc routines Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 18/23] .TOC. symbol is special in ppc64le Ram Pai
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 Use FUNC_START/FUNC_END for powerpc function definitions

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
From:    Anton Blanchard <anton@samba.org>
---
 grub-core/kern/powerpc/cache.S | 6 ++++--
 grub-core/lib/powerpc/setjmp.S | 8 +++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/grub-core/kern/powerpc/cache.S b/grub-core/kern/powerpc/cache.S
index d85e68d..82f10f8 100644
--- a/grub-core/kern/powerpc/cache.S
+++ b/grub-core/kern/powerpc/cache.S
@@ -17,10 +17,12 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <ppc-asm.h>
+
 	.text
 
 	.align 2
-	.globl grub_arch_sync_caches
-grub_arch_sync_caches:
+FUNC_START(grub_arch_sync_caches)
 #include "cache_flush.S"
 	blr
+FUNC_END(grub_arch_sync_caches)
diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
index 51fcae9..6fdd60e 100644
--- a/grub-core/lib/powerpc/setjmp.S
+++ b/grub-core/lib/powerpc/setjmp.S
@@ -18,6 +18,7 @@
 
 #include <grub/symbol.h>
 #include <grub/dl.h>
+#include <ppc-asm.h>
 
 	.file	"setjmp.S"
 
@@ -38,7 +39,7 @@ GRUB_MOD_LICENSE "GPLv3+"
 /*
  * int grub_setjmp (grub_jmp_buf env)
  */
-FUNCTION(grub_setjmp)
+FUNC_START(grub_setjmp)
 	STORE	1, 0(3)
 	STORE	14, 1*SZ_LONG(3)
 	STORE	15, 2*SZ_LONG(3)
@@ -64,11 +65,12 @@ FUNCTION(grub_setjmp)
 	STORE	4, 20*SZ_LONG(3)
 	li	3, 0
 	blr
+FUNC_END(grub_setjmp)
 
 /*
  * int grub_longjmp (grub_jmp_buf env, int val)
  */
-FUNCTION(grub_longjmp)
+FUNC_START(grub_longjmp)
 	LOAD	1, 0(3)
 	LOAD	14, 1*SZ_LONG(3)
 	LOAD	15, 2*SZ_LONG(3)
@@ -96,4 +98,4 @@ FUNCTION(grub_longjmp)
 	bne	1f
 	li	3, 1
 1:	blr
-
+FUNC_END(grub_longjmp)
-- 
1.8.5.3



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

* [RFC PATCH 18/23] .TOC. symbol is special in ppc64le
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (16 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 17/23] Use FUNC_START/FUNC_END for powerpc function definitions Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 19/23] align .toc section on 4byte boundary Ram Pai
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

 .TOC. symbol is special in ppc64le . It maps to the
 address of the .toc section.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/kern/dl.c | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index de2d0ed..ce2ff38 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -343,6 +343,26 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
   return GRUB_ERR_NONE;
 }
 
+#ifdef __powerpc64le__
+static int
+grub_dl_find_section_index (Elf_Ehdr *e, const char *name)
+{ 
+  Elf_Shdr *s;
+  const char *str;
+  unsigned i;
+
+  s = (Elf_Shdr *) ((char *) e + e->e_shoff + e->e_shstrndx * e->e_shentsize);
+  str = (char *) e + s->sh_offset;
+
+  for (i = 0, s = (Elf_Shdr *) ((char *) e + e->e_shoff);
+       i < e->e_shnum;
+       i++, s = (Elf_Shdr *) ((char *) s + e->e_shentsize))
+    if (grub_strcmp (str + s->sh_name, name) == 0)
+      return i;
+  return -1;
+}
+#endif
+
 static grub_err_t
 grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
 {
@@ -392,7 +412,19 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
 	  /* Resolve a global symbol.  */
 	  if (sym->st_name != 0 && sym->st_shndx == 0)
 	    {
-	      grub_symbol_t nsym = grub_dl_resolve_symbol (name);
+	      grub_symbol_t nsym;
+
+#ifdef __powerpc64le__
+              if (grub_strcmp(name, ".TOC.") == 0) {
+                int j = grub_dl_find_section_index (e, ".toc");
+                if (j < 0)
+                    return grub_error (GRUB_ERR_BAD_MODULE,
+                                   N_("section '.toc' not found"), name);
+                sym->st_value = (Elf_Addr) grub_dl_get_section_addr (mod, j);
+                break;
+              }
+#endif
+	      nsym = grub_dl_resolve_symbol (name);
 	      if (! nsym)
 		return grub_error (GRUB_ERR_BAD_MODULE,
 				   N_("symbol `%s' not found"), name);
-- 
1.8.5.3



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

* [RFC PATCH 19/23] align .toc section on 4byte boundary.
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (17 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 18/23] .TOC. symbol is special in ppc64le Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 20/23] fix parameter to firmware calls Ram Pai
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

 the .toc section in powerpc64le modules are sometimes
 not aligned on a four byte boundary. This fails the module linker especially
 when processing R_PPC64_TOC16_LO_DS, since the addresses are expected to be
 aligned on 4byte boundary.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/kern/dl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c
index ce2ff38..ee69c3c 100644
--- a/grub-core/kern/dl.c
+++ b/grub-core/kern/dl.c
@@ -304,7 +304,12 @@ grub_dl_load_segments (grub_dl_t mod, const Elf_Ehdr *e)
 	    {
 	      void *addr;
 
+#ifdef __powerpc64le__
+	      ptr = (char *) ALIGN_UP ((grub_addr_t) ptr,
+                             (s->sh_addralign < 4 ? 4 : s->sh_addralign));
+#else
 	      ptr = (char *) ALIGN_UP ((grub_addr_t) ptr, s->sh_addralign);
+#endif
 	      addr = ptr;
 	      ptr += s->sh_size;
 
-- 
1.8.5.3



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

* [RFC PATCH 20/23] fix parameter to firmware calls
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (18 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 19/23] align .toc section on 4byte boundary Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 17:45   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :) Ram Pai
                   ` (2 subsequent siblings)
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

 all parameter to firmware calls should to be BigEndian
 and the results should be CPU endian.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/disk/ieee1275/nand.c         |  41 +++++-----
 grub-core/disk/ieee1275/ofdisk.c       |  22 ++++--
 grub-core/kern/ieee1275/ieee1275.c     | 132 +++++++++++++++++++--------------
 grub-core/kern/ieee1275/openfw.c       |  19 ++---
 grub-core/lib/ieee1275/datetime.c      |  32 ++++----
 grub-core/net/drivers/ieee1275/ofnet.c |   6 +-
 include/grub/ieee1275/ieee1275.h       |   8 +-
 7 files changed, 146 insertions(+), 114 deletions(-)

diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c
index 576e9cc..1846c23 100644
--- a/grub-core/disk/ieee1275/nand.c
+++ b/grub-core/disk/ieee1275/nand.c
@@ -102,32 +102,33 @@ grub_nand_open (const char *name, grub_disk_t disk)
   data->handle = dev_ihandle;
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 2);
-  args.method = (grub_ieee1275_cell_t) "block-size";
-  args.ihandle = dev_ihandle;
-  args.result = 1;
+  args.method = IEEE1275_ADDR("block-size");
+  args.ihandle = IEEE1275_VALUE(dev_ihandle);
+  args.result = IEEE1275_VALUE(1);
 
-  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result))
     {
       grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get block size");
       goto fail;
     }
 
+  args.size1 = IEEE1275_VALUE(args.size1);
   data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS);
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
-  args.method = (grub_ieee1275_cell_t) "size";
-  args.ihandle = dev_ihandle;
-  args.result = 1;
+  args.method = IEEE1275_ADDR( "size");
+  args.ihandle = IEEE1275_VALUE(dev_ihandle);
+  args.result = IEEE1275_VALUE(1);
 
-  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+  if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result))
     {
       grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't get disk size");
       goto fail;
     }
 
-  disk->total_sectors = args.size1;
+  disk->total_sectors = IEEE1275_VALUE(args.size1);
   disk->total_sectors <<= 32;
-  disk->total_sectors += args.size2;
+  disk->total_sectors += IEEE1275_VALUE(args.size2);
   disk->total_sectors >>= GRUB_DISK_SECTOR_BITS;
 
   disk->id = dev_ihandle;
@@ -170,10 +171,10 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
     } args;
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
-  args.method = (grub_ieee1275_cell_t) "pio-read";
-  args.ihandle = data->handle;
-  args.buf = (grub_ieee1275_cell_t) buf;
-  args.page = (grub_ieee1275_cell_t) ((grub_size_t) sector / data->block_size);
+  args.method = IEEE1275_ADDR("pio-read");
+  args.ihandle = IEEE1275_VALUE(data->handle);
+  args.buf =  buf;
+  args.page = (grub_size_t) sector / data->block_size;
 
   ofs = ((grub_size_t) sector % data->block_size) << GRUB_DISK_SECTOR_BITS;
   size <<= GRUB_DISK_SECTOR_BITS;
@@ -185,16 +186,20 @@ grub_nand_read (grub_disk_t disk, grub_disk_addr_t sector,
 
       len = (ofs + size > bsize) ? (bsize - ofs) : size;
 
-      args.len = (grub_ieee1275_cell_t) len;
-      args.ofs = (grub_ieee1275_cell_t) ofs;
-      args.result = 1;
+      args.len = IEEE1275_VALUE(len);
+      args.ofs = IEEE1275_VALUE(ofs);
+      args.result = IEEE1275_VALUE(1);
+      args.buf =  IEEE1275_ADDR(args.buf);
+      args.page =  IEEE1275_VALUE(args.page);
 
-      if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || (args.result))
+      if ((IEEE1275_CALL_ENTRY_FN (&args) == -1) || IEEE1275_VALUE(args.result))
         return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx "
 						   "from `%s'"),
 			   (unsigned long long) sector,
 			   disk->name);
 
+      args.buf =  IEEE1275_ADDR(args.buf);
+      args.page =  IEEE1275_VALUE(args.page);
       ofs = 0;
       size -= len;
       args.buf += len;
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
index d785d6a..72b36c5 100644
--- a/grub-core/disk/ieee1275/ofdisk.c
+++ b/grub-core/disk/ieee1275/ofdisk.c
@@ -225,16 +225,19 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
     
       INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
       args.method = IEEE1275_ADDR("vscsi-report-luns");
-      args.ihandle = ihandle;
-      args.table = 0;
-      args.nentries = 0;
+      args.ihandle = IEEE1275_VALUE(ihandle);
+      args.table = IEEE1275_ADDR(0);
+      args.nentries = IEEE1275_VALUE(0);
 
-      if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || args.catch_result)
+      if (IEEE1275_CALL_ENTRY_FN (&args) == -1 || IEEE1275_VALUE(args.catch_result))
 	{
 	  grub_ieee1275_close (ihandle);
 	  return;
 	}
 
+      args.table = IEEE1275_ADDR(args.table);
+      args.nentries = IEEE1275_VALUE(args.nentries);
+
       buf = grub_malloc (grub_strlen (alias->path) + 32);
       if (!buf)
 	return;
@@ -245,6 +248,7 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
 	  grub_uint64_t *ptr;
 
 	  ptr = *(grub_uint64_t **) ((grub_addr_t)args.table + 4 + 8 * i);
+          ptr = (grub_uint64_t *) (grub_addr_t) IEEE1275_ADDR(ptr);
 	  while (*ptr)
 	    {
 	      grub_snprintf (bufptr, 32, "/disk@%" PRIxGRUB_UINT64_T, *ptr++);
@@ -614,18 +618,20 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
 
   INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2);
   args_ieee1275.method = IEEE1275_ADDR("block-size");
-  args_ieee1275.ihandle = last_ihandle;
-  args_ieee1275.result = 1;
+  args_ieee1275.ihandle = IEEE1275_VALUE(last_ihandle);
+  args_ieee1275.result = IEEE1275_VALUE(1);
 
   *block_size = GRUB_DISK_SECTOR_SIZE;
 
-  if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result))
+  if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || IEEE1275_VALUE(args_ieee1275.result))
     grub_dprintf ("disk", "can't get block size\n");
-  else
+  else {
+    args_ieee1275.size1 = IEEE1275_VALUE(args_ieee1275.size1);
     if (args_ieee1275.size1
         && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1))
         && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384)
       *block_size = args_ieee1275.size1;
+  }
 
   return 0;
 }
diff --git a/grub-core/kern/ieee1275/ieee1275.c b/grub-core/kern/ieee1275/ieee1275.c
index f933c89..9d3b180 100644
--- a/grub-core/kern/ieee1275/ieee1275.c
+++ b/grub-core/kern/ieee1275/ieee1275.c
@@ -42,7 +42,7 @@ grub_ieee1275_finddevice (const char *name, grub_ieee1275_phandle_t *phandlep)
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *phandlep = args.phandle;
+  *phandlep = args.phandle = IEEE1275_VALUE(args.phandle);
   if (args.phandle == IEEE1275_PHANDLE_INVALID)
     return -1;
   return 0;
@@ -65,13 +65,15 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "getprop", 4, 1);
-  args.phandle = phandle;
+  args.phandle = IEEE1275_VALUE(phandle);
   args.prop = IEEE1275_ADDR(property);
   args.buf = IEEE1275_ADDR(buf);
-  args.buflen = (grub_ieee1275_cell_t) size;
+  args.buflen = IEEE1275_VALUE(size);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+
+  args.size = IEEE1275_VALUE(args.size);
   if (actual)
     *actual = (grub_ssize_t) args.size;
   if (args.size == IEEE1275_CELL_INVALID)
@@ -79,6 +81,16 @@ grub_ieee1275_get_property (grub_ieee1275_phandle_t phandle,
   return 0;
 }
 
+static void
+grub_swap_bytes(grub_uint32_t *buf, grub_size_t len)
+{
+  /* Integer properties are always in big endian.  */
+     unsigned int i;
+     len /= sizeof (grub_uint32_t);
+     for (i = 0; i < len; i++)
+	buf[i] = IEEE1275_VALUE(buf[i]);
+}
+
 int
 grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
 				    const char *property, grub_uint32_t *buf,
@@ -86,16 +98,13 @@ grub_ieee1275_get_integer_property (grub_ieee1275_phandle_t phandle,
 {
   int ret;
   ret = grub_ieee1275_get_property (phandle, property, (void *) buf, size, actual);
-#ifndef GRUB_CPU_WORDS_BIGENDIAN
+
+#ifdef __powerpc64le__
   /* Integer properties are always in big endian.  */
   if (ret == 0)
-    {
-      unsigned int i;
-      size /= sizeof (grub_uint32_t);
-      for (i = 0; i < size; i++)
-	buf[i] = grub_be_to_cpu32 (buf[i]);
-    }
+     grub_swap_bytes(buf, size);
 #endif
+
   return ret;
 }
 
@@ -114,14 +123,14 @@ grub_ieee1275_next_property (grub_ieee1275_phandle_t phandle, char *prev_prop,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "nextprop", 3, 1);
-  args.phandle = phandle;
+  args.phandle = IEEE1275_VALUE(phandle);
   args.prev_prop = IEEE1275_ADDR(prev_prop);
   args.next_prop = IEEE1275_ADDR(prop);
-  args.flags = (grub_ieee1275_cell_t) -1;
+  args.flags = IEEE1275_VALUE(-1);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  return (int) args.flags;
+  return (int) IEEE1275_VALUE(args.flags);
 }
 
 int
@@ -138,13 +147,13 @@ grub_ieee1275_get_property_length (grub_ieee1275_phandle_t phandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "getproplen", 2, 1);
-  args.phandle = phandle;
+  args.phandle = IEEE1275_VALUE(phandle);
   args.prop = IEEE1275_ADDR(prop);
-  args.length = (grub_ieee1275_cell_t) -1;
+  args.length = IEEE1275_VALUE(-1);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *length = args.length;
+  *length = args.length = IEEE1275_VALUE(args.length);
   if (args.length == IEEE1275_CELL_INVALID)
     return -1;
   return 0;
@@ -163,11 +172,11 @@ grub_ieee1275_instance_to_package (grub_ieee1275_ihandle_t ihandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "instance-to-package", 1, 1);
-  args.ihandle = ihandle;
+  args.ihandle = IEEE1275_VALUE(ihandle);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *phandlep = args.phandle;
+  *phandlep = args.phandle = IEEE1275_VALUE(args.phandle);
   if (args.phandle == IEEE1275_PHANDLE_INVALID)
     return -1;
   return 0;
@@ -189,12 +198,14 @@ grub_ieee1275_package_to_path (grub_ieee1275_phandle_t phandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "package-to-path", 3, 1);
-  args.phandle = phandle;
+  args.phandle = IEEE1275_VALUE(phandle);
   args.buf = IEEE1275_ADDR(path);
-  args.buflen = (grub_ieee1275_cell_t) len;
+  args.buflen = IEEE1275_VALUE(len);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+
+  args.actual = IEEE1275_VALUE(args.actual);
   if (actual)
     *actual = args.actual;
   if (args.actual == IEEE1275_CELL_INVALID)
@@ -218,12 +229,14 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "instance-to-path", 3, 1);
-  args.ihandle = ihandle;
+  args.ihandle = IEEE1275_VALUE(ihandle);
   args.buf = IEEE1275_ADDR(path);
-  args.buflen = (grub_ieee1275_cell_t) len;
+  args.buflen = IEEE1275_VALUE(len);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+
+  args.actual = IEEE1275_VALUE(args.actual);
   if (actual)
     *actual = args.actual;
   if (args.actual == IEEE1275_CELL_INVALID)
@@ -231,6 +244,7 @@ grub_ieee1275_instance_to_path (grub_ieee1275_ihandle_t ihandle,
   return 0;
 }
 
+
 int
 grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
 		     grub_size_t len, grub_ssize_t *actualp)
@@ -246,12 +260,13 @@ grub_ieee1275_write (grub_ieee1275_ihandle_t ihandle, const void *buffer,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "write", 3, 1);
-  args.ihandle = ihandle;
+  args.ihandle = IEEE1275_VALUE(ihandle);
   args.buf = IEEE1275_ADDR(buffer);
-  args.len = (grub_ieee1275_cell_t) len;
+  args.len = IEEE1275_VALUE(len);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+  args.actual = IEEE1275_VALUE(args.actual);
   if (actualp)
     *actualp = args.actual;
   return 0;
@@ -272,14 +287,16 @@ grub_ieee1275_read (grub_ieee1275_ihandle_t ihandle, void *buffer,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "read", 3, 1);
-  args.ihandle = ihandle;
+  args.ihandle = IEEE1275_VALUE(ihandle);
   args.buf = IEEE1275_ADDR(buffer);
-  args.len = (grub_ieee1275_cell_t) len;
+  args.len = IEEE1275_VALUE(len);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+  args.actual = IEEE1275_VALUE(args.actual);
   if (actualp)
     *actualp = args.actual;
+
   return 0;
 }
 
@@ -298,20 +315,20 @@ grub_ieee1275_seek (grub_ieee1275_ihandle_t ihandle, grub_disk_addr_t pos,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "seek", 3, 1);
-  args.ihandle = ihandle;
+  args.ihandle = IEEE1275_VALUE(ihandle);
   /* To prevent stupid gcc warning.  */
 #if GRUB_IEEE1275_CELL_SIZEOF >= 8
   args.pos_hi = 0;
-  args.pos_lo = pos;
+  args.pos_lo = IEEE1275_VALUE(pos);
 #else
-  args.pos_hi = (grub_ieee1275_cell_t) (pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF));
-  args.pos_lo = (grub_ieee1275_cell_t) 
-    (pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1));
+  args.pos_hi = IEEE1275_VALUE((pos >> (8 * GRUB_IEEE1275_CELL_SIZEOF)));
+  args.pos_lo = IEEE1275_VALUE((pos & ((1ULL << (8 * GRUB_IEEE1275_CELL_SIZEOF)) - 1)));
 #endif
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
 
+  args.result = IEEE1275_VALUE(args.result);
   if (result)
     *result = args.result;
   return 0;
@@ -330,11 +347,11 @@ grub_ieee1275_peer (grub_ieee1275_phandle_t node,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "peer", 1, 1);
-  args.node = node;
+  args.node = IEEE1275_VALUE(node);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *result = args.result;
+  *result = args.result = IEEE1275_VALUE(args.result);
   if (args.result == 0)
     return -1;
   return 0;
@@ -353,12 +370,12 @@ grub_ieee1275_child (grub_ieee1275_phandle_t node,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "child", 1, 1);
-  args.node = node;
-  args.result = IEEE1275_PHANDLE_INVALID;
+  args.node = IEEE1275_VALUE(node);
+  args.result = IEEE1275_VALUE(IEEE1275_PHANDLE_INVALID);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *result = args.result;
+  *result = args.result = IEEE1275_VALUE(args.result);
   if (args.result == 0)
     return -1;
   return 0;
@@ -377,12 +394,12 @@ grub_ieee1275_parent (grub_ieee1275_phandle_t node,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "parent", 1, 1);
-  args.node = node;
-  args.result = IEEE1275_PHANDLE_INVALID;
+  args.node = IEEE1275_VALUE(node);
+  args.result = IEEE1275_VALUE(IEEE1275_PHANDLE_INVALID);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *result = args.result;
+  *result = IEEE1275_VALUE(args.result);
   return 0;
 }
 
@@ -405,6 +422,7 @@ grub_ieee1275_interpret (const char *command, grub_ieee1275_cell_t *catch)
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+  args.catch = IEEE1275_VALUE(args.catch);
   if (catch)
     *catch = args.catch;
   return 0;
@@ -457,7 +475,7 @@ grub_ieee1275_open (const char *path, grub_ieee1275_ihandle_t *result)
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *result = args.result;
+  *result = args.result = IEEE1275_VALUE(args.result);
   if (args.result == IEEE1275_IHANDLE_INVALID)
     return -1;
   return 0;
@@ -474,7 +492,7 @@ grub_ieee1275_close (grub_ieee1275_ihandle_t ihandle)
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "close", 1, 0);
-  args.ihandle = ihandle;
+  args.ihandle = IEEE1275_VALUE(ihandle);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
@@ -497,12 +515,14 @@ grub_ieee1275_claim (grub_addr_t addr, grub_size_t size, unsigned int align,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "claim", 3, 1);
-  args.addr = (grub_ieee1275_cell_t) addr;
-  args.size = (grub_ieee1275_cell_t) size;
-  args.align = (grub_ieee1275_cell_t) align;
+  args.addr = IEEE1275_VALUE(addr);
+  args.size = IEEE1275_VALUE(size);
+  args.align = IEEE1275_VALUE(align);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
+
+  args.base = IEEE1275_VALUE(args.base);
   if (result)
     *result = args.base;
   if (args.base == IEEE1275_CELL_INVALID)
@@ -522,8 +542,8 @@ grub_ieee1275_release (grub_addr_t addr, grub_size_t size)
  args;
 
   INIT_IEEE1275_COMMON (&args.common, "release", 2, 0);
-  args.addr = addr;
-  args.size = size;
+  args.addr = IEEE1275_VALUE(addr);
+  args.size = IEEE1275_VALUE(size);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
@@ -547,14 +567,14 @@ grub_ieee1275_set_property (grub_ieee1275_phandle_t phandle,
   args;
 
   INIT_IEEE1275_COMMON (&args.common, "setprop", 4, 1);
-  args.size = (grub_ieee1275_cell_t) size;
+  args.size = IEEE1275_VALUE(size);
   args.buf = IEEE1275_ADDR(buf);
   args.propname = IEEE1275_ADDR(propname);
-  args.phandle = (grub_ieee1275_cell_t) phandle;
+  args.phandle = IEEE1275_VALUE(phandle);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *actual = args.actual;
+  *actual = args.actual = IEEE1275_VALUE(args.actual);
   if ((args.actual == IEEE1275_CELL_INVALID) || (args.actual != args.size))
     return -1;
   return 0;
@@ -579,15 +599,15 @@ grub_ieee1275_set_color (grub_ieee1275_ihandle_t ihandle,
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 6, 1);
   args.method = IEEE1275_ADDR("color!");
-  args.ihandle = ihandle;
-  args.index = index;
-  args.r = r;
-  args.g = g;
-  args.b = b;
+  args.ihandle = IEEE1275_VALUE(ihandle);
+  args.index = IEEE1275_VALUE(index);
+  args.r = IEEE1275_VALUE(r);
+  args.g = IEEE1275_VALUE(g);
+  args.b = IEEE1275_VALUE(b);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  return args.catch_result;
+  return IEEE1275_VALUE(args.catch_result);
 }
 
 int
@@ -604,6 +624,6 @@ grub_ieee1275_milliseconds (grub_uint32_t *msecs)
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
-  *msecs = args.msecs;
+  *msecs = IEEE1275_VALUE(args.msecs);
   return 0;
 }
diff --git a/grub-core/kern/ieee1275/openfw.c b/grub-core/kern/ieee1275/openfw.c
index a8bbc71..ced8e3f 100644
--- a/grub-core/kern/ieee1275/openfw.c
+++ b/grub-core/kern/ieee1275/openfw.c
@@ -286,20 +286,20 @@ grub_ieee1275_map (grub_addr_t phys, grub_addr_t virt, grub_size_t size,
 #endif
 			1);
   args.method = IEEE1275_ADDR("map");
-  args.ihandle = grub_ieee1275_mmu;
+  args.ihandle = IEEE1275_VALUE(grub_ieee1275_mmu);
 #ifdef __sparc__
   args.phys_high = 0;
 #endif
-  args.phys_low = phys;
-  args.virt = virt;
-  args.size = size;
-  args.mode = mode; /* Format is WIMG0PP.  */
-  args.catch_result = (grub_ieee1275_cell_t) -1;
+  args.phys_low = IEEE1275_ADDR(phys);
+  args.virt = IEEE1275_ADDR(virt);
+  args.size = IEEE1275_VALUE(size);
+  args.mode = IEEE1275_VALUE(mode); /* Format is WIMG0PP.  */
+  args.catch_result = IEEE1275_VALUE((grub_ieee1275_cell_t) -1);
 
   if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
     return -1;
 
-  return args.catch_result;
+  return IEEE1275_VALUE(args.catch_result);
 }
 
 grub_err_t
@@ -545,10 +545,12 @@ grub_ieee1275_canonicalise_devname (const char *path)
       INIT_IEEE1275_COMMON (&args.common, "canon", 3, 1);
       args.path = IEEE1275_ADDR(path);
       args.buf = IEEE1275_ADDR(buf);
-      args.inlen = (grub_ieee1275_cell_t) (bufsize - 1);
+      args.inlen = IEEE1275_VALUE(bufsize - 1);
 
       if (IEEE1275_CALL_ENTRY_FN (&args) == -1)
 	return 0;
+
+      args.outlen = IEEE1275_VALUE(args.outlen);
       if (args.outlen > bufsize - 1)
 	{
 	  bufsize = args.outlen + 2;
@@ -560,4 +562,3 @@ grub_ieee1275_canonicalise_devname (const char *path)
   grub_free (buf);
   return NULL;
 }
-
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
index fa0d3b6..7ee1ae2 100644
--- a/grub-core/lib/ieee1275/datetime.c
+++ b/grub-core/lib/ieee1275/datetime.c
@@ -83,22 +83,22 @@ grub_get_datetime (struct grub_datetime *datetime)
     return grub_error (GRUB_ERR_IO, "couldn't open RTC");
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 7);
-  args.device = (grub_ieee1275_cell_t) ihandle;
+  args.device = IEEE1275_VALUE((grub_ieee1275_cell_t) ihandle);
   args.method = IEEE1275_ADDR("get-time");
 
   status = IEEE1275_CALL_ENTRY_FN (&args);
 
   grub_ieee1275_close (ihandle);
 
-  if (status == -1 || args.catch_result)
+  if (status == -1 || IEEE1275_VALUE(args.catch_result))
     return grub_error (GRUB_ERR_IO, "get-time failed");
 
-  datetime->year = args.year;
-  datetime->month = args.month;
-  datetime->day = args.day;
-  datetime->hour = args.hour;
-  datetime->minute = args.minute;
-  datetime->second = args.second;
+  datetime->year = IEEE1275_VALUE(args.year);
+  datetime->month = IEEE1275_VALUE(args.month);
+  datetime->day = IEEE1275_VALUE(args.day);
+  datetime->hour = IEEE1275_VALUE(args.hour);
+  datetime->minute = IEEE1275_VALUE(args.minute);
+  datetime->second = IEEE1275_VALUE(args.second);
 
   return GRUB_ERR_NONE;
 }
@@ -135,21 +135,21 @@ grub_set_datetime (struct grub_datetime *datetime)
     return grub_error (GRUB_ERR_IO, "couldn't open RTC");
 
   INIT_IEEE1275_COMMON (&args.common, "call-method", 8, 1);
-  args.device = (grub_ieee1275_cell_t) ihandle;
+  args.device = IEEE1275_VALUE(ihandle);
   args.method = IEEE1275_ADDR("set-time");
 
-  args.year = datetime->year;
-  args.month = datetime->month;
-  args.day = datetime->day;
-  args.hour = datetime->hour;
-  args.minute = datetime->minute;
-  args.second = datetime->second;
+  args.year = IEEE1275_VALUE(datetime->year);
+  args.month = IEEE1275_VALUE(datetime->month);
+  args.day = IEEE1275_VALUE(datetime->day);
+  args.hour = IEEE1275_VALUE(datetime->hour);
+  args.minute = IEEE1275_VALUE(datetime->minute);
+  args.second = IEEE1275_VALUE(datetime->second);
 
   status = IEEE1275_CALL_ENTRY_FN (&args);
 
   grub_ieee1275_close (ihandle);
 
-  if (status == -1 || args.catch_result)
+  if (status == -1 || IEEE1275_VALUE(args.catch_result))
     return grub_error (GRUB_ERR_IO, "set-time failed");
 
   return GRUB_ERR_NONE;
diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c
index 07c8446..01dfe85 100644
--- a/grub-core/net/drivers/ieee1275/ofnet.c
+++ b/grub-core/net/drivers/ieee1275/ofnet.c
@@ -385,17 +385,17 @@ search_net_devices (struct grub_ieee1275_devalias *alias)
       }
       args;
       INIT_IEEE1275_COMMON (&args.common, "interpret", 2, 2);
-      args.len = card->txbufsize;
+      args.len = IEEE1275_VALUE(card->txbufsize);
       args.method = IEEE1275_ADDR("alloc-mem");
 
       if (IEEE1275_CALL_ENTRY_FN (&args) == -1
-	  || args.catch)
+	  || IEEE1275_VALUE(args.catch))
 	{
 	  card->txbuf = 0;
 	  grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory"));
 	}
       else
-	card->txbuf = (void *) (grub_addr_t) args.result;
+	card->txbuf = (void *) (grub_addr_t) IEEE1275_VALUE(args.result);
     }
   else
     card->txbuf = grub_zalloc (card->txbufsize);
diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h
index 2e5270c..be0c235 100644
--- a/include/grub/ieee1275/ieee1275.h
+++ b/include/grub/ieee1275/ieee1275.h
@@ -49,12 +49,12 @@ struct grub_ieee1275_common_hdr
   grub_ieee1275_cell_t nr_outs;
 };
 
-#define IEEE1275_ADDR(x)         (grub_uint32_t)(grub_addr_t)(x)
-
+#define IEEE1275_ADDR(x)         (grub_uint32_t)grub_cpu_to_be32((grub_addr_t)(x))
+#define IEEE1275_VALUE(x)         (grub_uint32_t)grub_cpu_to_be32(x)
 #define INIT_IEEE1275_COMMON(p, xname, xins, xouts) \
   (p)->name = (grub_ieee1275_cell_t) IEEE1275_ADDR(xname); \
-  (p)->nr_ins = (grub_ieee1275_cell_t) xins; \
-  (p)->nr_outs = (grub_ieee1275_cell_t) xouts
+  (p)->nr_ins = (grub_ieee1275_cell_t) IEEE1275_VALUE(xins); \
+  (p)->nr_outs = (grub_ieee1275_cell_t) IEEE1275_VALUE(xouts)
 
 typedef grub_uint32_t grub_ieee1275_ihandle_t;
 typedef grub_uint32_t grub_ieee1275_phandle_t;
-- 
1.8.5.3



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

* [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (19 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 20/23] fix parameter to firmware calls Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-04-01 17:49   ` Andrey Borzenkov
  2014-02-26 18:31 ` [RFC PATCH 22/23] fix segfaults if initrd Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 23/23] Optional: Power7 VSX instructions workaround Ram Pai
  22 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

From: Anton Blanchard <anton@samba.org>

 powerpc64 is not necessarily BigEndian anymore! :)

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 include/grub/powerpc/types.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
index 7a2fc6b..ab138d4 100644
--- a/include/grub/powerpc/types.h
+++ b/include/grub/powerpc/types.h
@@ -19,7 +19,7 @@
 #ifndef GRUB_TYPES_CPU_HEADER
 #define GRUB_TYPES_CPU_HEADER	1
 
-#ifdef __powerpc64le__
+#ifdef __powerpc64__
 /* The size of void *.  */
 #define GRUB_TARGET_SIZEOF_VOID_P	8
 
@@ -33,8 +33,12 @@
 #define GRUB_TARGET_SIZEOF_LONG		4
 #endif
 
-/* powerpc is big-endian.  */
-#define GRUB_TARGET_WORDS_BIGENDIAN	1
+#ifdef __powerpc64le__
+#undef GRUB_TARGET_WORDS_BIGENDIAN
+#else
+#define GRUB_TARGET_WORDS_BIGENDIAN     1
+#endif
+
 
 
 #endif /* ! GRUB_TYPES_CPU_HEADER */
-- 
1.8.5.3



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

* [RFC PATCH 22/23] fix segfaults if initrd
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (20 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :) Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  2014-02-26 18:31 ` [RFC PATCH 23/23] Optional: Power7 VSX instructions workaround Ram Pai
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

 grub segfaults if initrd is specified before specifying
 the kernel. The problem is the initrd module sees that kernel is not
 specified and takes the fail path. In the fail path it checks if anything has
 be malloc'ed. Unfortunately the variable that it looks to check for is a
 uninitialized stack variable. The stack variable can incorrectly indicate
 something is malloced, which leads the module to free some unallocated
 memory. This patch fixes the problem by initializing the stack variable.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/loader/powerpc/ieee1275/linux.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
index 3d6a61e..7f85eab 100644
--- a/grub-core/loader/powerpc/ieee1275/linux.c
+++ b/grub-core/loader/powerpc/ieee1275/linux.c
@@ -335,6 +335,10 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
   grub_addr_t addr;
   struct grub_linux_initrd_context initrd_ctx;
 
+  // initialize, otherwise the fail path will try to 
+  // free up data and segfault
+  initrd_ctx.components = NULL; 
+
   if (argc == 0)
     {
       grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
-- 
1.8.5.3



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

* [RFC PATCH 23/23] Optional: Power7 VSX instructions workaround.
  2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
                   ` (21 preceding siblings ...)
  2014-02-26 18:31 ` [RFC PATCH 22/23] fix segfaults if initrd Ram Pai
@ 2014-02-26 18:31 ` Ram Pai
  22 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-02-26 18:31 UTC (permalink / raw)
  To: grub-devel; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

 Power7 cannot handle VSX instructions correctly. It
 segfaults. This patch is applicable only for power7 systems.

Signed-off-by: Ram Pai <linuxram@us.ibm.com>
---
 grub-core/fs/fshelp.c   | 10 ++++++++++
 grub-core/kern/term.c   | 11 +++++++++++
 grub-core/normal/term.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 63 insertions(+)

diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c
index 42bd542..bd610df 100644
--- a/grub-core/fs/fshelp.c
+++ b/grub-core/fs/fshelp.c
@@ -207,12 +207,22 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode,
 		       read_symlink_func read_symlink,
 		       enum grub_fshelp_filetype expecttype)
 {
+#ifdef __powerpc64le__
+   // workaround for a problem on power7 in LE.
+  struct grub_fshelp_find_file_ctx ctx;
+    ctx.path = path;
+    ctx.rootnode = rootnode;
+    ctx.foundtype = GRUB_FSHELP_DIR;
+    ctx.symlinknest = 0;
+#else 
   struct grub_fshelp_find_file_ctx ctx = {
     .path = path,
     .rootnode = rootnode,
     .foundtype = GRUB_FSHELP_DIR,
     .symlinknest = 0
   };
+#endif 
+
   grub_err_t err;
 
   if (!path || path[0] != '/')
diff --git a/grub-core/kern/term.c b/grub-core/kern/term.c
index 07720ee..4ff3886 100644
--- a/grub-core/kern/term.c
+++ b/grub-core/kern/term.c
@@ -40,6 +40,16 @@ static void
 grub_putcode_dumb (grub_uint32_t code,
 		   struct grub_term_output *term)
 {
+#ifdef __powerpc64le__
+  // this hack is needed for powerpc64le on power7 cpu only
+  // segfaults on VSX instructions generated by the compiler
+  struct grub_unicode_glyph c;
+      c.base = code;
+      c.variant = 0;
+      c.attributes = 0;
+      c.ncomb = 0;
+      c.estimated_width = 1;
+#else
   struct grub_unicode_glyph c =
     {
       .base = code,
@@ -48,6 +58,7 @@ grub_putcode_dumb (grub_uint32_t code,
       .ncomb = 0,
       .estimated_width = 1
     };
+#endif
 
   if (code == '\t' && term->getxy)
     {
diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c
index 4c2238b..adddcf9 100644
--- a/grub-core/normal/term.c
+++ b/grub-core/normal/term.c
@@ -224,6 +224,14 @@ grub_puts_terminal (const char *str, struct grub_term_output *term)
     {
       for (; *str; str++)
 	{
+#ifdef __powerpc64le__
+         struct grub_unicode_glyph c;
+             c.variant = 0;
+             c.attributes = 0;
+             c.ncomb = 0;
+             c.estimated_width = 1;
+             c.base = *str;
+#else
 	  struct grub_unicode_glyph c =
 	    {
 	      .variant = 0,
@@ -232,6 +240,7 @@ grub_puts_terminal (const char *str, struct grub_term_output *term)
 	      .estimated_width = 1,
 	      .base = *str
 	    };
+#endif
 
 	  FOR_ACTIVE_TERM_OUTPUTS(term)
 	  {
@@ -417,6 +426,13 @@ static void
 putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
 	  int fixed_tab)
 {
+#ifdef __powerpc64le__
+  struct grub_unicode_glyph c2;
+      c2.variant = 0;
+      c2.attributes = 0;
+      c2.ncomb = 0;
+      c2.estimated_width = 1;
+#else
   struct grub_unicode_glyph c2 =
     {
       .variant = 0,
@@ -424,6 +440,7 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
       .ncomb = 0,
       .estimated_width = 1
     };
+#endif
 
   if (c->base == '\t' && fixed_tab)
     {
@@ -500,6 +517,13 @@ putglyph (const struct grub_unicode_glyph *c, struct grub_term_output *term,
 static void
 putcode_real (grub_uint32_t code, struct grub_term_output *term, int fixed_tab)
 {
+#ifdef __powerpc64le__
+  struct grub_unicode_glyph c;
+      c.variant = 0;
+      c.attributes = 0;
+      c.ncomb = 0;
+      c.estimated_width = 1;
+#else
   struct grub_unicode_glyph c =
     {
       .variant = 0,
@@ -507,6 +531,7 @@ putcode_real (grub_uint32_t code, struct grub_term_output *term, int fixed_tab)
       .ncomb = 0,
       .estimated_width = 1
     };
+#endif
 
   c.base = map_code (code, term);
   putglyph (&c, term, fixed_tab);
@@ -527,12 +552,20 @@ static grub_ssize_t
 get_maxwidth (struct grub_term_output *term,
 	      int margin_left, int margin_right)
 {
+#ifdef __powerpc64le__
+  struct grub_unicode_glyph space_glyph;
+    space_glyph.base = ' ';
+    space_glyph.variant = 0;
+    space_glyph.attributes = 0;
+    space_glyph.ncomb = 0;
+#else
   struct grub_unicode_glyph space_glyph = {
     .base = ' ',
     .variant = 0,
     .attributes = 0,
     .ncomb = 0,
   };
+#endif
   return (grub_term_width (term)
 	  - grub_term_getcharwidth (term, &space_glyph) 
 	  * (margin_left + margin_right) - 1);
@@ -1021,6 +1054,14 @@ grub_xnputs (const char *str, grub_size_t msg_len)
     {
       for (; msg_len--; str++, msg_len++)
 	{
+	 #ifdef __powerpc64le__
+         struct grub_unicode_glyph c;
+             c.variant = 0;
+             c.attributes = 0;
+             c.ncomb = 0;
+             c.estimated_width = 1;
+             c.base = *str;
+	 #else /*  __powerpc64le__ */
 	  struct grub_unicode_glyph c =
 	    {
 	      .variant = 0,
@@ -1029,6 +1070,7 @@ grub_xnputs (const char *str, grub_size_t msg_len)
 	      .estimated_width = 1,
 	      .base = *str
 	    };
+	 #endif /*  __powerpc64le__ */
 
 	  FOR_ACTIVE_TERM_OUTPUTS(term)
 	  {
-- 
1.8.5.3



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

* Re: [RFC PATCH 03/23] ignore .TOC. symbol
  2014-02-26 18:31 ` [RFC PATCH 03/23] ignore .TOC. symbol Ram Pai
@ 2014-04-01 16:52   ` Andrey Borzenkov
  0 siblings, 0 replies; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 16:52 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

В Wed, 26 Feb 2014 10:31:02 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> powerpc64 LE's linker knows how to handle the undefined
> symbol .TOC. in grub modules. So just ignore that symbol during build.
> 
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> ---
>  grub-core/gensyminfo.sh.in | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/grub-core/gensyminfo.sh.in b/grub-core/gensyminfo.sh.in
> index 2e8716b..cad5af3 100644
> --- a/grub-core/gensyminfo.sh.in
> +++ b/grub-core/gensyminfo.sh.in
> @@ -34,4 +34,9 @@ else
>  fi
>  
>  # Print all undefined symbols used by module
> -@TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | sed "s@^\([^ ]*\).*@undefined $modname \1@g"
> +if test x"@GRUB_TARGET_CPU@" = xpowerpc64le; then
> +    #ignore the special .TOC. symbol on powerpc64le
> +    @TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module | grep -w -v '.TOC.' 

If I understand it correctly, it should rather be grep -F -w; just in
case someone adds something like RTOCN?

> +else
> +    @TARGET_NM@ -u @TARGET_NMFLAGS_MINUS_P@ -p $module
> +fi  | sed "s@^\([^ ]*\).*@undefined $modname \1@g"



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

* Re: [RFC PATCH 06/23] Add IEEE1275_ADDR helper
  2014-02-26 18:31 ` [RFC PATCH 06/23] Add IEEE1275_ADDR helper Ram Pai
@ 2014-04-01 17:11   ` Andrey Borzenkov
  0 siblings, 0 replies; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 17:11 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

В Wed, 26 Feb 2014 10:31:05 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> From: Anton Blanchard <anton@samba.org>
> 
> If the target pointer size doesn't match the IEEE1275 cell size, we
> need to cast twice to avoid a warning.
> 
> >  
> +#define IEEE1275_ADDR(x)         (grub_uint32_t)(grub_addr_t)(x)
> +


Should not this be conditional on sizeof(grub_ieee1275_cell_t)?
Otherwise it seems to truncate value on platform where it is 64 bit
(sparc64)?

Is it possible that pointer does exceed 32 bits?


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

* Re: [RFC PATCH 08/23] Add powerpc64 types
  2014-02-26 18:31 ` [RFC PATCH 08/23] Add powerpc64 types Ram Pai
@ 2014-04-01 17:15   ` Andrey Borzenkov
  2014-04-02 17:02     ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 17:15 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

В Wed, 26 Feb 2014 10:31:07 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> From: Anton Blanchard <anton@samba.org>
> 
>  Add powerpc64 types
> 
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> From: Anton Blanchard <anton@samba.org>
> ---
>  include/grub/powerpc/types.h | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
> index a098ae6..7a2fc6b 100644
> --- a/include/grub/powerpc/types.h
> +++ b/include/grub/powerpc/types.h
> @@ -19,11 +19,19 @@
>  #ifndef GRUB_TYPES_CPU_HEADER
>  #define GRUB_TYPES_CPU_HEADER	1
>  
> +#ifdef __powerpc64le__
> +/* The size of void *.  */
> +#define GRUB_TARGET_SIZEOF_VOID_P	8
> +
> +/* The size of long.  */
> +#define GRUB_TARGET_SIZEOF_LONG		8
> +#else
>  /* The size of void *.  */
>  #define GRUB_TARGET_SIZEOF_VOID_P	4
>  
>  /* The size of long.  */
>  #define GRUB_TARGET_SIZEOF_LONG		4
> +#endif
>  
>  /* powerpc is big-endian.  */
>  #define GRUB_TARGET_WORDS_BIGENDIAN	1

This sure can't be right on LE platform?


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

* Re: [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit
  2014-02-26 18:31 ` [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit Ram Pai
@ 2014-04-01 17:21   ` Andrey Borzenkov
  2014-04-02 17:03     ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 17:21 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

В Wed, 26 Feb 2014 10:31:08 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> From: Anton Blanchard <anton@samba.org>
> 
> Fix warnings when building powerpc linux loader 64bit
> 
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> From: Anton Blanchard <anton@samba.org>
> ---
>  grub-core/loader/powerpc/ieee1275/linux.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
> index 4a14f66..3d6a61e 100644
> --- a/grub-core/loader/powerpc/ieee1275/linux.c
> +++ b/grub-core/loader/powerpc/ieee1275/linux.c
> @@ -141,8 +141,8 @@ grub_linux_boot (void)
>    grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args,
>  			      grub_strlen (linux_args) + 1, &actual);
>  
> -  grub_dprintf ("loader", "Entry point: 0x%x\n", linux_entry);
> -  grub_dprintf ("loader", "Initrd at: 0x%x, size 0x%x\n", initrd_addr,
> +  grub_dprintf ("loader", "Entry point: 0x%lx\n", linux_entry);

I guess using PRIxGRUB_ADDR is more consistent - it can now be both 32 and 64 bits.

> +  grub_dprintf ("loader", "Initrd at: 0x%lx, size 0x%lx\n", initrd_addr,
>  		initrd_size);

Ditto and PRIuGRUB_SIZE.

>    grub_dprintf ("loader", "Boot arguments: %s\n", linux_args);
>    grub_dprintf ("loader", "Jumping to Linux...\n");
> @@ -360,7 +360,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
>    if (addr == (grub_addr_t) -1)
>       goto fail;
>  
> -  grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
> +  grub_dprintf ("loader", "Loading initrd at 0x%lx, size 0x%lx\n", addr, size);
>  

Ditto.

>    if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
>      goto fail;



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

* Re: [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-02-26 18:31 ` [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues Ram Pai
@ 2014-04-01 17:27   ` Andrey Borzenkov
  2014-04-02 17:06     ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 17:27 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

В Wed, 26 Feb 2014 10:31:10 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> From: Anton Blanchard <anton@samba.org>
> 
>  Fix powerpc setjmp/longjmp 64bit issues
> 
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> From:  Anton Blanchard <anton@samba.org>
> ---
>  grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
>  1 file changed, 52 insertions(+), 42 deletions(-)
> 
> diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
> index 716b563..51fcae9 100644
> --- a/grub-core/lib/powerpc/setjmp.S
> +++ b/grub-core/lib/powerpc/setjmp.S
> @@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
>  
>  	.text
>  
> +#if defined( __powerpc64__ ) || defined( __powerpc64le__ )

Where is __powerpc64__ defined? Your previous patch adds only
__powerpc64le__ and it does exist in current code as well?


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

* Re: [RFC PATCH 20/23] fix parameter to firmware calls
  2014-02-26 18:31 ` [RFC PATCH 20/23] fix parameter to firmware calls Ram Pai
@ 2014-04-01 17:45   ` Andrey Borzenkov
  2014-04-02 17:08     ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 17:45 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: tonyb, anton, linuxram, tlfalcon, tbberry

В Wed, 26 Feb 2014 10:31:19 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> -#define IEEE1275_ADDR(x)         (grub_uint32_t)(grub_addr_t)(x)
> -
> +#define IEEE1275_ADDR(x)         (grub_uint32_t)grub_cpu_to_be32((grub_addr_t)(x))
> +#define IEEE1275_VALUE(x)         (grub_uint32_t)grub_cpu_to_be32(x)

Same question - what about sparc64, is it safe to truncate values there?


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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-02-26 18:31 ` [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :) Ram Pai
@ 2014-04-01 17:49   ` Andrey Borzenkov
  2014-04-01 20:22     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-02 17:09     ` Ram Pai
  0 siblings, 2 replies; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-01 17:49 UTC (permalink / raw)
  To: The development of GNU GRUB
  Cc: tlfalcon, tbberry, anton, linuxram, tonyb, Anton Blanchard

В Wed, 26 Feb 2014 10:31:20 -0800
Ram Pai <linuxram@us.ibm.com> пишет:

> From: Anton Blanchard <anton@samba.org>
> 
>  powerpc64 is not necessarily BigEndian anymore! :)
> 
> Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> ---
>  include/grub/powerpc/types.h | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
> index 7a2fc6b..ab138d4 100644
> --- a/include/grub/powerpc/types.h
> +++ b/include/grub/powerpc/types.h
> @@ -19,7 +19,7 @@
>  #ifndef GRUB_TYPES_CPU_HEADER
>  #define GRUB_TYPES_CPU_HEADER	1
>  
> -#ifdef __powerpc64le__
> +#ifdef __powerpc64__
>  /* The size of void *.  */
>  #define GRUB_TARGET_SIZEOF_VOID_P	8
>  
> @@ -33,8 +33,12 @@
>  #define GRUB_TARGET_SIZEOF_LONG		4
>  #endif
>  
> -/* powerpc is big-endian.  */
> -#define GRUB_TARGET_WORDS_BIGENDIAN	1
> +#ifdef __powerpc64le__
> +#undef GRUB_TARGET_WORDS_BIGENDIAN
> +#else
> +#define GRUB_TARGET_WORDS_BIGENDIAN     1
> +#endif
> +

For the sake of bisectability this really should be moved earlier;
otherwise at least patch "fix parameter to firmware calls" would
be wrong.

>  
>  
>  #endif /* ! GRUB_TYPES_CPU_HEADER */



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-01 17:49   ` Andrey Borzenkov
@ 2014-04-01 20:22     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-03 17:33       ` Ram Pai
  2014-04-02 17:09     ` Ram Pai
  1 sibling, 1 reply; 68+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-01 20:22 UTC (permalink / raw)
  To: The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 959 bytes --]


> 
> For the sake of bisectability this really should be moved earlier;
> otherwise at least patch "fix parameter to firmware calls" would
> be wrong.
> 
Even bigger problem is whether we want to run in LE mode at all. From
what I understand (correct if I'm wrong) firmware calls remain
big-endian and you need to switch back and forth between LE and BE when
doing firmware calls. Byteswapping for the purpose of firmware calls is
to be avoided as bugs are easy to slip through (in fact the
byte-swapping isn't complete in proposed patches.
(correct me if I'm wrong) these new patches cover a subset of already
supported machines and don't add any user-visible feature and no new
kernel type (LE kernel can be loaded from BE GRUB).
Cross-compiling to BE from LE is easy (TARGET_CFLAGS=-EL).
So it looks like this patch series adds a new high-maintenance-cost port
covering only already supported machines and already supportred features.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

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

* Re: [RFC PATCH 08/23] Add powerpc64 types
  2014-04-01 17:15   ` Andrey Borzenkov
@ 2014-04-02 17:02     ` Ram Pai
  0 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-02 17:02 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

On Tue, Apr 01, 2014 at 09:15:03PM +0400, Andrey Borzenkov wrote:
> В Wed, 26 Feb 2014 10:31:07 -0800
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > From: Anton Blanchard <anton@samba.org>
> > 
> >  Add powerpc64 types
> > 
> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > From: Anton Blanchard <anton@samba.org>
> > ---
> >  include/grub/powerpc/types.h | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
> > index a098ae6..7a2fc6b 100644
> > --- a/include/grub/powerpc/types.h
> > +++ b/include/grub/powerpc/types.h
> > @@ -19,11 +19,19 @@
> >  #ifndef GRUB_TYPES_CPU_HEADER
> >  #define GRUB_TYPES_CPU_HEADER	1
> >  
> > +#ifdef __powerpc64le__
> > +/* The size of void *.  */
> > +#define GRUB_TARGET_SIZEOF_VOID_P	8
> > +
> > +/* The size of long.  */
> > +#define GRUB_TARGET_SIZEOF_LONG		8
> > +#else
> >  /* The size of void *.  */
> >  #define GRUB_TARGET_SIZEOF_VOID_P	4
> >  
> >  /* The size of long.  */
> >  #define GRUB_TARGET_SIZEOF_LONG		4
> > +#endif
> >  
> >  /* powerpc is big-endian.  */
> >  #define GRUB_TARGET_WORDS_BIGENDIAN	1
> 
> This sure can't be right on LE platform?


I have it updated later in the patch series. I think
it is better to merge that patch with this one.


BTW:  I have a new patch series, which simplifies the build,
and takes out lot of duplication. Will send that out soon.


Thanks,

-- 
Ram Pai



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

* Re: [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit
  2014-04-01 17:21   ` Andrey Borzenkov
@ 2014-04-02 17:03     ` Ram Pai
  0 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-02 17:03 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

On Tue, Apr 01, 2014 at 09:21:46PM +0400, Andrey Borzenkov wrote:
> В Wed, 26 Feb 2014 10:31:08 -0800
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > From: Anton Blanchard <anton@samba.org>
> > 
> > Fix warnings when building powerpc linux loader 64bit
> > 
> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > From: Anton Blanchard <anton@samba.org>
> > ---
> >  grub-core/loader/powerpc/ieee1275/linux.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c
> > index 4a14f66..3d6a61e 100644
> > --- a/grub-core/loader/powerpc/ieee1275/linux.c
> > +++ b/grub-core/loader/powerpc/ieee1275/linux.c
> > @@ -141,8 +141,8 @@ grub_linux_boot (void)
> >    grub_ieee1275_set_property (grub_ieee1275_chosen, "bootargs", linux_args,
> >  			      grub_strlen (linux_args) + 1, &actual);
> >  
> > -  grub_dprintf ("loader", "Entry point: 0x%x\n", linux_entry);
> > -  grub_dprintf ("loader", "Initrd at: 0x%x, size 0x%x\n", initrd_addr,
> > +  grub_dprintf ("loader", "Entry point: 0x%lx\n", linux_entry);
> 
> I guess using PRIxGRUB_ADDR is more consistent - it can now be both 32 and 64 bits.
> 
> > +  grub_dprintf ("loader", "Initrd at: 0x%lx, size 0x%lx\n", initrd_addr,
> >  		initrd_size);
> 
> Ditto and PRIuGRUB_SIZE.
> 
> >    grub_dprintf ("loader", "Boot arguments: %s\n", linux_args);
> >    grub_dprintf ("loader", "Jumping to Linux...\n");
> > @@ -360,7 +360,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
> >    if (addr == (grub_addr_t) -1)
> >       goto fail;
> >  
> > -  grub_dprintf ("loader", "Loading initrd at 0x%x, size 0x%x\n", addr, size);
> > +  grub_dprintf ("loader", "Loading initrd at 0x%lx, size 0x%lx\n", addr, size);
> >  
> 
> Ditto.
> 
> >    if (grub_initrd_load (&initrd_ctx, argv, (void *) addr))
> >      goto fail;

ok. will do.
RP



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

* Re: [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-04-01 17:27   ` Andrey Borzenkov
@ 2014-04-02 17:06     ` Ram Pai
  2014-04-02 17:19       ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-02 17:06 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

On Tue, Apr 01, 2014 at 09:27:19PM +0400, Andrey Borzenkov wrote:
> В Wed, 26 Feb 2014 10:31:10 -0800
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > From: Anton Blanchard <anton@samba.org>
> > 
> >  Fix powerpc setjmp/longjmp 64bit issues
> > 
> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > From:  Anton Blanchard <anton@samba.org>
> > ---
> >  grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
> >  1 file changed, 52 insertions(+), 42 deletions(-)
> > 
> > diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
> > index 716b563..51fcae9 100644
> > --- a/grub-core/lib/powerpc/setjmp.S
> > +++ b/grub-core/lib/powerpc/setjmp.S
> > @@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
> >  
> >  	.text
> >  
> > +#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
> 
> Where is __powerpc64__ defined? Your previous patch adds only
> __powerpc64le__ and it does exist in current code as well?

It is already defined even prior to this patch series. in this
patch series i am just adding __powerpc64le__ .

-- 
Ram Pai



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

* Re: [RFC PATCH 20/23] fix parameter to firmware calls
  2014-04-01 17:45   ` Andrey Borzenkov
@ 2014-04-02 17:08     ` Ram Pai
  2014-04-02 17:16       ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-02 17:08 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, anton, tlfalcon, tbberry, tonyb

On Tue, Apr 01, 2014 at 09:45:35PM +0400, Andrey Borzenkov wrote:
> В Wed, 26 Feb 2014 10:31:19 -0800
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > -#define IEEE1275_ADDR(x)         (grub_uint32_t)(grub_addr_t)(x)
> > -
> > +#define IEEE1275_ADDR(x)         (grub_uint32_t)grub_cpu_to_be32((grub_addr_t)(x))
> > +#define IEEE1275_VALUE(x)         (grub_uint32_t)grub_cpu_to_be32(x)
> 
> Same question - what about sparc64, is it safe to truncate values there?

dont know anything about sparc64. Probably not. 

These macros are used only for the powerpc specific code AFAICT. I will audit and confirm.


-- 
Ram Pai



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-01 17:49   ` Andrey Borzenkov
  2014-04-01 20:22     ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-02 17:09     ` Ram Pai
  1 sibling, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-02 17:09 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

On Tue, Apr 01, 2014 at 09:49:45PM +0400, Andrey Borzenkov wrote:
> В Wed, 26 Feb 2014 10:31:20 -0800
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > From: Anton Blanchard <anton@samba.org>
> > 
> >  powerpc64 is not necessarily BigEndian anymore! :)
> > 
> > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > ---
> >  include/grub/powerpc/types.h | 10 +++++++---
> >  1 file changed, 7 insertions(+), 3 deletions(-)
> > 
> > diff --git a/include/grub/powerpc/types.h b/include/grub/powerpc/types.h
> > index 7a2fc6b..ab138d4 100644
> > --- a/include/grub/powerpc/types.h
> > +++ b/include/grub/powerpc/types.h
> > @@ -19,7 +19,7 @@
> >  #ifndef GRUB_TYPES_CPU_HEADER
> >  #define GRUB_TYPES_CPU_HEADER	1
> >  
> > -#ifdef __powerpc64le__
> > +#ifdef __powerpc64__
> >  /* The size of void *.  */
> >  #define GRUB_TARGET_SIZEOF_VOID_P	8
> >  
> > @@ -33,8 +33,12 @@
> >  #define GRUB_TARGET_SIZEOF_LONG		4
> >  #endif
> >  
> > -/* powerpc is big-endian.  */
> > -#define GRUB_TARGET_WORDS_BIGENDIAN	1
> > +#ifdef __powerpc64le__
> > +#undef GRUB_TARGET_WORDS_BIGENDIAN
> > +#else
> > +#define GRUB_TARGET_WORDS_BIGENDIAN     1
> > +#endif
> > +
> 
> For the sake of bisectability this really should be moved earlier;
> otherwise at least patch "fix parameter to firmware calls" would
> be wrong.


Yes. will do.

Thanks for your time and valuable comments!
RP



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

* Re: [RFC PATCH 20/23] fix parameter to firmware calls
  2014-04-02 17:08     ` Ram Pai
@ 2014-04-02 17:16       ` Andrey Borzenkov
  0 siblings, 0 replies; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-02 17:16 UTC (permalink / raw)
  To: Ram Pai; +Cc: The development of GNU GRUB, anton, tlfalcon, tbberry, tonyb

В Wed, 2 Apr 2014 10:08:32 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> On Tue, Apr 01, 2014 at 09:45:35PM +0400, Andrey Borzenkov wrote:
> > В Wed, 26 Feb 2014 10:31:19 -0800
> > Ram Pai <linuxram@us.ibm.com> пишет:
> > 
> > > -#define IEEE1275_ADDR(x)         (grub_uint32_t)(grub_addr_t)(x)
> > > -
> > > +#define IEEE1275_ADDR(x)         (grub_uint32_t)grub_cpu_to_be32((grub_addr_t)(x))
> > > +#define IEEE1275_VALUE(x)         (grub_uint32_t)grub_cpu_to_be32(x)
> > 
> > Same question - what about sparc64, is it safe to truncate values there?
> 
> dont know anything about sparc64. Probably not. 
> 
> These macros are used only for the powerpc specific code AFAICT.

Files under grub-core/*/ieee1275 are used for ieee1275 platforms, which
include sparc64 (and actually i385 as well, so you need to check how it
affects these too)

GROUPS["ieee1275"]   = [ "i386_ieee1275", "sparc64_ieee1275", "powerpc_ieee1275" ]

> I will audit and confirm.
> 
> 



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

* Re: [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-04-02 17:06     ` Ram Pai
@ 2014-04-02 17:19       ` Andrey Borzenkov
  2014-04-02 17:48         ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-02 17:19 UTC (permalink / raw)
  To: Ram Pai
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

В Wed, 2 Apr 2014 10:06:05 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> On Tue, Apr 01, 2014 at 09:27:19PM +0400, Andrey Borzenkov wrote:
> > В Wed, 26 Feb 2014 10:31:10 -0800
> > Ram Pai <linuxram@us.ibm.com> пишет:
> > 
> > > From: Anton Blanchard <anton@samba.org>
> > > 
> > >  Fix powerpc setjmp/longjmp 64bit issues
> > > 
> > > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > > From:  Anton Blanchard <anton@samba.org>
> > > ---
> > >  grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
> > >  1 file changed, 52 insertions(+), 42 deletions(-)
> > > 
> > > diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
> > > index 716b563..51fcae9 100644
> > > --- a/grub-core/lib/powerpc/setjmp.S
> > > +++ b/grub-core/lib/powerpc/setjmp.S
> > > @@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
> > >  
> > >  	.text
> > >  
> > > +#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
> > 
> > Where is __powerpc64__ defined? Your previous patch adds only
> > __powerpc64le__ and it does exist in current code as well?
> 
> It is already defined even prior to this patch series.

Where?

bor@opensuse:~/src/grub> grep -rw __powerpc64__ .
bor@opensuse:~/src/grub> 


> in this
> patch series i am just adding __powerpc64le__ .
> 



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

* Re: [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-04-02 17:19       ` Andrey Borzenkov
@ 2014-04-02 17:48         ` Ram Pai
  2014-04-02 17:56           ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-02 17:48 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

On Wed, Apr 02, 2014 at 09:19:59PM +0400, Andrey Borzenkov wrote:
> В Wed, 2 Apr 2014 10:06:05 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > On Tue, Apr 01, 2014 at 09:27:19PM +0400, Andrey Borzenkov wrote:
> > > В Wed, 26 Feb 2014 10:31:10 -0800
> > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > 
> > > > From: Anton Blanchard <anton@samba.org>
> > > > 
> > > >  Fix powerpc setjmp/longjmp 64bit issues
> > > > 
> > > > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > > > From:  Anton Blanchard <anton@samba.org>
> > > > ---
> > > >  grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
> > > >  1 file changed, 52 insertions(+), 42 deletions(-)
> > > > 
> > > > diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
> > > > index 716b563..51fcae9 100644
> > > > --- a/grub-core/lib/powerpc/setjmp.S
> > > > +++ b/grub-core/lib/powerpc/setjmp.S
> > > > @@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
> > > >  
> > > >  	.text
> > > >  
> > > > +#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
> > > 
> > > Where is __powerpc64__ defined? Your previous patch adds only
> > > __powerpc64le__ and it does exist in current code as well?
> > 
> > It is already defined even prior to this patch series.
> 
> Where?

just checked. Looks like it is defined automatically by the compiler automatically when -m64 is
specified.

RP



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

* Re: [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-04-02 17:48         ` Ram Pai
@ 2014-04-02 17:56           ` Andrey Borzenkov
  2014-04-02 18:55             ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-02 17:56 UTC (permalink / raw)
  To: Ram Pai
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

В Wed, 2 Apr 2014 10:48:34 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> On Wed, Apr 02, 2014 at 09:19:59PM +0400, Andrey Borzenkov wrote:
> > В Wed, 2 Apr 2014 10:06:05 -0700
> > Ram Pai <linuxram@us.ibm.com> пишет:
> > 
> > > On Tue, Apr 01, 2014 at 09:27:19PM +0400, Andrey Borzenkov wrote:
> > > > В Wed, 26 Feb 2014 10:31:10 -0800
> > > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > > 
> > > > > From: Anton Blanchard <anton@samba.org>
> > > > > 
> > > > >  Fix powerpc setjmp/longjmp 64bit issues
> > > > > 
> > > > > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > > > > From:  Anton Blanchard <anton@samba.org>
> > > > > ---
> > > > >  grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
> > > > >  1 file changed, 52 insertions(+), 42 deletions(-)
> > > > > 
> > > > > diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
> > > > > index 716b563..51fcae9 100644
> > > > > --- a/grub-core/lib/powerpc/setjmp.S
> > > > > +++ b/grub-core/lib/powerpc/setjmp.S
> > > > > @@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
> > > > >  
> > > > >  	.text
> > > > >  
> > > > > +#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
> > > > 
> > > > Where is __powerpc64__ defined? Your previous patch adds only
> > > > __powerpc64le__ and it does exist in current code as well?
> > > 
> > > It is already defined even prior to this patch series.
> > 
> > Where?
> 
> just checked. Looks like it is defined automatically by the compiler automatically when -m64 is
> specified.
> 

grub does not use -m64 on powerpc. Existing target is 32 bit.


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

* Re: [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues
  2014-04-02 17:56           ` Andrey Borzenkov
@ 2014-04-02 18:55             ` Ram Pai
  0 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-02 18:55 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, tlfalcon, tbberry, anton, tonyb,
	Anton Blanchard

On Wed, Apr 02, 2014 at 09:56:54PM +0400, Andrey Borzenkov wrote:
> В Wed, 2 Apr 2014 10:48:34 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > On Wed, Apr 02, 2014 at 09:19:59PM +0400, Andrey Borzenkov wrote:
> > > В Wed, 2 Apr 2014 10:06:05 -0700
> > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > 
> > > > On Tue, Apr 01, 2014 at 09:27:19PM +0400, Andrey Borzenkov wrote:
> > > > > В Wed, 26 Feb 2014 10:31:10 -0800
> > > > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > > > 
> > > > > > From: Anton Blanchard <anton@samba.org>
> > > > > > 
> > > > > >  Fix powerpc setjmp/longjmp 64bit issues
> > > > > > 
> > > > > > Signed-off-by: Ram Pai <linuxram@us.ibm.com>
> > > > > > From:  Anton Blanchard <anton@samba.org>
> > > > > > ---
> > > > > >  grub-core/lib/powerpc/setjmp.S | 94 +++++++++++++++++++++++-------------------
> > > > > >  1 file changed, 52 insertions(+), 42 deletions(-)
> > > > > > 
> > > > > > diff --git a/grub-core/lib/powerpc/setjmp.S b/grub-core/lib/powerpc/setjmp.S
> > > > > > index 716b563..51fcae9 100644
> > > > > > --- a/grub-core/lib/powerpc/setjmp.S
> > > > > > +++ b/grub-core/lib/powerpc/setjmp.S
> > > > > > @@ -25,33 +25,43 @@ GRUB_MOD_LICENSE "GPLv3+"
> > > > > >  
> > > > > >  	.text
> > > > > >  
> > > > > > +#if defined( __powerpc64__ ) || defined( __powerpc64le__ )
> > > > > 
> > > > > Where is __powerpc64__ defined? Your previous patch adds only
> > > > > __powerpc64le__ and it does exist in current code as well?
> > > > 
> > > > It is already defined even prior to this patch series.
> > > 
> > > Where?
> > 
> > just checked. Looks like it is defined automatically by the compiler automatically when -m64 is
> > specified.
> > 
> 
> grub does not use -m64 on powerpc. Existing target is 32 bit.

Confirmed with our toolchain folks. the gcc compiler for LE targets
assumes -m64 by default. -m32 is not supported for LE target.

However, it does feel a little kludgy to have __powerpc64__ defined by
the compiler and __powerpc64le__ by my patches. Have to figure out a way
to clean it up.

RP



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-01 20:22     ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-03 17:33       ` Ram Pai
  2014-04-03 17:53         ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-03 17:33 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: phcoder, pfsmorigo

On Tue, Apr 01, 2014 at 10:22:10PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> 
> > 
> > For the sake of bisectability this really should be moved earlier;
> > otherwise at least patch "fix parameter to firmware calls" would
> > be wrong.
> > 
> Even bigger problem is whether we want to run in LE mode at all. From
> what I understand (correct if I'm wrong) firmware calls remain
> big-endian and you need to switch back and forth between LE and BE when
> doing firmware calls.

Yes. firmware runs in 32bit BE mode. And there is a constant switch from
64bit LE to 32bit BE and vice-versa for each firmware call.

> doing firmware calls. Byteswapping for the purpose of firmware calls is
> to be avoided as bugs are easy to slip through (in fact the
> byte-swapping isn't complete in proposed patches.
> (correct me if I'm wrong) 

Is that true? maybe you are right. I might have missed something.
However please hint me what i have missed. I will look into some
other arch code that support the same ieee platform.


> these new patches cover a subset of already
> supported machines and don't add any user-visible feature and no new
> kernel type (LE kernel can be loaded from BE GRUB).
> Cross-compiling to BE from LE is easy (TARGET_CFLAGS=-EL).

Well. that is the issue.  Various distros have varied support for
cross-compilation (multi-arch support). If the distro does not 
have 32bit BE libraries natively installed (out-of-the-box), they
wont be able to generate a 32bit BE grub loader. These set of patches
overcomes the deficiency by generating a working native executable 
on LE systems.

> So it looks like this patch series adds a new high-maintenance-cost port
> covering only already supported machines and already supportred features.

It does add maintainence; I agree. But than it does overcome some
deficiences aswell.


Thanks for your comments. And sorry for the delay. I had not seen this
email, since i was not on copy. I will watch the mailing list regularly.
RP




> 



> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Ram Pai



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 17:33       ` Ram Pai
@ 2014-04-03 17:53         ` Andrey Borzenkov
  2014-04-03 18:37           ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-03 17:53 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: phcoder, linuxram, pfsmorigo

В Thu, 3 Apr 2014 10:33:36 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> On Tue, Apr 01, 2014 at 10:22:10PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> > 
> > > 
> > > For the sake of bisectability this really should be moved earlier;
> > > otherwise at least patch "fix parameter to firmware calls" would
> > > be wrong.
> > > 
> > Even bigger problem is whether we want to run in LE mode at all. From
> > what I understand (correct if I'm wrong) firmware calls remain
> > big-endian and you need to switch back and forth between LE and BE when
> > doing firmware calls.
> 
> Yes. firmware runs in 32bit BE mode. And there is a constant switch from
> 64bit LE to 32bit BE and vice-versa for each firmware call.
> 
> > doing firmware calls. Byteswapping for the purpose of firmware calls is
> > to be avoided as bugs are easy to slip through (in fact the
> > byte-swapping isn't complete in proposed patches.
> > (correct me if I'm wrong) 
> 
> Is that true? maybe you are right. I might have missed something.
> However please hint me what i have missed. I will look into some
> other arch code that support the same ieee platform.
> 
> 
> > these new patches cover a subset of already
> > supported machines and don't add any user-visible feature and no new
> > kernel type (LE kernel can be loaded from BE GRUB).
> > Cross-compiling to BE from LE is easy (TARGET_CFLAGS=-EL).
> 

Hmm ... gcc docs mention this only for MIPS, not for PowerPC; for
PowerPC it says -mbig.

> Well. that is the issue.  Various distros have varied support for
> cross-compilation (multi-arch support). If the distro does not 
> have 32bit BE libraries natively installed (out-of-the-box), they
> wont be able to generate a 32bit BE grub loader.

We speak only about target code that runs at boot time. This code does
not use any library. It only needs compiler support. GRUB does not
support anything besides gcc and recently some clang support was added.
Do you have real life example of distribution which does not support
-mbig gcc option to produce big-endian *code*?

It is perfectly legal to have different architectures for host and
target. So you will have little-endian 64 bit host tools and big-endan
32 bit target. If this works for you this of course is much better
solution (at the end it requires just a single line in configure.ac).

>                                                 These set of patches
> overcomes the deficiency by generating a working native executable 
> on LE systems.
> 
> > So it looks like this patch series adds a new high-maintenance-cost port
> > covering only already supported machines and already supportred features.
> 
> It does add maintainence; I agree. But than it does overcome some
> deficiences aswell.
> 

Do you mean there are some problems with big-endian code at boot time?
Could you give more details?

> 
> Thanks for your comments. And sorry for the delay. I had not seen this
> email, since i was not on copy. I will watch the mailing list regularly.
> RP
> 
> 
> 
> 
> > 
> 
> 
> 
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> 
> 



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 17:53         ` Andrey Borzenkov
@ 2014-04-03 18:37           ` Ram Pai
  2014-04-03 19:03             ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-03 18:37 UTC (permalink / raw)
  To: Andrey Borzenkov; +Cc: The development of GNU GRUB, pfsmorigo, phcoder

On Thu, Apr 03, 2014 at 09:53:56PM +0400, Andrey Borzenkov wrote:
> В Thu, 3 Apr 2014 10:33:36 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > On Tue, Apr 01, 2014 at 10:22:10PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> > > 
> > > > 
> > > > For the sake of bisectability this really should be moved earlier;
> > > > otherwise at least patch "fix parameter to firmware calls" would
> > > > be wrong.
> > > > 
> > > Even bigger problem is whether we want to run in LE mode at all. From
> > > what I understand (correct if I'm wrong) firmware calls remain
> > > big-endian and you need to switch back and forth between LE and BE when
> > > doing firmware calls.
> > 
> > Yes. firmware runs in 32bit BE mode. And there is a constant switch from
> > 64bit LE to 32bit BE and vice-versa for each firmware call.
> > 
> > > doing firmware calls. Byteswapping for the purpose of firmware calls is
> > > to be avoided as bugs are easy to slip through (in fact the
> > > byte-swapping isn't complete in proposed patches.
> > > (correct me if I'm wrong) 
> > 
> > Is that true? maybe you are right. I might have missed something.
> > However please hint me what i have missed. I will look into some
> > other arch code that support the same ieee platform.
> > 
> > 
> > > these new patches cover a subset of already
> > > supported machines and don't add any user-visible feature and no new
> > > kernel type (LE kernel can be loaded from BE GRUB).
> > > Cross-compiling to BE from LE is easy (TARGET_CFLAGS=-EL).
> > 
> 
> Hmm ... gcc docs mention this only for MIPS, not for PowerPC; for
> PowerPC it says -mbig.
> 
> > Well. that is the issue.  Various distros have varied support for
> > cross-compilation (multi-arch support). If the distro does not 
> > have 32bit BE libraries natively installed (out-of-the-box), they
> > wont be able to generate a 32bit BE grub loader.
> 
> We speak only about target code that runs at boot time. This code does
> not use any library. 

I am not a compiler/toolchain expert. But dont we need all the necessary
tools and libraries in /lib/<arch>-<dist>-linux/ directory for cross
compilation; even to generate static executables?

> It only needs compiler support. GRUB does not
> support anything besides gcc and recently some clang support was added.
> Do you have real life example of distribution which does not support
> -mbig gcc option to produce big-endian *code*?

This is ideally what I want too. But it is not possible
**out-of-the-box** on any distro for power arch.  I am told
that debian has a new multi-arch support added which makes this
work out-of-the-box, but it is still in early stages to work
seemlessly **out-of-the-box**. I may be wrong.

> 
> It is perfectly legal to have different architectures for host and
> target. So you will have little-endian 64 bit host tools and big-endan
> 32 bit target. If this works for you this of course is much better
> solution (at the end it requires just a single line in configure.ac).
> 
> >                                                 These set of patches
> > overcomes the deficiency by generating a working native executable 
> > on LE systems.
> > 
> > > So it looks like this patch series adds a new high-maintenance-cost port
> > > covering only already supported machines and already supportred features.
> > 
> > It does add maintainence; I agree. But than it does overcome some
> > deficiences aswell.
> > 
> 
> Do you mean there are some problems with big-endian code at boot time?
> Could you give more details?

No there is absolutely no problem with big endian code at boot time.
I am talking about the challenges faced in cross compiling, if the
necessary multiarch/multilib support is not natively(out-of-the-box) 
available on the distro.


RP



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 18:37           ` Ram Pai
@ 2014-04-03 19:03             ` Andrey Borzenkov
  2014-04-03 19:26               ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-03 19:03 UTC (permalink / raw)
  To: Ram Pai; +Cc: The development of GNU GRUB, pfsmorigo, phcoder

В Thu, 3 Apr 2014 11:37:05 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> On Thu, Apr 03, 2014 at 09:53:56PM +0400, Andrey Borzenkov wrote:
> > В Thu, 3 Apr 2014 10:33:36 -0700
> > Ram Pai <linuxram@us.ibm.com> пишет:
> > 
> > > On Tue, Apr 01, 2014 at 10:22:10PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> > > > 
> > > > > 
> > > > > For the sake of bisectability this really should be moved earlier;
> > > > > otherwise at least patch "fix parameter to firmware calls" would
> > > > > be wrong.
> > > > > 
> > > > Even bigger problem is whether we want to run in LE mode at all. From
> > > > what I understand (correct if I'm wrong) firmware calls remain
> > > > big-endian and you need to switch back and forth between LE and BE when
> > > > doing firmware calls.
> > > 
> > > Yes. firmware runs in 32bit BE mode. And there is a constant switch from
> > > 64bit LE to 32bit BE and vice-versa for each firmware call.
> > > 
> > > > doing firmware calls. Byteswapping for the purpose of firmware calls is
> > > > to be avoided as bugs are easy to slip through (in fact the
> > > > byte-swapping isn't complete in proposed patches.
> > > > (correct me if I'm wrong) 
> > > 
> > > Is that true? maybe you are right. I might have missed something.
> > > However please hint me what i have missed. I will look into some
> > > other arch code that support the same ieee platform.
> > > 
> > > 
> > > > these new patches cover a subset of already
> > > > supported machines and don't add any user-visible feature and no new
> > > > kernel type (LE kernel can be loaded from BE GRUB).
> > > > Cross-compiling to BE from LE is easy (TARGET_CFLAGS=-EL).
> > > 
> > 
> > Hmm ... gcc docs mention this only for MIPS, not for PowerPC; for
> > PowerPC it says -mbig.
> > 
> > > Well. that is the issue.  Various distros have varied support for
> > > cross-compilation (multi-arch support). If the distro does not 
> > > have 32bit BE libraries natively installed (out-of-the-box), they
> > > wont be able to generate a 32bit BE grub loader.
> > 
> > We speak only about target code that runs at boot time. This code does
> > not use any library. 
> 
> I am not a compiler/toolchain expert. But dont we need all the necessary
> tools and libraries in /lib/<arch>-<dist>-linux/ directory for cross
> compilation; even to generate static executables?
> 
> > It only needs compiler support. GRUB does not
> > support anything besides gcc and recently some clang support was added.
> > Do you have real life example of distribution which does not support
> > -mbig gcc option to produce big-endian *code*?
> 
> This is ideally what I want too. But it is not possible
> **out-of-the-box** on any distro for power arch.  I am told
> that debian has a new multi-arch support added which makes this
> work out-of-the-box, but it is still in early stages to work
> seemlessly **out-of-the-box**. I may be wrong.
> 

If distribution is capable of building Linux kernel, it should be
capable of compiling 32 bit big-endian code. Linux startup code on
PowerPC is built as 32 bit big-endian:

BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                 -fno-strict-aliasing -Os -msoft-float -pipe \
                 -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
                 -isystem $(shell $(CROSS32CC) -print-file-name=include) \
                 -mbig-endian


> > 
> > It is perfectly legal to have different architectures for host and
> > target. So you will have little-endian 64 bit host tools and big-endan
> > 32 bit target. If this works for you this of course is much better
> > solution (at the end it requires just a single line in configure.ac).
> > 
> > >                                                 These set of patches
> > > overcomes the deficiency by generating a working native executable 
> > > on LE systems.
> > > 
> > > > So it looks like this patch series adds a new high-maintenance-cost port
> > > > covering only already supported machines and already supportred features.
> > > 
> > > It does add maintainence; I agree. But than it does overcome some
> > > deficiences aswell.
> > > 
> > 
> > Do you mean there are some problems with big-endian code at boot time?
> > Could you give more details?
> 
> No there is absolutely no problem with big endian code at boot time.
> I am talking about the challenges faced in cross compiling, if the
> necessary multiarch/multilib support is not natively(out-of-the-box) 
> available on the distro.
> 
> 
> RP
> 



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 19:03             ` Andrey Borzenkov
@ 2014-04-03 19:26               ` Ram Pai
  2014-04-03 19:42                 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-03 19:54                 ` Andrey Borzenkov
  0 siblings, 2 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-03 19:26 UTC (permalink / raw)
  To: Andrey Borzenkov; +Cc: The development of GNU GRUB, pfsmorigo, phcoder

On Thu, Apr 03, 2014 at 11:03:29PM +0400, Andrey Borzenkov wrote:
> В Thu, 3 Apr 2014 11:37:05 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > On Thu, Apr 03, 2014 at 09:53:56PM +0400, Andrey Borzenkov wrote:
> > > В Thu, 3 Apr 2014 10:33:36 -0700
> > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > 
> > > > On Tue, Apr 01, 2014 at 10:22:10PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> > > > > 
> > > > > > 
> > > > > > For the sake of bisectability this really should be moved earlier;
> > > > > > otherwise at least patch "fix parameter to firmware calls" would
> > > > > > be wrong.
> > > > > > 
> > > > > Even bigger problem is whether we want to run in LE mode at all. From
> > > > > what I understand (correct if I'm wrong) firmware calls remain
> > > > > big-endian and you need to switch back and forth between LE and BE when
> > > > > doing firmware calls.
> > > > 
> > > > Yes. firmware runs in 32bit BE mode. And there is a constant switch from
> > > > 64bit LE to 32bit BE and vice-versa for each firmware call.
> > > > 
> > > > > doing firmware calls. Byteswapping for the purpose of firmware calls is
> > > > > to be avoided as bugs are easy to slip through (in fact the
> > > > > byte-swapping isn't complete in proposed patches.
> > > > > (correct me if I'm wrong) 
> > > > 
> > > > Is that true? maybe you are right. I might have missed something.
> > > > However please hint me what i have missed. I will look into some
> > > > other arch code that support the same ieee platform.
> > > > 
> > > > 
> > > > > these new patches cover a subset of already
> > > > > supported machines and don't add any user-visible feature and no new
> > > > > kernel type (LE kernel can be loaded from BE GRUB).
> > > > > Cross-compiling to BE from LE is easy (TARGET_CFLAGS=-EL).
> > > > 
> > > 
> > > Hmm ... gcc docs mention this only for MIPS, not for PowerPC; for
> > > PowerPC it says -mbig.
> > > 
> > > > Well. that is the issue.  Various distros have varied support for
> > > > cross-compilation (multi-arch support). If the distro does not 
> > > > have 32bit BE libraries natively installed (out-of-the-box), they
> > > > wont be able to generate a 32bit BE grub loader.
> > > 
> > > We speak only about target code that runs at boot time. This code does
> > > not use any library. 
> > 
> > I am not a compiler/toolchain expert. But dont we need all the necessary
> > tools and libraries in /lib/<arch>-<dist>-linux/ directory for cross
> > compilation; even to generate static executables?
> > 
> > > It only needs compiler support. GRUB does not
> > > support anything besides gcc and recently some clang support was added.
> > > Do you have real life example of distribution which does not support
> > > -mbig gcc option to produce big-endian *code*?
> > 
> > This is ideally what I want too. But it is not possible
> > **out-of-the-box** on any distro for power arch.  I am told
> > that debian has a new multi-arch support added which makes this
> > work out-of-the-box, but it is still in early stages to work
> > seemlessly **out-of-the-box**. I may be wrong.
> > 
> 
> If distribution is capable of building Linux kernel, it should be
> capable of compiling 32 bit big-endian code. Linux startup code on
> PowerPC is built as 32 bit big-endian:
> 
> BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>                  -fno-strict-aliasing -Os -msoft-float -pipe \
>                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
>                  -isystem $(shell $(CROSS32CC) -print-file-name=include) \
>                  -mbig-endian


But that is different though. Yes it is possible to cross compile for
any target on any arch.  But the key is that the environment needs to be
setup to do so.  

We are talking about generating crosscompiled grub boot loader by an
uninitiated/not-so-expert adminstrator. If the distribution makes it
easy for that administrator to be able to cross-compile, than life is
easy.  But that is not generally the case though. The administrator has
to scramble around to find the right cross-compilation setup installed
on her system to achieve the end result.

RP



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 19:26               ` Ram Pai
@ 2014-04-03 19:42                 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-03 20:23                   ` Ram Pai
  2014-04-03 19:54                 ` Andrey Borzenkov
  1 sibling, 1 reply; 68+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-03 19:42 UTC (permalink / raw)
  To: Ram Pai, Andrey Borzenkov; +Cc: The development of GNU GRUB, pfsmorigo

[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]

On 03.04.2014 21:26, Ram Pai wrote:
>> > BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>> >                  -fno-strict-aliasing -Os -msoft-float -pipe \
>> >                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
>> >                  -isystem $(shell $(CROSS32CC) -print-file-name=include) \
>> >                  -mbig-endian
> 
> But that is different though.
How so? It's exactly the same thing: compilation of standalone BE using
LE compiler.
Andrey found a very good argument. And if distro can't compile Linux,
it's surely broken.
Also powerpc64le is relatively new platform as far as distrros are
concerned. I think if big distros show good example, other minor will
follow, resulting in more comfortable environment rather than locking
ourselves into uncomfortable environments.
> Yes it is possible to cross compile for
> any target on any arch.  But the key is that the environment needs to be
> setup to do so.  
> 
> We are talking about generating crosscompiled grub boot loader by an
> uninitiated/not-so-expert adminstrator.
It probably amounts to adding -mbig-endian to TARGET_* and using right
--target. Both of which can be automated in configure.ac rather than
maintaining yet another port.

> If the distribution makes it
> easy for that administrator to be able to cross-compile, than life is
> easy.  But that is not generally the case though. The administrator has
> to scramble around to find the right cross-compilation setup installed
> on her system to achieve the end result.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 19:26               ` Ram Pai
  2014-04-03 19:42                 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-03 19:54                 ` Andrey Borzenkov
  2014-04-03 20:32                   ` Ram Pai
  2014-04-04  6:37                   ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 2 replies; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-03 19:54 UTC (permalink / raw)
  To: Ram Pai; +Cc: The development of GNU GRUB, pfsmorigo, phcoder

В Thu, 3 Apr 2014 12:26:57 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> > > > 
> > > > > Well. that is the issue.  Various distros have varied support for
> > > > > cross-compilation (multi-arch support). If the distro does not 
> > > > > have 32bit BE libraries natively installed (out-of-the-box), they
> > > > > wont be able to generate a 32bit BE grub loader.
> > > > 
> > > > We speak only about target code that runs at boot time. This code does
> > > > not use any library. 
> > > 
> > > I am not a compiler/toolchain expert. But dont we need all the necessary
> > > tools and libraries in /lib/<arch>-<dist>-linux/ directory for cross
> > > compilation; even to generate static executables?
> > > 
> > > > It only needs compiler support. GRUB does not
> > > > support anything besides gcc and recently some clang support was added.
> > > > Do you have real life example of distribution which does not support
> > > > -mbig gcc option to produce big-endian *code*?
> > > 
> > > This is ideally what I want too. But it is not possible
> > > **out-of-the-box** on any distro for power arch.  I am told
> > > that debian has a new multi-arch support added which makes this
> > > work out-of-the-box, but it is still in early stages to work
> > > seemlessly **out-of-the-box**. I may be wrong.
> > > 
> > 
> > If distribution is capable of building Linux kernel, it should be
> > capable of compiling 32 bit big-endian code. Linux startup code on
> > PowerPC is built as 32 bit big-endian:
> > 
> > BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> >                  -fno-strict-aliasing -Os -msoft-float -pipe \
> >                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
> >                  -isystem $(shell $(CROSS32CC) -print-file-name=include) \
> >                  -mbig-endian
> 
> 
> But that is different though. Yes it is possible to cross compile for
> any target on any arch.  But the key is that the environment needs to be
> setup to do so.  
> 
> We are talking about generating crosscompiled grub boot loader by an
> uninitiated/not-so-expert adminstrator. If the distribution makes it
> easy for that administrator to be able to cross-compile, than life is
> easy.  But that is not generally the case though.

E-h-h ... could you be more specific? You need exactly the same tool
set to compile 32 bit big-endian grub as to compile Linux kernel. So
it follows that generally it is impossible to compile Linux kernel on
distributions for ppc64le. Is it what you mean?

>                                                   The administrator has
> to scramble around to find the right cross-compilation setup installed
> on her system to achieve the end result.
> 

I try to understand what exactly is required beyond what is needed to
compile Linux kernel? I do not consider need to install a couple of
RPMs as high burden.

Here is what grub2 on SUSE needs:

%ifarch x86_64 ppc64
BuildRequires:  gcc-32bit
BuildRequires:  glibc-32bit
BuildRequires:  glibc-devel-32bit
%else
BuildRequires:  gcc
BuildRequires:  glibc-devel
%ifarch s390x
BuildRequires:  glibc-static
%endif
%endif

See https://build.opensuse.org/package/show/Base:System/grub2 for
details. It simply forces -m32 -big-endian for powerpc. It also includes
brute-force patche to work around libgcc issue that probably may be
done differently, but otherwise it is amazingly small change.


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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 19:42                 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-03 20:23                   ` Ram Pai
  0 siblings, 0 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-03 20:23 UTC (permalink / raw)
  To: Vladimir 'φ-coder/phcoder' Serbinenko
  Cc: Andrey Borzenkov, The development of GNU GRUB, pfsmorigo

On Thu, Apr 03, 2014 at 09:42:54PM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> On 03.04.2014 21:26, Ram Pai wrote:
> >> > BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> >> >                  -fno-strict-aliasing -Os -msoft-float -pipe \
> >> >                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
> >> >                  -isystem $(shell $(CROSS32CC) -print-file-name=include) \
> >> >                  -mbig-endian
> > 
> > But that is different though.
> How so? It's exactly the same thing: compilation of standalone BE using
> LE compiler.
> Andrey found a very good argument. And if distro can't compile Linux,
> it's surely broken.
> Also powerpc64le is relatively new platform as far as distrros are
> concerned. I think if big distros show good example, other minor will
> follow, resulting in more comfortable environment rather than locking
> ourselves into uncomfortable environments.

Two things:

a) the cross-compilation on 64bit LE to 32bit-BE target has to be
	working and supported.
b) distros need to enable (a).

regarding (a) -- is not true currently and i am told that its not in their plans in
	the near future.

regarding (b) -- can't speak for all the major distros. But none have it currently.


> > Yes it is possible to cross compile for
> > any target on any arch.  But the key is that the environment needs to be
> > setup to do so.  
> > 
> > We are talking about generating crosscompiled grub boot loader by an
> > uninitiated/not-so-expert adminstrator.
> It probably amounts to adding -mbig-endian to TARGET_* and using right
> --target. Both of which can be automated in configure.ac rather than
> maintaining yet another port.

Yes, if (a) and (b) line up.

RP



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 19:54                 ` Andrey Borzenkov
@ 2014-04-03 20:32                   ` Ram Pai
  2014-04-03 21:41                     ` Vladimir 'phcoder' Serbinenko
  2014-04-04  2:28                     ` Andrey Borzenkov
  2014-04-04  6:37                   ` Vladimir 'φ-coder/phcoder' Serbinenko
  1 sibling, 2 replies; 68+ messages in thread
From: Ram Pai @ 2014-04-03 20:32 UTC (permalink / raw)
  To: Andrey Borzenkov; +Cc: The development of GNU GRUB, pfsmorigo, phcoder

On Thu, Apr 03, 2014 at 11:54:46PM +0400, Andrey Borzenkov wrote:
> В Thu, 3 Apr 2014 12:26:57 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > > > > 
> > > > > > Well. that is the issue.  Various distros have varied support for
> > > > > > cross-compilation (multi-arch support). If the distro does not 
> > > > > > have 32bit BE libraries natively installed (out-of-the-box), they
> > > > > > wont be able to generate a 32bit BE grub loader.
> > > > > 
> > > > > We speak only about target code that runs at boot time. This code does
> > > > > not use any library. 
> > > > 
> > > > I am not a compiler/toolchain expert. But dont we need all the necessary
> > > > tools and libraries in /lib/<arch>-<dist>-linux/ directory for cross
> > > > compilation; even to generate static executables?
> > > > 
> > > > > It only needs compiler support. GRUB does not
> > > > > support anything besides gcc and recently some clang support was added.
> > > > > Do you have real life example of distribution which does not support
> > > > > -mbig gcc option to produce big-endian *code*?
> > > > 
> > > > This is ideally what I want too. But it is not possible
> > > > **out-of-the-box** on any distro for power arch.  I am told
> > > > that debian has a new multi-arch support added which makes this
> > > > work out-of-the-box, but it is still in early stages to work
> > > > seemlessly **out-of-the-box**. I may be wrong.
> > > > 
> > > 
> > > If distribution is capable of building Linux kernel, it should be
> > > capable of compiling 32 bit big-endian code. Linux startup code on
> > > PowerPC is built as 32 bit big-endian:
> > > 
> > > BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> > >                  -fno-strict-aliasing -Os -msoft-float -pipe \
> > >                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
> > >                  -isystem $(shell $(CROSS32CC) -print-file-name=include) \
> > >                  -mbig-endian
> > 
> > 
> > But that is different though. Yes it is possible to cross compile for
> > any target on any arch.  But the key is that the environment needs to be
> > setup to do so.  
> > 
> > We are talking about generating crosscompiled grub boot loader by an
> > uninitiated/not-so-expert adminstrator. If the distribution makes it
> > easy for that administrator to be able to cross-compile, than life is
> > easy.  But that is not generally the case though.
> 
> E-h-h ... could you be more specific? You need exactly the same tool
> set to compile 32 bit big-endian grub as to compile Linux kernel. So
> it follows that generally it is impossible to compile Linux kernel on
> distributions for ppc64le. Is it what you mean?

It is not possible to generate a ppc64be kernel on a ppc64le distro.
Toolchain does not support it.  Vice-versa is possible.


> 
> >                                                   The administrator has
> > to scramble around to find the right cross-compilation setup installed
> > on her system to achieve the end result.
> > 
> 
> I try to understand what exactly is required beyond what is needed to
> compile Linux kernel? I do not consider need to install a couple of
> RPMs as high burden.
> 
> Here is what grub2 on SUSE needs:
> 
> %ifarch x86_64 ppc64
> BuildRequires:  gcc-32bit
> BuildRequires:  glibc-32bit
> BuildRequires:  glibc-devel-32bit
> %else
> BuildRequires:  gcc
> BuildRequires:  glibc-devel
> %ifarch s390x
> BuildRequires:  glibc-static
> %endif
> %endif
> 
> See https://build.opensuse.org/package/show/Base:System/grub2 for
> details. It simply forces -m32 -big-endian for powerpc. It also includes
> brute-force patche to work around libgcc issue that probably may be
> done differently, but otherwise it is amazingly small change.

They generate a 32bit BE grub binary  on a LE system?  No. I dont think
so. Because the cross-compile tool chain is not enabled do so.

-- 
Ram Pai



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 20:32                   ` Ram Pai
@ 2014-04-03 21:41                     ` Vladimir 'phcoder' Serbinenko
  2014-04-04  2:28                     ` Andrey Borzenkov
  1 sibling, 0 replies; 68+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2014-04-03 21:41 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 4494 bytes --]

On 3 Apr 2014 22:33, "Ram Pai" <linuxram@us.ibm.com> wrote:
>
> On Thu, Apr 03, 2014 at 11:54:46PM +0400, Andrey Borzenkov wrote:
> > В Thu, 3 Apr 2014 12:26:57 -0700
> > Ram Pai <linuxram@us.ibm.com> пишет:
> >
> > > > > >
> > > > > > > Well. that is the issue.  Various distros have varied support
for
> > > > > > > cross-compilation (multi-arch support). If the distro does not
> > > > > > > have 32bit BE libraries natively installed (out-of-the-box),
they
> > > > > > > wont be able to generate a 32bit BE grub loader.
> > > > > >
> > > > > > We speak only about target code that runs at boot time. This
code does
> > > > > > not use any library.
> > > > >
> > > > > I am not a compiler/toolchain expert. But dont we need all the
necessary
> > > > > tools and libraries in /lib/<arch>-<dist>-linux/ directory for
cross
> > > > > compilation; even to generate static executables?
> > > > >
> > > > > > It only needs compiler support. GRUB does not
> > > > > > support anything besides gcc and recently some clang support
was added.
> > > > > > Do you have real life example of distribution which does not
support
> > > > > > -mbig gcc option to produce big-endian *code*?
> > > > >
> > > > > This is ideally what I want too. But it is not possible
> > > > > **out-of-the-box** on any distro for power arch.  I am told
> > > > > that debian has a new multi-arch support added which makes this
> > > > > work out-of-the-box, but it is still in early stages to work
> > > > > seemlessly **out-of-the-box**. I may be wrong.
> > > > >
> > > >
> > > > If distribution is capable of building Linux kernel, it should be
> > > > capable of compiling 32 bit big-endian code. Linux startup code on
> > > > PowerPC is built as 32 bit big-endian:
> > > >
> > > > BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
> > > >                  -fno-strict-aliasing -Os -msoft-float -pipe \
> > > >                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
> > > >                  -isystem $(shell $(CROSS32CC)
-print-file-name=include) \
> > > >                  -mbig-endian
> > >
> > >
> > > But that is different though. Yes it is possible to cross compile for
> > > any target on any arch.  But the key is that the environment needs to
be
> > > setup to do so.
> > >
> > > We are talking about generating crosscompiled grub boot loader by an
> > > uninitiated/not-so-expert adminstrator. If the distribution makes it
> > > easy for that administrator to be able to cross-compile, than life is
> > > easy.  But that is not generally the case though.
> >
> > E-h-h ... could you be more specific? You need exactly the same tool
> > set to compile 32 bit big-endian grub as to compile Linux kernel. So
> > it follows that generally it is impossible to compile Linux kernel on
> > distributions for ppc64le. Is it what you mean?
>
> It is not possible to generate a ppc64be kernel on a ppc64le distro.
> Toolchain does not support it.  Vice-versa is possible.
>
>
No. Ppc64le kernel has some BE code. If you can compile ppc64le kernel you
can compile ppc32be GRUB
> >
> > >                                                   The administrator
has
> > > to scramble around to find the right cross-compilation setup installed
> > > on her system to achieve the end result.
> > >
> >
> > I try to understand what exactly is required beyond what is needed to
> > compile Linux kernel? I do not consider need to install a couple of
> > RPMs as high burden.
> >
> > Here is what grub2 on SUSE needs:
> >
> > %ifarch x86_64 ppc64
> > BuildRequires:  gcc-32bit
> > BuildRequires:  glibc-32bit
> > BuildRequires:  glibc-devel-32bit
> > %else
> > BuildRequires:  gcc
> > BuildRequires:  glibc-devel
> > %ifarch s390x
> > BuildRequires:  glibc-static
> > %endif
> > %endif
> >
> > See https://build.opensuse.org/package/show/Base:System/grub2 for
> > details. It simply forces -m32 -big-endian for powerpc. It also includes
> > brute-force patche to work around libgcc issue that probably may be
> > done differently, but otherwise it is amazingly small change.
>
> They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> so. Because the cross-compile tool chain is not enabled do so.
>
> --
> Ram Pai
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel

[-- Attachment #2: Type: text/html, Size: 6183 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 20:32                   ` Ram Pai
  2014-04-03 21:41                     ` Vladimir 'phcoder' Serbinenko
@ 2014-04-04  2:28                     ` Andrey Borzenkov
  2014-04-04 17:47                       ` Ram Pai
  1 sibling, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-04  2:28 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: phcoder, linuxram, pfsmorigo

В Thu, 3 Apr 2014 13:32:22 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> 
> They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> so. Because the cross-compile tool chain is not enabled do so.
> 

bor@opensuse:/tmp/binaries> file usr/bin/grub2-mkimage
usr/bin/grub2-mkimage: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=4a9b7759e1c41a2b2de9f4d33bc179186bf04f8f, stripped
bor@opensuse:/tmp/binaries> file usr/lib/grub2/powerpc-ieee1275/kernel.exec
usr/lib/grub2/powerpc-ieee1275/kernel.exec: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
bor@opensuse:/tmp/binaries> 


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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-03 19:54                 ` Andrey Borzenkov
  2014-04-03 20:32                   ` Ram Pai
@ 2014-04-04  6:37                   ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-04 17:08                     ` Andrey Borzenkov
  1 sibling, 1 reply; 68+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-04  6:37 UTC (permalink / raw)
  To: Andrey Borzenkov, Ram Pai; +Cc: The development of GNU GRUB, pfsmorigo

[-- Attachment #1: Type: text/plain, Size: 3805 bytes --]

On 03.04.2014 21:54, Andrey Borzenkov wrote:
> В Thu, 3 Apr 2014 12:26:57 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
>>>>>
>>>>>> Well. that is the issue.  Various distros have varied support for
>>>>>> cross-compilation (multi-arch support). If the distro does not 
>>>>>> have 32bit BE libraries natively installed (out-of-the-box), they
>>>>>> wont be able to generate a 32bit BE grub loader.
>>>>>
>>>>> We speak only about target code that runs at boot time. This code does
>>>>> not use any library. 
>>>>
>>>> I am not a compiler/toolchain expert. But dont we need all the necessary
>>>> tools and libraries in /lib/<arch>-<dist>-linux/ directory for cross
>>>> compilation; even to generate static executables?
>>>>
>>>>> It only needs compiler support. GRUB does not
>>>>> support anything besides gcc and recently some clang support was added.
>>>>> Do you have real life example of distribution which does not support
>>>>> -mbig gcc option to produce big-endian *code*?
>>>>
>>>> This is ideally what I want too. But it is not possible
>>>> **out-of-the-box** on any distro for power arch.  I am told
>>>> that debian has a new multi-arch support added which makes this
>>>> work out-of-the-box, but it is still in early stages to work
>>>> seemlessly **out-of-the-box**. I may be wrong.
>>>>
>>>
>>> If distribution is capable of building Linux kernel, it should be
>>> capable of compiling 32 bit big-endian code. Linux startup code on
>>> PowerPC is built as 32 bit big-endian:
>>>
>>> BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
>>>                  -fno-strict-aliasing -Os -msoft-float -pipe \
>>>                  -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
>>>                  -isystem $(shell $(CROSS32CC) -print-file-name=include) \
>>>                  -mbig-endian
>>
>>
>> But that is different though. Yes it is possible to cross compile for
>> any target on any arch.  But the key is that the environment needs to be
>> setup to do so.  
>>
>> We are talking about generating crosscompiled grub boot loader by an
>> uninitiated/not-so-expert adminstrator. If the distribution makes it
>> easy for that administrator to be able to cross-compile, than life is
>> easy.  But that is not generally the case though.
> 
> E-h-h ... could you be more specific? You need exactly the same tool
> set to compile 32 bit big-endian grub as to compile Linux kernel. So
> it follows that generally it is impossible to compile Linux kernel on
> distributions for ppc64le. Is it what you mean?
> 
>>                                                   The administrator has
>> to scramble around to find the right cross-compilation setup installed
>> on her system to achieve the end result.
>>
> 
> I try to understand what exactly is required beyond what is needed to
> compile Linux kernel? I do not consider need to install a couple of
> RPMs as high burden.
> 
> Here is what grub2 on SUSE needs:
> 
> %ifarch x86_64 ppc64
> BuildRequires:  gcc-32bit
> BuildRequires:  glibc-32bit
> BuildRequires:  glibc-devel-32bit
> %else
> BuildRequires:  gcc
> BuildRequires:  glibc-devel
> %ifarch s390x
> BuildRequires:  glibc-static
> %endif
> %endif
> 
> See https://build.opensuse.org/package/show/Base:System/grub2

I see you have some outdated patches like btrfs ones, you shouldn't need
them now (didn't really look in them).
As for eliminating libgcc dependency I created branch phcoder/no-libgcc.
For ppc only ucmpdi2 was needed actually.
> for
> details. It simply forces -m32 -big-endian for powerpc. It also includes
> brute-force patche to work around libgcc issue that probably may be
> done differently, but otherwise it is amazingly small change.
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04  6:37                   ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-04 17:08                     ` Andrey Borzenkov
  2014-04-05 15:45                       ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-04 17:08 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

В Fri, 04 Apr 2014 08:37:20 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:

> As for eliminating libgcc dependency I created branch phcoder/no-libgcc.

I'm afraid it results in too much churn that will be unmanageable

module-cmos.o `test -f 'lib/ieee1275/cmos.c' || echo '../../grub-core/'`lib/ieee1275/cmos.c
[  140s] ../../grub-core/lib/relocator.c:655:2: error: implicit declaration of function 'memset' [-Werror=implicit-function-declaration]
[  140s]   memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0]));
[  140s]   ^
[  140s] ../../grub-core/lib/relocator.c:655:2: error: nested extern declaration of 'memset' [-Werror=nested-externs]

It is impossible to include compiler-rt.h from misc.h due to circular
dependencies and it is near to impossible to find all places where
compiler-rt.h has to be included (at least I do not have an idea).

Someone will need to build test it for sparc, mips, arm (two flavors)
and powerpc (three flavors).

> For ppc only ucmpdi2 was needed actually.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04  2:28                     ` Andrey Borzenkov
@ 2014-04-04 17:47                       ` Ram Pai
  2014-04-04 18:17                         ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-04 17:47 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: phcoder, pfsmorigo

On Fri, Apr 04, 2014 at 06:28:51AM +0400, Andrey Borzenkov wrote:
> В Thu, 3 Apr 2014 13:32:22 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > 
> > They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> > so. Because the cross-compile tool chain is not enabled do so.
> > 
> 
> bor@opensuse:/tmp/binaries> file usr/bin/grub2-mkimage
> usr/bin/grub2-mkimage: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=4a9b7759e1c41a2b2de9f4d33bc179186bf04f8f, stripped
> bor@opensuse:/tmp/binaries> file usr/lib/grub2/powerpc-ieee1275/kernel.exec
> usr/lib/grub2/powerpc-ieee1275/kernel.exec: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
> bor@opensuse:/tmp/binaries> 

I know Dinar had attempted and abondoned the work, because it did not work for him.

As of now that thing is not there anymore...if you look at openSUSE:Factory:PowerPC/grub2
RP



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 17:47                       ` Ram Pai
@ 2014-04-04 18:17                         ` Andrey Borzenkov
  2014-04-04 18:24                           ` Dinar Valeev
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-04 18:17 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: phcoder, dvaleev, linuxram, pfsmorigo

В Fri, 4 Apr 2014 10:47:35 -0700
Ram Pai <linuxram@us.ibm.com> пишет:

> On Fri, Apr 04, 2014 at 06:28:51AM +0400, Andrey Borzenkov wrote:
> > В Thu, 3 Apr 2014 13:32:22 -0700
> > Ram Pai <linuxram@us.ibm.com> пишет:
> > 
> > > 
> > > They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> > > so. Because the cross-compile tool chain is not enabled do so.
> > > 
> > 
> > bor@opensuse:/tmp/binaries> file usr/bin/grub2-mkimage
> > usr/bin/grub2-mkimage: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=4a9b7759e1c41a2b2de9f4d33bc179186bf04f8f, stripped
> > bor@opensuse:/tmp/binaries> file usr/lib/grub2/powerpc-ieee1275/kernel.exec
> > usr/lib/grub2/powerpc-ieee1275/kernel.exec: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
> > bor@opensuse:/tmp/binaries> 
> 
> I know Dinar had attempted and abondoned the work, because it did not work for him.
> 
> As of now that thing is not there anymore...if you look at openSUSE:Factory:PowerPC/grub2

What do you mean? openSUSE:Factory:PowerPC/grub2 does not exist because
openSUSE:Factory:PowerPC links to openSUSE:Factory and pulls everything
not explicitly defined from there. And openSUSE:Factory itself gets
updates from Base:System.

Cc'ing to clear confusion :)

Fri Jan 31 14:42:26 UTC 2014 - dvaleev@suse.com

- Enable grub2 for PowerPC LE (ppc64le)
- Add ppc64le to exclusive arches
- Don't require gcc-32bit (PowerLE don't have 32bit toolchain)

- added patches:
  * grub2-powerpc-libgcc.patch
     Provide 32bit libgcc functions for PowerLE

  * grub2-ppc64le-core-bigendian.patch
     Build grub kernel and images as BE on ppc64le (BL is BE there)

  * grub2-ppc64le-platform.patch
     Enable ppc64le platform



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 18:17                         ` Andrey Borzenkov
@ 2014-04-04 18:24                           ` Dinar Valeev
  2014-04-04 19:12                             ` Andrey Borzenkov
  2014-09-27  5:42                             ` Andrei Borzenkov
  0 siblings, 2 replies; 68+ messages in thread
From: Dinar Valeev @ 2014-04-04 18:24 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, linuxram, pfsmorigo, phcoder

On Fri, 2014-04-04 at 22:17 +0400, Andrey Borzenkov wrote:
> В Fri, 4 Apr 2014 10:47:35 -0700
> Ram Pai <linuxram@us.ibm.com> пишет:
> 
> > On Fri, Apr 04, 2014 at 06:28:51AM +0400, Andrey Borzenkov wrote:
> > > В Thu, 3 Apr 2014 13:32:22 -0700
> > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > 
> > > > 
> > > > They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> > > > so. Because the cross-compile tool chain is not enabled do so.
> > > > 
> > > 
> > > bor@opensuse:/tmp/binaries> file usr/bin/grub2-mkimage
> > > usr/bin/grub2-mkimage: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=4a9b7759e1c41a2b2de9f4d33bc179186bf04f8f, stripped
> > > bor@opensuse:/tmp/binaries> file usr/lib/grub2/powerpc-ieee1275/kernel.exec
> > > usr/lib/grub2/powerpc-ieee1275/kernel.exec: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
> > > bor@opensuse:/tmp/binaries> 
> > 
> > I know Dinar had attempted and abondoned the work, because it did not work for him.
> > 
> > As of now that thing is not there anymore...if you look at openSUSE:Factory:PowerPC/grub2
> 
> What do you mean? openSUSE:Factory:PowerPC/grub2 does not exist because
> openSUSE:Factory:PowerPC links to openSUSE:Factory and pulls everything
> not explicitly defined from there. And openSUSE:Factory itself gets
> updates from Base:System.
> 
> Cc'ing to clear confusion :)

Right, my mistake. I recall a message message with 64bit LE patches. But
seems that came from somewhere else.

Long story short. With 32Bit BE stage one I had several issues like
accessing btrfs and booting from media. I gave up on my hack, and now
use proposed patches (64Bit LE).

I'll submit it to Base:System.

Have fun,
Dinar
> 
> Fri Jan 31 14:42:26 UTC 2014 - dvaleev@suse.com
> 
> - Enable grub2 for PowerPC LE (ppc64le)
> - Add ppc64le to exclusive arches
> - Don't require gcc-32bit (PowerLE don't have 32bit toolchain)
> 
> - added patches:
>   * grub2-powerpc-libgcc.patch
>      Provide 32bit libgcc functions for PowerLE
> 
>   * grub2-ppc64le-core-bigendian.patch
>      Build grub kernel and images as BE on ppc64le (BL is BE there)
> 
>   * grub2-ppc64le-platform.patch
>      Enable ppc64le platform
> 
> 




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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 18:24                           ` Dinar Valeev
@ 2014-04-04 19:12                             ` Andrey Borzenkov
  2014-04-04 20:29                               ` Dinar Valeev
  2014-09-27  5:42                             ` Andrei Borzenkov
  1 sibling, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-04 19:12 UTC (permalink / raw)
  To: Dinar Valeev; +Cc: The development of GNU GRUB, linuxram, pfsmorigo, phcoder

В Fri, 04 Apr 2014 20:24:58 +0200
Dinar Valeev <dvaleev@suse.de> пишет:

> 
> Right, my mistake. I recall a message message with 64bit LE patches. But
> seems that came from somewhere else.
> 
> Long story short. With 32Bit BE stage one I had several issues like
> accessing btrfs and booting from media. I gave up on my hack, and now
> use proposed patches (64Bit LE).
>

Well, then this is the real bug that has to be fixed. btrfs driver is
supposed to be endian-clean.

Did you try to disable SUSE btrfs patch to verify? There is at least one
suspicious place

+  tree = grub_le_to_cpu64(data->sblock.root_tree);
+  err = get_fs_root(data, tree, grub_cpu_to_le64(GRUB_BTRFS_FS_TREE_OBJECTID),
+                    0, &fs_root);

get_fs_root expects "tree" in on-disk format, not in CPU format.

+get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree,
+            grub_uint64_t objectid, grub_uint64_t offset,
+            grub_uint64_t *fs_root)
...

+  err = lower_bound(data, &key_in, &key_out, tree,
+                    &elemaddr, &elemsize, &desc, 0);

and lower_bound converts fourth argument again

lower_bound (struct grub_btrfs_data *data,
             const struct grub_btrfs_key *key_in,
             struct grub_btrfs_key *key_out,
             grub_uint64_t root
...
  grub_disk_addr_t addr = grub_le_to_cpu64 (root);


> I'll submit it to Base:System.
> 



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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 19:12                             ` Andrey Borzenkov
@ 2014-04-04 20:29                               ` Dinar Valeev
  2014-04-04 22:19                                 ` Ram Pai
  0 siblings, 1 reply; 68+ messages in thread
From: Dinar Valeev @ 2014-04-04 20:29 UTC (permalink / raw)
  To: Andrey Borzenkov
  Cc: The development of GNU GRUB, linuxram, pfsmorigo, phcoder

On Fri, 2014-04-04 at 23:12 +0400, Andrey Borzenkov wrote:
> В Fri, 04 Apr 2014 20:24:58 +0200
> Dinar Valeev <dvaleev@suse.de> пишет:
> 
> > 
> > Right, my mistake. I recall a message message with 64bit LE patches. But
> > seems that came from somewhere else.
> > 
> > Long story short. With 32Bit BE stage one I had several issues like
> > accessing btrfs and booting from media. I gave up on my hack, and now
> > use proposed patches (64Bit LE).
> >
> 
> Well, then this is the real bug that has to be fixed. btrfs driver is
> supposed to be endian-clean.
> 
> Did you try to disable SUSE btrfs patch to verify? There is at least one
> suspicious place
> 
> +  tree = grub_le_to_cpu64(data->sblock.root_tree);
> +  err = get_fs_root(data, tree, grub_cpu_to_le64(GRUB_BTRFS_FS_TREE_OBJECTID),
> +                    0, &fs_root);
> 
> get_fs_root expects "tree" in on-disk format, not in CPU format.
> 
> +get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree,
> +            grub_uint64_t objectid, grub_uint64_t offset,
> +            grub_uint64_t *fs_root)
> ...
> 
> +  err = lower_bound(data, &key_in, &key_out, tree,
> +                    &elemaddr, &elemsize, &desc, 0);
> 
> and lower_bound converts fourth argument again
> 
> lower_bound (struct grub_btrfs_data *data,
>              const struct grub_btrfs_key *key_in,
>              struct grub_btrfs_key *key_out,
>              grub_uint64_t root
> ...
>   grub_disk_addr_t addr = grub_le_to_cpu64 (root);
Huh... I can give it a try, if time permits.
> 
> 
> > I'll submit it to Base:System.
> > 
> 




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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 20:29                               ` Dinar Valeev
@ 2014-04-04 22:19                                 ` Ram Pai
       [not found]                                   ` <CAEaD8JN9SkqU9+BkU2MYub=aC3Wb143nMPgRWjVbFvgit90yBQ@mail.gmail.com>
  0 siblings, 1 reply; 68+ messages in thread
From: Ram Pai @ 2014-04-04 22:19 UTC (permalink / raw)
  To: Dinar Valeev
  Cc: Andrey Borzenkov, The development of GNU GRUB, pfsmorigo, phcoder

On Fri, Apr 04, 2014 at 10:29:13PM +0200, Dinar Valeev wrote:
> On Fri, 2014-04-04 at 23:12 +0400, Andrey Borzenkov wrote:
> > В Fri, 04 Apr 2014 20:24:58 +0200
> > Dinar Valeev <dvaleev@suse.de> пишет:
> > 
> > > 
> > > Right, my mistake. I recall a message message with 64bit LE patches. But
> > > seems that came from somewhere else.
> > > 
> > > Long story short. With 32Bit BE stage one I had several issues like
> > > accessing btrfs and booting from media. I gave up on my hack, and now
> > > use proposed patches (64Bit LE).
> > >
> > 
> > Well, then this is the real bug that has to be fixed. btrfs driver is
> > supposed to be endian-clean.
> > 
> > Did you try to disable SUSE btrfs patch to verify? There is at least one
> > suspicious place
> > 
> > +  tree = grub_le_to_cpu64(data->sblock.root_tree);
> > +  err = get_fs_root(data, tree, grub_cpu_to_le64(GRUB_BTRFS_FS_TREE_OBJECTID),
> > +                    0, &fs_root);
> > 
> > get_fs_root expects "tree" in on-disk format, not in CPU format.
> > 
> > +get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree,
> > +            grub_uint64_t objectid, grub_uint64_t offset,
> > +            grub_uint64_t *fs_root)
> > ...
> > 
> > +  err = lower_bound(data, &key_in, &key_out, tree,
> > +                    &elemaddr, &elemsize, &desc, 0);
> > 
> > and lower_bound converts fourth argument again
> > 
> > lower_bound (struct grub_btrfs_data *data,
> >              const struct grub_btrfs_key *key_in,
> >              struct grub_btrfs_key *key_out,
> >              grub_uint64_t root
> > ...
> >   grub_disk_addr_t addr = grub_le_to_cpu64 (root);
> Huh... I can give it a try, if time permits.

If this works; assuming all the libgcc calls have been replaced
appropriately with native code, there is no strong reason; that I 
can think off, to do 64bit LE grub.  May the best solution win.

However in the long run, it does constrain grub bootloader from using
any libgcc calls, thus impeding easy extensibility in the future for
this architecture.

RP



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

* Fwd: Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
       [not found]                                   ` <CAEaD8JN9SkqU9+BkU2MYub=aC3Wb143nMPgRWjVbFvgit90yBQ@mail.gmail.com>
@ 2014-04-05  0:04                                     ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 68+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2014-04-05  0:04 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 2803 bytes --]

---------- Forwarded message ----------
From: "Vladimir 'phcoder' Serbinenko" <phcoder@gmail.com>
Date: 5 Apr 2014 01:45
Subject: Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian
anymore! :)
To: "Ram Pai" <linuxram@us.ibm.com>
Cc:


On 5 Apr 2014 00:19, "Ram Pai" <linuxram@us.ibm.com> wrote:
>
> On Fri, Apr 04, 2014 at 10:29:13PM +0200, Dinar Valeev wrote:
> > On Fri, 2014-04-04 at 23:12 +0400, Andrey Borzenkov wrote:
> > > В Fri, 04 Apr 2014 20:24:58 +0200
> > > Dinar Valeev <dvaleev@suse.de> пишет:
> > >
> > > >
> > > > Right, my mistake. I recall a message message with 64bit LE
patches. But
> > > > seems that came from somewhere else.
> > > >
> > > > Long story short. With 32Bit BE stage one I had several issues like
> > > > accessing btrfs and booting from media. I gave up on my hack, and
now
> > > > use proposed patches (64Bit LE).
> > > >
> > >
> > > Well, then this is the real bug that has to be fixed. btrfs driver is
> > > supposed to be endian-clean.
> > >
> > > Did you try to disable SUSE btrfs patch to verify? There is at least
one
> > > suspicious place
> > >
> > > +  tree = grub_le_to_cpu64(data->sblock.root_tree);
> > > +  err = get_fs_root(data, tree,
grub_cpu_to_le64(GRUB_BTRFS_FS_TREE_OBJECTID),
> > > +                    0, &fs_root);
> > >
> > > get_fs_root expects "tree" in on-disk format, not in CPU format.
> > >
> > > +get_fs_root(struct grub_btrfs_data *data, grub_uint64_t tree,
> > > +            grub_uint64_t objectid, grub_uint64_t offset,
> > > +            grub_uint64_t *fs_root)
> > > ...
> > >
> > > +  err = lower_bound(data, &key_in, &key_out, tree,
> > > +                    &elemaddr, &elemsize, &desc, 0);
> > >
> > > and lower_bound converts fourth argument again
> > >
> > > lower_bound (struct grub_btrfs_data *data,
> > >              const struct grub_btrfs_key *key_in,
> > >              struct grub_btrfs_key *key_out,
> > >              grub_uint64_t root
> > > ...
> > >   grub_disk_addr_t addr = grub_le_to_cpu64 (root);
> > Huh... I can give it a try, if time permits.
>
> If this works; assuming all the libgcc calls have been replaced
> appropriately with native code, there is no strong reason; that I
> can think off, to do 64bit LE grub.  May the best solution win.
>
> However in the long run, it does constrain grub bootloader from using
> any libgcc calls, thus impeding easy extensibility in the future for
> this architecture.
>
There are other reasons to replace libgcc as well. Main one is that libgcc
may be compiled with options that use instructions unavailable at runtime.
It already happened with libgcc using fpu for divisions. Adding libgcc
functions as needed is already needed so maintaining increase ia small.
> RP
>

[-- Attachment #2: Type: text/html, Size: 3901 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 17:08                     ` Andrey Borzenkov
@ 2014-04-05 15:45                       ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-05 16:49                         ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-05 15:45 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1836 bytes --]

On 04.04.2014 19:08, Andrey Borzenkov wrote:
> В Fri, 04 Apr 2014 08:37:20 +0200
> Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:
> 
>> As for eliminating libgcc dependency I created branch phcoder/no-libgcc.
> 
> I'm afraid it results in too much churn that will be unmanageable
> 
> module-cmos.o `test -f 'lib/ieee1275/cmos.c' || echo '../../grub-core/'`lib/ieee1275/cmos.c
> [  140s] ../../grub-core/lib/relocator.c:655:2: error: implicit declaration of function 'memset' [-Werror=implicit-function-declaration]
> [  140s]   memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0]));
> [  140s]   ^
> [  140s] ../../grub-core/lib/relocator.c:655:2: error: nested extern declaration of 'memset' [-Werror=nested-externs]
> 
memset in GRUB code is a bug. I fixed the instances I've found and added
#define's to posix wrapping
> It is impossible to include compiler-rt.h from misc.h due to circular
> dependencies and it is near to impossible to find all places where
> compiler-rt.h has to be included (at least I do not have an idea).
> 
compiler-rt.,h shouldn't be included anywhere. The idea is that it
contains only functions used by compiler and never used by GRUB code.
> Someone will need to build test it for sparc, mips, arm (two flavors)
> and powerpc (three flavors).
I did all of this (I have a script).
A problem is that restgpr and [al]sh[lr]di3 weren't used by any
platform. Some other gcc versions probably use them. I'll need to figure
out on which platforms.
restgpr is definitely ppc-only.
[al]sh[lr]di3 I think was for arm.
> 
>> For ppc only ucmpdi2 was needed actually.
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-05 15:45                       ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-05 16:49                         ` Andrey Borzenkov
  2014-04-05 18:29                           ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-05 16:49 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1458 bytes --]

В Sat, 05 Apr 2014 17:45:30 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:

> A problem is that restgpr and [al]sh[lr]di3 weren't used by any
> platform.

What do you mean? They are used, but resolved from -lgcc for all
current platforms. Where it breaks is ppc64le where libgcc for BE does
not normally exist. And without -lgcc we get

[  152s] kern/powerpc/kernel_exec-dl.o: In function `grub_arch_dl_relocate_symbols':
[  152s] /home/abuild/rpmbuild/BUILD/grub-2.02~beta2/build/grub-core/../../grub-core/kern/powerpc/dl.c:167: undefined reference to `_restgpr_21_x'
[  152s] disk/ieee1275/kernel_exec-ofdisk.o: In function `grub_ofdisk_close':
[  152s] /home/abuild/rpmbuild/BUILD/grub-2.02~beta2/build/grub-core/../../grub-core/disk/ieee1275/ofdisk.c:448: undefined reference to `_restgpr_29_x'
...


>           Some other gcc versions probably use them. I'll need to figure
> out on which platforms.

Just set TARGET_LDFLAGS_STATIC_LIBGCC= and TARGET_LIBGCC= and try to
compile. If you intend to replace libgcc by internal implementation,
those flags are not needed anyway.

> restgpr is definitely ppc-only.
> [al]sh[lr]di3 I think was for arm.
> > 
> >> For ppc only ucmpdi2 was needed actually.
> > 
> > 
> > 
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> > 
> 
> 


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-05 16:49                         ` Andrey Borzenkov
@ 2014-04-05 18:29                           ` Vladimir 'φ-coder/phcoder' Serbinenko
  2014-04-05 18:48                             ` Andrey Borzenkov
  0 siblings, 1 reply; 68+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2014-04-05 18:29 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1787 bytes --]

On 05.04.2014 18:49, Andrey Borzenkov wrote:
> В Sat, 05 Apr 2014 17:45:30 +0200
> Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:
> 
>> A problem is that restgpr and [al]sh[lr]di3 weren't used by any
>> platform.
> 
> What do you mean? They are used, but resolved from -lgcc for all
> current platforms. Where it breaks is ppc64le where libgcc for BE does
> not normally exist. And without -lgcc we get
> 
> [  152s] kern/powerpc/kernel_exec-dl.o: In function `grub_arch_dl_relocate_symbols':
> [  152s] /home/abuild/rpmbuild/BUILD/grub-2.02~beta2/build/grub-core/../../grub-core/kern/powerpc/dl.c:167: undefined reference to `_restgpr_21_x'
> [  152s] disk/ieee1275/kernel_exec-ofdisk.o: In function `grub_ofdisk_close':
> [  152s] /home/abuild/rpmbuild/BUILD/grub-2.02~beta2/build/grub-core/../../grub-core/disk/ieee1275/ofdisk.c:448: undefined reference to `_restgpr_29_x'
> ...
> 
> 
Not on my system. I use GCC 4.7.2. What version do you get this with?
>>           Some other gcc versions probably use them. I'll need to figure
>> out on which platforms.
> 
> Just set TARGET_LDFLAGS_STATIC_LIBGCC= and TARGET_LIBGCC= and try to
> compile. If you intend to replace libgcc by internal implementation,
> those flags are not needed anyway.
> 
>> restgpr is definitely ppc-only.
>> [al]sh[lr]di3 I think was for arm.
>>>
>>>> For ppc only ucmpdi2 was needed actually.
>>>
>>>
>>>
>>> _______________________________________________
>>> Grub-devel mailing list
>>> Grub-devel@gnu.org
>>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>>
>>
>>
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 274 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-05 18:29                           ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2014-04-05 18:48                             ` Andrey Borzenkov
  0 siblings, 0 replies; 68+ messages in thread
From: Andrey Borzenkov @ 2014-04-05 18:48 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 2012 bytes --]

В Sat, 05 Apr 2014 20:29:24 +0200
Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:

> On 05.04.2014 18:49, Andrey Borzenkov wrote:
> > В Sat, 05 Apr 2014 17:45:30 +0200
> > Vladimir 'φ-coder/phcoder' Serbinenko <phcoder@gmail.com> пишет:
> > 
> >> A problem is that restgpr and [al]sh[lr]di3 weren't used by any
> >> platform.
> > 
> > What do you mean? They are used, but resolved from -lgcc for all
> > current platforms. Where it breaks is ppc64le where libgcc for BE does
> > not normally exist. And without -lgcc we get
> > 
> > [  152s] kern/powerpc/kernel_exec-dl.o: In function `grub_arch_dl_relocate_symbols':
> > [  152s] /home/abuild/rpmbuild/BUILD/grub-2.02~beta2/build/grub-core/../../grub-core/kern/powerpc/dl.c:167: undefined reference to `_restgpr_21_x'
> > [  152s] disk/ieee1275/kernel_exec-ofdisk.o: In function `grub_ofdisk_close':
> > [  152s] /home/abuild/rpmbuild/BUILD/grub-2.02~beta2/build/grub-core/../../grub-core/disk/ieee1275/ofdisk.c:448: undefined reference to `_restgpr_29_x'
> > ...
> > 
> > 
> Not on my system. I use GCC 4.7.2. What version do you get this with?

GCC 4.8

> >>           Some other gcc versions probably use them. I'll need to figure
> >> out on which platforms.
> > 
> > Just set TARGET_LDFLAGS_STATIC_LIBGCC= and TARGET_LIBGCC= and try to
> > compile. If you intend to replace libgcc by internal implementation,
> > those flags are not needed anyway.
> > 
> >> restgpr is definitely ppc-only.
> >> [al]sh[lr]di3 I think was for arm.
> >>>
> >>>> For ppc only ucmpdi2 was needed actually.
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Grub-devel mailing list
> >>> Grub-devel@gnu.org
> >>> https://lists.gnu.org/mailman/listinfo/grub-devel
> >>>
> >>
> >>
> > 
> > 
> > 
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel
> > 
> 
> 


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-04-04 18:24                           ` Dinar Valeev
  2014-04-04 19:12                             ` Andrey Borzenkov
@ 2014-09-27  5:42                             ` Andrei Borzenkov
  2014-09-28  6:33                               ` Andrei Borzenkov
  1 sibling, 1 reply; 68+ messages in thread
From: Andrei Borzenkov @ 2014-09-27  5:42 UTC (permalink / raw)
  To: Dinar Valeev; +Cc: The development of GNU GRUB, linuxram, pfsmorigo, phcoder

В Fri, 04 Apr 2014 20:24:58 +0200
Dinar Valeev <dvaleev@suse.de> пишет:

> On Fri, 2014-04-04 at 22:17 +0400, Andrey Borzenkov wrote:
> > В Fri, 4 Apr 2014 10:47:35 -0700
> > Ram Pai <linuxram@us.ibm.com> пишет:
> > 
> > > On Fri, Apr 04, 2014 at 06:28:51AM +0400, Andrey Borzenkov wrote:
> > > > В Thu, 3 Apr 2014 13:32:22 -0700
> > > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > > 
> > > > > 
> > > > > They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> > > > > so. Because the cross-compile tool chain is not enabled do so.
> > > > > 
> > > > 
> > > > bor@opensuse:/tmp/binaries> file usr/bin/grub2-mkimage
> > > > usr/bin/grub2-mkimage: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=4a9b7759e1c41a2b2de9f4d33bc179186bf04f8f, stripped
> > > > bor@opensuse:/tmp/binaries> file usr/lib/grub2/powerpc-ieee1275/kernel.exec
> > > > usr/lib/grub2/powerpc-ieee1275/kernel.exec: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
> > > > bor@opensuse:/tmp/binaries> 
> > > 
> > > I know Dinar had attempted and abondoned the work, because it did not work for him.
> > > 
> > > As of now that thing is not there anymore...if you look at openSUSE:Factory:PowerPC/grub2
> > 
> > What do you mean? openSUSE:Factory:PowerPC/grub2 does not exist because
> > openSUSE:Factory:PowerPC links to openSUSE:Factory and pulls everything
> > not explicitly defined from there. And openSUSE:Factory itself gets
> > updates from Base:System.
> > 
> > Cc'ing to clear confusion :)
> 
> Right, my mistake. I recall a message message with 64bit LE patches. But
> seems that came from somewhere else.
> 
> Long story short. With 32Bit BE stage one I had several issues like
> accessing btrfs and booting from media. I gave up on my hack, and now
> use proposed patches (64Bit LE).
> 
> I'll submit it to Base:System.
> 

It does not look like it has anything to do with these patches. I
cannot access btrfs on PPC BE as well - using packages from Factory ppc
and ppc64. It sounds like there is missing endian conversion somewhere
in btrfs code and using LE platform simply masks it off.

I can access all other filesystems I tried which makes me believe it is
btrfs issue.


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

* Re: [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :)
  2014-09-27  5:42                             ` Andrei Borzenkov
@ 2014-09-28  6:33                               ` Andrei Borzenkov
  0 siblings, 0 replies; 68+ messages in thread
From: Andrei Borzenkov @ 2014-09-28  6:33 UTC (permalink / raw)
  To: Andrei Borzenkov
  Cc: The development of GNU GRUB, Dinar Valeev, linuxram, pfsmorigo, phcoder

В Sat, 27 Sep 2014 09:42:04 +0400
Andrei Borzenkov <arvidjaar@gmail.com> пишет:

> В Fri, 04 Apr 2014 20:24:58 +0200
> Dinar Valeev <dvaleev@suse.de> пишет:
> 
> > On Fri, 2014-04-04 at 22:17 +0400, Andrey Borzenkov wrote:
> > > В Fri, 4 Apr 2014 10:47:35 -0700
> > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > 
> > > > On Fri, Apr 04, 2014 at 06:28:51AM +0400, Andrey Borzenkov wrote:
> > > > > В Thu, 3 Apr 2014 13:32:22 -0700
> > > > > Ram Pai <linuxram@us.ibm.com> пишет:
> > > > > 
> > > > > > 
> > > > > > They generate a 32bit BE grub binary  on a LE system?  No. I dont think
> > > > > > so. Because the cross-compile tool chain is not enabled do so.
> > > > > > 
> > > > > 
> > > > > bor@opensuse:/tmp/binaries> file usr/bin/grub2-mkimage
> > > > > usr/bin/grub2-mkimage: ELF 64-bit LSB executable, 64-bit PowerPC or cisco 7500, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.0.0, BuildID[sha1]=4a9b7759e1c41a2b2de9f4d33bc179186bf04f8f, stripped
> > > > > bor@opensuse:/tmp/binaries> file usr/lib/grub2/powerpc-ieee1275/kernel.exec
> > > > > usr/lib/grub2/powerpc-ieee1275/kernel.exec: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), statically linked, not stripped
> > > > > bor@opensuse:/tmp/binaries> 
> > > > 
> > > > I know Dinar had attempted and abondoned the work, because it did not work for him.
> > > > 
> > > > As of now that thing is not there anymore...if you look at openSUSE:Factory:PowerPC/grub2
> > > 
> > > What do you mean? openSUSE:Factory:PowerPC/grub2 does not exist because
> > > openSUSE:Factory:PowerPC links to openSUSE:Factory and pulls everything
> > > not explicitly defined from there. And openSUSE:Factory itself gets
> > > updates from Base:System.
> > > 
> > > Cc'ing to clear confusion :)
> > 
> > Right, my mistake. I recall a message message with 64bit LE patches. But
> > seems that came from somewhere else.
> > 
> > Long story short. With 32Bit BE stage one I had several issues like
> > accessing btrfs and booting from media. I gave up on my hack, and now
> > use proposed patches (64Bit LE).
> > 
> > I'll submit it to Base:System.
> > 
> 
> It does not look like it has anything to do with these patches. I
> cannot access btrfs on PPC BE as well - using packages from Factory ppc
> and ppc64. It sounds like there is missing endian conversion somewhere
> in btrfs code and using LE platform simply masks it off.
> 
> I can access all other filesystems I tried which makes me believe it is
> btrfs issue.

And this was even fixed in GIT at the same time this discussion was
active :) I added patch to our RPM.


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

end of thread, other threads:[~2014-09-28  6:34 UTC | newest]

Thread overview: 68+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-26 18:30 [RFC PATCH 00/23] grub 64bit little-endian on power Ram Pai
2014-02-26 18:31 ` [RFC PATCH 01/23] Add a new architecture to the build process Ram Pai
2014-02-26 18:31 ` [RFC PATCH 02/23] Build LE grub as O1 Ram Pai
2014-02-26 18:31 ` [RFC PATCH 03/23] ignore .TOC. symbol Ram Pai
2014-04-01 16:52   ` Andrey Borzenkov
2014-02-26 18:31 ` [RFC PATCH 04/23] grub-install can now recognize and install a LE grub boot loader Ram Pai
2014-02-26 18:31 ` [RFC PATCH 05/23] set ABI version in e_flag of the PPC64LE ELF image Ram Pai
2014-02-26 18:31 ` [RFC PATCH 06/23] Add IEEE1275_ADDR helper Ram Pai
2014-04-01 17:11   ` Andrey Borzenkov
2014-02-26 18:31 ` [RFC PATCH 07/23] Fix some more warnings when casting Ram Pai
2014-02-26 18:31 ` [RFC PATCH 08/23] Add powerpc64 types Ram Pai
2014-04-01 17:15   ` Andrey Borzenkov
2014-04-02 17:02     ` Ram Pai
2014-02-26 18:31 ` [RFC PATCH 09/23] Fix warnings when building powerpc linux loader 64bit Ram Pai
2014-04-01 17:21   ` Andrey Borzenkov
2014-04-02 17:03     ` Ram Pai
2014-02-26 18:31 ` [RFC PATCH 10/23] GRUB_ELF_R_PPC_* processing is applicable only for 32 bit bootloader Ram Pai
2014-02-26 18:31 ` [RFC PATCH 11/23] Fix powerpc setjmp/longjmp 64bit issues Ram Pai
2014-04-01 17:27   ` Andrey Borzenkov
2014-04-02 17:06     ` Ram Pai
2014-04-02 17:19       ` Andrey Borzenkov
2014-04-02 17:48         ` Ram Pai
2014-04-02 17:56           ` Andrey Borzenkov
2014-04-02 18:55             ` Ram Pai
2014-02-26 18:31 ` [RFC PATCH 12/23] Add powerpc64 ieee1275 trampoline Ram Pai
2014-02-26 18:31 ` [RFC PATCH 13/23] Add 64bit support to powerpc startup code Ram Pai
2014-02-26 18:31 ` [RFC PATCH 14/23] Add grub_dl_find_section_addr Ram Pai
2014-02-26 18:31 ` [RFC PATCH 15/23] Add ppc64 relocations Ram Pai
2014-02-26 18:31 ` [RFC PATCH 16/23] ppc64 doesn't need libgcc routines Ram Pai
2014-02-26 18:31 ` [RFC PATCH 17/23] Use FUNC_START/FUNC_END for powerpc function definitions Ram Pai
2014-02-26 18:31 ` [RFC PATCH 18/23] .TOC. symbol is special in ppc64le Ram Pai
2014-02-26 18:31 ` [RFC PATCH 19/23] align .toc section on 4byte boundary Ram Pai
2014-02-26 18:31 ` [RFC PATCH 20/23] fix parameter to firmware calls Ram Pai
2014-04-01 17:45   ` Andrey Borzenkov
2014-04-02 17:08     ` Ram Pai
2014-04-02 17:16       ` Andrey Borzenkov
2014-02-26 18:31 ` [RFC PATCH 21/23] powerpc64 is not necessarily BigEndian anymore! :) Ram Pai
2014-04-01 17:49   ` Andrey Borzenkov
2014-04-01 20:22     ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-04-03 17:33       ` Ram Pai
2014-04-03 17:53         ` Andrey Borzenkov
2014-04-03 18:37           ` Ram Pai
2014-04-03 19:03             ` Andrey Borzenkov
2014-04-03 19:26               ` Ram Pai
2014-04-03 19:42                 ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-04-03 20:23                   ` Ram Pai
2014-04-03 19:54                 ` Andrey Borzenkov
2014-04-03 20:32                   ` Ram Pai
2014-04-03 21:41                     ` Vladimir 'phcoder' Serbinenko
2014-04-04  2:28                     ` Andrey Borzenkov
2014-04-04 17:47                       ` Ram Pai
2014-04-04 18:17                         ` Andrey Borzenkov
2014-04-04 18:24                           ` Dinar Valeev
2014-04-04 19:12                             ` Andrey Borzenkov
2014-04-04 20:29                               ` Dinar Valeev
2014-04-04 22:19                                 ` Ram Pai
     [not found]                                   ` <CAEaD8JN9SkqU9+BkU2MYub=aC3Wb143nMPgRWjVbFvgit90yBQ@mail.gmail.com>
2014-04-05  0:04                                     ` Fwd: " Vladimir 'phcoder' Serbinenko
2014-09-27  5:42                             ` Andrei Borzenkov
2014-09-28  6:33                               ` Andrei Borzenkov
2014-04-04  6:37                   ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-04-04 17:08                     ` Andrey Borzenkov
2014-04-05 15:45                       ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-04-05 16:49                         ` Andrey Borzenkov
2014-04-05 18:29                           ` Vladimir 'φ-coder/phcoder' Serbinenko
2014-04-05 18:48                             ` Andrey Borzenkov
2014-04-02 17:09     ` Ram Pai
2014-02-26 18:31 ` [RFC PATCH 22/23] fix segfaults if initrd Ram Pai
2014-02-26 18:31 ` [RFC PATCH 23/23] Optional: Power7 VSX instructions workaround Ram Pai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.