Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3164949imw; Mon, 11 Jul 2022 03:18:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIyOgF33iIL059gxncGiAZkhmIycuI06TIhs/1UdoH3eM6xnmzIPcp6Afum/XaWSsq9/Xi X-Received: by 2002:a05:6402:270b:b0:43a:d89e:8c2d with SMTP id y11-20020a056402270b00b0043ad89e8c2dmr4103478edd.413.1657534737980; Mon, 11 Jul 2022 03:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657534737; cv=none; d=google.com; s=arc-20160816; b=GH8OiJmWMFmuoMBTI7NKP+FDxoj1GCLOwzlSjb08JEzy2Pdn8p4luHIh636IEU0QMi 5NFxKRgweVyaV5sMCzo9+oU+y2SkBP9MbRunA0ImO3R38ZaZ2MbaegJNyEY0DWm4PIeT 2h8la1hVKWvObbXkWINtVUGOr3CbvEK3VJ5hY5ztQ/rwJoyqZm9kV/P7g/CpCRNQaIwI ZXb9V2GkNfXOL7P0EkZgL6pUJwaaSN2D946w8mIhp0IMxHLcEhmm8NZlOqAs57tZ5e/E yifW0FWCKui6oxxdhDqkw6D0jPOvVX+0h2omq0jTOkvl7RYCqHWvWo1AQw2Sh9b+e7KC rxAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=8WUVUIQ2lUCCeRlW36gA0A9STrt+sFiLO7F4boIU5Ms=; b=jvsu0QAHTTvOcM5bJTOWXPO1J+1tAqi65Q1Md4Thfpt0nLdALr6fB8dprckcCdxWTW vx9/LeO4sSXldSBV0yBDC0u+0lQDI54C5+KMZrqh+jhthcGQ2wM2WcYcxk+1XUBptmwr 3EpgC5qrsABNyQC35nAGtcqxFtkI20Fnpxfgd9NFv1O71XYBGR/FSmiLeovt6HFoKQ09 4SuWhFtEJ2hPvHIpCAKG3F2kuhLRlMttmcqSb58nY2RCBuFD6Kw8/FNkbPIqBA2OD9MZ VNZiI/K5282/XMOFAp2s8bAaJbrM5lhxb1VTor0bA5KUW+MQOMXd4k47+zG1xSHw4OAB vgAA== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m22-20020aa7c2d6000000b004396bf4d279si9238147edp.593.2022.07.11.03.18.33; Mon, 11 Jul 2022 03:18:57 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233852AbiGKJxd (ORCPT + 99 others); Mon, 11 Jul 2022 05:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbiGKJxF (ORCPT ); Mon, 11 Jul 2022 05:53:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4C6A7ADD51; Mon, 11 Jul 2022 02:25:26 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9865415BF; Mon, 11 Jul 2022 02:25:25 -0700 (PDT) Received: from [10.57.43.82] (unknown [10.57.43.82]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E3E43F73D; Mon, 11 Jul 2022 02:25:22 -0700 (PDT) Message-ID: <8d282e87-c1c8-f7a0-631b-8d569c2154a6@arm.com> Date: Mon, 11 Jul 2022 10:25:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 2/8] perf evsel: Do not request ptrauth sample field if not supported Content-Language: en-US To: Vince Weaver , Andrew Kilroy Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, acme@kernel.org, Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Tom Rix , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org, llvm@lists.linux.dev References: <20220704145333.22557-1-andrew.kilroy@arm.com> <20220704145333.22557-3-andrew.kilroy@arm.com> From: James Clark In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 06/07/2022 17:01, Vince Weaver wrote: > On Mon, 4 Jul 2022, Andrew Kilroy wrote: > >> A subsequent patch alters perf to perf_event_open with the >> PERF_SAMPLE_ARCH_1 bit on. >> >> This patch deals with the case where the kernel does not know about the >> PERF_SAMPLE_ARCH_1 bit, and does not know to send the pointer >> authentication masks. In this case the perf_event_open system call >> returns -EINVAL (-22) and perf exits with an error. >> >> This patch causes userspace process to re-attempt the perf_event_open >> system call but without asking for the PERF_SAMPLE_ARCH_1 sample >> field, allowing the perf_event_open system call to succeed. > > So in this case you are leaking ARM64-specific info into the generic > perf_event_open() call? Is there any way the kernel could implement this > without userspace having to deal with the issue? Hi Vince, The alternative to this change is just to call it "PERF_SAMPLE_POINTER_AUTH_MASK" and then it's not Arm specific, it's just that only Arm implements it for now. This is definitely an option. But if no platform ever implements something similar then that bit is wasted. The intention of adding "PERF_SAMPLE_ARCH_1" was to prevent wasting that bit. But as you say, maybe making it arch specific isn't the right way either. I wouldn't say the perf_event_open call is currently generic though, lots of it already requires knowledge of the current platform, and searching for 'x86' in the docs for it gives 10 matches. > > There are a few recent ARM64 perf_event related patches that are pushing > ARM specific interfaces into the generic code, with the apparent > assumption that it will just be implemented in the userspace perf tool. > However there are a number of outside-the-kernel codebases that also use > perf_event_open() and it seems a bit onerous if all of them have to start > adding a lot of extra ARM64-specific code, especially because as far as I Because pointer auth is a hardware feature, other tools have no choice but to implement this if they do Dwarf based stack unwinding. There is no way around that. The pointers are stored mangled and they don't make sense without masking them. GDB has already implemented support for it. If they don't do Dwarf based stack unwinding then they can carry on as they are and everything will still work. > can tell there haven't been any documentation patches included for the > Makefile. We plan to update the docs for the syscall, but it's in another repo, and we'll wait for this change to be finalised first. I'm not sure what you mean about the Makefile? Thanks James > > The other recent change that's annoying for userspace is the addition of > the ARM-specific /proc/sys/kernel/perf_user_access that duplicates > functionality found in /sys/devices/cpu/rdpmc > > Vince Weaver > vincent.weaver@maine.edu