From patchwork Fri Mar 1 13:28:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 159477 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp734246jad; Fri, 1 Mar 2019 05:28:17 -0800 (PST) X-Google-Smtp-Source: APXvYqyvik1VHofuouNASWLSqxv+dROiDAfd1V32p6JdIrmSBnFnyFTs34xIozFxGwTVK32Ecc7n X-Received: by 2002:a63:c64c:: with SMTP id x12mr4862685pgg.285.1551446897915; Fri, 01 Mar 2019 05:28:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551446897; cv=none; d=google.com; s=arc-20160816; b=qrHKOwwjpc57EmUCREzmGZ5WnHZJj6mtorPmAZNcQozOof4gR8ARl0Wr0PsOXStty9 IIBvM4sZHa7m3Cvjnwa/MLm+c8sYi/aVZZ2OxR5Nqowg1AcPToHjZGKNZ9xynnGopJZR t8i0nWCoGeK9Hi+7X8IUV9+tO1+QWEP5MRUQ/LjYTR3c8lLVmMzFdwu6WPeTWpxQqGZB 4H2lkYyre1NK9knsrM+Vi7xWEELRK5B3DOyDNTMptv73f9n3JcAuq0+twEsaiKgC/UDU ujdD/2zWSoEn+Rid9/vwi4zR+hepfzxkJ827zn6IWBkNxWvdrrNmkGGrFnUXsW3GhXoJ ciQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=7WtimDScbDkuC77N2AIsblN8hDPeVK1DAteiwfWWk1A=; b=XHyh4dncEoYDjUisA+0dNy4ilqJ81LnssWAknDL00Syt2TqXCdfOdxROKGwc7Y7KlD g16GSBBtex5EZ+FqzGY9IVE5t8E/qoiYxF0s4Eht4HLXabaYL4mxIVegHq8xCqPmCqgL d/WyYul8rVP71aKeKO5saSqyXxUjWFtX5EQhbJypQu9Y3H5Qwr3+RmEt9FM4xE9WyrcP xb/pHrnoiyzyw7mdg/pnvADt0Zu0SpT0jBnzrXkNsVj47rjVwTpfpGvZzBf5kZcPz+uM 1p6T12yK6H9swR2iMU8DH7VhH62JD2rZ5mSYB+khvnjEED5u6p9tEubU2knb+cExbZ5V Qw7g== 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 cy1si22781169plb.429.2019.03.01.05.28.17; Fri, 01 Mar 2019 05:28:17 -0800 (PST) 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 S1728216AbfCAN2R (ORCPT + 14 others); Fri, 1 Mar 2019 08:28:17 -0500 Received: from foss.arm.com ([217.140.101.70]:34742 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727697AbfCAN2R (ORCPT ); Fri, 1 Mar 2019 08:28:17 -0500 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 54D6B165C; Fri, 1 Mar 2019 05:28:16 -0800 (PST) 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 44FF13F5C1; Fri, 1 Mar 2019 05:28:15 -0800 (PST) From: Will Deacon To: linux-arm-kernel@lists.infradead.org Cc: catalin.marinas@arm.com, mark.rutland@arm.com, Will Deacon , stable@vger.kernel.org Subject: [PATCH 01/10] arm64: debug: Don't propagate UNKNOWN FAR into si_code for debug signals Date: Fri, 1 Mar 2019 13:28:00 +0000 Message-Id: <20190301132809.24653-2-will.deacon@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190301132809.24653-1-will.deacon@arm.com> References: <20190301132809.24653-1-will.deacon@arm.com> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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: Signed-off-by: Will Deacon --- arch/arm64/mm/fault.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) -- 2.11.0 Reviewed-by: Mark Rutland diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index efb7b2cbead5..ef46925096f0 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -824,11 +824,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 = esr_to_debug_fault_info(esr); + unsigned long pc = instruction_pointer(regs); int rv; /* @@ -838,14 +839,14 @@ asmlinkage int __exception do_debug_exception(unsigned long addr, if (interrupts_enabled(regs)) trace_hardirqs_off(); - if (user_mode(regs) && !is_ttbr0_addr(instruction_pointer(regs))) + if (user_mode(regs) && !is_ttbr0_addr(pc)) arm64_apply_bp_hardening(); - if (!inf->fn(addr, esr, regs)) { + if (!inf->fn(addr_if_watchpoint, esr, regs)) { rv = 1; } else { arm64_notify_die(inf->name, regs, - inf->sig, inf->code, (void __user *)addr, esr); + inf->sig, inf->code, (void __user *)pc, esr); rv = 0; }