Received: by 10.223.176.5 with SMTP id f5csp1287110wra; Fri, 2 Feb 2018 14:45:41 -0800 (PST) X-Google-Smtp-Source: AH8x224Rga+mZ4T8O6rHuMGpRLaNXMtRrt5bT+z2gdKqLBssIRtnXaFrEdSpcnKTfb9/Sjw6N2md X-Received: by 10.101.72.69 with SMTP id i5mr29327879pgs.9.1517611541046; Fri, 02 Feb 2018 14:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517611541; cv=none; d=google.com; s=arc-20160816; b=xrRWRT9OoxAKE3WGAS1UbjhWI8mGTXv2uBUUTLGKspTxhhpYHC87prhLzPG0BU8AGH 9aHScUZU+Kv1Ihav+1B/QYCF6QFR+b127cQ9RccR8r1ol9ZVDw0puB4JB2K5F1XvBKa5 6IJlv7+SgHoOkwqQsWvIxdSFRRkhKpwgdNgYrqWjtSa9rvPbyn235R1FIIZ3jTjHOvbm E12pcBGpbQKfKigS3OBhyWorGCJBe0taQl9VJIWcwtvFHtwsqiwzKksreDp2ZaKsLM/w pcO0YO2owxlwr/teswsoHsih5shjYNIDGmgrOBN7kwP5SbepROGFNglB78UEeKBkXL7t aXOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:arc-authentication-results; bh=LtdXkRCnt4ylUXgaWr58+QzSrGUtI8Fye5/OOnu1REc=; b=o89MN8s6960kPWw5mR8cFfcYx2jrFhD+W4SXXzyp0XOpynPupCX7OxeKqYXm0r7XU3 CUdHHzDpyifv7742kpFiot4I95AvxC1LHUNvdonFfMbcNYoO2B7JeOnauuqtLnjoNRin XTYx99nGj9fmIUEyI2hzoK2o4fHfiX2BJvwGhTeAZVg9BmlzgdAPFXOIz3SxrjGW+KRx Wv/HabrMQMYYYNFO6fSFaX5/5mRbmRpdIkIB0BLNu1paTXrMgy21WQefvM4XjSg5JGR2 2dB1+5fyjojM8wegSU36AGu7wFU6TT+pMH1y9PpoQ7PMJdwlDLdoJD7hRjDvW6dLQnAa YXhQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 34-v6si2565494pln.468.2018.02.02.14.45.26; Fri, 02 Feb 2018 14:45:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gentoo.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752641AbeBBWMl (ORCPT + 99 others); Fri, 2 Feb 2018 17:12:41 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:60942 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752211AbeBBWMg (ORCPT ); Fri, 2 Feb 2018 17:12:36 -0500 Received: from sf.home (host86-155-196-2.range86-155.btcentralplus.com [86.155.196.2]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: slyfox) by smtp.gentoo.org (Postfix) with ESMTPSA id 4321E335C63; Fri, 2 Feb 2018 22:12:34 +0000 (UTC) Received: by sf.home (Postfix, from userid 1000) id D77BE1E2A4FBF; Fri, 2 Feb 2018 22:12:29 +0000 (GMT) From: Sergei Trofimovich To: Tony Luck , Fenghua Yu , linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sergei Trofimovich Subject: [PATCH] ia64: fix ptrace(PTRACE_GETREGS) (unbreaks strace, gdb) Date: Fri, 2 Feb 2018 22:12:24 +0000 Message-Id: <20180202221224.16597-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.16.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 CC: Fenghua Yu CC: linux-ia64@vger.kernel.org CC: linux-kernel@vger.kernel.org Bug: https://github.com/strace/strace/issues/33 Bug: https://gcc.gnu.org/PR84184 Reported-by: Émeric Maschino Signed-off-by: Sergei Trofimovich --- 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; -- 2.16.1