From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 85A0527FB0C; Tue, 27 May 2025 16:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748365140; cv=none; b=USd3TO8wHW+FRr2FB3PL3YaQrR9l3nUUA6R6HVCoSS7YDegijNmMFuL+g8VZ5153O2wYzWiaG34HPV0Ur69EdiAsNuyeDxDUorfJehvPCcHPlAsZUER0xPMd/kEoZV9quSRqUiGUI//lvXGKb1qDwvIXmENggFr/rJgwxFb4J44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748365140; c=relaxed/simple; bh=TmAZUyNHjrgox8fHCdxEG8x0LJWTKIBhCy0D24hYxd0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rqDSG6eVSXQ7Q2z2TADU5CbMKApWeIqbsHgXRwbHTQAUCwiL5V6L2HW8JmYKvQUnwFLQ22QYQ6jImWUeTxfdnsZS8UoRLmglV5nztHbR5/bIORFq1VE6OOECRu5bHDz21lp3BVIdeSyWEk+BUCoIYW7MwHwVxdkEokqQRO8k0OI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hPgrgP8Y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="hPgrgP8Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6F20C4CEE9; Tue, 27 May 2025 16:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748365140; bh=TmAZUyNHjrgox8fHCdxEG8x0LJWTKIBhCy0D24hYxd0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPgrgP8Y7WvPoPtqkgRvUGyUh1+GBcR+sk50n4/jUlxv9q67oMN20jikwOOf9vNIZ k2z4vtHNsjofKEquNHl5r6LyW8wI1hJqgFDMwJWf6s2/xrCZSa9LNtiOcZK0/l6U63 /mtdAXn6ieFrb7dnr4bVKFOZ5d82iH846IA471JM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Saket Kumar Bhaskar , Ingo Molnar , Marco Elver , Dmitry Vyukov , Ian Rogers , Frederic Weisbecker , Sasha Levin Subject: [PATCH 6.12 249/626] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Date: Tue, 27 May 2025 18:22:22 +0200 Message-ID: <20250527162455.130201263@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250527162445.028718347@linuxfoundation.org> References: <20250527162445.028718347@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Saket Kumar Bhaskar [ Upstream commit 061c991697062f3bf87b72ed553d1d33a0e370dd ] Currently, __reserve_bp_slot() returns -ENOSPC for unsupported breakpoint types on the architecture. For example, powerpc does not support hardware instruction breakpoints. This causes the perf_skip BPF selftest to fail, as neither ENOENT nor EOPNOTSUPP is returned by perf_event_open for unsupported breakpoint types. As a result, the test that should be skipped for this arch is not correctly identified. To resolve this, hw_breakpoint_event_init() should exit early by checking for unsupported breakpoint types using hw_breakpoint_slots_cached() and return the appropriate error (-EOPNOTSUPP). Signed-off-by: Saket Kumar Bhaskar Signed-off-by: Ingo Molnar Cc: Marco Elver Cc: Dmitry Vyukov Cc: Ian Rogers Cc: Frederic Weisbecker Link: https://lore.kernel.org/r/20250303092451.1862862-1-skb99@linux.ibm.com Signed-off-by: Sasha Levin --- kernel/events/hw_breakpoint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/events/hw_breakpoint.c b/kernel/events/hw_breakpoint.c index 6c2cb4e4f48da..8f3f624419aa9 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -950,9 +950,10 @@ static int hw_breakpoint_event_init(struct perf_event *bp) return -ENOENT; /* - * no branch sampling for breakpoint events + * Check if breakpoint type is supported before proceeding. + * Also, no branch sampling for breakpoint events. */ - if (has_branch_stack(bp)) + if (!hw_breakpoint_slots_cached(find_slot_idx(bp->attr.bp_type)) || has_branch_stack(bp)) return -EOPNOTSUPP; err = register_perf_hw_breakpoint(bp); -- 2.39.5