Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6C55C25B76 for ; Wed, 5 Jun 2024 03:35:06 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEhPy-0000tP-V1; Tue, 04 Jun 2024 23:34:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEhPv-0000t4-Hi for qemu-devel@nongnu.org; Tue, 04 Jun 2024 23:34:27 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sEhPt-0007Eu-Ak for qemu-devel@nongnu.org; Tue, 04 Jun 2024 23:34:27 -0400 Received: by mail-pg1-x534.google.com with SMTP id 41be03b00d2f7-6c55e3d2740so346674a12.0 for ; Tue, 04 Jun 2024 20:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1717558463; x=1718163263; darn=nongnu.org; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=V5VAYHFU492pz04tgjhSTWj5MtVeGwNywFm4FrzJrfs=; b=dUdc0h9C0Fpa3FBfXmi3ugKC2imdwB89uQrewON7q/DIBl7mGyk2BBxLEpdvAGJzWJ VYB26Lz8xFoM+I3aBRC5bqmX5ht04fdzLbAV6b6qF9ocRY8LovcHx7UHFN/BKYRBeCwr sIfeVtzrOmLJnJ1JN5ZBkPc3X7lsGAT4Cb57ljzpj7zDE6mI2xV+rI3CpeoECawNh2dG qASnrL0eOywFYTpO+/gx037bGKE2tMMhHrOuEQT2WLr0uqu8kF+elusWYf9De0mbDB6+ +e9hT8QwId+PHy7hxBS/XFdVOxbuJoZqYEeIeZpw7nuBrayIXBkbdtdpToeSMgUWxREp 6YxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717558463; x=1718163263; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=V5VAYHFU492pz04tgjhSTWj5MtVeGwNywFm4FrzJrfs=; b=rR8jiVpWBujRORVzgcOYxPcdZQs/piYGeeh3+bOLJNOWwtR/+ldao8t2NZWWO1OjwD Tu7P6WC46byD2zRP/OreTOSgLEBBNHJGxBTXRy3uGY5t0v7hXrSfzZj1ZoFDVo2YUyaf Y1TqEOO0O/Kj7LIlEW30cLOW/irxo+ZQDvYteiy5YWTJVZ8xP8ZleeOVj/S/pJCkKV/D 3q70Jm7AlbYmPzUYFUgE1ioZFl39cLo6aWxIclIyF/W1L570dkxJqPbFEJe9iYIhfV2r Wlaty7+EicDpR3mkmHKG5I6SlE880NtJeRvHID2t5ziXYjzsh2v5Ls743SmGXugF8KJ3 XYTQ== X-Forwarded-Encrypted: i=1; AJvYcCVrNq1/YhanuUhO4xNpNHfMZhDSGYA+T1BXLDFbaj3aB15PXZ39Cf2LPJ+bemPYGO0mlnCuHFKvkWbUYCSw4AYEy3Yew+A= X-Gm-Message-State: AOJu0Yyw8WSFHcEZuy5OH1KqoKz/X2gWJF68NpZOSCD8lCQe6aOvOjdd ZIEIfGw1AsDnHLlQgKNw4eLm7oSVshM7Cgu3JUZNkrcadhWRyk2AQWNq3yr6/5TKjuZmP0RPJNg iI38= X-Google-Smtp-Source: AGHT+IEqb9vtxMBSEwBbZUNtsCqXE5xyBD+LbeP2TQNQe51kDTXcSlkrUEgYd+rXk4ufEJWZeI3x5w== X-Received: by 2002:a17:90b:1e11:b0:2ab:8324:1b47 with SMTP id 98e67ed59e1d1-2c27cc3d5fdmr2232235a91.15.1717558463222; Tue, 04 Jun 2024 20:34:23 -0700 (PDT) Received: from [192.168.100.252] (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c28067b192sm309929a91.30.2024.06.04.20.34.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 04 Jun 2024 20:34:22 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------WYIS1LWe0NRq2HXlYwrkjJfU" Message-ID: Date: Wed, 5 Jun 2024 11:34:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 0/6] target/riscv: Add support for Control Transfer Records Ext. To: Beeman Strong Cc: Rajnesh Kanwal , alistair.francis@wdc.com, apatel@ventanamicro.com, atishp@rivosinc.com, bin.meng@windriver.com, dbarboza@ventanamicro.com, liweiwei@iscas.ac.cn, qemu-devel@nongnu.org, qemu-riscv@nongnu.org, tech-control-transfer-records@lists.riscv.org, zhiwei_liu@linux.alibaba.com References: <20240529160950.132754-1-rkanwal@rivosinc.com> Content-Language: en-US From: Jason Chien In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=jason.chien@sifive.com; helo=mail-pg1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This is a multi-part message in MIME format. --------------WYIS1LWe0NRq2HXlYwrkjJfU Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Thank you for pointing that out. CTR does not use miselect and mireg*. There is no dependency on Smcsrind. I believe the spec needs to be corrected. Chapter 1 states that: Smctr depends on the Smcsrind extension, while Ssctr depends on the Sscsrind extension. Further, both Smctr and Ssctr depend upon implementation of S-mode. Beeman Strong 於 2024/6/5 上午 06:32 寫道: > There is no dependency on Smcsrind, only Sscsrind. > > On Tue, Jun 4, 2024 at 12:29 AM Jason Chien > wrote: > > Smctr depends on the Smcsrind extension, Ssctr depends on the > Sscsrind > extension, and both Smctr and Ssctr depend upon implementation of > S-mode. > There should be a dependency check in > riscv_cpu_validate_set_extensions(). > > Rajnesh Kanwal 於 2024/5/30 上午 12:09 寫道: > > This series enables Control Transfer Records extension support > on riscv > > platform. This extension is similar to Arch LBR in x86 and BRBE > in ARM. > > The Extension has been stable and the latest release can be > found here [0] > > > > CTR extension depends on couple of other extensions: > > > > 1. S[m|s]csrind : The indirect CSR extension [1] which defines > additional > >     ([M|S|VS]IREG2-[M|S|VS]IREG6) register to address size > limitation of > >     RISC-V CSR address space. CTR access ctrsource, ctrtartget > and ctrdata > >     CSRs using sscsrind extension. > > > > 2. Smstateen: The mstateen bit[54] controls the access to the > CTR ext to > >     S-mode. > > > > 3. Sscofpmf: Counter overflow and privilege mode filtering. [2] > > > > The series is based on Smcdeleg/Ssccfg counter delegation > extension [3] > > patches. CTR itself doesn't depend on counter delegation > support. This > > rebase is basically to include the Smcsrind patches. > > > > Due to the dependency of these extensions, the following > extensions must be > > enabled to use the control transfer records feature. > > > > > "smstateen=true,sscofpmf=true,smcsrind=true,sscsrind=true,smctr=true,ssctr=true" > > > > Here is the link to a quick guide [5] to setup and run a basic > perf demo on > > Linux to use CTR Ext. > > > > The Qemu patches can be found here: > > https://github.com/rajnesh-kanwal/qemu/tree/ctr_upstream > > > > The opensbi patch can be found here: > > https://github.com/rajnesh-kanwal/opensbi/tree/ctr_upstream > > > > The Linux kernel patches can be found here: > > https://github.com/rajnesh-kanwal/linux/tree/ctr_upstream > > > > [0]:https://github.com/riscv/riscv-control-transfer-records/release > > [1]:https://github.com/riscv/riscv-indirect-csr-access > > [2]:https://github.com/riscvarchive/riscv-count-overflow/tree/main > > [3]:https://github.com/riscv/riscv-smcdeleg-ssccfg > > > [4]:https://lore.kernel.org/all/20240217000134.3634191-1-atishp@rivosinc.com/ > > > [5]:https://github.com/rajnesh-kanwal/linux/wiki/Running-CTR-basic-demo-on-QEMU-RISC%E2%80%90V-Virt-machine > > > > Rajnesh Kanwal (6): > >    target/riscv: Remove obsolete sfence.vm instruction > >    target/riscv: Add Control Transfer Records CSR definitions. > >    target/riscv: Add support for Control Transfer Records > extension CSRs. > >    target/riscv: Add support to record CTR entries. > >    target/riscv: Add CTR sctrclr instruction. > >    target/riscv: Add support to access ctrsource, ctrtarget, ctrdata > >      regs. > > > >   target/riscv/cpu.c                            |   4 + > >   target/riscv/cpu.h                            |  14 + > >   target/riscv/cpu_bits.h                       | 154 +++++++++ > >   target/riscv/cpu_cfg.h                        |   2 + > >   target/riscv/cpu_helper.c                     | 213 ++++++++++++ > >   target/riscv/csr.c                            | 312 > +++++++++++++++++- > >   target/riscv/helper.h                         |   8 +- > >   target/riscv/insn32.decode                    |   2 +- > >   .../riscv/insn_trans/trans_privileged.c.inc   |  21 +- > >   target/riscv/insn_trans/trans_rvi.c.inc       |  27 ++ > >   target/riscv/op_helper.c                      | 117 ++++++- > >   target/riscv/translate.c                      |   9 + > >   12 files changed, 870 insertions(+), 13 deletions(-) > > > --------------WYIS1LWe0NRq2HXlYwrkjJfU Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Thank you for pointing that out. CTR does not use miselect and mireg*. There is no dependency on Smcsrind. I believe the spec needs to be corrected.

Chapter 1 states that:
Smctr depends on the Smcsrind extension, while Ssctr depends on the Sscsrind extension. Further, both Smctr and Ssctr depend upon implementation of S-mode.

Beeman Strong 於 2024/6/5 上午 06:32 寫道:
There is no dependency on Smcsrind, only Sscsrind. 

On Tue, Jun 4, 2024 at 12:29 AM Jason Chien <jason.chien@sifive.com> wrote:
Smctr depends on the Smcsrind extension, Ssctr depends on the Sscsrind
extension, and both Smctr and Ssctr depend upon implementation of S-mode.
There should be a dependency check in riscv_cpu_validate_set_extensions().

Rajnesh Kanwal 於 2024/5/30 上午 12:09 寫道:
> This series enables Control Transfer Records extension support on riscv
> platform. This extension is similar to Arch LBR in x86 and BRBE in ARM.
> The Extension has been stable and the latest release can be found here [0]
>
> CTR extension depends on couple of other extensions:
>
> 1. S[m|s]csrind : The indirect CSR extension [1] which defines additional
>     ([M|S|VS]IREG2-[M|S|VS]IREG6) register to address size limitation of
>     RISC-V CSR address space. CTR access ctrsource, ctrtartget and ctrdata
>     CSRs using sscsrind extension.
>
> 2. Smstateen: The mstateen bit[54] controls the access to the CTR ext to
>     S-mode.
>
> 3. Sscofpmf: Counter overflow and privilege mode filtering. [2]
>
> The series is based on Smcdeleg/Ssccfg counter delegation extension [3]
> patches. CTR itself doesn't depend on counter delegation support. This
> rebase is basically to include the Smcsrind patches.
>
> Due to the dependency of these extensions, the following extensions must be
> enabled to use the control transfer records feature.
>
> "smstateen=true,sscofpmf=true,smcsrind=true,sscsrind=true,smctr=true,ssctr=true"
>
> Here is the link to a quick guide [5] to setup and run a basic perf demo on
> Linux to use CTR Ext.
>
> The Qemu patches can be found here:
> https://github.com/rajnesh-kanwal/qemu/tree/ctr_upstream
>
> The opensbi patch can be found here:
> https://github.com/rajnesh-kanwal/opensbi/tree/ctr_upstream
>
> The Linux kernel patches can be found here:
> https://github.com/rajnesh-kanwal/linux/tree/ctr_upstream
>
> [0]:https://github.com/riscv/riscv-control-transfer-records/release
> [1]:https://github.com/riscv/riscv-indirect-csr-access
> [2]:https://github.com/riscvarchive/riscv-count-overflow/tree/main
> [3]:https://github.com/riscv/riscv-smcdeleg-ssccfg
> [4]:https://lore.kernel.org/all/20240217000134.3634191-1-atishp@rivosinc.com/
> [5]:https://github.com/rajnesh-kanwal/linux/wiki/Running-CTR-basic-demo-on-QEMU-RISC%E2%80%90V-Virt-machine
>
> Rajnesh Kanwal (6):
>    target/riscv: Remove obsolete sfence.vm instruction
>    target/riscv: Add Control Transfer Records CSR definitions.
>    target/riscv: Add support for Control Transfer Records extension CSRs.
>    target/riscv: Add support to record CTR entries.
>    target/riscv: Add CTR sctrclr instruction.
>    target/riscv: Add support to access ctrsource, ctrtarget, ctrdata
>      regs.
>
>   target/riscv/cpu.c                            |   4 +
>   target/riscv/cpu.h                            |  14 +
>   target/riscv/cpu_bits.h                       | 154 +++++++++
>   target/riscv/cpu_cfg.h                        |   2 +
>   target/riscv/cpu_helper.c                     | 213 ++++++++++++
>   target/riscv/csr.c                            | 312 +++++++++++++++++-
>   target/riscv/helper.h                         |   8 +-
>   target/riscv/insn32.decode                    |   2 +-
>   .../riscv/insn_trans/trans_privileged.c.inc   |  21 +-
>   target/riscv/insn_trans/trans_rvi.c.inc       |  27 ++
>   target/riscv/op_helper.c                      | 117 ++++++-
>   target/riscv/translate.c                      |   9 +
>   12 files changed, 870 insertions(+), 13 deletions(-)
>
--------------WYIS1LWe0NRq2HXlYwrkjJfU--