Skip to contentSkip to conversation

iommu/riscv: Support Svpbmt memory types in generic_pt

PATCH Superseded [email protected] 6 participants 16 messages Apr 11 – Apr 13

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover iommu/riscv: Support Svpbmt memory types in generic_pt

From: Fangyu Yu <[email protected]>

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/[email protected]

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 | 9 +++++++++
 drivers/iommu/riscv/iommu.c          | 2 ++
 include/linux/generic_pt/common.h    | 1 +
 3 files changed, 12 insertions(+)
Signature · 1 line
2.50.1
#1 lore raw

PATCH 1/2 iommu/riscv: Advertise Svpbmt support to generic page table

From: Fangyu Yu <[email protected]>

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.

---
 drivers/iommu/riscv/iommu.c       | 2 ++
 include/linux/generic_pt/common.h | 1 +
 2 files changed, 3 insertions(+)
drivers/iommu/riscv/iommu.c +2 -0
index c7d0342aa747..e53883935563 100644
@@ -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;
 
include/linux/generic_pt/common.h +1 -0
index fc5d0b5edadc..dfadf8a5752a 100644
@@ -188,6 +188,7 @@ enum {
 	 * Support the 64k contiguous page size following the Svnapot extension.
 	 */
 	PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+	PT_FEAT_RISCV_SVPBMT,
 
 };
 
Signature · 1 line
2.50.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

Quoted 7 lines · On Sat, Apr 11, 2026 at 10:22:22AM +0800, [email protected] wrote:

From: Fangyu Yu <[email protected]>

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.

Quoted 5 lines
---
 drivers/iommu/riscv/iommu.c       | 2 ++
 include/linux/generic_pt/common.h | 1 +
 2 files changed, 3 insertions(+)

Jason

maintainer Reviewed-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

In reply to [email protected]
Quoted 9 lines · On Sat, Apr 11, 2026 at 7:52 AM <[email protected]> wrote:

From: Fangyu Yu <[email protected]>

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.

Looks good from RISC-V perspective.

Regards,
Anup

Quoted 34 lines
---
 drivers/iommu/riscv/iommu.c       | 2 ++
 include/linux/generic_pt/common.h | 1 +
 2 files changed, 3 insertions(+)
drivers/iommu/riscv/iommu.c +2 -0
index c7d0342aa747..e53883935563 100644
@@ -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;
 
include/linux/generic_pt/common.h +1 -1
index fc5d0b5edadc..dfadf8a5752a 100644
@@ -188,6 +188,7 @@ enum {
         * Support the 64k contiguous page size following the Svnapot extension.
         */
        PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+       PT_FEAT_RISCV_SVPBMT,
 
 };
 
--

2.50.1

Reviewed-by on v1 1/2
#4 lore raw

Re: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

In reply to [email protected]
Quoted 40 lines · On Sat, Apr 11, 2026 at 10:22 AM <[email protected]> wrote:

From: Fangyu Yu <[email protected]>

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.

---
 drivers/iommu/riscv/iommu.c       | 2 ++
 include/linux/generic_pt/common.h | 1 +
 2 files changed, 3 insertions(+)
drivers/iommu/riscv/iommu.c +2 -0
index c7d0342aa747..e53883935563 100644
@@ -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;
 
include/linux/generic_pt/common.h +1 -1
index fc5d0b5edadc..dfadf8a5752a 100644
@@ -188,6 +188,7 @@ enum {
         * Support the 64k contiguous page size following the Svnapot extension.
         */
        PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+       PT_FEAT_RISCV_SVPBMT,
 
 };
 
--
Quoted 2 lines

2.50.1

--
Best Regards
Guo Ren

Reviewed-by on v1 1/2
#5 lore raw

Re: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

In reply to [email protected]
Quoted 7 lines · On 4/11/2026 10:22 AM, [email protected] wrote:

From: Fangyu Yu <[email protected]>

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.

Quoted 5 lines
---
  drivers/iommu/riscv/iommu.c       | 2 ++
  include/linux/generic_pt/common.h | 1 +
  2 files changed, 3 insertions(+)

Thanks,
Nutty

Reviewed-by on v1 1/2
#6 lore raw

RE: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

In reply to [email protected]
Quoted 12 lines

From: [email protected] <[email protected]>
Sent: Saturday, April 11, 2026 10:22 AM

