commit:     b189fdcd14007187e344be210355f0ad3f5b6486
Author:     Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 28 18:46:00 2018 +0000
Commit:     Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
CommitDate: Wed Feb 28 18:46:00 2018 +0000
URL:        https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=b189fdcd

ia64 fix ptrace

 0000_README                |  6 ++--
 1701_ia64_fix_ptrace.patch | 87 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 3 deletions(-)

diff --git a/0000_README b/0000_README
index c56bd07..bf6df96 100644
--- a/0000_README
+++ b/0000_README
@@ -399,9 +399,9 @@ Patch:  1700_ia64-fix-module-loading-for-gcc-5.4.patch
 From:   http://www.kernel.org
 Desc:   ia64: Lift the slot=2 restriction from the kernel module loader.
 
-Patch:  1701_amd-support-for-fam17h-microcode-loading.patch
-From:   
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/patch/?id=f4e9b7af0cd58dd039a0fb2cd67d57cea4889abf
-Desc:   x86/microcode/AMD: Add support for fam17h microcode loading
+Patch:  1701_ia64_fix_ptrace.patch
+From:   https://patchwork.kernel.org/patch/10198159/
+Desc:   ia64: fix ptrace(PTRACE_GETREGS) (unbreaks strace, gdb).
 
 Patch:  2300_enable-poweroff-on-Mac-Pro-11.patch
 From:   
http://kernel.ubuntu.com/git/ubuntu/ubuntu-xenial.git/patch/drivers/pci/quirks.c?id=5080ff61a438f3dd80b88b423e1a20791d8a774c

diff --git a/1701_ia64_fix_ptrace.patch b/1701_ia64_fix_ptrace.patch
new file mode 100644
index 0000000..6173b05
--- /dev/null
+++ b/1701_ia64_fix_ptrace.patch
@@ -0,0 +1,87 @@
+From patchwork Fri Feb  2 22:12:24 2018
+Content-Type: text/plain; charset="utf-8"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 8bit
+Subject: ia64: fix ptrace(PTRACE_GETREGS) (unbreaks strace, gdb)
+From: Sergei Trofimovich <sly...@gentoo.org>
+X-Patchwork-Id: 10198159
+Message-Id: <20180202221224.16597-1-sly...@gentoo.org>
+To: Tony Luck <tony.l...@intel.com>, Fenghua Yu <fenghua...@intel.com>,
+ linux-i...@vger.kernel.org, linux-ker...@vger.kernel.org
+Cc: Sergei Trofimovich <sly...@gentoo.org>
+Date: Fri,  2 Feb 2018 22:12:24 +0000
+
+The strace breakage looks like that:
+./strace: get_regs: get_regs_error: Input/output error
+
+It happens because ia64 needs to load unwind tables
+to read certain registers. Unwind tables fail to load
+due to GCC quirk on the following code:
+
+    extern char __end_unwind[];
+    const struct unw_table_entry *end = (struct unw_table_entry *)table_end;
+    table->end = segment_base + end[-1].end_offset;
+
+GCC does not generate correct code for this single memory
+reference after constant propagation (see https://gcc.gnu.org/PR84184).
+Two triggers are required for bad code generation:
+- '__end_unwind' has alignment lower (char), than
+  'struct unw_table_entry' (8).
+- symbol offset is negative.
+
+This commit workarounds it by fixing alignment of '__end_unwind'.
+While at it use hidden symbols to generate shorter gp-relative
+relocations.
+
+CC: Tony Luck <tony.l...@intel.com>
+CC: Fenghua Yu <fenghua...@intel.com>
+CC: linux-i...@vger.kernel.org
+CC: linux-ker...@vger.kernel.org
+Bug: https://github.com/strace/strace/issues/33
+Bug: https://gcc.gnu.org/PR84184
+Reported-by: Émeric Maschino <emeric.masch...@gmail.com>
+Signed-off-by: Sergei Trofimovich <sly...@gentoo.org>
+Tested-by: stanton_a...@mail.com
+---
+ arch/ia64/include/asm/sections.h |  1 -
+ arch/ia64/kernel/unwind.c        | 15 ++++++++++++++-
+ 2 files changed, 14 insertions(+), 2 deletions(-)
+
+diff --git a/arch/ia64/include/asm/sections.h 
b/arch/ia64/include/asm/sections.h
+index f3481408594e..0fc4f1757a44 100644
+--- a/arch/ia64/include/asm/sections.h
++++ b/arch/ia64/include/asm/sections.h
+@@ -24,7 +24,6 @@ extern char __start_gate_mckinley_e9_patchlist[], 
__end_gate_mckinley_e9_patchli
+ extern char __start_gate_vtop_patchlist[], __end_gate_vtop_patchlist[];
+ extern char __start_gate_fsyscall_patchlist[], 
__end_gate_fsyscall_patchlist[];
+ extern char __start_gate_brl_fsys_bubble_down_patchlist[], 
__end_gate_brl_fsys_bubble_down_patchlist[];
+-extern char __start_unwind[], __end_unwind[];
+ extern char __start_ivt_text[], __end_ivt_text[];
+ 
+ #undef dereference_function_descriptor
+diff --git a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c
+index e04efa088902..025ba6700790 100644
+--- a/arch/ia64/kernel/unwind.c
++++ b/arch/ia64/kernel/unwind.c
+@@ -2243,7 +2243,20 @@ __initcall(create_gate_table);
+ void __init
+ unw_init (void)
+ {
+-      extern char __gp[];
++      #define __ia64_hidden __attribute__((visibility("hidden")))
++      /*
++       * We use hidden symbols to generate more efficient code using
++       * gp-relative addressing.
++       */
++      extern char __gp[] __ia64_hidden;
++      /*
++       * Unwind tables need to have proper alignment as init_unwind_table()
++       * uses negative offsets against '__end_unwind'.
++       * See https://gcc.gnu.org/PR84184
++       */
++      extern const struct unw_table_entry __start_unwind[] __ia64_hidden;
++      extern const struct unw_table_entry __end_unwind[] __ia64_hidden;
++      #undef __ia64_hidden
+       extern void unw_hash_index_t_is_too_narrow (void);
+       long i, off;
+ 

Reply via email to