Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp752390ybt; Wed, 17 Jun 2020 13:03:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxl+yhkbvRH80gtw0JRypNlgqxhL+P1RvpfVuYjERTh1p3i+uJszothb9WVj5wOAeZuxCQR X-Received: by 2002:a17:906:97cb:: with SMTP id ef11mr793390ejb.69.1592424210241; Wed, 17 Jun 2020 13:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592424210; cv=none; d=google.com; s=arc-20160816; b=jd+f6OrTLH9Lpv/VMrhEqFMzyB/3VWw9/8ihsQtn7169RBUdiI207xiqUkx2vuzJZV C2t5Nif6q61ymcWGnOKyHiW3TUz6xoW9KCHd/iGVBDceiOPQuUO9i6S/6tsM+qSBOxY6 5ZtHl2A2G36xR+wyMZBOdrgJqfF3j7p9ZwHztd7fJStlWxuvJ74bBLcAJexppsamTB1T c9GsKI5GpPU3flXm0LkYXfCtYvKlvOWGB6sr3jMgy11E4oAu0qKIyiwHVeJtTcrPv141 P9Ho9ajSD0wKA/5Ez9yKO/qRCdVS0I8f9QXarIjUxOQMh1Vxg/DvdluS9JyTgzF7WaHl q3mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:date:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=caNCPxuwnsfme3cJQ3yFnZipKvQl8RiDyCwsEjsLsMc=; b=A3Gs5QM1RHn74kyVHmsvRKObj17O8PW3vcyAF3O1u5QFW5rVFjnrd/vjZ2wk7adBzd GFPrg43w0K0XFo/eUmscgg5MnkJ43zM+SnJmVuKqw2XiKUa61b5CT8wFvfHNxH+A7k+K llNyM9ar6vdyk0u7XhlRh2H//Ff/kx5I13852d3FKSUL3paX1BGVFE9xD9lNkyWOhR8j Y7XAr6EERnxTvuqcb1phgoYWBeGaozeYjkuCcBycPAMBcyHz/OpYRADCie+lyO7hbQD5 lS/rXpGR+be+LpztGB17h20Vkl6aTg+Xo5DIx0ZQZ/qPfOvp4c2GdI3tqic+ULCm//My HPvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X27pYeMz; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p4si583638edq.229.2020.06.17.13.03.05; Wed, 17 Jun 2020 13:03:30 -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=@chromium.org header.s=google header.b=X27pYeMz; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726845AbgFQUBL (ORCPT + 99 others); Wed, 17 Jun 2020 16:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgFQUBL (ORCPT ); Wed, 17 Jun 2020 16:01:11 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5D62C06174E for ; Wed, 17 Jun 2020 13:01:09 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id i4so1592091pjd.0 for ; Wed, 17 Jun 2020 13:01:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:content-transfer-encoding:in-reply-to:references :subject:from:cc:to:date:message-id:user-agent; bh=caNCPxuwnsfme3cJQ3yFnZipKvQl8RiDyCwsEjsLsMc=; b=X27pYeMzeBegpSXYr94WQ9cQIx8qfoKI7mRjZFuswG0wtv2Fk0MvxnXTKKZn2wySjq XdXkAxGseiME2d5R6P6OTH3Hu3IXnbw6OaWe4/UQHwh8egU/Zeb/T/Yoa7mgMmoyDvmO Mf5NUUL0VBTx07Qg5Vblr2/bsdgQoz2/oi92w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:content-transfer-encoding :in-reply-to:references:subject:from:cc:to:date:message-id :user-agent; bh=caNCPxuwnsfme3cJQ3yFnZipKvQl8RiDyCwsEjsLsMc=; b=CncqHi6sFSVBvnOVy5ZPNK0Phk/aD/siZTdhTm+sh0Rz3US61JEYPMhuhbHXXrHssG UH42m6FawNy5+xklE7rd0sm68bH7XqzBK/b7zceDPNTRUrHj4yGIn/CJufNUZiT+gWLM RWTSKaPonAJjx6IU2JIo7Ssqc3D1iyLDoXgebbOa3W7ao161Lwl+t+SrloaenKytw7zy pDi8ExvW8v49TchL7DGJyaCNl/soRmXDaus/FzaSTmvVCY+mSl7X9NxI4iXVkXC4RMmt unILpMLG4asoujKqbu+f8oNDJ3tcQHkcrxNOkfjeS1TMbE2PbDYIE2bmav7sme7zicwT 5/LQ== X-Gm-Message-State: AOAM533RMpBYeA4rdnpoIm9/3MwdMJixsztKv3pJxvjdgvj2EnfXYXvV Ce88zW9YMXd4fVSDw8EwJtj6Y+7K3gQ= X-Received: by 2002:a17:90a:ce11:: with SMTP id f17mr654054pju.123.1592424069090; Wed, 17 Jun 2020 13:01:09 -0700 (PDT) Received: from chromium.org ([2620:15c:202:1:fa53:7765:582b:82b9]) by smtp.gmail.com with ESMTPSA id h7sm599873pgg.17.2020.06.17.13.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 13:01:08 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200617113851.607706-2-alexandru.elisei@arm.com> References: <20200617113851.607706-1-alexandru.elisei@arm.com> <20200617113851.607706-2-alexandru.elisei@arm.com> Subject: Re: [PATCH v5 1/7] arm64: perf: Add missing ISB in armv8pmu_enable_event() From: Stephen Boyd Cc: mark.rutland@arm.com, Julien Thierry , Peter Zijlstra , maz@kernel.org, Jiri Olsa , Will Deacon , Arnaldo Carvalho de Melo , Alexander Shishkin , Ingo Molnar , catalin.marinas@arm.com, Namhyung Kim , will@kernel.org, Julien Thierry To: Alexandru Elisei , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Date: Wed, 17 Jun 2020 13:01:07 -0700 Message-ID: <159242406774.62212.13909672383879587787@swboyd.mtv.corp.google.com> User-Agent: alot/0.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Alexandru Elisei (2020-06-17 04:38:45) > Writes to the PMXEVTYPER_EL0 register are not self-synchronising. In > armv8pmu_enable_event(), the PE can reorder configuring the event type > after we have enabled the counter and the interrupt. This can lead to an > interrupt being asserted because the of the previous event type that we 'because the of the' doesn't read properly. > were counting, not the one that we've just enabled. >=20 > The same rationale applies to writes to the PMINTENSET_EL1 register. The = PE > can reorder enabling the interrupt at any point in the future after we ha= ve > enabled the event. >=20 > Prevent both situations from happening by adding an ISB just before we > enable the event counter. >=20 > diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_even= t.c > index 4d7879484cec..ee180b2a5b39 100644 > --- a/arch/arm64/kernel/perf_event.c > +++ b/arch/arm64/kernel/perf_event.c > @@ -605,6 +605,7 @@ static void armv8pmu_enable_event(struct perf_event *= event) > * Enable interrupt for this counter > */ > armv8pmu_enable_event_irq(event); > + isb(); Please add a comment before the isb() explaining the situation. Nobody knows what this is for when reading the code and they don't want to do git archaeology to figure it out.