All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: openembedded-core@lists.openembedded.org,
	 richard.purdie@linuxfoundation.org
Subject: Re: [PATCH][Fido ONLY] binutils: Add -momit-lock-prefix support
Date: Fri, 26 Jun 2015 14:10:31 -0700	[thread overview]
Message-ID: <558DBFC7.4030902@linux.intel.com> (raw)
In-Reply-To: <1435352780-7438-1-git-send-email-sgw@linux.intel.com>


Gah, I just discovered a patch in fido next conflict with this one, V2 
coming.

Sau!

On 06/26/2015 02:06 PM, Saul Wold wrote:
> This patch is needed for certain cpus and has been accepted into upstream
>
> Signed-off-by: Saul Wold <sgw@linux.intel.com>
> ---
>
> This patch is already in 2.25 which is  in master so this is Fido ONLY
>
>
>   meta/recipes-devtools/binutils/binutils-2.24.inc   |   1 +
>   .../0001-Add-momit_lock_prefix-no-yes-option.patch | 238 +++++++++++++++++++++
>   2 files changed, 239 insertions(+)
>   create mode 100644 meta/recipes-devtools/binutils/binutils/0001-Add-momit_lock_prefix-no-yes-option.patch
>
> diff --git a/meta/recipes-devtools/binutils/binutils-2.24.inc b/meta/recipes-devtools/binutils/binutils-2.24.inc
> index 2fb56eb..e71a110 100644
> --- a/meta/recipes-devtools/binutils/binutils-2.24.inc
> +++ b/meta/recipes-devtools/binutils/binutils-2.24.inc
> @@ -41,6 +41,7 @@ SRC_URI = "\
>        file://binutils_CVE-2014-8504.patch \
>        file://binutils_CVE-2014-8737.patch \
>        file://Fix-tc-i386.c-Werror-logical-not-parentheses-error.patch \
> +     file://0001-Add-momit_lock_prefix-no-yes-option.patch \
>        "
>
>   SRC_URI[md5sum] = "e0f71a7b2ddab0f8612336ac81d9636b"
> diff --git a/meta/recipes-devtools/binutils/binutils/0001-Add-momit_lock_prefix-no-yes-option.patch b/meta/recipes-devtools/binutils/binutils/0001-Add-momit_lock_prefix-no-yes-option.patch
> new file mode 100644
> index 0000000..ce2be37
> --- /dev/null
> +++ b/meta/recipes-devtools/binutils/binutils/0001-Add-momit_lock_prefix-no-yes-option.patch
> @@ -0,0 +1,238 @@
> +From ee57d586166f36f4a6bddaa2305fd66a7752f967 Mon Sep 17 00:00:00 2001
> +From: Ilya Tocar <ilya.tocar@intel.com>
> +Date: Fri, 1 Aug 2014 17:58:32 +0400
> +Subject: [PATCH] Add -momit_lock_prefix=[no|yes] option
> +
> +This option serves as a workaround for processors, which fail on lock
> +prefix.
> +
> +gas/
> +	* config/tc-i386.c (omit_lock_prefix): New.
> +	(output_insn): Omit lock prefix if omit_lock_prefix is true.
> +	(OPTION_omit_lock_prefix): New.
> +	(md_longopts): Add momit-lock-prefix.
> +	(md_parse_option): Handle momit-lock-prefix.
> +	(md_show_usage): Add momit-lock-prefix=[no|yes].
> +	* doc/c-i386.texi (momit-lock-prefix): Document.
> +
> +gas/testsuite/
> +
> +	* gas/i386/i386.exp: Run new tests.
> +	* gas/i386/omit-lock-no.d: New.
> +	* gas/i386/omit-lock-yes.d: Ditto.
> +	* gas/i386/omit-lock.s: Ditto.
> +
> +Cherry-pick from git://sourceware.org/git/binutils-gdb.git
> +rev d022bddd4fd93428a7fa3cc7ad404c912ed20dbf
> +into binutils v2.24
> +
> +Upstream-Status: [Accepted]
> +Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
> +Signed-off-by: Saul Wold <sgw@linux.intel.com>
> +---
> + gas/ChangeLog                          |   10 ++++++++++
> + gas/config/tc-i386.c                   |   27 +++++++++++++++++++++++++++
> + gas/doc/c-i386.texi                    |   12 ++++++++++++
> + gas/testsuite/ChangeLog                |    7 +++++++
> + gas/testsuite/gas/i386/i386.exp        |    2 ++
> + gas/testsuite/gas/i386/omit-lock-no.d  |   12 ++++++++++++
> + gas/testsuite/gas/i386/omit-lock-yes.d |   12 ++++++++++++
> + gas/testsuite/gas/i386/omit-lock.s     |    6 ++++++
> + 8 files changed, 88 insertions(+)
> + create mode 100644 gas/testsuite/gas/i386/omit-lock-no.d
> + create mode 100644 gas/testsuite/gas/i386/omit-lock-yes.d
> + create mode 100644 gas/testsuite/gas/i386/omit-lock.s
> +
> +diff --git a/gas/ChangeLog b/gas/ChangeLog
> +index 7fafa26..b243bf1 100644
> +--- a/gas/ChangeLog
> ++++ b/gas/ChangeLog
> +@@ -1,3 +1,13 @@
> ++2014-08-06  Ilya Tocar  <ilya.tocar@intel.com>
> ++
> ++	* config/tc-i386.c (omit_lock_prefix): New.
> ++	(output_insn): Omit lock prefix if omit_lock_prefix is true.
> ++	(OPTION_omit_lock_prefix): New.
> ++	(md_longopts): Add momit-lock-prefix.
> ++	(md_parse_option): Handle momit-lock-prefix.
> ++	(md_show_usage): Add momit-lock-prefix=[no|yes].
> ++	* doc/c-i386.texi (momit-lock-prefix): Document.
> ++
> + 2013-11-18  H.J. Lu  <hongjiu.lu@intel.com>
> +
> + 	* config/tc-i386.c (lex_got): Add a dummy "int bnd_prefix"
> +diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
> +index 3c423da..e7c9d47 100644
> +--- a/gas/config/tc-i386.c
> ++++ b/gas/config/tc-i386.c
> +@@ -541,6 +541,10 @@ static int add_bnd_prefix = 0;
> + /* 1 if pseudo index register, eiz/riz, is allowed .  */
> + static int allow_index_reg = 0;
> +
> ++/* 1 if the assembler should ignore LOCK prefix, even if it was
> ++   specified explicitly.  */
> ++static int omit_lock_prefix = 0;
> ++
> + static enum check_kind
> +   {
> +     check_none = 0,
> +@@ -6910,6 +6914,15 @@ output_insn (void)
> +       unsigned int j;
> +       unsigned int prefix;
> +
> ++      /* Some processors fail on LOCK prefix. This options makes
> ++	 assembler ignore LOCK prefix and serves as a workaround.  */
> ++      if (omit_lock_prefix)
> ++	{
> ++	  if (i.tm.base_opcode == LOCK_PREFIX_OPCODE)
> ++	    return;
> ++	  i.prefix[LOCK_PREFIX] = 0;
> ++	}
> ++
> +       /* Since the VEX/EVEX prefix contains the implicit prefix, we
> + 	 don't need the explicit prefix.  */
> +       if (!i.tm.opcode_modifier.vex && !i.tm.opcode_modifier.evex)
> +@@ -9483,6 +9496,7 @@ const char *md_shortopts = "qn";
> + #define OPTION_MADD_BND_PREFIX (OPTION_MD_BASE + 15)
> + #define OPTION_MEVEXLIG (OPTION_MD_BASE + 16)
> + #define OPTION_MEVEXWIG (OPTION_MD_BASE + 17)
> ++#define OPTION_omit_lock_prefix (OPTION_MD_BASE + 18)
> +
> + struct option md_longopts[] =
> + {
> +@@ -9509,6 +9523,7 @@ struct option md_longopts[] =
> +   {"madd-bnd-prefix", no_argument, NULL, OPTION_MADD_BND_PREFIX},
> +   {"mevexlig", required_argument, NULL, OPTION_MEVEXLIG},
> +   {"mevexwig", required_argument, NULL, OPTION_MEVEXWIG},
> ++  {"momit-lock-prefix", required_argument, NULL, OPTION_omit_lock_prefix},
> +   {NULL, no_argument, NULL, 0}
> + };
> + size_t md_longopts_size = sizeof (md_longopts);
> +@@ -9790,6 +9805,15 @@ md_parse_option (int c, char *arg)
> + 	as_fatal (_("invalid -mevexwig= option: `%s'"), arg);
> +       break;
> +
> ++    case OPTION_omit_lock_prefix:
> ++      if (strcasecmp (arg, "yes") == 0)
> ++        omit_lock_prefix = 1;
> ++      else if (strcasecmp (arg, "no") == 0)
> ++        omit_lock_prefix = 0;
> ++      else
> ++        as_fatal (_("invalid -momit-lock-prefix= option: `%s'"), arg);
> ++      break;
> ++
> +     default:
> +       return 0;
> +     }
> +@@ -9942,6 +9966,9 @@ md_show_usage (FILE *stream)
> +   -mold-gcc               support old (<= 2.8.1) versions of gcc\n"));
> +   fprintf (stream, _("\
> +   -madd-bnd-prefix        add BND prefix for all valid branches\n"));
> ++  fprintf (stream, _("\
> ++  -momit-lock-prefix=[no|yes]\n\
> ++                          strip all lock prefixes\n"));
> + }
> +
> + #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
> +diff --git a/gas/doc/c-i386.texi b/gas/doc/c-i386.texi
> +index 7ca70c9..2100b48 100644
> +--- a/gas/doc/c-i386.texi
> ++++ b/gas/doc/c-i386.texi
> +@@ -282,6 +282,18 @@ The @code{.att_syntax} and @code{.intel_syntax} directives will take precedent.
> + This option forces the assembler to add BND prefix to all branches, even
> + if such prefix was not explicitly specified in the source code.
> +
> ++@cindex @samp{-momit-lock-prefix=} option, i386
> ++@cindex @samp{-momit-lock-prefix=} option, x86-64
> ++@item -momit-lock-prefix=@var{no}
> ++@itemx -momit-lock-prefix=@var{yes}
> ++These options control how the assembler should encode lock prefix.
> ++This option is intended as a workaround for processors, that fail on
> ++lock prefix. This option can only be safely used with single-core,
> ++single-thread computers
> ++@option{-momit-lock-prefix=@var{yes}} will omit all lock prefixes.
> ++@option{-momit-lock-prefix=@var{no}} will encode lock prefix as usual,
> ++which is the default.
> ++
> + @end table
> + @c man end
> +
> +diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
> +index be67b6e..afa687d 100644
> +--- a/gas/testsuite/ChangeLog
> ++++ b/gas/testsuite/ChangeLog
> +@@ -1,3 +1,10 @@
> ++2014-08-06  Ilya Tocar  <ilya.tocar@intel.com>
> ++
> ++	* gas/i386/i386.exp: Run new tests.
> ++	* gas/i386/omit-lock-no.d: New.
> ++	* gas/i386/omit-lock-yes.d: Ditto.
> ++	* gas/i386/omit-lock.s: Ditto.+
> ++
> + 2013-11-20  Yufeng Zhang  <yufeng.zhang@arm.com>
> +
> + 	* gas/aarch64/msr.s: Add tests.
> +diff --git a/gas/testsuite/gas/i386/i386.exp b/gas/testsuite/gas/i386/i386.exp
> +index 55ed9de..c2579e1 100644
> +--- a/gas/testsuite/gas/i386/i386.exp
> ++++ b/gas/testsuite/gas/i386/i386.exp
> +@@ -267,6 +267,8 @@ if [expr ([istarget "i*86-*-*"] ||  [istarget "x86_64-*-*"]) && [gas_32_check]]
> +     run_list_test "mpx-inval-1" "-al"
> +     run_dump_test "mpx-add-bnd-prefix"
> +     run_dump_test "sha"
> ++    run_dump_test "omit-lock-yes"
> ++    run_dump_test "omit-lock-no"
> +
> +     # These tests require support for 8 and 16 bit relocs,
> +     # so we only run them for ELF and COFF targets.
> +diff --git a/gas/testsuite/gas/i386/omit-lock-no.d b/gas/testsuite/gas/i386/omit-lock-no.d
> +new file mode 100644
> +index 0000000..87f796f
> +--- /dev/null
> ++++ b/gas/testsuite/gas/i386/omit-lock-no.d
> +@@ -0,0 +1,12 @@
> ++#source: omit-lock.s
> ++#as: -momit-lock-prefix=yes  -momit-lock-prefix=no
> ++#objdump: -dw
> ++#name: i386  omit lock = no
> ++
> ++.*: +file format .*i386.*
> ++
> ++Disassembly of section .text:
> ++
> ++0+ <main>:
> ++   0:	f0 f0 83 00 01       	lock lock addl \$0x1,\(%eax\)
> ++#pass
> +diff --git a/gas/testsuite/gas/i386/omit-lock-yes.d b/gas/testsuite/gas/i386/omit-lock-yes.d
> +new file mode 100644
> +index 0000000..67f0ef1
> +--- /dev/null
> ++++ b/gas/testsuite/gas/i386/omit-lock-yes.d
> +@@ -0,0 +1,12 @@
> ++#source: omit-lock.s
> ++#as: -momit-lock-prefix=yes
> ++#objdump: -dw
> ++#name: i386  omit lock = yes
> ++
> ++.*: +file format .*i386.*
> ++
> ++Disassembly of section .text:
> ++
> ++0+ <main>:
> ++   0:	83 00 01             	addl   \$0x1,\(%eax\)
> ++#pass
> +diff --git a/gas/testsuite/gas/i386/omit-lock.s b/gas/testsuite/gas/i386/omit-lock.s
> +new file mode 100644
> +index 0000000..3a6a065
> +--- /dev/null
> ++++ b/gas/testsuite/gas/i386/omit-lock.s
> +@@ -0,0 +1,6 @@
> ++        .code32
> ++.globl main
> ++        .type   main, @function
> ++main:
> ++        lock
> ++        lock addl $0x1,(%eax)
> +--
> +1.7.9.5
> +
>


      reply	other threads:[~2015-06-26 21:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-26 21:06 [PATCH][Fido ONLY] binutils: Add -momit-lock-prefix support Saul Wold
2015-06-26 21:10 ` Saul Wold [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=558DBFC7.4030902@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=richard.purdie@linuxfoundation.org \
    /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 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.