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 EC5D4221FBB; Mon, 2 Jun 2025 15:10:06 +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=1748877007; cv=none; b=iAYi8zfu7zfZk6HQkWsxde46AQJ6oa+5p6ewpY5B1vo5uzZb/fn/BjkyAl4iGarIsZ8VVIhMxfSM6gbNuKFLKcsDS/g4nh5GdaGdgpDDPJHml5F39/8K42fVjywa19APQZVhAyH7k1E26LVmpmey3gRLa7GYhtNh5r7cLfurWu0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748877007; c=relaxed/simple; bh=4ceOGnpddeSp7IzHzU2s+NDwnl8C9Mzl0tED0Z6XTAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jdq4D0duTcRoclIB0xwa1n6LgApQbzGIdMCxIXpzywX7neb031wT1kMW61X0Jv4G/ZmG9tujB1dGAj1joZBvLKbulgsspCA197v1EgqvcAbrCh1OzNK9V8twlRvJ9s+7A1YlflKuotwcQpdsItfLVuYz45xb7F5fOVtyRF6gBRM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=E8W8BaeP; 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="E8W8BaeP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C29CC4CEEB; Mon, 2 Jun 2025 15:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1748877006; bh=4ceOGnpddeSp7IzHzU2s+NDwnl8C9Mzl0tED0Z6XTAU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E8W8BaePYiMHI0JniDSZ0tZdskz8vZZMR0E2qFkkV34JiCm99kj4WuxruRQlvMHwE WDfoFyi9ruWceMOAvh9+AoBKZk3c6nM19jOXzAJfgnoNE5y8P1er79ussr1WOJdDn7 ovXQ0wxe5Q58A3jzpnfPHtNfGWIR6DCXfRPTsVdU= 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.1 112/325] perf/hw_breakpoint: Return EOPNOTSUPP for unsupported breakpoint type Date: Mon, 2 Jun 2025 15:46:28 +0200 Message-ID: <20250602134324.335711650@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250602134319.723650984@linuxfoundation.org> References: <20250602134319.723650984@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.1-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 c3797701339cb..382a3b04f6d33 100644 --- a/kernel/events/hw_breakpoint.c +++ b/kernel/events/hw_breakpoint.c @@ -978,9 +978,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