Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2447634pxb; Tue, 23 Feb 2021 07:18:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCVzsX/vv0HYmdCa5AVbhkkrHVYMSWVE+Ny9hM/9KqTJC8uI2qrrTZ8z4pUZlrDeQjcFkL X-Received: by 2002:a17:906:3acc:: with SMTP id z12mr27600901ejd.494.1614093533607; Tue, 23 Feb 2021 07:18:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614093533; cv=none; d=google.com; s=arc-20160816; b=Xs1A4wupMhULlKQNeXZNRbhGupGohtgMrVY7XaDbYSwRSgwFWQNkQ098Rn6TngMNHr KHqIIuIDljz8EXWteqPqTUGXWxHZZOYKiv0+FSzseg/oWBTnO84Lcs7QKvyWJ46mlXXH sAZ1dgUlrt/zNnzQMYrym4AhXnIaRXJy3N7QZi2eTRdwYv3kWcFvE/Yv0s4+rlIta0SL CdnWdA8+eAmSMwPueBBxSoXb6MSAWwiXbpI0sNBGX1Ld1/meQAOPaTfcL+XNztZHjEBd 7dcVXyMwPXkqPPrx0eUgV8MZDZXlO5GYIuNLJ59huTHoukub3lFApxXZCBs8uxIe8Wx/ Btqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=3yeydPNUBbnBa03B4CtFFI71u/VogiWMTrnYPrUvA5o=; b=vfTnkOqlvhdKR2w9NzJBbq5xjHRdDNUI8+hKkA/l5BHh/x3pl5G3HsgeV6c/9LvgNB XZeWEajoENSD2Ps3YFqVX917CS+EjauF+SQHk4TNg3goKBtYlBcyMN4bBe5HG3irtUpx WCVEPNRxQmYHciShaWzcLTZRbrd6vUtSv6IK0UrCSmXm+c8KV9e6d2XbidoJjIK0WIUV 3V25TjIur/m7soDDO+vPkh/mgAipuGOKfF/52ZoVL3ylgZMrjhPtscn8+lU8Q4pvAzha 6h4qdlWLvo0IuVvIhbuOHvP1ytUQvIHO7XsuR00EsN2uQ2etJ/kDoxDk9Xe3AyHKBTgV EZ8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="uA/OwFba"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v13si4245003edl.282.2021.02.23.07.18.29; Tue, 23 Feb 2021 07:18:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="uA/OwFba"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232834AbhBWPRZ (ORCPT + 99 others); Tue, 23 Feb 2021 10:17:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232342AbhBWPRX (ORCPT ); Tue, 23 Feb 2021 10:17:23 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA926C061574 for ; Tue, 23 Feb 2021 07:16:41 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id k8so7461564qvm.6 for ; Tue, 23 Feb 2021 07:16:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=3yeydPNUBbnBa03B4CtFFI71u/VogiWMTrnYPrUvA5o=; b=uA/OwFba1OXPlE3eec0Lkuteazee/7d9Xd178WLkv5dnu8A92vJ3djvigMQ7jAUU3x nME8FehzY+kcVllN570rvIsKcFTRvTQDbwiIWDA0cQJz1KzNcJZX4h3plHWk+bqaBjZn SvN7Gfc1RxuY/+i/jtrAaPenwBNwNWegEHtOvmo0Vjx+8aRq1Ed96qCOX++Sjt87mB/X GTaVTu2K4unxbuD3deSDB5Gpq8x62S/upY7qcSNNBkfFos/vSWFzs2kFtXbKsusKVwNb 7OlTcPYQlWfPWA0VtuzWC2Oxbe11yZH4qDiRafr6Ymkyv+N7fk7X9ZAaFHxyTMoLW8ij Er2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3yeydPNUBbnBa03B4CtFFI71u/VogiWMTrnYPrUvA5o=; b=iMvDyai8lY5FtPBZTP0dY2PAHYjJbJi5L0U7K45KmmFd8vAgzMhxsV4zUgFyewALOR G68PAQ/SiRztdu22FtIJTerH0mUNgsF5ZZ6DGnQ7kmMmKIW5OyhGtwaWjgHOU3kGdU+q h7QROAzaCBI8FIx9du1NGLdd1iXNPIKddRnEpUGTvkC26HGGc61O2DTiX8khzkisrGdN ecs3nCO/wOMRvvITVClkxK4xF/z174KjMHngv6Mz7gBcNWc54+GkYEFDYXWj5cng86MC tI/ZMFDUnktlM6aLmVu83AINbvYDk8YO+WNjxCzjFRUdYlWoDhNmPPi/pfIFifZeld9F QISA== X-Gm-Message-State: AOAM531+cDarZMeBS4wKCvUNSlqVayN3XvgzCxGxS58LssqzcmlekTzh 0sqPLpnLE4XTAP65PlSIXQk+gfm+gsvtnc7rv3pPfg== X-Received: by 2002:a0c:8304:: with SMTP id j4mr25737289qva.18.1614093400799; Tue, 23 Feb 2021 07:16:40 -0800 (PST) MIME-Version: 1.0 References: <20210223143426.2412737-1-elver@google.com> <20210223143426.2412737-5-elver@google.com> In-Reply-To: From: Dmitry Vyukov Date: Tue, 23 Feb 2021 16:16:29 +0100 Message-ID: Subject: Re: [PATCH RFC 4/4] perf/core: Add breakpoint information to siginfo on SIGTRAP To: Marco Elver Cc: Peter Zijlstra , Alexander Shishkin , Arnaldo Carvalho de Melo , Ingo Molnar , Jiri Olsa , Mark Rutland , Namhyung Kim , Thomas Gleixner , Alexander Potapenko , Al Viro , Arnd Bergmann , Christian Brauner , Jann Horn , Jens Axboe , Matt Morehouse , Peter Collingbourne , Ian Rogers , kasan-dev , linux-arch , linux-fsdevel , LKML , linux-m68k@lists.linux-m68k.org, "the arch/x86 maintainers" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2021 at 4:10 PM 'Marco Elver' via kasan-dev wrote: > > > Encode information from breakpoint attributes into siginfo_t, which > > > helps disambiguate which breakpoint fired. > > > > > > Note, providing the event fd may be unreliable, since the event may have > > > been modified (via PERF_EVENT_IOC_MODIFY_ATTRIBUTES) between the event > > > triggering and the signal being delivered to user space. > > > > > > Signed-off-by: Marco Elver > > > --- > > > kernel/events/core.c | 11 +++++++++++ > > > 1 file changed, 11 insertions(+) > > > > > > diff --git a/kernel/events/core.c b/kernel/events/core.c > > > index 8718763045fd..d7908322d796 100644 > > > --- a/kernel/events/core.c > > > +++ b/kernel/events/core.c > > > @@ -6296,6 +6296,17 @@ static void perf_sigtrap(struct perf_event *event) > > > info.si_signo = SIGTRAP; > > > info.si_code = TRAP_PERF; > > > info.si_errno = event->attr.type; > > > + > > > + switch (event->attr.type) { > > > + case PERF_TYPE_BREAKPOINT: > > > + info.si_addr = (void *)(unsigned long)event->attr.bp_addr; > > > + info.si_perf = (event->attr.bp_len << 16) | (u64)event->attr.bp_type; > > > + break; > > > + default: > > > + /* No additional info set. */ > > > > Should we prohibit using attr.sigtrap for !PERF_TYPE_BREAKPOINT if we > > don't know what info to pass yet? > > I don't think it's necessary. This way, by default we get support for > other perf events. If user space observes si_perf==0, then there's no > information available. That would require that any event type that > sets si_perf in future, must ensure that it sets si_perf!=0. > > I can add a comment to document the requirement here (and user space > facing documentation should get a copy of how the info is encoded, > too). > > Alternatively, we could set si_errno to 0 if no info is available, at > the cost of losing the type information for events not explicitly > listed here. > > What do you prefer? Ah, I see. Let's wait for the opinions of other people. There are a number of options for how to approach this. > > > + break; > > > + } > > > + > > > force_sig_info(&info); > > > } > > > > > > -- > > > 2.30.0.617.g56c4b15f3c-goog > > > > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/CANpmjNP1wQvG0SNPP2L9QO%3Dnatf0XU8HXj-r2_-U4QZxtr-dVA%40mail.gmail.com.