From patchwork Mon Oct 25 19:44:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Patra X-Patchwork-Id: 1545950 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=owazzBaT; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.a=rsa-sha256 header.s=dkim.wdc.com header.b=jh5jfDDg; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HdQQx4skZz9shn for ; Tue, 26 Oct 2021 06:45:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=L1x306H5WkKdKcr2/UeIDBjlng5wS1aJuW43yzdBG0s=; b=owazzBaTEn0Rz+ 4Zg1r6q6WK4U9Xlcv49BNKySA18vEnCQNbx5hT2RxCIzqkoyXjdQw10hXRidDYHthDJs3SdBojB1B RXy/dEuRDUvXfJJb+bpxren7fwFTcKruT5G17icmjM9CRSHJjF+VvtYKfTX5MUw/sMT2pecCpvKmW 7UEPo+cxfbVlY3/4FTsYqPZNOXaKDsei5RDw1bjnihZiCpJtC+OVAQF8x0lz9Zb0rM0IrJU1fgLeO PGcwsZvKX4vM3WwegKE9/9e0r/YTVZLcEBEhsjPf9bnvD/MHAIz4W4CuNwtWsLv1U9+2GyNJafIYl iOpJOcu9/CfAa1uJliGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf5u7-00HTI9-20; Mon, 25 Oct 2021 19:45:07 +0000 Received: from esa2.hgst.iphmx.com ([68.232.143.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mf5u3-00HTFZ-U5 for opensbi@lists.infradead.org; Mon, 25 Oct 2021 19:45:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1635191103; x=1666727103; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=MRA5zsQJayANAJ1UqSl8q3T7rzo//V4C+7M2NXZtGWk=; b=jh5jfDDgpjrAO1+/JhUDkuPCTzCeNvPm96m8AE4gIrOLN7gDCBpxrdEJ 02d5xfkUC8HtlnoO2l78uTAU+WWh1EjSHRepZpJuvE1L5qEYrvYn6WDE6 +8tmLd3pMbNE618TfbyoFrrMFfQQlPHP5XGB6s9u2rb22jYWR9LMXNKJ3 aDe5eMatHsm9MsHzl0GaqFs27GG6NhEOzrP34IPuGCKC9RbSc+602p1ur TCiBD8Imn/4kupEc7o7MBzmgaqT3gfgglImoTHIY3aVdsaiHXRRyNfFkX onLj4TSlwSL0GmkbR9R+/JSTZNARiOVd5R7B7FUQy7YybpOPkVtCemTPn A==; X-IronPort-AV: E=Sophos;i="5.87,181,1631548800"; d="scan'208";a="287682473" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 26 Oct 2021 03:45:01 +0800 IronPort-SDR: MN/wNm4kK/+0mAeMFUUmlOQNHcJf7Eoz7jl2wJu8vfuj0Sf5jFp/0mbjb4a2bMDZewH6rg6nXq wlcFyVMhs+4jRNTyu5qbrkoRyl/m8LnNAR0hmOJx4Iub67uteX0IwHLAHBQoPKUk/qzy9iGC6W PZAh2RCiPtNRwNasC1yprGEwmZPykAtUE8l5+uaRnGXJhyPld5kDQd/E2+w06RcG6Cn6KVFKfd m7J+JlE0KtWFW7JtwMFnLPrVw8G4A1aJuz565qVRqlxEj3CHx11xtncbByOLWHeFTcIdo1JbGc f0dYTJz5MDX1cKuUAYYbXbg3 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2021 12:20:32 -0700 IronPort-SDR: 7tmpsYvtJdLkvhgna4nU5PA7KdrGOWjaOjT7RO5NRkN225dVADZjcUOUS64JXv2+HbOCw7IVzt Z6xqAvjsffjHJP31KeojKBsN9cfB5SQrlB0BEvI5e4U+Lpp6ZMKzJk3+izEetKd2rSzIWHoRNj J5VmMiS8fzZ+bdj42mYHVWDepkSDsMp2RRR86qkRSNf4N8R9WFVmNfPD2O0uAQgRY7a9A5ULYv SEtXcs8cNkAVATCCzoop99ZmtCVbTS153W27Y+CIpXyJPdwNbOoJau+B7eJ/+T8Hxw0jgoUsFJ K5E= WDCIronportException: Internal Received: from unknown (HELO hulk.wdc.com) ([10.225.167.27]) by uls-op-cesaip02.wdc.com with ESMTP; 25 Oct 2021 12:45:02 -0700 From: Atish Patra To: opensbi@lists.infradead.org Cc: Atish Patra , anup.patel@wdc.com Subject: [PATCH v2 00/10] Sscof extension support Date: Mon, 25 Oct 2021 12:44:45 -0700 Message-Id: <20211025194455.232828-1-atish.patra@wdc.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_124504_055865_B4EB665C X-CRM114-Status: GOOD ( 12.19 ) X-Spam-Score: -2.5 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The Sscofpmf extension [1] ('Ss' for Privileged arch and Supervisor-level extensions, and 'cofpmf' for Count OverFlow and Privilege Mode Filtering) allows the perf like tool to handle overflow interru [...] Content analysis details: (-2.5 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [68.232.143.124 listed in list.dnswl.org] 0.0 SPF_NONE SPF: sender does not publish an SPF Record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The Sscofpmf extension [1] ('Ss' for Privileged arch and Supervisor-level extensions, and 'cofpmf' for Count OverFlow and Privilege Mode Filtering) allows the perf like tool to handle overflow interrupts and filtering support. This series implements all the bits required to support "Sscof" extension and few other fixes. This series can be found at github[4] as well. It has been tested with Linux kernel patches[3] for different hardware/firmware events on Qemu. This patch requires QEMU support series[2] to work. As the Qemu did not support mhpmevent/mhpmcounter before this series, these changes are not backward compatible to avoid code churn. Anybody who wants to use perf must include Qemu, OpenSBI, Linux kernel patches. Tested on both Qemu and HiFive unmatched. Changes from v1->v2: 1. Addressed all the comments on v1. 2. Relaxed the mcountinhibit restriction for PMU extension enablement. 3. Delete the interrupt node in DT if sscof extension is not present. [1] https://drive.google.com/file/d/171j4jFjIkKdj5LWcExphq4xG_2sihbfd/edit https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc [2] https://github.com/atishp04/qemu/tree/riscv_pmu_v3 [3] https://github.com/atishp04/linux/tree/riscv_pmu_v4 [4] https://github.com/atishp04/opensbi/tree/pmu_sscofpmf_v2 Atish Patra (10): riscv: Add new CSRs introduced by Sscofpmf extension lib: sbi: Use csr_read/write_num for mhpmevent[h] csrs as well lib: sbi: Detect SSCOF extension at run time lib: sbi: Delegate PMU counter overflow interrupt to S mode lib: sbi: Support sscof extension in OpenSBI lib: sbi: Always enable access for all counters lib: sbi: Allow programmable counters to monitor cycle/instret events lib: sbi: Reset the mhpmevent value upon counter reset lib: sbi: Counter info width should be zero indexed lib: sbi: Enable PMU extension for platforms without mcountinhibit include/sbi/riscv_encoding.h | 60 ++++++++++ include/sbi/sbi_hart.h | 4 +- include/sbi/sbi_pmu.h | 1 + lib/sbi/riscv_asm.c | 13 ++ lib/sbi/sbi_ecall_pmu.c | 10 +- lib/sbi/sbi_hart.c | 36 +++--- lib/sbi/sbi_pmu.c | 225 ++++++++++++++++++++++++++--------- lib/utils/fdt/fdt_pmu.c | 4 + 8 files changed, 273 insertions(+), 80 deletions(-) --- 2.31.1