public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
From: fangyu.yu@linux.alibaba.com
To: kevin.tian@intel.com
Cc: alex@ghiti.fr, aou@eecs.berkeley.edu, baolu.lu@linux.intel.com,
	fangyu.yu@linux.alibaba.com, guoren@kernel.org,
	iommu@lists.linux.dev, jgg@ziepe.ca, joro@8bytes.org,
	kvm-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org, palmer@dabbelt.com,
	pjw@kernel.org, robin.murphy@arm.com, tjeznach@rivosinc.com,
	vasant.hegde@amd.com, will@kernel.org
Subject: Re: RE: [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits
Date: Mon, 13 Apr 2026 19:36:45 +0800	[thread overview]
Message-ID: <20260413113645.28757-1-fangyu.yu@linux.alibaba.com> (raw)
In-Reply-To: <BN9PR11MB52766502D575970096482F428C242@BN9PR11MB5276.namprd11.prod.outlook.com>

>> From: fangyu.yu@linux.alibaba.com <fangyu.yu@linux.alibaba.com>
>> Sent: Saturday, April 11, 2026 10:22 AM
>>
>> 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_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
>
>??
>

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

>>   - 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.
>>
>> Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
>> ---
>>  drivers/iommu/generic_pt/fmt/riscv.h | 9 +++++++++
>>  1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/iommu/generic_pt/fmt/riscv.h
>> b/drivers/iommu/generic_pt/fmt/riscv.h
>> index a7fef6266a36..02051bb3c6e5 100644
>> --- a/drivers/iommu/generic_pt/fmt/riscv.h
>> +++ b/drivers/iommu/generic_pt/fmt/riscv.h
>> @@ -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.

>>
>> @@ -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;
>

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

>> +		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

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

      reply	other threads:[~2026-04-13 11:37 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11  2:22 [PATCH 0/2] iommu/riscv: Support Svpbmt memory types in generic_pt fangyu.yu
2026-04-11  2:22 ` [PATCH 1/2] iommu/riscv: Advertise Svpbmt support to generic page table fangyu.yu
2026-04-11 12:47   ` Jason Gunthorpe
2026-04-11 16:51   ` Anup Patel
2026-04-12 13:03   ` Guo Ren
2026-04-13  2:55   ` Nutty.Liu
2026-04-13  6:45   ` Tian, Kevin
2026-04-13 11:16     ` fangyu.yu
2026-04-13 12:33     ` Jason Gunthorpe
2026-04-11  2:22 ` [PATCH 2/2] iommupt: Encode IOMMU_MMIO/IOMMU_CACHE via RISC-V Svpbmt bits fangyu.yu
2026-04-11 12:47   ` Jason Gunthorpe
2026-04-11 16:51   ` Anup Patel
2026-04-12 14:08   ` Guo Ren
2026-04-13  3:23   ` Nutty.Liu
2026-04-13  6:53   ` Tian, Kevin
2026-04-13 11:36     ` fangyu.yu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260413113645.28757-1-fangyu.yu@linux.alibaba.com \
    --to=fangyu.yu@linux.alibaba.com \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=baolu.lu@linux.intel.com \
    --cc=guoren@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=tjeznach@rivosinc.com \
    --cc=vasant.hegde@amd.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox