Received: by 10.223.185.116 with SMTP id b49csp1773749wrg; Sun, 4 Mar 2018 09:36:51 -0800 (PST) X-Google-Smtp-Source: AG47ELueAP4eL7YBMdCeckSur/KzOZxTC54fLF7mcitzV8GK/wgnQ//YvvNIpTd1IL68ioG1VbVh X-Received: by 10.101.67.198 with SMTP id n6mr10085322pgp.150.1520185010941; Sun, 04 Mar 2018 09:36:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520185010; cv=none; d=google.com; s=arc-20160816; b=d/9+JHqgfOA0MxUodmWVYkGqpPyK9eZo3qXT4DTZTkzGGEe5BakUMrugfZ3gkV2x96 NXIETFhHxaKx6mXZ94DnkMUOgNiQYuTNv+awqKzNxBvdIxQ3/pz5oimqR/SNkgoq/5Av i0sf/WHCM1ZzSBV4T0Xh3EhfQ5QRC1cNRtYnVpyeHvu5E0x+dow1CTIci1+zdrXvIBls 9+9ork+zoyQ/kC/evapO7gQvsBZWYZ63WzybhknnFrJQsYvFh3gRohH+AfKUdJG1sF8c lzNI4HEoK+3RXThQYYQF178BO2oWWjDRaBsU0Va+/Ndn717U0E5N8wmdKoVF1Nq18LP/ jFXA== 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 :arc-authentication-results; bh=xQg1BjX5Qz/YyqCN26IDDOxfX5ca/7GmWuexobzAgt4=; b=XdpKbfhqInTve9bAbOlcb4dgRmbtIMfNckprfpo6ZgueG4MY7mxPwuP5S728rYEQiR 19wf+vl0iFj+eLHXPlooaieNDYyFX5Xi37hSQ4XkgplC0KjJWzgnYK5FS26deKEdjjcd s1Ely6tRg+ogXb05sWDcQPsbb40plAfgEJfIOotP1FiRYM59PFrMqU41dyFcBnH0lMSd aS0HX2X+TIkP7Z2IbWjebx3lDFOF19GqI1wQ3cVBr/a5QJPvtg9aeiGdrdfDkDMcPlVl En1Qn9JkJnahlSzIFwUy/p2m+3c4Ll1DQ2/fnxP9+vrXszG4Yhc1DV2hY8iaUSgCkZ+w Kqgw== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7-v6si7919932plz.338.2018.03.04.09.36.31; Sun, 04 Mar 2018 09:36:50 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbeCDRcK (ORCPT + 99 others); Sun, 4 Mar 2018 12:32:10 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34692 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751838AbeCDRcJ (ORCPT ); Sun, 4 Mar 2018 12:32:09 -0500 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w24HTORE054313 for ; Sun, 4 Mar 2018 12:32:09 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0b-001b2d01.pphosted.com with ESMTP id 2gga2j878a-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Sun, 04 Mar 2018 12:32:08 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 4 Mar 2018 17:32:07 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 4 Mar 2018 17:32:03 -0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w24HW2fT57409754; Sun, 4 Mar 2018 17:32:02 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7C6BA4040; Sun, 4 Mar 2018 17:25:01 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 52261A404D; Sun, 4 Mar 2018 17:24:58 +0000 (GMT) Received: from vajain21.in.ibm.com.com (unknown [9.85.147.39]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 4 Mar 2018 17:24:57 +0000 (GMT) From: Vaibhav Jain To: Michael Ellerman , Balbir Singh Cc: Vaibhav Jain , Frederic Barrat , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Benjamin Herrenschmidt , Paul Mackerras , Nicholas Piggin , Douglas Miller Subject: [PATCH] xmon: Clear all breakpoints when xmon is disabled via debugfs Date: Sun, 4 Mar 2018 23:01:32 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18030417-0040-0000-0000-0000041A93F4 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030417-0041-0000-0000-0000261DA03D Message-Id: <20180304173132.19677-1-vaibhav@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-04_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803040227 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Presently when xmon is disabled by debugfs any existing instruction/data-access breakpoints set are not disabled. This may lead to kernel oops when those breakpoints are hit as the necessary debugger hooks aren't installed. Hence this patch introduces a new function named clear_all_bpt() which is called when xmon is disabled via debugfs. The function will unpatch/clear all the trap and ciabr/dab based breakpoints. Signed-off-by: Vaibhav Jain --- arch/powerpc/xmon/xmon.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c index e9c7ec8f15f8..f43aacd74625 100644 --- a/arch/powerpc/xmon/xmon.c +++ b/arch/powerpc/xmon/xmon.c @@ -903,6 +903,27 @@ static void remove_bpts(void) } } +static void clear_all_bpt(void) +{ + int i; + + /* clear/unpatch all breakpoints */ + remove_bpts(); + remove_cpu_bpts(); + + /* Disable all breakpoints */ + for (i = 0; i < NBPTS; ++i) + bpts[i].enabled = 0; + + /* Clear any data or iabr breakpoints */ + if (iabr || dabr.enabled) { + iabr = NULL; + dabr.enabled = 0; + } + + printf("xmon: All breakpoints cleared\n"); +} + static void remove_cpu_bpts(void) { hw_breakpoint_disable(); @@ -3671,6 +3692,9 @@ static int xmon_dbgfs_set(void *data, u64 val) xmon_on = !!val; xmon_init(xmon_on); + /* make sure all breakpoints removed when disabling */ + if (!xmon_on) + clear_all_bpt(); return 0; } -- 2.14.3