Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2894807pxt; Mon, 9 Aug 2021 11:19:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy35YvdkMXgcm7eVSLu6pbGVX8oxwgijLXCBMLzlzqrpp/Sx063b/BcmITE2swHccJmba4d X-Received: by 2002:a5d:824e:: with SMTP id n14mr27076ioo.134.1628533199795; Mon, 09 Aug 2021 11:19:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628533199; cv=none; d=google.com; s=arc-20160816; b=baz8wmix6YXQq23hP6GXNIGWgwMxuFLRGvq8Jkdgcl7qYpNsQnD/aY87voDfRYOdy1 yMHuCnWbtMf5c5JLax7SE9KdhDpc8LoPL5fB+Si+157vjZtqKccZ32QRSyi6XhUnRasn YO2EHNz6iSlwI3HKkmI5t8ru4oH+lCVAUu9ui0PAsE0DKplsFnhnikQhztZhAtTXhUxe AjAr7d8iGmn2ARfdSo2eCDViq+18/KohTx2O0JOfcyUrPYRVtpMb6fXp/nIL84sdw1+F tUYfwNuetNt/DZGjCn8sFDJ2BWGaUoWOs+wUaKydxSkHNVJuqd3El4birkd+3mWjXcj4 Tzlw== 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=qbVrjTG6KtD1ShxcQyr/Iy25T6noL4kVDyEjmN56a1Y=; b=yjCAoRuRkOEa2Hl5mnMNg1DHxMfWS/jOuh4znXUV7k8hvKXE5VcSyyDUwLy1Wnw46o oTh2ZdBmVwimN+72G6e1+2L1OwybYC6j7cF7QSe76QbzCOaSyOKs42DbOuB7nevoFqIM HtSgT8dIoeyROXC3tuZlaxZBHNbUJAfbFTWK1kFSZ7tTmz6IQu30uEELcY0c7D0eNhm/ nz4y9mZN9ihEue+jMhMKoIowqVel19ViPnQUQtdZr853zrRixY7hPAVBeedKLWKdpENv l6VAELlxicVS62dhLqE0VT4kUkCVdu61CyYlFta2O7xpdcoKK44QIheaYaYS/DNLaYvG Z0Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=aASeeFZA; 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 l8si18325613jap.104.2021.08.09.11.19.48; Mon, 09 Aug 2021 11:19:59 -0700 (PDT) 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=aASeeFZA; 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 S233837AbhHISSN (ORCPT + 99 others); Mon, 9 Aug 2021 14:18:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231357AbhHISSM (ORCPT ); Mon, 9 Aug 2021 14:18:12 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34591C0613D3 for ; Mon, 9 Aug 2021 11:17:51 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id t9so35806701lfc.6 for ; Mon, 09 Aug 2021 11:17:51 -0700 (PDT) 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=qbVrjTG6KtD1ShxcQyr/Iy25T6noL4kVDyEjmN56a1Y=; b=aASeeFZAXdWDc9jRFXU5zoyBl7CgTDnaf+pOucZ3iLDiLUPtAPEl/QKWWyF0b5u3dZ lGkweHcBqNzo+sB1qCGqEZEHnvqAewZPwx71Nj731fJyOn/J2UABTGzuMdpVaKPvEbVP WwTfT5DvC8C2uDtoseUxCOJgO3iCuPY+Bf/mcQhei/syL4VVtFxN4NgEw5X9gUtxFt2/ alhUjKqnwy+mEdDwBW7NXWCcLnMFhq6nJgSk4Zs9eafqMxsyJr0BJO2hMsjIQodzgaH1 v4S3vPWklSmfSftWHLbDTIwwmBnyzt7kIImP4D2fU3ydXxjgufcFNJauZAl5dPEYNbkr b/5g== 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=qbVrjTG6KtD1ShxcQyr/Iy25T6noL4kVDyEjmN56a1Y=; b=Hi9nCcm2n8V9orEIjE3grfKvDhf2UiLFbyTJO3XCJHRR//pRK0qqQuGN8ZCOFZwYuW P01RA3lS+nANR//Tq8a6sD9u//IOcG9xZp25oQ4HLmAp1OQ7PBk/kzwa9XTQYbaqkHI0 Mfe63kdgT9L6bcz88Weq1lu/AM6x+C6QkZQM5pm4TkZI6wNO0MIX/2kzgt0244ns8/Pf r634a10FJtvmBf2apv2v9gKy0oHBYRhAz/cHAMfiX54h1h1UUFVfJSCvUWUUN4hKtjBT 5iFvdZ3VjyooeV1ZmxxNXN/o3H8UVgMG+FbdkBCn2ih2QB44YfmL3X+WovuY2i9og77Y M3Pg== X-Gm-Message-State: AOAM533+Z7sDcrK+gM6Nqzqa0tssrz0HTqB5Z3o/AWp7wY0IKKhPKf5c nZJobl3jt4J9jA9gvNrE2QqF3WqZ5yvk9KrY78Gc0w== X-Received: by 2002:a05:6512:3fa8:: with SMTP id x40mr3338313lfa.0.1628533069113; Mon, 09 Aug 2021 11:17:49 -0700 (PDT) MIME-Version: 1.0 References: <20210809152651.2297337-1-maz@kernel.org> <20210809152651.2297337-14-maz@kernel.org> <87im0ebi9m.wl-maz@kernel.org> In-Reply-To: <87im0ebi9m.wl-maz@kernel.org> From: Oliver Upton Date: Mon, 9 Aug 2021 11:17:38 -0700 Message-ID: Subject: Re: [PATCH 13/13] arm64: Add CNT{P,V}CTSS_EL0 alternatives to cnt{p,v}ct_el0 To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Rutland , Daniel Lezcano , Thomas Gleixner , Peter Shier , Raghavendra Rao Ananta , Ricardo Koller , Will Deacon , Catalin Marinas , Linus Walleij , kernel-team@android.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 9, 2021 at 11:11 AM Marc Zyngier wrote: > > On Mon, 09 Aug 2021 17:42:00 +0100, > Oliver Upton wrote: > > > > On Mon, Aug 9, 2021 at 8:48 AM Marc Zyngier wrote: > > > > > > CNTPCTSS_EL0 and CNTVCTSS_EL0 are alternatives to the usual > > > CNTPCT_EL0 and CNTVCT_EL0 that do not require a previous ISB > > > to be synchronised (SS stands for Self-Synchronising). > > > > > > Use the ARM64_HAS_ECV capability to control alternative sequences > > > that switch to these low(er)-cost primitives. Note that the > > > counter access in the VDSO is for now left alone until we decide > > > whether we want to allow this. > > > > What remains to be figured out before we add this to the vDSO (and > > presumably advertise to userspace through some standard convention)? > > We need to understand what breaks if we runtime-patch the VDSO just > like we do with the rest of the kernel. To start with, the debug > version of the shared object is not the same as the object presented > to the process. Maybe that's not a problem, but I would tend to err on > the side of caution. I would too, but there sadly are instances of Linux patching *user* memory already (go look at how KVM/x86 handles the VMCALL/VMMCALL instruction). But yes, I would much prefer the debug vDSO correspond to the actual instructions. > An alternative suggested by Ard was to have a separate function > altogether for the counter access and an ifunc mapping to pick the > right one. > Hmm, this does sound promising. > > It would be nice to skip the trap handler altogether, unless there's a > > can of worms lurking that I'm not aware of. > > The trap handlers are only there to work around errata. If you look at > the arch timer code, you will notice that there is a bunch of SoCs and > CPUs that do not have a reliable counter, and for which we have to > trap the virtual counter accesses from userspace (as well as the > VDSO). > > On sane platforms, userspace is free to use the virtual counter > without any trap. /facepalm I was about 2 cups of coffee short when writing this :) Thanks! -- Oliver