grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: Ram Pai <linuxram@us.ibm.com>
To: grub-devel@gnu.org
Cc: tonyb@au1.ibm.com, anton@au1.ibm.com, linuxram@us.ibm.com,
	tlfalcon@linux.vnet.ibm.com, tbberry@us.ibm.com
Subject: [RFC PATCH 23/23] Optional: Power7 VSX instructions workaround.
Date: Wed, 26 Feb 2014 10:31:22 -0800	[thread overview]
Message-ID: <1393439482-20341-24-git-send-email-linuxram@us.ibm.com> (raw)
In-Reply-To: <1393439482-20341-1-git-send-email-linuxram@us.ibm.com>

 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



      parent reply	other threads:[~2014-02-26 18:32 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Ram Pai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393439482-20341-24-git-send-email-linuxram@us.ibm.com \
    --to=linuxram@us.ibm.com \
    --cc=anton@au1.ibm.com \
    --cc=grub-devel@gnu.org \
    --cc=tbberry@us.ibm.com \
    --cc=tlfalcon@linux.vnet.ibm.com \
    --cc=tonyb@au1.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).