From patchwork Mon Jul 3 19:10:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pratyush Anand X-Patchwork-Id: 9823841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 603AB60353 for ; Mon, 3 Jul 2017 19:18:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4EEB425F3E for ; Mon, 3 Jul 2017 19:18:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 424FA265B9; Mon, 3 Jul 2017 19:18:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD1FB25F3E for ; Mon, 3 Jul 2017 19:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vkip14pNyUTcltVS7YESjlJUy6eovWH3x3M15sDJWh8=; b=MnLzGP2O2pOuAoFo6dUatpf2mH q8wUBQ2sarSGpJgC29mohypffhpEMwG31AjWgnn3u9cXaJsznc1fRHRf0NOBaJxWK1z3t1X3KxwLN rYcSQjW0rL26afFHUegH3w3K4xkKjriZ9XX8VTkBW7BmVBMrvJW7c5Xir0fr//6t07vfbqFugNCLj 74pUof37+T1qdBv/Tm/YDnoWL4guoiq52rVnXydLXtmT3+mb3Fx9W8jzK6zHeiLODIc+YLl13rIF5 5grnNCX4/3xg/Jbt0vjp6qzU1AIYTU9X38I2c2i3savadfUd1j2DgI2jB/z7p5nrao+jkqGmuA7Vz ovbKvFhw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dS6rw-0001A6-SG; Mon, 03 Jul 2017 19:18:48 +0000 Received: from mail-pg0-f44.google.com ([74.125.83.44]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dS6rt-000173-8R for linux-arm-kernel@lists.infradead.org; Mon, 03 Jul 2017 19:18:47 +0000 Received: by mail-pg0-f44.google.com with SMTP id k14so23352678pgr.0 for ; Mon, 03 Jul 2017 12:18:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=0FUR4t5rIQ7C75PzxpvvR3qMlcLB+H33wj1GAl1NZ64=; b=DULD61EBVpbzDVneXj9qX54OjMSphYsbHETSwuva9+BuxWh+g2klSZtfP4oiQOHocS A3ZjkhlEWzc371weEw0YN44Q2JX+laGTCyP/PqBH9SdmIZthG5z7Jgdfa/6YFdc6bYTN Q5zgNzeQDO8muLwAerI4K1X1tehsafQGPehHiyNgh4Ihj4R73tLsoBYJtQD4nERvp5d+ tP/o6iQbQvZ96TT8puGah24SEs682l1/Xb2ly8IjCx7vtMZlFui/Q8fjfM0VooHmn7UR O0qecvlhbniZyhJD5q0DWQIxRvP1ykaDKzyvkbPcqYlofg6XDniE03ZjjpvJfttXdJZp JN8Q== X-Gm-Message-State: AIVw113cxJz4R736KmMRn6LGjrv+uXZaTtCFhHYhH84+EzYi5nPkfwrJ lGneQkr5Fb5TJc8czDgaVQ== X-Received: by 10.98.12.76 with SMTP id u73mr11350742pfi.62.1499109045144; Mon, 03 Jul 2017 12:10:45 -0700 (PDT) Received: from localhost ([122.162.147.68]) by smtp.gmail.com with ESMTPSA id k67sm13287898pfg.37.2017.07.03.12.10.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Jul 2017 12:10:44 -0700 (PDT) From: Pratyush Anand To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com, mark.rutland@arm.com Subject: [PATCH 1/2] arm64: hw_breakpoint: Allow stepping if a kernel mode overflow handler exists Date: Tue, 4 Jul 2017 00:40:26 +0530 Message-Id: X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170703_121845_349961_322A0C74 X-CRM114-Status: GOOD ( 12.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pratyush Anand , huawei.libin@huawei.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Currently we allow to single step only for the perf user. However, we have a kernel sample test (samples/hw_breakpoint/data_breakpoint.c) which implements its own overflow handler. Therefore, additionally allow single stepping if there exists a overflow handler in kernel mode. We still have issues with test, which causes kernel to go into an infinite loop of overflow_handler being called, and that reveals a corner case bug with perf breakpoint implementation as well. See the next patch, which talks more about it and attempts to resolve it. Signed-off-by: Pratyush Anand --- arch/arm64/kernel/hw_breakpoint.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c index 749f81779420..46dbbf94f72d 100644 --- a/arch/arm64/kernel/hw_breakpoint.c +++ b/arch/arm64/kernel/hw_breakpoint.c @@ -661,7 +661,8 @@ static int breakpoint_handler(unsigned long unused, unsigned int esr, perf_bp_event(bp, regs); /* Do we need to handle the stepping? */ - if (is_default_overflow_handler(bp)) + if (is_default_overflow_handler(bp) || + (!user_mode(regs) && bp->overflow_handler)) step = 1; unlock: rcu_read_unlock(); @@ -789,7 +790,8 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr, perf_bp_event(wp, regs); /* Do we need to handle the stepping? */ - if (is_default_overflow_handler(wp)) + if (is_default_overflow_handler(wp) || + (!user_mode(regs) && wp->overflow_handler)) step = 1; } if (min_dist > 0 && min_dist != -1) { @@ -800,7 +802,8 @@ static int watchpoint_handler(unsigned long addr, unsigned int esr, perf_bp_event(wp, regs); /* Do we need to handle the stepping? */ - if (is_default_overflow_handler(wp)) + if (is_default_overflow_handler(wp) || + (!user_mode(regs) && wp->overflow_handler)) step = 1; } rcu_read_unlock();