include/linux/generic_pt/common.h +0 -0
index fc5d0b5edadc..dfadf8a5752a 100644
@@ -188,6 +188,7 @@ enum {
 	 * Support the 64k contiguous page size following the Svnapot

extension.

include/linux/generic_pt/common.h enum { · line 191

Quoted 3 lines
include/linux/generic_pt/common.h +1 -0
 	 */
 	PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+	PT_FEAT_RISCV_SVPBMT,

nit - every feature has a comment.

#7 lore raw

Re: RE: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

Quoted 17 lines
Quoted 12 lines

From: [email protected] <[email protected]>
Sent: Saturday, April 11, 2026 10:22 AM

include/linux/generic_pt/common.h +0 -0
index fc5d0b5edadc..dfadf8a5752a 100644
@@ -188,6 +188,7 @@ enum {
 	 * Support the 64k contiguous page size following the Svnapot

extension.

include/linux/generic_pt/common.h enum { · line 191

Quoted 3 lines
include/linux/generic_pt/common.h +1 -0
 	 */
 	PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+	PT_FEAT_RISCV_SVPBMT,

nit - every feature has a comment.

Thanks Kevin.
I'll add a comment for PT_FEAT_RISCV_SVPBMT in the next revision.

Fangyu,
Thanks

Quoted 2 lines
#8 lore raw

Re: [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table

In reply to Tian, Kevin
Quoted 18 lines · Kevin
Quoted 12 lines

From: [email protected] <[email protected]>
Sent: Saturday, April 11, 2026 10:22 AM

include/linux/generic_pt/common.h +0 -0
index fc5d0b5edadc..dfadf8a5752a 100644
@@ -188,6 +188,7 @@ enum {
 	 * Support the 64k contiguous page size following the Svnapot

extension.

include/linux/generic_pt/common.h enum { · line 191

Quoted 3 lines
include/linux/generic_pt/common.h +1 -0
 	 */
 	PT_FEAT_RISCV_SVNAPOT_64K = PT_FEAT_FMT_START,
+	PT_FEAT_RISCV_SVPBMT,

nit - every feature has a comment.

Quoted 1 line

Oh that's right, please add a good comment!

Jason

#9 lore raw

PATCH 2/2 iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

In reply to [email protected]

From: Fangyu Yu <[email protected]>

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_CACHE -> PBMT=NC
- otherwise -> PBMT=Normal (PBMT=0)

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

---
 drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/iommu/generic_pt/fmt/riscv.h +9 -0
index a7fef6266a36..02051bb3c6e5 100644
@@ -58,6 +58,8 @@ enum {
 	RISCVPT_G = BIT(5),
 	RISCVPT_A = BIT(6),
 	RISCVPT_D = BIT(7),
+	RISCVPT_NC = BIT(61),
+	RISCVPT_IO = BIT(62),
 	RISCVPT_RSW = GENMASK(9, 8),
 	RISCVPT_PPN32 = GENMASK(31, 10),
 
@@ -237,6 +239,13 @@ 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)) {
+		pte &= ~RISCVPT_PBMT;
+		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))
Signature · 1 line
2.50.1
Reviewed-by on v1 2/2
#10 lore raw

Re: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

Quoted 10 lines · On Sat, Apr 11, 2026 at 10:22:23AM +0800, [email protected] wrote:

From: Fangyu Yu <[email protected]>

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_CACHE -> PBMT=NC
- otherwise -> PBMT=Normal (PBMT=0)

Quoted 7 lines

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

---
 drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
 1 file changed, 9 insertions(+)

This is similar to ARM now with the 3 kinds..

Jason

maintainer Reviewed-by on v1 2/2
#11 lore raw

Re: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

In reply to [email protected]
Quoted 7 lines · On Sat, Apr 11, 2026 at 7:52 AM <[email protected]> wrote:

From: Fangyu Yu <[email protected]>

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:

Quoted 8 lines

- IOMMU_MMIO -> PBMT=IO
- !IOMMU_CACHE -> PBMT=NC
- otherwise -> PBMT=Normal (PBMT=0)

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

Looks good from RISC-V perspective.

Regards,
Anup

Quoted 35 lines
---
 drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/iommu/generic_pt/fmt/riscv.h +9 -1
index a7fef6266a36..02051bb3c6e5 100644
@@ -58,6 +58,8 @@ enum {
        RISCVPT_G = BIT(5),
        RISCVPT_A = BIT(6),
        RISCVPT_D = BIT(7),
+       RISCVPT_NC = BIT(61),
+       RISCVPT_IO = BIT(62),
        RISCVPT_RSW = GENMASK(9, 8),
        RISCVPT_PPN32 = GENMASK(31, 10),
 
@@ -237,6 +239,13 @@ 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)) {
+               pte &= ~RISCVPT_PBMT;
+               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

Reviewed-by on v1 2/2
#12 lore raw

Re: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

In reply to [email protected]
Quoted 47 lines · On Sat, Apr 11, 2026 at 10:22 AM <[email protected]> wrote:

From: Fangyu Yu <[email protected]>

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_CACHE -> PBMT=NC
- otherwise -> PBMT=Normal (PBMT=0)

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

---
 drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/iommu/generic_pt/fmt/riscv.h +9 -1
index a7fef6266a36..02051bb3c6e5 100644
@@ -58,6 +58,8 @@ enum {
        RISCVPT_G = BIT(5),
        RISCVPT_A = BIT(6),
        RISCVPT_D = BIT(7),
+       RISCVPT_NC = BIT(61),
+       RISCVPT_IO = BIT(62),
        RISCVPT_RSW = GENMASK(9, 8),
        RISCVPT_PPN32 = GENMASK(31, 10),
 
@@ -237,6 +239,13 @@ 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)) {
+               pte &= ~RISCVPT_PBMT;
+               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))
--
Quoted 2 lines

2.50.1

I'm okay with the current way of MMIO & CACHE mapping to IO & NC.

Signature · 2 lines
Best Regards
 Guo Ren
Reviewed-by on v1 2/2
#13 lore raw

Re: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

In reply to [email protected]
Quoted 10 lines · On 4/11/2026 10:22 AM, [email protected] wrote:

From: Fangyu Yu <[email protected]>

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_CACHE -> PBMT=NC
- otherwise -> PBMT=Normal (PBMT=0)

Quoted 7 lines

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

---
  drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
  1 file changed, 9 insertions(+)

Thanks,
Nutty

#14 lore raw

RE: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

In reply to [email protected]
Quoted 11 lines

From: [email protected] <[email protected]>
Sent: Saturday, April 11, 2026 10:22 AM

From: Fangyu Yu <[email protected]>

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_CACHE -> PBMT=NC

In concept IOMMU_CACHE is cleared when IOMMU_MMIO is set. From the code PBMT=IO in this case.

So strictly speaking the 2nd line should be:

- !IOMMU_MMIO && !IOMMU_CACHE -> PBMT=NC

??

Quoted 16 lines

- otherwise -> PBMT=Normal (PBMT=0)

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

---
 drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/iommu/generic_pt/fmt/riscv.h +0 -0
index a7fef6266a36..02051bb3c6e5 100644

drivers/iommu/generic_pt/fmt/riscv.h enum { · line 64

Quoted 7 lines
drivers/iommu/generic_pt/fmt/riscv.h +2 -0
@@ -58,6 +58,8 @@ enum {
 	RISCVPT_G = BIT(5),
 	RISCVPT_A = BIT(6),
 	RISCVPT_D = BIT(7),
+	RISCVPT_NC = BIT(61),
+	RISCVPT_IO = BIT(62),
 	RISCVPT_RSW = GENMASK(9, 8),
 	RISCVPT_PPN32 = GENMASK(31, 10),

sort by bit positions

drivers/iommu/generic_pt/fmt/riscv.h static inline int riscvpt_iommu_set_prot(struct · line 244

Quoted 8 lines
drivers/iommu/generic_pt/fmt/riscv.h +2 -0
@@ -237,6 +239,13 @@ 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)) {
+		pte &= ~RISCVPT_PBMT;

this is unnecessary due to the earlier assignment:

	pte = RISCVPT_A | RISCVPT_U;
Quoted 10 lines
drivers/iommu/generic_pt/fmt/riscv.h +5 -0
+		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

#15 lore raw

Re: RE: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits

Quoted 12 lines
Quoted 11 lines

From: [email protected] <[email protected]>
Sent: Saturday, April 11, 2026 10:22 AM

From: Fangyu Yu <[email protected]>

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_CACHE -> PBMT=NC

Quoted 9 lines

In concept IOMMU_CACHE is cleared when IOMMU_MMIO is set. From the code PBMT=IO in this case.

So strictly speaking the 2nd line should be:

- !IOMMU_MMIO && !IOMMU_CACHE -> PBMT=NC

??

Agree. I'll clarify the commit message accordingly to avoid implying that the MMIO case could fall into the NC rule.

Quoted 10 lines
Quoted 10 lines

- otherwise -> PBMT=Normal (PBMT=0)

Clear the PBMT field before applying the selected encoding, and only touch PBMT when PT_FEAT_RISCV_SVPBMT is advertised.

---
 drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 16 lines

drivers/iommu/generic_pt/fmt/riscv.h enum { · line 64

Quoted 13 lines
drivers/iommu/generic_pt/fmt/riscv.h +2 -0
index a7fef6266a36..02051bb3c6e5 100644
@@ -58,6 +58,8 @@ enum {
 	RISCVPT_G = BIT(5),
 	RISCVPT_A = BIT(6),
 	RISCVPT_D = BIT(7),
+	RISCVPT_NC = BIT(61),
+	RISCVPT_IO = BIT(62),
 	RISCVPT_RSW = GENMASK(9, 8),
 	RISCVPT_PPN32 = GENMASK(31, 10),

sort by bit positions

Got it, will reorder in v2.

Quoted 11 lines

drivers/iommu/generic_pt/fmt/riscv.h static inline int riscvpt_iommu_set_prot(struct · line 244

Quoted 8 lines
drivers/iommu/generic_pt/fmt/riscv.h +2 -0
@@ -237,6 +239,13 @@ 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)) {
+		pte &= ~RISCVPT_PBMT;

this is unnecessary due to the earlier assignment:

Quoted 2 lines
	pte = RISCVPT_A | RISCVPT_U;

As things stand it’s not needed, I'll drop it in v2.

Quoted 10 lines
Quoted 10 lines
drivers/iommu/generic_pt/fmt/riscv.h +5 -0
+		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

Thanks,
Fangyu