From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1259F2BB17 for ; Mon, 23 Feb 2026 04:49:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771822169; cv=none; b=iT8d7KofaWge4H36yyFXZpvZas1WKLsSMjzefbpLeALfbnLuNOqoXE2UAt7z5hgV4GPcTslHYiW/6s47Ly/7eFM74S9gkgB1R0fTTfPxjEPGqc8SWZ1tqzG6yUA0zET6mxTA0Yv0QUSZfR+1wHRCCEnsW6zfmTQQbawG+NvlnEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771822169; c=relaxed/simple; bh=VdkrSYf9/FcBnmmiG81jVgVgD2Bj9Q84KiKwveBfqbU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=KassokjMr9ZwtJ1ivvAqmjZ30wN7UsMP15O5ja+STUALTTObnOc0zP+IBC0iWMh74AJVZsKIJgw9fpoRaGQeaUh3c1rtOsquo+iukyyjLCg6jv+1w0Zu8raUeq1UR8oCgApLeZAHtVKW5KsAeySdyJrC9MqXfoc6q8UOUXy46vw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=avce3QLl; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UVjoQHUr; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="avce3QLl"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UVjoQHUr" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 61MBZRN0670853 for ; Mon, 23 Feb 2026 04:49:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=97WzUlery+Lu32sx5iV+DbtbOjrH5XZBo8z xyuyWm30=; b=avce3QLlW5dh/VnktkYX7gaiNRjx6le8pbIFFyh5o5qOuf8ANQw Hnsa6LeP12NiUIPqHmPAHJAMj4I4hWe03OcVLuzdYM73VXkJ4VanOpBFO4JPQehI hguwc2a6Pd2LgZV4A1UE/cpgm6XF83L7Eao7YJc1c0sAQ+hCktC63z+Ji4hU44fv Hm3mdGECWFx1fcVGD+dqgvMxh0jHdvny9MFmqqVrV6MpH1SP/ZZmyNEwXe0XRXkQ v2aXvWI3BwwSfCLL/v/mBHAF7hppxaR9Rww5PG4Kp8gIF8SnkwKtyUMPsoD71Ooh K76BmjlHa0IYe1Khd1ky4AfW9Ne7Gjf3+3Q== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cf5waucxe-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 23 Feb 2026 04:49:27 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-3562bdba6f7so28261158a91.2 for ; Sun, 22 Feb 2026 20:49:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1771822166; x=1772426966; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=97WzUlery+Lu32sx5iV+DbtbOjrH5XZBo8zxyuyWm30=; b=UVjoQHUr0gcKSRAKQU0jnnBmDZMMxiaQeC8dIn2VvfgoGQ3b+z6f4n7rkdNwdCQcA8 qyxLPF+vIMBuAeNPh9TrXGjM+TC1pAfvOYPrNWSwujAkUF1oEpE327Y2OPO4Eb/ym2Fo akv4cmGll/06Oa0a2o6xhQRs3ZdhAGV6hgSbb7607fclMJIrZfLYbp2A+5Gpz0wWgMBM hgnK2v8rngK8EsbFtiQSoxijtt5vZhh6qXgRJXTGNK9dlBbB3bJ40CDyfIlxFoqeWFPK IQhYXk8SVKJUsi4zlit17l/X+gWRv2I0KIImOY6qmTLK1wk3DIpiS0A7YvqYESrOLq50 OV1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771822166; x=1772426966; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=97WzUlery+Lu32sx5iV+DbtbOjrH5XZBo8zxyuyWm30=; b=WcDdS5ZgcZD56FGBxO7iSkumcVjg7x+vAq87lHnlfQ8wdijV/zI1aR+bSTLlPMfT1U w7yTPqATm0H8dMN5hF6TT+yxrdmY7aUgNQJUw1hjMhF2NOtGRIEdG6OfB+FgiBVuTmhA uYN2cHRS5R2I/oywAOoUL74fRehaYmHhDesbNiwW0CtWCTT5rhbcYHAifGxcw0sXg7/S aEaw+DfqHJu/GV/4my/xd7aP/5dNFfxOG8mBaWkSp+SHxpGi6VF80O/zQ7YbQnek85dQ Mcy1ghKLJJvziahciBEFZ5qJ7bSEihSPf5LTAxx3/SdOBgmwkKiKkb/Pq4DTH1h7EHUv A3tQ== X-Forwarded-Encrypted: i=1; AJvYcCXVnIpF0IJsXXT5y34O2Py/M3hrYZv7bfPW33LwYpTjOfEJ0tMrH/oSfo408J6e9INlTqF9vL74/2qEMNo=@vger.kernel.org X-Gm-Message-State: AOJu0Yyb7C4lziDtXNAKNJb9BxjmKRQuVsYiGSJ7tR9yWSH4PnrsxJ5l lnX8Hmf8GrGY6veTyCW1/dbarjEaI/Basp2JyflVKHmbad4TYyP9mzv/K7VcEgAqg+817v1G5e1 ykfsm3zuHcQWUsgbTXYayT7Im3sYWX0FN3zXRlL3J5H71xvRIXXwLpMbKiloqzP+bvbI= X-Gm-Gg: ATEYQzxKY0TBNXYnhLYnm41j4Vwo27uWhvY7cv7VhvfkxKNJDYuOWKSXPcJiR8bZZki 69uRf+fNwvjw9wkri1qPOZt8/aE7OGVsWRaVJDXDs1K0y/xATXvQtfpQY00QxUSXMbjaVGQ5g9j rm74xrLGEecIANGake3dhgswi3RyevIsOCjXl55vNNnscnWbvDDha7jJLQ13/j6y57urjvSVhNz 8goffbH6IJu/oGWuSKXJgwE9M0TfyqYUWGm+VtoGh0vBVF0b6YfUHBmR8SAKfeQxUI8v6IXZhpp Cda86E/OeSkamVHbv2+dUehcTdelRB516AQ2cko8WMOP9rUtVf8am4R45SwTGV8PjMKCiFERKyT su1Kx3dld55LQDxd0EUZN6adoDUXbw7/+eNvbO6SoDm36o9ubki8jPEz8N/VkM2bKpQIcEcLiew WdaMUnAxcIHeocNN1RN4CbedGeN87qUx27X8H32CCDFeq/Pg== X-Received: by 2002:a17:90a:d884:b0:354:a05d:9dc2 with SMTP id 98e67ed59e1d1-358ae810988mr6219596a91.9.1771822166401; Sun, 22 Feb 2026 20:49:26 -0800 (PST) X-Received: by 2002:a17:90a:d884:b0:354:a05d:9dc2 with SMTP id 98e67ed59e1d1-358ae810988mr6219584a91.9.1771822165915; Sun, 22 Feb 2026 20:49:25 -0800 (PST) Received: from hu-himchau-blr.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-358a2a768bcsm5623954a91.4.2026.02.22.20.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Feb 2026 20:49:25 -0800 (PST) From: Himanshu Chauhan To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, shuah@kernel.org Cc: Himanshu Chauhan Subject: [PATCH v3 0/2] riscv: Introduce support for hardware break/watchpoints Date: Mon, 23 Feb 2026 10:19:16 +0530 Message-ID: <20260223044918.1359983-1-himanshu.chauhan@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=KJVXzVFo c=1 sm=1 tr=0 ts=699bdc57 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=Ou0eQOY4+eZoSc0qltEV5Q==:17 a=HzLeVaNsDn8A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=V1jnuoLLAAAA:20 a=NEAV23lmAAAA:8 a=JSQdZKtrMsnwzkd4akMA:9 a=mQ_c8vxmzFEMiUWkPHU9:22 a=bA3UWDv6hWIuX7UZL3qL:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMjIzMDA0MCBTYWx0ZWRfX4uSjY3/OGig2 1zjfQ75eDAuw88ejoVxBMOeYtRET1tAVNuJIGb/92s1tKi7+g8J/8nvmLW73cb0J7BaBeEPwT2f qgIODbrEHhPMKAjuYv2iIhwFovXYIg4jixmQY7DPRPWx/sykNB9P2Uz/kbcfuFOcno5v7iQgN8a A4ecvLTnh7q2ogAxEjBgvXmLQ0QjX3I6QdiHN7Jxt65a0/Q3A7TSpEFtecz5XMzXDn0PqCrUL9j ZCHw1ZlefGBkBw+PY7sY/4enYuVw4MjnJ6RxYWxqfA/BEcbp/JS4VK3GMkuFDuqWZpfzBnUsy0n 5uS1YrUuXHYOwBb2E6jyKv/TzeSc8tgT7v+fQMmgbhpPLZgBZHuUS6swh8+ZjwOKsrewXT+LGEe noNBT7gbQNJ893Y4J5q1JCGIoiBvSpRC6zV8HA6uz7GZQoV9kXw93VRbyNyKe3gXFUT+CycB7Bu n4bQK6HBJQRolAvWUJQ== X-Proofpoint-ORIG-GUID: SL2QrPsrw_OMYlBNAbfW37nc6aTfxK7f X-Proofpoint-GUID: SL2QrPsrw_OMYlBNAbfW37nc6aTfxK7f X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-02-23_01,2026-02-20_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 spamscore=0 malwarescore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2602230040 This patchset adds support of hardware breakpoints and watchpoints in RISC-V architecture. The framework is built on top of perf subsystem and SBI debug trigger extension. Currently following features are not supported and are in works: - Ptrace support - Single stepping - Virtualization of debug triggers The SBI debug trigger extension proposal can be found in Chapter-19 of SBI specification: https://github.com/riscv-non-isa/riscv-sbi-doc/releases/download/v3.0/riscv-sbi.pdf The Sdtrig ISA is part of RISC-V debug specification which can be found at: https://github.com/riscv/riscv-debug-spec Changes from v2: - Rebased to v7.0-rc1 - Fixed the warnings from `checkpatch.pl --strict` run. Changes from v1: - The patch that adds the extension and the function IDs defined by the extension is already merged. So this patch builds on top of that. - Added breakpoint test application in self tests to test debug triggers How to use: ~~~~~~~~~~~ OpenSBI: https://github.com/riscv-software-src/opensbi.git Qemu: https://github.com/qemu/qemu.git Linux Kernel: You can pull v7.0-rc1 branch from Linus' Tree and apply these patches. How to test: ~~~~~~~~~~~ >From the Linux kernel directory issue the following command: make -C tools/testing/selftests/breakpoints/ This will make a binary named breakpoint_test_riscv under the same directory. Load it on the machine and run. Sample output is given below: / # /apps/breakpoint_test_riscv breakpoint triggered! Breakpoint test passed! watchpoint triggered! Watchpoint test passed! Himanshu Chauhan (2): riscv: Introduce support for hardware break/watchpoints riscv: Add breakpoint and watchpoint test for riscv arch/riscv/Kconfig | 1 + arch/riscv/include/asm/hw_breakpoint.h | 332 +++++++++ arch/riscv/include/asm/kdebug.h | 3 +- arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/hw_breakpoint.c | 657 ++++++++++++++++++ arch/riscv/kernel/traps.c | 6 + tools/testing/selftests/breakpoints/Makefile | 5 + .../breakpoints/breakpoint_test_riscv.c | 174 +++++ 8 files changed, 1178 insertions(+), 1 deletion(-) create mode 100644 arch/riscv/include/asm/hw_breakpoint.h create mode 100644 arch/riscv/kernel/hw_breakpoint.c create mode 100644 tools/testing/selftests/breakpoints/breakpoint_test_riscv.c -- 2.43.0