Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2284075rwb; Wed, 30 Nov 2022 04:58:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HoBPeX47L/p9d66q8Ba/sotkj9CSEnQMJyLrw2XQnn7csseSv3IrkV3xUEIaYhX4iS4YI X-Received: by 2002:a17:902:c194:b0:189:6995:660c with SMTP id d20-20020a170902c19400b001896995660cmr24869415pld.48.1669813127488; Wed, 30 Nov 2022 04:58:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669813127; cv=pass; d=google.com; s=arc-20160816; b=qCz4OxXyc5kXAms8ls0Wg8BIbwxfB7ZpHXrjQrc4XHbaO3Lhzmvq0v0w72THE18Cil /P1tlCd8EFBBYyJq6g6pXiCj5ptWrTRoq5RSwVgDW8MwOdXmiYeX+EVy4Gd+7RyVnHrr CCdB6ldZjf2XZZoGLMSpMqJv95sDK+kphAk72QuezZ+S+E0bb7Vk+x7xmYzh3n+vE8tb kBFxrP/yO7e3jabcl5H6p//fX6xqEx1qhDPrKy5442L0lI8CxGeiqovWEaDPSwWC0HP+ fdM5zP/OVGTRzy2OptRmlgi1oTcjUjlW9uRRRL8RfGmEdpV2d9j76EF2W4W9azAHBHnZ HXaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-id:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature; bh=7xJD/cejjWxC5vbuDPxPZsic/EGS8IpYIXahGFDby50=; b=XvMDjQe+lVWt9oC5Q7I6lQnl6Wcka4RIRYGGXmOn/f3qAkWDJd2DXMQIOCeYf13Hp2 iDEmggy0lpiV2nwyfd00MV+cT9XBQGuoCsdwRO3Ni8DkllATO9Mir2RjYwfR7arrWx2W CnSb9KtX6Hq8Ilu4nMCLqHhpspmauc7BZs8vm4DjoryOYydC2pNwbHE6NFzLvUmvOoGV hjoizveTVLWCRZCKlz4MlfaGFJAuj2HnKTVcTNcofdFql2NQ/G8h2HO97T4vjvrMkIHz JDJkrRRz1of+gOw7UUYoOoN8zWl6VDGCo7uXJ2z8OkPMnDgYJG2jpXeL81tiuvKCEPv7 Q/wA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b="E5hGyJ/F"; arc=pass (i=1 spf=pass spfdomain=meta.com dkim=pass dkdomain=meta.com dmarc=pass fromdomain=meta.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=meta.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k1-20020a170902c40100b001896ba683acsi1216855plk.460.2022.11.30.04.58.36; Wed, 30 Nov 2022 04:58:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@meta.com header.s=s2048-2021-q4 header.b="E5hGyJ/F"; arc=pass (i=1 spf=pass spfdomain=meta.com dkim=pass dkdomain=meta.com dmarc=pass fromdomain=meta.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=meta.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234131AbiK3MIk (ORCPT + 84 others); Wed, 30 Nov 2022 07:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233510AbiK3MIf (ORCPT ); Wed, 30 Nov 2022 07:08:35 -0500 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A82A01EECF; Wed, 30 Nov 2022 04:08:09 -0800 (PST) Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AUAKop2027405; Wed, 30 Nov 2022 04:08:09 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : mime-version; s=s2048-2021-q4; bh=7xJD/cejjWxC5vbuDPxPZsic/EGS8IpYIXahGFDby50=; b=E5hGyJ/F9jhSkxHh3B9AaXANZovUVrdLMdcxZk4WXzgW4C1zkPIvjNaMvC+keuvQMvjA /ifvnoUc7BDEkw7OYDDmHslIsIKVAH/P0S2uvr4nKBRHQ06ZLQ9P7TCEAePeOpWqa2Fw bqxc9f4vTGL7eyQDZ/2GksRyfhAN/TRzS1IbtIVcGUX/Bu1Y8ZBNZUsKKilWjxZnqgsK SNoRFXrKqfOT4vuOPYO6cfLjhTeUQs4Ez0aL6TwBO0ETEJVRdj8Behj7zGdH6+FzOk4Y jW0DKZxguxyorhgNJ4G3chCJ4g0MAyeKSGSbUzSN1tcxUgJWOT4pScrqvsRBxpgbxkNo 1g== Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2173.outbound.protection.outlook.com [104.47.55.173]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3m65bcgrux-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 30 Nov 2022 04:08:09 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QRtP9KQB28CuB4+pXV2bTzNY054sLMkaSVrj1X3Tq82UIaNMdGIIzfEaSAlRWPRQX4NcAPSvvrrJkeDf6cE7q+qTewGHT8K0ODHiqgbxy9KEwoXwEbnNUTjPSnFKeIl64UnViURe4vbwIQEaTkWj3kLYzxKHalX2hYB6TPJ8Hk4Iqm3BFkbWZdDcU0IspmfPp8smxBBIbEJjDfiIgSfR9+Pi/A+yWGl4bRJ7ooUm7+2pWCWEPFBWWH0K+J//ol/3zsZpuWEk6bkgazrdXZr4paC5n313vJQ1e2o1DnJJcm0L+A6+rLkhkakS5lVrvOcE7UR0+325pKFuoJ5vMbY9Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7xJD/cejjWxC5vbuDPxPZsic/EGS8IpYIXahGFDby50=; b=JSnet/4cByS53NJIeePfyHmQaWLpCaIHvUyd8xXMF02XYjN/Z8k+Swbq15swD8lQGq439ljVH5rEcIK2egMwHvEKj4bkq4bhQ27eCWC9jQPW2OHi22ZX27gnytvu9Doxcwnyag9Y9qzkd84nQvCsLfLbLZk7YZLfFCFZruquxf0Dh2Jc48CTAghCtZMjnPuSeCYnKLQdrEPK8U6IbQrGRGHoKRN8/i+coZapl2EWJ0OpyTZVl/6mpfRb4pud6lInoTdVbKyVzEZnsnJ8mst5VaR/v1L0t+KKW8HIpKZugL8P3C12ttIDlF+78eD271EJxg9dyoXizJdFSs0e4de9Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=meta.com; dmarc=pass action=none header.from=meta.com; dkim=pass header.d=meta.com; arc=none Received: from PH0PR15MB5191.namprd15.prod.outlook.com (2603:10b6:510:14c::12) by MWHPR15MB1711.namprd15.prod.outlook.com (2603:10b6:301:4d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.20; Wed, 30 Nov 2022 12:08:05 +0000 Received: from PH0PR15MB5191.namprd15.prod.outlook.com ([fe80::d410:da8a:ad1b:a6bc]) by PH0PR15MB5191.namprd15.prod.outlook.com ([fe80::d410:da8a:ad1b:a6bc%7]) with mapi id 15.20.5857.023; Wed, 30 Nov 2022 12:08:05 +0000 From: Tomislav Novak To: Catalin Marinas CC: Alexei Starovoitov , Will Deacon , "bpf@vger.kernel.org" , "linux-perf-users@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Mark Rutland , Russell King , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo Subject: Re: [PATCH] hw_breakpoint: fix single-stepping when using bpf_overflow_handler Thread-Topic: [PATCH] hw_breakpoint: fix single-stepping when using bpf_overflow_handler Thread-Index: AQHYz4xNSRmGp4l1PUKwAHNo0kfo465AaXSAgBQ5MQCAAxHJAIAAFUKA Date: Wed, 30 Nov 2022 12:08:05 +0000 Message-ID: References: <20220923203644.2731604-1-tnovak@fb.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH0PR15MB5191:EE_|MWHPR15MB1711:EE_ x-ms-office365-filtering-correlation-id: 15739534-1f9d-4ce3-d296-08dad2cb89a3 x-fb-source: Internal x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: T0Idj9HwulHjORUiT0L5gtOvwNeJAOaI+sWQ+3N6djZ1myPwjOFHOVvrTYmo7vAcPaP0I6FElC5eyT6YsLa0hj+W/bvxPSXnJUfz6rWv1FpkY/hEWejsyhApOHuwMUbEX0xUPYKf82FwRBCjsOSGJqDM0ZJWa8fChbwqG6wi8JNpqv+CIeYaiKoLInItGoeVquipGOj5uxtoBCEQKTzwp20XR9hftDoc1TDVfRar35+BD4TfFWhXwM+DHkGt2vzr/Wgb4qLequfgJp3mnP6MJCld95kpVKfcxuOIsYV9iollmJ1zJO9s9YE85wSq/ztbnrPe7osXXfVZHjYCFuwUPDpNUZFGGlFY1Wcr1eeIcgDeLSosUc2d/WsNfwgqvIWkOAzE2973xsfpHHuX5nN+SzLcCryM/BMkUQ2ucSe0Ljy/OtoOoTA6ox1j1+VlOh7tbSFWTtiEpN36NMXgTyGzrpJ2zF0ONQqUxrCR+yux13foraSIdL7QhtznmKaevZMGcUpAgNWCH0B2nvfAGZPDbjrjVY8sU4ewyWYdy8dtvbmMOyuIzNE0z8FFzzAkrbyraJyn1Uw2rB6a6F/zHXbZ3fP+X9BdRlO6QZyGY6UO9n+hA6ljnLkKRRIPq69z1PfBJwxjJ2XgwEXd7fX7Pp1/R9rzrZfkS0HlAbpXwyrCxTNeQo6ytXmGLGOLcnjMNtiH x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR15MB5191.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(396003)(136003)(376002)(346002)(451199015)(26005)(316002)(122000001)(9686003)(86362001)(71200400001)(54906003)(6916009)(6506007)(38100700002)(6512007)(83380400001)(2906002)(66446008)(4326008)(8676002)(64756008)(66556008)(76116006)(91956017)(66476007)(5660300002)(8936002)(66946007)(41300700001)(186003)(66899015)(6486002)(478600001)(38070700005)(7416002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?0hvGsWffbitqHW7L6ypV7mBJVIKtp5jrwa3kkVeDiLtWI/r2Is68cSDXJUIQ?= =?us-ascii?Q?QN9LyCnUrVvja8zho9qmSxL7KnDiMOvggpCmckl1MLRqRpG04+oslYi4uYyi?= =?us-ascii?Q?N1iDxgz728j0mY8vrQZVLkAXnLYZUybBbDdC58TzLUf9EO4SrIG3Eu+23sYo?= =?us-ascii?Q?aPho3+pF3AbScEmITFp3BPbwBQ37ftB282fobixwOLfJ6ysdGH/llcjjH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zOfAtOOEcS210NS1Upp2TcsqD?= =?us-ascii?Q?BUjFKflTmSsw5rR7yVaZ16RVwSACFXMdyzyfa2/ShdejiYcwEK5G0tqTlfEa?= =?us-ascii?Q?NrMbOuRuoxc1LM3DJmwYcQTqRf7eHBWIL++hc+rzqWeMi+YFQFj58XYvJjd+?= =?us-ascii?Q?CJ3tUEbxvbAZICzSfQqXJIR5UQzJaZEmKkLA8hby3TkEA0iFxcZ/GN/EV33/?= =?us-ascii?Q?nzzlwReLjTrIKSgJ0dcCIwP7SGHj8i2xbmGykVkksS4VftpyLJr39Bxlj5E1?= =?us-ascii?Q?d7dgwBFXB/VPDWivP9mc47qLgpOfsUQTTj6NWznyxLQNU3nK3Y32NIZ+Whfl?= =?us-ascii?Q?YXifcIFQpxSUpyKwtVftL2ElRFz/g1LwOYiBsQUcYD+Ugg5JPXY0JpNsSzjA?= =?us-ascii?Q?NkRazafgbqb+ZQSawmGbspDlTzre8SjfpG4wanDxlxad1SLKqo4Vrlfd3MzK?= =?us-ascii?Q?vVO9/t+et7Mm1b/4whR0DbdsKZw4AeVWs9F168Q1?= Content-Type: text/plain; charset="us-ascii" Content-ID: <769DAE826B69074EA165DF465CAE5966@namprd15.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: meta.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR15MB5191.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15739534-1f9d-4ce3-d296-08dad2cb89a3 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Nov 2022 12:08:05.5130 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: fbtDyFeYS4Movh6RiHPfd7ExHW3FtGIP7YYyt/7yaU1XL5L8YblggYYaVI0obIC6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR15MB1711 X-Proofpoint-GUID: bq5bkCpqx1EOFG2oTVxqTN2pJW0YiPW5 X-Proofpoint-ORIG-GUID: bq5bkCpqx1EOFG2oTVxqTN2pJW0YiPW5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-30_04,2022-11-30_02,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 30, 2022 at 10:51:56AM +0000, Catalin Marinas wrote: > On Mon, Nov 28, 2022 at 11:59:37AM +0000, Tomislav Novak wrote: > > On Tue, Nov 15, 2022 at 03:09:37PM +0000, Catalin Marinas wrote: > > > > On ARM platforms is_default_overflow_handler() is used to determine if > > > > hw_breakpoint code should single-step over the watchpoint trigger or > > > > let the custom handler deal with it. > > > > > > > > Attaching a BPF program to a watchpoint replaces the handler with > > > > bpf_overflow_handler, which isn't recognized as a default handler so we > > > > never step over the instruction triggering the data abort exception (the > > > > watchpoint keeps firing): > > > > > > > > # bpftrace -e 'watchpoint:0x10000000:4:w { printf("hit\n"); }' ./wp_test > > > > Attaching 1 probe... > > > > hit > > > > hit > > > > hit > > > > [...] > > > > > > > > (wp_test performs a single 4-byte store to address 0x10000000) > > > > > > > > This patch replaces the check with uses_default_overflow_handler(), which > > > > accounts for the bpf_overflow_handler() case by also testing if the handler > > > > invokes one of the perf_event_output functions via orig_default_handler. > > > > > > > > Signed-off-by: Tomislav Novak > > > > Tested-by: Samuel Gosselin # arm64 > > > > --- > > > > arch/arm/kernel/hw_breakpoint.c | 8 ++++---- > > > > arch/arm64/kernel/hw_breakpoint.c | 4 ++-- > > > > include/linux/perf_event.h | 22 +++++++++++++++++++--- > > > > 3 files changed, 25 insertions(+), 9 deletions(-) > > > > > > It looks like this slipped through the cracks. I'm fine with the patch > > > but could you split the arm and arm64 parts in separate patches? Unless > > > rmk acks it and we can take the patch through the arm64 (or perf) tree. > > > > Thanks for reviewing! > > > > Given the changes in the arch-independent perf_event.h, I think merging it > > as a single commit may be easiest (assuming rmk acks it). > > > > Alternatively I could move arm changes into a separate patch, keeping arm64 > > and perf_event.h in this one (possibly splitting out the latter into its own > > commit). One that's merged, the arm patch could be submitted to linux-arm. > > What would you prefer? > > Actually, arch/arm*/kernel/hw_breakpoint.c come under the ARM PMU > profiling, so no need to split the patch. It may need an ack from the > generic perf maintainers for include/linux/perf.h. Good point! I realized I've neglected to CC perf_event maintainers (sorry!), doing so now. -- T.