Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp97469pxb; Mon, 18 Oct 2021 21:40:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsXTO51+OzGvFFQu4CGI32lpD4Bcg+/RP5UkoBFemFGZBoyao/osdh3EC99xX4H8uSZmb6 X-Received: by 2002:aa7:cd8b:: with SMTP id x11mr51113681edv.384.1634618409363; Mon, 18 Oct 2021 21:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634618409; cv=none; d=google.com; s=arc-20160816; b=YWNYHnx/8Gr9WxtJDodONHk7oKwAgJItZAbi/4qPNK+NV8gAyoXT2pC/8LDMhFDbo1 bOxEah42Im8aIO3XbT5SJNJHobNWlzMQTjI0bCuRCIBk2++YGO9VQRlCppsCV33kpsxe ePTx20GNulaFAfOtpap3itIUCcxFZ02plIh8qNz4FoKUQ+ktkA8V4seeiXGaS2/vcA5H Ns4Srg7dBU1WiJDJKpHx9ce0otN5+BHZNAOjpGoc9VKWfYJ0TleEFPOwcpXI5Z+HC0Ta WgWvm1FWGtu3vR8UmLmuoELI6DUFU59IuzmorMDucTW2ChPKvBBssnR6WiOBuVRLuOgi 5UDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=gosG9DZ5V4Ov8z5A6VHjVBjsXZr8uMyB3IQHK4aPSFs=; b=bCTiM2pH5woyl8UH26tmX8Af/oxwZ3stl4Fgji6de2VWmlI9UpfGQ0qjaxxiExmPDe B78s43HXdgT+FulavS5od0ePq7uXRInXeMf7eP7VbxCrpXBoiHpGM6kkZoG3NepCPDC6 Wiji70hiD7MgYhVC8KBg3INX5ZWcPXZWyEsLkKugTqCZuC8+D365rTIbOz0H73jXAN/Z aLORTdhxpHhDIVdZiIhN4Z2dUifQtqAIVkhFVsQz18bVGfa6WZfl4spGexcCK2Qt4TF5 95cq9kPKYJtJ6y8xT2aCiLV4+FqgNEyNsgtmn/8/O8HccEEnhvv/DT+4LVYlL6kL6TtC i+yg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp24si29098222ejc.400.2021.10.18.21.39.45; Mon, 18 Oct 2021 21:40:09 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229755AbhJSEiq (ORCPT + 99 others); Tue, 19 Oct 2021 00:38:46 -0400 Received: from foss.arm.com ([217.140.110.172]:44286 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229649AbhJSEip (ORCPT ); Tue, 19 Oct 2021 00:38:45 -0400 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 C76D2D6E; Mon, 18 Oct 2021 21:36:32 -0700 (PDT) Received: from [10.163.74.241] (unknown [10.163.74.241]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 442FB3F70D; Mon, 18 Oct 2021 21:36:29 -0700 (PDT) Subject: Re: [PATCH v5 10/15] coresight: trbe: Workaround TRBE errata overwrite in FILL mode To: Suzuki K Poulose , Mathieu Poirier Cc: will@kernel.org, catalin.marinas@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, maz@kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20211014223125.2605031-1-suzuki.poulose@arm.com> <20211014223125.2605031-11-suzuki.poulose@arm.com> <20211018155154.GB3163131@p14s> From: Anshuman Khandual Message-ID: <1dd61f9a-cd55-c9a5-8573-1b6a0327247b@arm.com> Date: Tue, 19 Oct 2021 10:06:28 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/19/21 2:45 AM, Suzuki K Poulose wrote: > On 18/10/2021 16:51, Mathieu Poirier wrote: >> On Thu, Oct 14, 2021 at 11:31:20PM +0100, Suzuki K Poulose wrote: >>> ARM Neoverse-N2 (#2139208) and Cortex-A710(##2119858) suffers from >>> an erratum, which when triggered, might cause the TRBE to overwrite >>> the trace data already collected in FILL mode, in the event of a WRAP. >>> i.e, the TRBE doesn't stop writing the data, instead wraps to the base >>> and could write upto 3 cache line size worth trace. Thus, this could >>> corrupt the trace at the "BASE" pointer. >>> >>> The workaround is to program the write pointer 256bytes from the >>> base, such that if the erratum is triggered, it doesn't overwrite >>> the trace data that was captured. This skipped region could be >>> padded with ignore packets at the end of the session, so that >>> the decoder sees a continuous buffer with some padding at the >>> beginning. The trace data written at the base is considered >>> lost as the limit could have been in the middle of the perf >>> ring buffer, and jumping to the "base" is not acceptable. >>> We set the flags already to indicate that some amount of trace >>> was lost during the FILL event IRQ. So this is fine. >>> >>> One important change with the work around is, we program the >>> TRBBASER_EL1 to current page where we are allowed to write. >>> Otherwise, it could overwrite a region that may be consumed >>> by the perf. Towards this, we always make sure that the >>> "handle->head" and thus the trbe_write is PAGE_SIZE aligned, >>> so that we can set the BASE to the PAGE base and move the >>> TRBPTR to the 256bytes offset. >>> >>> Cc: Mike Leach >>> Cc: Mathieu Poirier >>> Cc: Anshuman Khandual >>> Cc: Leo Yan >>> Reviewed-by: Mathieu Poirier >>> Signed-off-by: Suzuki K Poulose >>> --- >>> Changes since v2: >>>   - Updated the ASCII art to include better description of >>>     all the steps in the work around >>> Change since v1: >>>   - Updated comment with ASCII art >>>   - Add _BYTES suffix for the space to skip for the work around. >>> --- >>>   drivers/hwtracing/coresight/coresight-trbe.c | 169 +++++++++++++++++-- >>>   1 file changed, 158 insertions(+), 11 deletions(-) >>> >>> diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c >>> index 314e5e7374c7..b56b166b2dec 100644 >>> --- a/drivers/hwtracing/coresight/coresight-trbe.c >>> +++ b/drivers/hwtracing/coresight/coresight-trbe.c >>> @@ -16,6 +16,7 @@ >>>   #define pr_fmt(fmt) DRVNAME ": " fmt >>>     #include >>> +#include >> >> Here too I get a checkpatch warning... >> > > That is a false alarm. I guess that warns for including > linux/cpufeature.h? It is a bit odd, we include this > for the arm64 cpucaps, not the generic linux feature It is a bit odd, I saw that too. > checks. (They are used for "loading modules" based > on "features" which are more like ELF HWCAPs). Should be renamed as or something similar instead to differentiate it from the generic as they are not related. Also, probably this warning could be avoided. > > As such I chose to ignore it. > > Suzuki