From patchwork Wed Apr 3 10:31:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 161690 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp149877jan; Wed, 3 Apr 2019 03:31:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoH2Dbtct7gtgd837jac8OQoR6ypY+bIA86MIjBJJbLI4k/yDlpvLbO5rLKZt4oCO9HiBJ X-Received: by 2002:a17:902:2e03:: with SMTP id q3mr74645062plb.166.1554287485292; Wed, 03 Apr 2019 03:31:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554287485; cv=none; d=google.com; s=arc-20160816; b=WnKkKbrj5/D75bPG7lKZEQlXt63G9pJjJNFODcwr+k0cHAvxqnKxEZU8g3yvzSChuT ic3vmF00cLag0ZC+XrXV6duNrQvehxZ3I1jzn1QAo90GRu6D3EYXFAh/vMPi/7cTPd9S 3nMcpgTOSehuPgvQLRK6eL+QHU75aLeVUx8YygYVFxgme3aIy1PFiAeO0dfKNnPQwrQs j457gArxKdsf7cNx4amht/24y6js1POqCt15xOBz2edA2tNEx5EzZDQSwXI6aA29aDAt x928k4gUapJwLw/xCkVmIGhiQDNq5sE1kWhk6Y1Y64YRDawQ6d0CaJ4cQIaFc8sEMW8i C0TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=LJpKVnWKK7ieWKkifoZv6ipr90yJp8BxZ3+S+7eBx48=; b=Ut/zjyfc6eQSXWusqpehoM7DV14n4cfhgw7rOEVRmg+rvC3mESaDFBEWFLYh/XHOs6 +KpSHctrOEdzYrCZBEe/oOF4b6bxS7ULbSwKEJbUfWFfW3OS7t7LN/Ic4JMN1/4CwB6V gJ7eJ3vlXDHkfKSAWxHYv7JqJhDSG0lhAYJBdv7hesfK7inOr1EdCdbWnFiHp1o7qfOp 6DVxusT6+WU35p5EPgGj8XYR4G1lTXFUc/DffjsMvf8eXBoMif1NEUvXwxKb4UwA+KAi DXwZJFCiPCTO0g1aoOatwuD81vJ3ZYT2eoAaRTV409tkoN2xk+1LLatchIaATmAfiq94 mDBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si13185866pfa.59.2019.04.03.03.31.25; Wed, 03 Apr 2019 03:31:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726328AbfDCKbY (ORCPT + 14 others); Wed, 3 Apr 2019 06:31:24 -0400 Received: from foss.arm.com ([217.140.101.70]:36996 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfDCKbY (ORCPT ); Wed, 3 Apr 2019 06:31:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A4BC080D; Wed, 3 Apr 2019 03:31:23 -0700 (PDT) Received: from fuggles.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7066D3F59C; Wed, 3 Apr 2019 03:31:22 -0700 (PDT) From: Will Deacon To: gregkh@linuxfoundation.org Cc: stable@vger.kernel.org, linux-kernel@vger.kernel.org, sashal@kernel.org, Will Deacon , Catalin Marinas Subject: [PATCH 4.4 BACKPORT 1/2] arm64: debug: Don't propagate UNKNOWN FAR into si_code for debug signals Date: Wed, 3 Apr 2019 11:31:13 +0100 Message-Id: <20190403103114.29050-1-will.deacon@arm.com> X-Mailer: git-send-email 2.11.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit b9a4b9d084d978f80eb9210727c81804588b42ff upstream. FAR_EL1 is UNKNOWN for all debug exceptions other than those caused by taking a hardware watchpoint. Unfortunately, if a debug handler returns a non-zero value, then we will propagate the UNKNOWN FAR value to userspace via the si_addr field of the SIGTRAP siginfo_t. Instead, let's set si_addr to take on the PC of the faulting instruction, which we have available in the current pt_regs. Cc: # 4.4.y Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas --- arch/arm64/mm/fault.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.11.0 diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 04c4b88706d8..89abdf9af4e6 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -589,11 +589,12 @@ void __init hook_debug_fault_code(int nr, debug_fault_info[nr].name = name; } -asmlinkage int __exception do_debug_exception(unsigned long addr, +asmlinkage int __exception do_debug_exception(unsigned long addr_if_watchpoint, unsigned int esr, struct pt_regs *regs) { const struct fault_info *inf = debug_fault_info + DBG_ESR_EVT(esr); + unsigned long pc = instruction_pointer(regs); struct siginfo info; int rv; @@ -604,16 +605,16 @@ asmlinkage int __exception do_debug_exception(unsigned long addr, if (interrupts_enabled(regs)) trace_hardirqs_off(); - if (!inf->fn(addr, esr, regs)) { + if (!inf->fn(addr_if_watchpoint, esr, regs)) { rv = 1; } else { pr_alert("Unhandled debug exception: %s (0x%08x) at 0x%016lx\n", - inf->name, esr, addr); + inf->name, esr, pc); info.si_signo = inf->sig; info.si_errno = 0; info.si_code = inf->code; - info.si_addr = (void __user *)addr; + info.si_addr = (void __user *)pc; arm64_notify_die("", regs, &info, 0); rv = 0; }