* [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt
@ 2026-04-14 11:02 fangyu.yu
2026-04-14 11:02 ` [PATCH v2 1/2] iommu/riscv: Advertise Svpbmt support to generic page table fangyu.yu
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: fangyu.yu @ 2026-04-14 11:02 UTC (permalink / raw)
To: joro, will, robin.murphy, pjw, palmer, aou, alex, tjeznach, jgg,
kevin.tian, baolu.lu, vasant.hegde, anup, nutty.liu, jgg
Cc: guoren, iommu, kvm-riscv, linux-riscv, linux-kernel, Fangyu Yu
From: Fangyu Yu <fangyu.yu@linux.alibaba.com>
RISC-V Svpbmt adds page-based memory types (PBMT) to PTEs, allowing
mappings to be tagged as e.g. normal memory, non-cacheable memory, or
I/O.
This series wires the RISC-V IOMMU Svpbmt capability into generic_pt
and uses PBMT to encode device memory attributes for IOMMU mappings.
This series builds on top of the new RISC-V IOMMU page table patches:
https://patch.msgid.link/r/0-v3-9dbf0a72a51c+302-iommu_pt_riscv_jgg@nvidia.com
---
Changes in v2:
- Add a comment for PT_FEAT_RISCV_SVPBMT (per Kevin and Jason).
- Clarify PBMT encoding condition, sort PBMT-related bits by
position, and drop the redundant PBMT clear(per Kevin).
- Link to v1:
https://lore.kernel.org/linux-iommu/20260411022223.91029-1-fangyu.yu@linux.alibaba.com/
Fangyu Yu (2):
iommu/riscv: Advertise Svpbmt support to generic page table
iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits
drivers/iommu/generic_pt/fmt/riscv.h | 8 ++++++++
drivers/iommu/riscv/iommu.c | 2 ++
include/linux/generic_pt/common.h | 4 ++++
3 files changed, 14 insertions(+)
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] iommu/riscv: Advertise Svpbmt support to generic page table
2026-04-14 11:02 [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt fangyu.yu
@ 2026-04-14 11:02 ` fangyu.yu
2026-04-14 11:02 ` [PATCH v2 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits fangyu.yu
2026-05-11 7:56 ` [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt Jörg Rödel
2 siblings, 0 replies; 5+ messages in thread
From: fangyu.yu @ 2026-04-14 11:02 UTC (permalink / raw)
To: joro, will, robin.murphy, pjw, palmer, aou, alex, tjeznach, jgg,
kevin.tian, baolu.lu, vasant.hegde, anup, nutty.liu, jgg
Cc: guoren, iommu, kvm-riscv, linux-riscv, linux-kernel, Fangyu Yu
From: Fangyu Yu <fangyu.yu@linux.alibaba.com>
The RISC-V IOMMU can optionally support Svpbmt page-based memory types
in its page table format. When present,the generic page table code can
use this capability to encode memory attributes (e.g. MMIO vs normal
memory) in PTEs.
Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
---
drivers/iommu/riscv/iommu.c | 2 ++
include/linux/generic_pt/common.h | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
index c7d0342aa747..e53883935563 100644
--- a/drivers/iommu/riscv/iommu.c
+++ b/drivers/iommu/riscv/iommu.c
@@ -1194,6 +1194,8 @@ static struct iommu_domain *riscv_iommu_alloc_paging_domain(struct device *dev)
cfg.common.features = BIT(PT_FEAT_SIGN_EXTEND) |
BIT(PT_FEAT_FLUSH_RANGE) |
BIT(PT_FEAT_RISCV_SVNAPOT_64K);
+ if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SVPBMT)
+ cfg.common.features |= BIT(PT_FEAT_RISCV_SVPBMT);
domain->riscvpt.iommu.nid = dev_to_node(iommu->dev);
domain->domain.ops = &riscv_iommu_paging_domain_ops;
diff --git a/include/linux/generic_pt/common.h b/include/linux/generic_pt/common.h
index fc5d0b5edadc..2683e5b38998 100644
--- a/include/linux/generic_pt/common.h
+++ b/include/linux/generic_pt/common.h
@@ -188,6 +188,10 @@ enum {
* Support the 64k contiguous page size following the Svnapot extension.
*/
PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+ /*
+ * Support Svpbmt extension: encode page-based memory type (PBMT) in PTEs.
+ */
+ PT_FEAT_RISCV_SVPBMT,
};
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits
2026-04-14 11:02 [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt fangyu.yu
2026-04-14 11:02 ` [PATCH v2 1/2] iommu/riscv: Advertise Svpbmt support to generic page table fangyu.yu
@ 2026-04-14 11:02 ` fangyu.yu
2026-04-15 6:52 ` Tian, Kevin
2026-05-11 7:56 ` [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt Jörg Rödel
2 siblings, 1 reply; 5+ messages in thread
From: fangyu.yu @ 2026-04-14 11:02 UTC (permalink / raw)
To: joro, will, robin.murphy, pjw, palmer, aou, alex, tjeznach, jgg,
kevin.tian, baolu.lu, vasant.hegde, anup, nutty.liu, jgg
Cc: guoren, iommu, kvm-riscv, linux-riscv, linux-kernel, Fangyu Yu
From: Fangyu Yu <fangyu.yu@linux.alibaba.com>
When the RISC-V IOMMU page table format support Svpbmt, PBMT provides
a way to tag mappings with page-based memory types. Encode memory type
via PBMT in RISC-V IOMMU PTEs:
- IOMMU_MMIO -> PBMT=IO
- !IOMMU_MMIO && !IOMMU_CACHE -> PBMT=NC
- otherwise -> PBMT=Normal (PBMT=0)
Only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.
Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Reviewed-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
---
drivers/iommu/generic_pt/fmt/riscv.h | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/iommu/generic_pt/fmt/riscv.h b/drivers/iommu/generic_pt/fmt/riscv.h
index a7fef6266a36..57e51e5def9f 100644
--- a/drivers/iommu/generic_pt/fmt/riscv.h
+++ b/drivers/iommu/generic_pt/fmt/riscv.h
@@ -64,6 +64,8 @@ enum {
RISCVPT_PPN64 = GENMASK_ULL(53, 10),
RISCVPT_PPN64_64K = GENMASK_ULL(53, 14),
RISCVPT_PBMT = GENMASK_ULL(62, 61),
+ RISCVPT_NC = BIT(61),
+ RISCVPT_IO = BIT(62),
RISCVPT_N = BIT_ULL(63),
/* Svnapot encodings for ppn[0] */
@@ -237,6 +239,12 @@ static inline int riscvpt_iommu_set_prot(struct pt_common *common,
pte |= RISCVPT_R;
if (!(iommu_prot & IOMMU_NOEXEC))
pte |= RISCVPT_X;
+ if (common->features & BIT(PT_FEAT_RISCV_SVPBMT)) {
+ if (iommu_prot & IOMMU_MMIO)
+ pte |= RISCVPT_IO;
+ else if (!(iommu_prot & IOMMU_CACHE))
+ pte |= RISCVPT_NC;
+ }
/* Caller must specify a supported combination of flags */
if (unlikely((pte & (RISCVPT_X | RISCVPT_W | RISCVPT_R)) == 0))
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH v2 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits
2026-04-14 11:02 ` [PATCH v2 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits fangyu.yu
@ 2026-04-15 6:52 ` Tian, Kevin
0 siblings, 0 replies; 5+ messages in thread
From: Tian, Kevin @ 2026-04-15 6:52 UTC (permalink / raw)
To: fangyu.yu, joro, will, robin.murphy, pjw, palmer, aou, alex,
tjeznach, jgg, baolu.lu, vasant.hegde, anup, nutty.liu, jgg
Cc: guoren, iommu, kvm-riscv, linux-riscv, linux-kernel
> From: fangyu.yu@linux.alibaba.com <fangyu.yu@linux.alibaba.com>
> Sent: Tuesday, April 14, 2026 7:02 PM
>
> From: Fangyu Yu <fangyu.yu@linux.alibaba.com>
>
> When the RISC-V IOMMU page table format support Svpbmt, PBMT provides
> a way to tag mappings with page-based memory types. Encode memory type
> via PBMT in RISC-V IOMMU PTEs:
>
> - IOMMU_MMIO -> PBMT=IO
> - !IOMMU_MMIO && !IOMMU_CACHE -> PBMT=NC
> - otherwise -> PBMT=Normal (PBMT=0)
>
> Only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.
>
> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
> Reviewed-by: Anup Patel <anup@brainfault.org>
> Reviewed-by: Guo Ren <guoren@kernel.org>
> Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt
2026-04-14 11:02 [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt fangyu.yu
2026-04-14 11:02 ` [PATCH v2 1/2] iommu/riscv: Advertise Svpbmt support to generic page table fangyu.yu
2026-04-14 11:02 ` [PATCH v2 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits fangyu.yu
@ 2026-05-11 7:56 ` Jörg Rödel
2 siblings, 0 replies; 5+ messages in thread
From: Jörg Rödel @ 2026-05-11 7:56 UTC (permalink / raw)
To: fangyu.yu
Cc: will, robin.murphy, pjw, palmer, aou, alex, tjeznach, jgg,
kevin.tian, baolu.lu, vasant.hegde, anup, nutty.liu, jgg, guoren,
iommu, kvm-riscv, linux-riscv, linux-kernel
On Tue, Apr 14, 2026 at 07:02:10PM +0800, fangyu.yu@linux.alibaba.com wrote:
> Fangyu Yu (2):
> iommu/riscv: Advertise Svpbmt support to generic page table
> iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits
>
> drivers/iommu/generic_pt/fmt/riscv.h | 8 ++++++++
> drivers/iommu/riscv/iommu.c | 2 ++
> include/linux/generic_pt/common.h | 4 ++++
> 3 files changed, 14 insertions(+)
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-11 7:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-14 11:02 [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt fangyu.yu
2026-04-14 11:02 ` [PATCH v2 1/2] iommu/riscv: Advertise Svpbmt support to generic page table fangyu.yu
2026-04-14 11:02 ` [PATCH v2 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits fangyu.yu
2026-04-15 6:52 ` Tian, Kevin
2026-05-11 7:56 ` [PATCH v2 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt Jörg Rödel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®