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 62607CAC598 for ; Wed, 17 Sep 2025 01:41:39 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uyhAh-0004Yr-Px; Tue, 16 Sep 2025 21:41:23 -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 1uyhAc-0004Os-OF; Tue, 16 Sep 2025 21:41:19 -0400 Received: from [115.124.30.98] (helo=out30-98.freemail.mail.aliyun.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uyhAQ-0007vH-4q; Tue, 16 Sep 2025 21:41:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1758073224; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:From; bh=haZp8VNoaezTAg6Zh1rZ7qYo9JwKw7CSWvchNkA7fHM=; b=bGVUjMpe2WI95pRdsiemrf7Dge5zUWe5N07ojShzXVMi3gmJol281r73hVGFWwZM/kYnmkvXzsNEUlgGc2fYLoA4vCjFT5XkINDcbEtxuJwcJBYgdOeomNRpRtLe7Dgb2Ir2cXCq4OnUvaalvo1X7lUGYiR234SNrlzwfLCtqe4= Received: from 30.166.64.187(mailfrom:zhiwei_liu@linux.alibaba.com fp:SMTPD_---0WoAfjNg_1758073222 cluster:ay36) by smtp.aliyun-inc.com; Wed, 17 Sep 2025 09:40:22 +0800 Content-Type: multipart/alternative; boundary="------------hOTlUqcrM0fKov1MZwH51DHx" Message-ID: <192bf4d1-f519-4303-9636-e6d572971553@linux.alibaba.com> Date: Wed, 17 Sep 2025 09:40:21 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 0/5] target/riscv: Implement SMSDID and SMMPT extension To: Daniel Henrique Barboza , qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, palmer@dabbelt.com, alistair.francis@wdc.com, liwei1518@gmail.com References: <20250909132533.32205-1-zhiwei_liu@linux.alibaba.com> <1d82761a-a968-467b-96ca-427bca7edc65@ventanamicro.com> Content-Language: en-US From: LIU Zhiwei In-Reply-To: <1d82761a-a968-467b-96ca-427bca7edc65@ventanamicro.com> X-Host-Lookup-Failed: Reverse DNS lookup failed for 115.124.30.98 (deferred) Received-SPF: pass client-ip=115.124.30.98; envelope-from=zhiwei_liu@linux.alibaba.com; helo=out30-98.freemail.mail.aliyun.com X-Spam_score_int: -166 X-Spam_score: -16.7 X-Spam_bar: ---------------- X-Spam_report: (-16.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@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-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org This is a multi-part message in MIME format. --------------hOTlUqcrM0fKov1MZwH51DHx Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 9/16/25 8:49 PM, Daniel Henrique Barboza wrote: > Hi! > > On 9/9/25 10:25 AM, LIU Zhiwei wrote: >> This patch set introduces support for the RISC-V Smmpt (Supervisor >> Domain Access Protection) extension. It only includes two >> sub-extensions: >> SMSDID and SMMPT. >> >> This patch set implements the v0.3.4 version of Smmpt >> (https://github.com/riscv/riscv-smmtt/releases/tag/v0.3.4). >> >> As there are newer SMMPT specification versions, this patch set is >> not intend for merging. > > I'm not sure I understood. Do you mean this patch set isn't supposed > to be > merged even after review? > Hi Daniel, Thanks for the follow-up. My primary goal is to have this feature merged eventually. I marked this version as "not for merging" because I'm aware it's based on an older specification, and I plan to update it to the latest one. However, if the community finds this specific version (v0.3.4) useful for current development, such as for CoVE or other ongoing work, I am open to having it merged as is. In any case, I will continue to work on an implementation aligned with the newest specification. I would greatly appreciate any review comments or feedback on the current approach. Best regards, Zhiwei > > Daniel > >> >> The implementation is broken down into a series of logical steps: >> >> Patch 1 adds the fundamental definitions for the Smmpt extension, >> including >> new CSRs (mmpt, msdcfg), their bit-field layouts, and the corresponding >> CPU >> configuration flags (ext_smmpt, ext_smsdid). >> >> Patch 2 introduces the core logic for Memory Protection Table (MPT) >> lookups. >> It includes a new file, riscv_smmpt.c, which implements the multi-level >> table walk to determine permissions for a given physical address. >> >> Patch 3 integrates the MPT permission checks into the main MMU and TLB >> handling pathways. This ensures that both page table walks and final >> data accesses are subject to Smmpt protection rules. >> >> Patch 4 adds support for the new fence instructions defined by the Smmpt >> extension, specifically `mfence.spa` and `minval.spa`. >> >> Patch 5 enables smmpt and smsdia extendion. >> >> With this series, QEMU can now model systems that utilize the Smmpt >> extension for enhanced memory security. >> >> LIU Zhiwei (5): >>    target/riscv: Add basic definitions and CSRs for SMMPT >>    target/riscv: Implement core SMMPT lookup logic >>    target/riscv: Integrate SMMPT checks into MMU and TLB fill >>    target/riscv: Implement SMMPT fence instructions >>    target/riscv: Enable SMMPT extension >> >>   target/riscv/cpu.c                            |   4 + >>   target/riscv/cpu.h                            |   9 +- >>   target/riscv/cpu_bits.h                       |  27 ++ >>   target/riscv/cpu_cfg_fields.h.inc             |   2 + >>   target/riscv/cpu_helper.c                     |  81 +++++- >>   target/riscv/csr.c                            |  83 ++++++ >>   target/riscv/insn32.decode                    |   2 + >>   .../riscv/insn_trans/trans_privileged.c.inc   |  30 ++ >>   target/riscv/meson.build                      |   1 + >>   target/riscv/pmp.h                            |   3 + >>   target/riscv/riscv_smmpt.c                    | 273 ++++++++++++++++++ >>   target/riscv/riscv_smmpt.h                    |  38 +++ >>   12 files changed, 548 insertions(+), 5 deletions(-) >>   create mode 100644 target/riscv/riscv_smmpt.c >>   create mode 100644 target/riscv/riscv_smmpt.h >> > --------------hOTlUqcrM0fKov1MZwH51DHx Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 9/16/25 8:49 PM, Daniel Henrique Barboza wrote:
Hi!

On 9/9/25 10:25 AM, LIU Zhiwei wrote:
This patch set introduces support for the RISC-V Smmpt (Supervisor
Domain Access Protection) extension. It only includes two sub-extensions:
SMSDID and SMMPT.

This patch set implements the v0.3.4 version of Smmpt
(https://github.com/riscv/riscv-smmtt/releases/tag/v0.3.4).

As there are newer SMMPT specification versions, this patch set is
not intend for merging.

I'm not sure I understood. Do you mean this patch set isn't supposed to be
merged even after review? 


Hi Daniel,

Thanks for the follow-up.

My primary goal is to have this feature merged eventually. I marked this version as "not for merging" because I'm aware it's based on an older specification, and I plan to update it to the latest one.

However, if the community finds this specific version (v0.3.4) useful for current development, such as for CoVE or other ongoing work, I am open to having it merged as is.

In any case, I will continue to work on an implementation aligned with the newest specification. I would greatly appreciate any review comments or feedback on the current approach.

Best regards,
Zhiwei


Daniel


The implementation is broken down into a series of logical steps:

Patch 1 adds the fundamental definitions for the Smmpt extension,
including
new CSRs (mmpt, msdcfg), their bit-field layouts, and the corresponding
CPU
configuration flags (ext_smmpt, ext_smsdid).

Patch 2 introduces the core logic for Memory Protection Table (MPT)
lookups.
It includes a new file, riscv_smmpt.c, which implements the multi-level
table walk to determine permissions for a given physical address.

Patch 3 integrates the MPT permission checks into the main MMU and TLB
handling pathways. This ensures that both page table walks and final
data accesses are subject to Smmpt protection rules.

Patch 4 adds support for the new fence instructions defined by the Smmpt
extension, specifically `mfence.spa` and `minval.spa`.

Patch 5 enables smmpt and smsdia extendion.

With this series, QEMU can now model systems that utilize the Smmpt
extension for enhanced memory security.

LIU Zhiwei (5):
   target/riscv: Add basic definitions and CSRs for SMMPT
   target/riscv: Implement core SMMPT lookup logic
   target/riscv: Integrate SMMPT checks into MMU and TLB fill
   target/riscv: Implement SMMPT fence instructions
   target/riscv: Enable SMMPT extension

  target/riscv/cpu.c                            |   4 +
  target/riscv/cpu.h                            |   9 +-
  target/riscv/cpu_bits.h                       |  27 ++
  target/riscv/cpu_cfg_fields.h.inc             |   2 +
  target/riscv/cpu_helper.c                     |  81 +++++-
  target/riscv/csr.c                            |  83 ++++++
  target/riscv/insn32.decode                    |   2 +
  .../riscv/insn_trans/trans_privileged.c.inc   |  30 ++
  target/riscv/meson.build                      |   1 +
  target/riscv/pmp.h                            |   3 +
  target/riscv/riscv_smmpt.c                    | 273 ++++++++++++++++++
  target/riscv/riscv_smmpt.h                    |  38 +++
  12 files changed, 548 insertions(+), 5 deletions(-)
  create mode 100644 target/riscv/riscv_smmpt.c
  create mode 100644 target/riscv/riscv_smmpt.h


--------------hOTlUqcrM0fKov1MZwH51DHx--