From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20837C4742C for ; Tue, 29 Sep 2020 20:48:10 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B43320738 for ; Tue, 29 Sep 2020 20:48:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bUMhivaI"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="0sSaEX7L" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B43320738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=yy1mBV6fM6aEAu5f6koUdH34qsEB0V+PSNcQwtlhVWw=; b=bUMhivaIFwXEwqUFWeyWoL3eI LmGjDp5OK2GkT6qDRX5txq8WjbBELgZpjU3dbe2tx6yew29lZApmfFN2ZQud8dGcEnMz2CVfh0khT zKr4yG8RB40XDGCCCuragwlx5q6JF204KoqsP6qrDewlzL6dZ8cWYURPNfd+iWiSd69qIcIa/rhNU pg9vHmVGcAuP+5+KWWhqLHxwbHRyaKaGkGcDV0YIiXZhYGizIuTBoCLirbpV05K9L/x+kgNfdRqMx SzMtMoIvX/1hmERJlc9qLkaZvzNcKSj7afdHTtDG0q7LEZwbqbBuWh/OuVwOsSVFYNjI4VIGHLAKO wlQC5n31A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNMWW-0004YH-KJ; Tue, 29 Sep 2020 20:46:56 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNMWT-0004X5-8W for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2020 20:46:54 +0000 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1BD5720774 for ; Tue, 29 Sep 2020 20:46:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601412412; bh=JHw1Uf5slsOiDNTKZL8Fbrvk/TKjzxBGYnnwKlEm5gg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=0sSaEX7L/mAwF2/mcK0erDt3iwi2ndSAx2EDoSq5NIUtHMvFTMsSdEvv3d28pe7Fl 0gHNB/L03tXmgnWQmywMlehku1uM/tC1GCKRrI+vy4K04cSFiSHBbpxt9TzrcxZrm2 FADoiAG4LgPLFKo/WBDiCWWfrp084QUhCC/CKQYI= Received: by mail-ot1-f44.google.com with SMTP id a2so5795112otr.11 for ; Tue, 29 Sep 2020 13:46:52 -0700 (PDT) X-Gm-Message-State: AOAM5330uQFDsvTQI+DvNJWKtwm5PmAQtZxukRbhKG2BfG4R8CGCD1WJ 76bfCEPf9DY5g6/mG4PRZxfU6I28YI0J7DMFgQ== X-Google-Smtp-Source: ABdhPJyfd913FA/oUSPfYTVepgeuEPzJPsvt3+EaI8pfiIXrX2MlunOw0oOWw+PHOFFHwB8bC9eH9CPQ/gI5julmCPk= X-Received: by 2002:a05:6830:1008:: with SMTP id a8mr3762612otp.107.1601412411216; Tue, 29 Sep 2020 13:46:51 -0700 (PDT) MIME-Version: 1.0 References: <20200911215118.2887710-1-robh@kernel.org> <20200911215118.2887710-2-robh@kernel.org> <20200928182601.GA11974@willie-the-truck> <20200929174933.GF14317@willie-the-truck> In-Reply-To: <20200929174933.GF14317@willie-the-truck> From: Rob Herring Date: Tue, 29 Sep 2020 15:46:40 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 01/10] arm64: pmu: Add hook to handle pmu-related undefined instructions To: Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200929_164653_574506_984A41BB X-CRM114-Status: GOOD ( 32.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Ian Rogers , Peter Zijlstra , Catalin Marinas , "linux-kernel@vger.kernel.org" , Arnaldo Carvalho de Melo , Alexander Shishkin , Raphael Gault , Ingo Molnar , Honnappa Nagarahalli , Jonathan Cameron , Namhyung Kim , Jiri Olsa , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Sep 29, 2020 at 12:49 PM Will Deacon wrote: > > On Tue, Sep 29, 2020 at 08:46:46AM -0500, Rob Herring wrote: > > On Mon, Sep 28, 2020 at 1:26 PM Will Deacon wrote: > > > On Fri, Sep 11, 2020 at 03:51:09PM -0600, Rob Herring wrote: > > > > +static int emulate_pmu(struct pt_regs *regs, u32 insn) > > > > +{ > > > > + u32 rt; > > > > + u32 pmuserenr; > > > > + > > > > + rt = aarch64_insn_decode_register(AARCH64_INSN_REGTYPE_RT, insn); > > > > + pmuserenr = read_sysreg(pmuserenr_el0); > > > > + > > > > + if ((pmuserenr & (ARMV8_PMU_USERENR_ER|ARMV8_PMU_USERENR_CR)) != > > > > + (ARMV8_PMU_USERENR_ER|ARMV8_PMU_USERENR_CR)) > > > > + return -EINVAL; > > > > + > > > > + > > > > + /* > > > > + * Userspace is expected to only use this in the context of the scheme > > > > + * described in the struct perf_event_mmap_page comments. > > > > + * > > > > + * Given that context, we can only get here if we got migrated between > > > > + * getting the register index and doing the MSR read. This in turn > > > > + * implies we'll fail the sequence and retry, so any value returned is > > > > + * 'good', all we need is to be non-fatal. > > > > + * > > > > + * The choice of the value 0 is comming from the fact that when > > > > + * accessing a register which is not counting events but is accessible, > > > > + * we get 0. > > > > + */ > > > > + pt_regs_write_reg(regs, rt, 0); > > > > > > Hmm... this feels pretty fragile since, although we may expect userspace only > > > to trigger this in the context of the specific perf use-case, we don't have > > > a way to detect that, so the ABI we're exposing is that EL0 accesses to > > > non-existent counters will return 0. I don't really think that's something > > > we want to commit to. > > > > > > When restartable sequences were added to the kernel, one of the proposed > > > use-cases was to allow PMU access on big/little systems, because the > > > sequence will abort on preemption. Taking that approach removes the need > > > for this emulation hook entirely. Is that something we can rely on instead > > > of this emulation hook? > > > > So back to the RFC version[1]!? That would mean pulling librseq into > > the kernel based on the prior discussion. It doesn't look like that > > has happened yet. > > Yeah, or just don't bother supporting heterogeneous systems with this > for now. But the people are asking for it. :) > > Why not just drop the undef hook? For heterogeneous systems, we > > require userspace to pin itself to cores for a specific PMU. See patch > > 9. If userspace fails to do that, then it gets to keep the pieces. > > Dropping it works too! Great. I asked Mark R to comment in case I'm forgetting some other reason. Rob _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel