hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/kernel/events/hw_breakpoint.c
....@@ -1,18 +1,5 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
2
- * This program is free software; you can redistribute it and/or modify
3
- * it under the terms of the GNU General Public License as published by
4
- * the Free Software Foundation; either version 2 of the License, or
5
- * (at your option) any later version.
6
- *
7
- * This program is distributed in the hope that it will be useful,
8
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
- * GNU General Public License for more details.
11
- *
12
- * You should have received a copy of the GNU General Public License
13
- * along with this program; if not, write to the Free Software
14
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
- *
163 * Copyright (C) 2007 Alan Stern
174 * Copyright (C) IBM Corporation, 2009
185 * Copyright (C) 2009, Frederic Weisbecker <fweisbec@gmail.com>
....@@ -226,6 +213,15 @@
226213 list_del(&bp->hw.bp_list);
227214 }
228215
216
+__weak int arch_reserve_bp_slot(struct perf_event *bp)
217
+{
218
+ return 0;
219
+}
220
+
221
+__weak void arch_release_bp_slot(struct perf_event *bp)
222
+{
223
+}
224
+
229225 /*
230226 * Function to perform processor-specific cleanup during unregistration
231227 */
....@@ -238,7 +234,7 @@
238234 }
239235
240236 /*
241
- * Contraints to check before allowing this new breakpoint counter:
237
+ * Constraints to check before allowing this new breakpoint counter:
242238 *
243239 * == Non-pinned counter == (Considered as pinned for now)
244240 *
....@@ -283,6 +279,7 @@
283279 struct bp_busy_slots slots = {0};
284280 enum bp_type_idx type;
285281 int weight;
282
+ int ret;
286283
287284 /* We couldn't initialize breakpoint constraints on boot */
288285 if (!constraints_initialized)
....@@ -307,6 +304,10 @@
307304 if (slots.pinned + (!!slots.flexible) > nr_slots[type])
308305 return -ENOSPC;
309306
307
+ ret = arch_reserve_bp_slot(bp);
308
+ if (ret)
309
+ return ret;
310
+
310311 toggle_bp_slot(bp, true, type, weight);
311312
312313 return 0;
....@@ -330,6 +331,8 @@
330331 enum bp_type_idx type;
331332 int weight;
332333
334
+ arch_release_bp_slot(bp);
335
+
333336 type = find_slot_idx(bp_type);
334337 weight = hw_breakpoint_weight(bp);
335338 toggle_bp_slot(bp, false, type, weight);