From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FFCC38BF76 for ; Sun, 26 Jul 2026 12:23:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785068615; cv=none; b=Y091hmztbI8fRypKerJ1PfVJpchRrmTrXCDuybO0XaL0nil6JtP6Dpn4zQhi+S7C2HIeq4JGB4DbWWCw5NRcDT0FDJkTgJZv18Pamiank6e/wcK7T2ohY2+XVIUDqS2YwDRrkd7YYDaKezotg8mWXvuq7FYNHLzLorzAl8wCLJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785068615; c=relaxed/simple; bh=ccoLxXcVCAekN8O5gMgLDn7JdMt0YqOZNIb3h7ismYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DqWBSzNu9dy4pwtn54wH2CGDHEQNuHsTeGLbWkHTc+E9RebyjejQWHgnAtNmEOb7r0xcoAFIr2MnuaIdQ7t1lupDPOC2bMhZjI28j+Nj/b2Fh5+kJhntAH71troj6ReUTdSE4CckRon9mOEC/6KMIigSL9vVLnMpS1wgdK8y+3k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=f7ruABK1; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f7ruABK1" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7eb64371a2aso1074690a34.0 for ; Sun, 26 Jul 2026 05:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785068612; x=1785673412; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0oVEf5/gSaD+al9Pequ5m2rnhtlrO+HvKfH1QE9WEkQ=; b=f7ruABK1b9LOdLMLX0hoUbdnicYBAG40by648S0h3Hw6n65j2AtAsT5gvosd66eOgc HUbPfC498tJGg4NKwggeU0T1EK1632mv5rhSCb51w6eX6hUj5BAg1POhbwpwTlt3KO4T C+ZKFAx06jrRgi7SOI/RdpTO+253hTAEWSPJjpK6FYtinl5fUM/UOOwu4W5VcfH9HzG6 W8AZSOq+vmvvAtBKNBeO///i/v+iOaT4aisXjgP1iy/vXYxK25mYJhUn2lMTm6vZDS+d ciNLVJMpXPGKh0NdhHc1BATFKEZ06wv7S0SER1aCi2p8gILw8mgiI9n5JSBKoDu1c5c4 rLXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785068612; x=1785673412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0oVEf5/gSaD+al9Pequ5m2rnhtlrO+HvKfH1QE9WEkQ=; b=dNr64+ep6qBp75Lqmir49Zm2mvj+vxZP9tqZujZk5IO7ZTa/8utYEZl8ks3i3Y08Sq 1ZseejuYmNLMmgSXBykzo03usaQIea9T0/Yo1V+BekbPx6lD/8Y/d4rFuWf4lu8OkdqR k88VHvrvNSVgdNhmYnHih6PNChUfTCP4PtE8h2bt6ch18QVwR7dmTRZictpNi0rar5bS F2pFrPrHdHKLnrlvMZX/PAAadvB2WZRDd+liXPRug97qs06/QtBGIBDShBdsNe63kwjS N0din8vGcxaVOgXnDldVtDk1SsQGgwf5Oyga25IiHvVh0Jvbwnqmr/+FMhe1jm70frQ0 eD6w== X-Forwarded-Encrypted: i=1; AHgh+Rq6rJF5FOIhq37rQ5oIGoz4FJOO4+j89+j+sP5or3yBpa15bVMZzHZUM/fd1i31+CXypmyrOLz5BvrXSnc=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1AxHVgNz7lNNeCHU3K4SRgxTkhaF7aiUyxXVOUPyEmZO9qtNY zU4Bp912vDBZ8OC7yBCnV8QgX16PlxZsC767Hd6pdgy5C8wPjSLO4xvj X-Gm-Gg: AR+sD12spAaYQuUw43UpRrcRPAejYBaUD7Xlxto8tXhA3b1qNVhnS4aCNEMXL+cBqxs jDs8Zh6dsjFgccsSg2NhUhudI2/m6CPY//khr6qSNf53/HJDF8M9OuKANuZe5cQEy+KsAg+K6V/ nvwASmWAkRIqIU3NXgoVEDgZWpKIYfxsComxALLakHY1YLvNidhJrWyuY2OlQm2/bP8H7KVC0YP wTUVkFC+RAwwB+VOJtyb6YuFxkG+lS+pZHXu1FsMIoXT+V/vClp9bYdVul9Iy0hk57VAj8f4IQ7 /mDE1ObCIikdYJ+l6NcxAEIKMzbBpLJZlBK4o06SwgEyE6mJ3CdVin738d9UHUS/ctYUYVESxIU 7PStI2FKzjyA3Dg4AmddnTtCGUnbJHGgLCcFUZlvQitgRjaJ4CObPH4f0SGRetA5wpIemu+mWzp ce2A== X-Received: by 2002:a05:6830:2692:b0:7e9:e808:e9c1 with SMTP id 46e09a7af769-7ee78c42561mr4564556a34.8.1785068611885; Sun, 26 Jul 2026 05:23:31 -0700 (PDT) Received: from localhost ([144.24.58.22]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7ee29db0d23sm9853507a34.1.2026.07.26.05.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2026 05:23:31 -0700 (PDT) From: Jinchao Wang To: Masami Hiramatsu , Peter Zijlstra , Thomas Gleixner , Steven Rostedt , x86@kernel.org Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Ian Rogers , Mathieu Desnoyers , Tony Luck , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-edac@vger.kernel.org, Jinchao Wang Subject: [PATCH 3/3] HWBP: Add modify_local_hw_breakpoint_addr() API Date: Sun, 26 Jul 2026 20:22:32 +0800 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: <178476143000.26117.9810509272687580410.stgit@devnote2> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Masami Hiramatsu (Google)" Add modify_local_hw_breakpoint_addr() to update only the watched address of an installed hardware breakpoint on the local CPU without releasing and reserving its hardware slot. This is available when the architecture selects CONFIG_HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR. The caller must provide an installed local event and a valid address, and update other CPUs separately. Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Jinchao Wang --- arch/Kconfig | 8 ++++++++ arch/x86/Kconfig | 1 + include/linux/hw_breakpoint.h | 6 ++++++ kernel/events/hw_breakpoint.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index fa7507ac8e13..bea383408e32 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -457,6 +457,14 @@ config HAVE_MIXED_BREAKPOINTS_REGS Select this option if your arch implements breakpoints under the latter fashion. +config HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR + bool + depends on HAVE_HW_BREAKPOINT + help + Select this if the architecture can modify the address of an + installed hardware breakpoint on the local CPU without releasing + and reserving its hardware slot. + config HAVE_USER_RETURN_NOTIFIER bool diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index bdad90f210e4..09e599f2d0dd 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -246,6 +246,7 @@ config X86 select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS select HAVE_HW_BREAKPOINT + select HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR select HAVE_IOREMAP_PROT select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 select HAVE_IRQ_TIME_ACCOUNTING diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index db199d653dd1..bf65c7fffd99 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -81,6 +81,9 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, void *context); +int modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr); + extern int register_perf_hw_breakpoint(struct perf_event *bp); extern void unregister_hw_breakpoint(struct perf_event *bp); extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events); @@ -124,6 +127,9 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, void *context) { return NULL; } static inline int +modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr) { return -EOPNOTSUPP; } +static inline int register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } static inline void unregister_hw_breakpoint(struct perf_event *bp) { } static inline void diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index 789add0c185a..0b1fc01f1934 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -888,6 +888,36 @@ void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) } EXPORT_SYMBOL_GPL(unregister_wide_hw_breakpoint); +/** + * modify_local_hw_breakpoint_addr - update a local breakpoint address + * @bp: the hwbp perf event for this CPU + * @addr: the new address for @bp + * + * Update only the address of an installed breakpoint on the local CPU without + * releasing and reserving its hardware slot. The caller must update other CPUs. + * Return 0, or -EOPNOTSUPP if the architecture does not support this operation. + */ +#ifdef CONFIG_HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR +int modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr) +{ + lockdep_assert_irqs_disabled(); + + counter_arch_bp(bp)->address = addr; + bp->attr.bp_addr = addr; + arch_modify_local_hw_breakpoint_addr(bp, addr); + + return 0; +} +#else +int modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr) +{ + return -EOPNOTSUPP; +} +#endif +EXPORT_SYMBOL_GPL(modify_local_hw_breakpoint_addr); + /** * hw_breakpoint_is_used - check if breakpoints are currently used * -- 2.53.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FB4A3ACF02 for ; Sun, 26 Jul 2026 12:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785068885; cv=none; b=WgBdee2tp/rOBbFQbD/8uYC573+TDwywYjPj4RfYnbmN3GUypdhc8cCxJlFgHUe0l1Mo/BN386oerjuPpA/Ty16CErfz8SWZlinaneG0cv+Rv8cuODir8RmVUV1Nzee0MbSc/xsZhyHn9uMSkiQvcBn7eMxp9pryrIKdqswjGCA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785068885; c=relaxed/simple; bh=ccoLxXcVCAekN8O5gMgLDn7JdMt0YqOZNIb3h7ismYM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hggVjnzfqO5kFa87U8GgGBk4aXpTSBiTTytdhP/tWnF+ZNVemg/Ly0t7LPI08+gBJSLbvcR9jt6Ey0s2v/T6mL1kSwHvippo7DXbw/usg7bBS/aCy7/t06BVrls0wtkFN8cG5a1Ndvo9O2+z61g0iCfeWNNomXZ69JqfXZye0ZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Tg7jnPX6; arc=none smtp.client-ip=209.85.161.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tg7jnPX6" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-6ab0223a3d3so400555eaf.3 for ; Sun, 26 Jul 2026 05:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785068880; x=1785673680; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0oVEf5/gSaD+al9Pequ5m2rnhtlrO+HvKfH1QE9WEkQ=; b=Tg7jnPX6RNUuQtCqe7gQKvbuo6uI020ByxoFuHeWAOAbYS2hErTrgS+Y5/0dCezjUm 4ZjOowfwrAVKNIPjgVoA9ToN3jH3hEoJ5tkfiJO4E9CSdo6KqN+sYAG/ebAw/JxgELUK kd1eS6MMcRyadlidxsg3eNfvNojzxbvxtwfu5VC3Pyz3wXwkD1lJ3CkFN5d0u4NPaFaT Lw8qlYf1ui294361LVlQsrRUI4N+aa9McMklfjIXCHvVCRzDoaw/nM00TSHC4FU4WDNH NtyA/7aBT0XWbAm5mWaJLEhe9Y5d+E934uLS3TLjBz6lzTUNgSkGFwX8D7Y3NSHxM4Ed tzuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785068880; x=1785673680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0oVEf5/gSaD+al9Pequ5m2rnhtlrO+HvKfH1QE9WEkQ=; b=FNQDGyHpHaXPJMkS87dTn0ZQVKfJwyQkKRym2T3Zh4jQ38DWE04+xnlTB9S/7mlZkW RMQP8j/3NBomB6/AxJMpVIwlZO4hRhGcXu8z86pHcQvx8f+g6rdcVartOnkNjeNmU/DB m2L6gVTKAlC1T7pl2NsobTguDrAAWzBrBeHQYnOf+wVJp6MS6IfL5bJbQa8QAsi9rn+h 9/4PF8jHlRZo8tOW9iakeMpdkeuIVc5b5KjmG6+OwxGlYZlayiIl76k3R9ipqn7T+u3D cqeDf8LonFrrJJNP9LnSihVSgRC/LZVK7ZJC7A8y3iDc0jGaiQzoTeWzjl36KCK3cgrp ibmw== X-Forwarded-Encrypted: i=1; AHgh+RrPdtg3/oHFIK0kWYRZmYL2M2BtIlsmFtIQGB57GPgc02lzgqxCXbtocmItn4/RNAqAvqmXHsbAeFb97x4=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9nm0UuHPRSEvxeLzqps0cvsrLksFI3DVSvK8hFNsmimYt4TMl dL7D88ZBewguWUliC0jF9xbXr2q3PMDMDVecioq+HEaq1NvXrgUZOV45 X-Gm-Gg: AR+sD12BxMZlMTvvOzhBBxeuLqXwgUyy9ZiaEvfLL1RuJt+48nOEasfaZ7GTGH4T40d 8aBD4fS2vBMPGxVs5K/kjFlae4gAXyuNlQDSJ82IueFXafHVsMyYp/dkFWiH/Wd4MVWp9g7+fs8 A55vGvh0OvXJe6LDrh6IsKJYf6qlZQyGr3lUOvU5JwhWIP/gWhIYUY7v+FGHoXd5sgfaOPiQAd+ dGkym8vaadt8Xplk8FGF+xKpqRkneHZlKKpHr63q136pJ2tVgvpR6R7tOVTNyBQfpkKLb741U1n GIoXWlUx8FlhcngSXZrK59OX2kvJfsYpbLu/E/lWZHuGmnZEhDYkeL8zOrCASCRA+PDf/UODoFj HB2d74hSy31iAo3eVNJbKbVBTeUCu7JrRVuCRyz6uSgEMnXr8H8cxiS439B2QtcFIHWoBLrh3FI B5vet4rxk7tWST X-Received: by 2002:a05:6820:1caa:b0:6aa:df4e:e373 with SMTP id 006d021491bc7-6aaffadde25mr3034725eaf.62.1785068880306; Sun, 26 Jul 2026 05:28:00 -0700 (PDT) Received: from localhost ([144.24.58.22]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6aaf973036dsm3324321eaf.14.2026.07.26.05.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2026 05:27:59 -0700 (PDT) From: Jinchao Wang To: Masami Hiramatsu , Peter Zijlstra , Thomas Gleixner , Steven Rostedt , x86@kernel.org Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Ian Rogers , Mathieu Desnoyers , Tony Luck , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-edac@vger.kernel.org, Jinchao Wang Subject: [PATCH 3/3] HWBP: Add modify_local_hw_breakpoint_addr() API Date: Sun, 26 Jul 2026 20:27:45 +0800 Message-ID: X-Mailer: git-send-email 2.53.0 In-Reply-To: References: <178476143000.26117.9810509272687580410.stgit@devnote2> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: <20260726122745.qKxnEKeljpLRpZ5k5lKVc3QvTZMRZSvaw3dLH7URIgg@z> From: "Masami Hiramatsu (Google)" Add modify_local_hw_breakpoint_addr() to update only the watched address of an installed hardware breakpoint on the local CPU without releasing and reserving its hardware slot. This is available when the architecture selects CONFIG_HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR. The caller must provide an installed local event and a valid address, and update other CPUs separately. Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Jinchao Wang --- arch/Kconfig | 8 ++++++++ arch/x86/Kconfig | 1 + include/linux/hw_breakpoint.h | 6 ++++++ kernel/events/hw_breakpoint.c | 30 ++++++++++++++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/arch/Kconfig b/arch/Kconfig index fa7507ac8e13..bea383408e32 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -457,6 +457,14 @@ config HAVE_MIXED_BREAKPOINTS_REGS Select this option if your arch implements breakpoints under the latter fashion. +config HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR + bool + depends on HAVE_HW_BREAKPOINT + help + Select this if the architecture can modify the address of an + installed hardware breakpoint on the local CPU without releasing + and reserving its hardware slot. + config HAVE_USER_RETURN_NOTIFIER bool diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index bdad90f210e4..09e599f2d0dd 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -246,6 +246,7 @@ config X86 select HAVE_FUNCTION_TRACER select HAVE_GCC_PLUGINS select HAVE_HW_BREAKPOINT + select HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR select HAVE_IOREMAP_PROT select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 select HAVE_IRQ_TIME_ACCOUNTING diff --git a/include/linux/hw_breakpoint.h b/include/linux/hw_breakpoint.h index db199d653dd1..bf65c7fffd99 100644 --- a/include/linux/hw_breakpoint.h +++ b/include/linux/hw_breakpoint.h @@ -81,6 +81,9 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, void *context); +int modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr); + extern int register_perf_hw_breakpoint(struct perf_event *bp); extern void unregister_hw_breakpoint(struct perf_event *bp); extern void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events); @@ -124,6 +127,9 @@ register_wide_hw_breakpoint(struct perf_event_attr *attr, perf_overflow_handler_t triggered, void *context) { return NULL; } static inline int +modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr) { return -EOPNOTSUPP; } +static inline int register_perf_hw_breakpoint(struct perf_event *bp) { return -ENOSYS; } static inline void unregister_hw_breakpoint(struct perf_event *bp) { } static inline void diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index 789add0c185a..0b1fc01f1934 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -888,6 +888,36 @@ void unregister_wide_hw_breakpoint(struct perf_event * __percpu *cpu_events) } EXPORT_SYMBOL_GPL(unregister_wide_hw_breakpoint); +/** + * modify_local_hw_breakpoint_addr - update a local breakpoint address + * @bp: the hwbp perf event for this CPU + * @addr: the new address for @bp + * + * Update only the address of an installed breakpoint on the local CPU without + * releasing and reserving its hardware slot. The caller must update other CPUs. + * Return 0, or -EOPNOTSUPP if the architecture does not support this operation. + */ +#ifdef CONFIG_HAVE_MODIFY_LOCAL_HW_BREAKPOINT_ADDR +int modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr) +{ + lockdep_assert_irqs_disabled(); + + counter_arch_bp(bp)->address = addr; + bp->attr.bp_addr = addr; + arch_modify_local_hw_breakpoint_addr(bp, addr); + + return 0; +} +#else +int modify_local_hw_breakpoint_addr(struct perf_event *bp, + unsigned long addr) +{ + return -EOPNOTSUPP; +} +#endif +EXPORT_SYMBOL_GPL(modify_local_hw_breakpoint_addr); + /** * hw_breakpoint_is_used - check if breakpoints are currently used * -- 2.53.0