Received: by 10.223.185.111 with SMTP id b44csp855454wrg; Fri, 9 Mar 2018 15:17:19 -0800 (PST) X-Google-Smtp-Source: AG47ELsUjoO2wQ1px1HPRhpicTpw4q9T3wzjNvVGmGkWSegPmwHxrt0tFRQQkI/pIcL4rskojCgn X-Received: by 2002:a17:902:7686:: with SMTP id m6-v6mr155087pll.199.1520637439653; Fri, 09 Mar 2018 15:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520637439; cv=none; d=google.com; s=arc-20160816; b=e7+Gbbx6w6tZaYDhShAXUqJ9h3dTywalW8GDXfKtPnyqtdPQFTATwSgQEFt527jCyZ NSVuC7g8SCkDnvIcXAot0yPMucaj2/PQg4sfU3E5XQSBaZvm5fvnDMo+qUvp0+eRTsI4 2l/WiIHzbnhHpmyPpLXKBcbws4I+dlPPg7LYYO6IHoLN+j8+OL1vQZ1EHDEEPMdwxo8H r65rnKvcDIvB8SN4vuwEQJ0eRPhYPi3XtwcRBESoGG9z0++MUq7HkVk4KzuE9fwioO6K D+Jp2KS1TgRHzTFEHHF8xjOm4MAGo2P0fL/m02KYKomR2HJtDSx1aBdHmKJXj8rZF/dB 3Ipw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=yG51/kv57MUhVu9yw/ysrvMI0YyAl/RW7GYLZZkgh/o=; b=0ykASHFDUT+x3oLrNtMZIzxuuHg8mX4XkX3X1oleVZ3sHNZoNVbQf4K/cUMJAnZx8g VzGzDRH+NYBQ72xolJ+vNCaCsROamyDnXIHB84CYsfRvnjXZLlEmA8pgxQ3tXzbyvHdN ziuGlqu0EYLrCGE7ln5CtF/rWMjSJhHYPk70fMCVzd8nYehtclI1M6vUvqZVd5Aektgh YUM/Fz8eUhmJJ74Ml63pBrMErH9aGIe24VsJf7d0eUKcEykn6w6OotYn0tMcIONUcSMk kvEGuUMI2R5MbOa1cgpewS/om0vlS3TF2DqajyvFT4oArxPkCXXN6uY4ikJZOA1mWsFl wD2g== 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 e9si1389429pgt.774.2018.03.09.15.17.04; Fri, 09 Mar 2018 15:17:19 -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 S932666AbeCIXQE (ORCPT + 99 others); Fri, 9 Mar 2018 18:16:04 -0500 Received: from smtp.gentoo.org ([140.211.166.183]:47622 "EHLO smtp.gentoo.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932276AbeCIXQB (ORCPT ); Fri, 9 Mar 2018 18:16:01 -0500 Received: from sf.home (trofi-1-pt.tunnel.tserv1.lon2.ipv6.he.net [IPv6:2001:470:1f1c:a0f::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 0B483335C34; Fri, 9 Mar 2018 23:16:00 +0000 (UTC) Received: by sf.home (Postfix, from userid 1000) id C24A01E49B91B; Fri, 9 Mar 2018 23:15:56 +0000 (GMT) From: Sergei Trofimovich To: Tony Luck Cc: Sergei Trofimovich , Fenghua Yu , linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2, simpler] ia64: fix ptrace(PTRACE_GETREGS) (unbreaks strace, gdb) Date: Fri, 9 Mar 2018 23:15:55 +0000 Message-Id: <20180309231555.16925-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180211185134.76ccfd45@sf> References: <20180211185134.76ccfd45@sf> 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 in 'PTRACE_GETREGS'. Unwind tables fail to load at kernel startup due to GCC quirk on the following code (logged as PR 84184): 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. 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 disabling inline on init_unwind_table(). This way we avoid const-propagation of '__end_unwind' and pass address via register. Tested in ski (emulator) and on rx2600, rx3600 (real hardware). In case of rx2600 it unbreaks booting. This patch is a lighter version of patch https://lkml.org/lkml/2018/2/2/914 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 Tested-by: stanton_arch@mail.com Signed-off-by: Sergei Trofimovich --- arch/ia64/kernel/unwind.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/ia64/kernel/unwind.c b/arch/ia64/kernel/unwind.c index e04efa088902..a18190bc99a9 100644 --- a/arch/ia64/kernel/unwind.c +++ b/arch/ia64/kernel/unwind.c @@ -2078,7 +2078,14 @@ unw_init_from_blocked_task (struct unw_frame_info *info, struct task_struct *t) } EXPORT_SYMBOL(unw_init_from_blocked_task); -static void +/* + * We use 'noinline' to evade GCC bug https://gcc.gnu.org/PR84184 + * where gcc code generator emits incorrect code when '__end_unwind' + * is const-propagated to 'end[-1].end_offset' and gcc generates + * incorrect code. The prigger there is negative offset relative + * to externally-defined symbol. + */ +noinline static void init_unwind_table (struct unw_table *table, const char *name, unsigned long segment_base, unsigned long gp, const void *table_start, const void *table_end) { -- 2.16.2