From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: fangyu.yu@linux.alibaba.com, ajones@ventanamicro.com
Cc: alex.williamson@redhat.com, alex@ghiti.fr, anup@brainfault.org,
atish.patra@linux.dev, iommu@lists.linux.dev, jgg@nvidia.com,
joro@8bytes.org, kvm-riscv@lists.infradead.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, palmer@dabbelt.com,
paul.walmsley@sifive.com, robin.murphy@arm.com,
tglx@linutronix.de, tjeznach@rivosinc.com, will@kernel.org,
zong.li@sifive.com
Subject: Re: [RFC PATCH v2 18/18] DO NOT UPSTREAM: RISC-V: KVM: Workaround kvm_riscv_gstage_ioremap() bug
Date: Mon, 20 Oct 2025 16:47:07 -0300 [thread overview]
Message-ID: <4d1e8b55-e404-466b-a2d6-b189de910637@ventanamicro.com> (raw)
In-Reply-To: <20251020131218.68932-1-fangyu.yu@linux.alibaba.com>
Drew,
On 10/20/25 10:12 AM, fangyu.yu@linux.alibaba.com wrote:
>> Workaround a bug that breaks guest booting with device assignment that
>> was introduced with commit 9bca8be646e0 ("RISC-V: KVM: Fix pte settings
>> within kvm_riscv_gstage_ioremap()")
>
> The root cause of the guest booting failure is that an HPA is obtained
> in the kvm_arch_prepare_memory_region.
>
> Here [1] might be the correct fixes for this issue.
> [1] https://lore.kernel.org/linux-riscv/20251020130801.68356-1-fangyu.yu@linux.alibaba.com/T/#u
This patch fixes the issue we've been seeing with device assignment inside a
kvm guest. I suggest folding it into this series and dropping this workaround
patch in the next version.
Thanks,
Daniel
>
>> ---
>> arch/riscv/kvm/mmu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
>> index 525fb5a330c0..994f18b92143 100644
>> --- a/arch/riscv/kvm/mmu.c
>> +++ b/arch/riscv/kvm/mmu.c
>> @@ -56,7 +56,7 @@ int kvm_riscv_mmu_ioremap(struct kvm *kvm, gpa_t gpa, phys_addr_t hpa,
>>
>> end = (gpa + size + PAGE_SIZE - 1) & PAGE_MASK;
>> pfn = __phys_to_pfn(hpa);
>> - prot = pgprot_noncached(PAGE_WRITE);
>> + prot = pgprot_noncached(__pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_READ | _PAGE_WRITE));
>>
>> for (addr = gpa; addr < end; addr += PAGE_SIZE) {
>> map.addr = addr;
>> --
>> 2.49.0
>
> Thanks,
> Fangyu
>
--
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: fangyu.yu@linux.alibaba.com, ajones@ventanamicro.com
Cc: alex.williamson@redhat.com, alex@ghiti.fr, anup@brainfault.org,
atish.patra@linux.dev, iommu@lists.linux.dev, jgg@nvidia.com,
joro@8bytes.org, kvm-riscv@lists.infradead.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, palmer@dabbelt.com,
paul.walmsley@sifive.com, robin.murphy@arm.com,
tglx@linutronix.de, tjeznach@rivosinc.com, will@kernel.org,
zong.li@sifive.com
Subject: Re: [RFC PATCH v2 18/18] DO NOT UPSTREAM: RISC-V: KVM: Workaround kvm_riscv_gstage_ioremap() bug
Date: Mon, 20 Oct 2025 16:47:07 -0300 [thread overview]
Message-ID: <4d1e8b55-e404-466b-a2d6-b189de910637@ventanamicro.com> (raw)
In-Reply-To: <20251020131218.68932-1-fangyu.yu@linux.alibaba.com>
Drew,
On 10/20/25 10:12 AM, fangyu.yu@linux.alibaba.com wrote:
>> Workaround a bug that breaks guest booting with device assignment that
>> was introduced with commit 9bca8be646e0 ("RISC-V: KVM: Fix pte settings
>> within kvm_riscv_gstage_ioremap()")
>
> The root cause of the guest booting failure is that an HPA is obtained
> in the kvm_arch_prepare_memory_region.
>
> Here [1] might be the correct fixes for this issue.
> [1] https://lore.kernel.org/linux-riscv/20251020130801.68356-1-fangyu.yu@linux.alibaba.com/T/#u
This patch fixes the issue we've been seeing with device assignment inside a
kvm guest. I suggest folding it into this series and dropping this workaround
patch in the next version.
Thanks,
Daniel
>
>> ---
>> arch/riscv/kvm/mmu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
>> index 525fb5a330c0..994f18b92143 100644
>> --- a/arch/riscv/kvm/mmu.c
>> +++ b/arch/riscv/kvm/mmu.c
>> @@ -56,7 +56,7 @@ int kvm_riscv_mmu_ioremap(struct kvm *kvm, gpa_t gpa, phys_addr_t hpa,
>>
>> end = (gpa + size + PAGE_SIZE - 1) & PAGE_MASK;
>> pfn = __phys_to_pfn(hpa);
>> - prot = pgprot_noncached(PAGE_WRITE);
>> + prot = pgprot_noncached(__pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_READ | _PAGE_WRITE));
>>
>> for (addr = gpa; addr < end; addr += PAGE_SIZE) {
>> map.addr = addr;
>> --
>> 2.49.0
>
> Thanks,
> Fangyu
>
WARNING: multiple messages have this Message-ID (diff)
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: fangyu.yu@linux.alibaba.com, ajones@ventanamicro.com
Cc: alex.williamson@redhat.com, alex@ghiti.fr, anup@brainfault.org,
atish.patra@linux.dev, iommu@lists.linux.dev, jgg@nvidia.com,
joro@8bytes.org, kvm-riscv@lists.infradead.org,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, palmer@dabbelt.com,
paul.walmsley@sifive.com, robin.murphy@arm.com,
tglx@linutronix.de, tjeznach@rivosinc.com, will@kernel.org,
zong.li@sifive.com
Subject: Re: [RFC PATCH v2 18/18] DO NOT UPSTREAM: RISC-V: KVM: Workaround kvm_riscv_gstage_ioremap() bug
Date: Mon, 20 Oct 2025 16:47:07 -0300 [thread overview]
Message-ID: <4d1e8b55-e404-466b-a2d6-b189de910637@ventanamicro.com> (raw)
In-Reply-To: <20251020131218.68932-1-fangyu.yu@linux.alibaba.com>
Drew,
On 10/20/25 10:12 AM, fangyu.yu@linux.alibaba.com wrote:
>> Workaround a bug that breaks guest booting with device assignment that
>> was introduced with commit 9bca8be646e0 ("RISC-V: KVM: Fix pte settings
>> within kvm_riscv_gstage_ioremap()")
>
> The root cause of the guest booting failure is that an HPA is obtained
> in the kvm_arch_prepare_memory_region.
>
> Here [1] might be the correct fixes for this issue.
> [1] https://lore.kernel.org/linux-riscv/20251020130801.68356-1-fangyu.yu@linux.alibaba.com/T/#u
This patch fixes the issue we've been seeing with device assignment inside a
kvm guest. I suggest folding it into this series and dropping this workaround
patch in the next version.
Thanks,
Daniel
>
>> ---
>> arch/riscv/kvm/mmu.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c
>> index 525fb5a330c0..994f18b92143 100644
>> --- a/arch/riscv/kvm/mmu.c
>> +++ b/arch/riscv/kvm/mmu.c
>> @@ -56,7 +56,7 @@ int kvm_riscv_mmu_ioremap(struct kvm *kvm, gpa_t gpa, phys_addr_t hpa,
>>
>> end = (gpa + size + PAGE_SIZE - 1) & PAGE_MASK;
>> pfn = __phys_to_pfn(hpa);
>> - prot = pgprot_noncached(PAGE_WRITE);
>> + prot = pgprot_noncached(__pgprot(_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_READ | _PAGE_WRITE));
>>
>> for (addr = gpa; addr < end; addr += PAGE_SIZE) {
>> map.addr = addr;
>> --
>> 2.49.0
>
> Thanks,
> Fangyu
>
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2025-10-20 19:47 UTC|newest]
Thread overview: 159+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-20 20:38 [RFC PATCH v2 00/18] iommu/riscv: Add irqbypass support Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` [RFC PATCH v2 01/18] genirq/msi: Provide DOMAIN_BUS_MSI_REMAP Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-30 8:25 ` Nutty.Liu
2025-09-30 8:25 ` Nutty.Liu
2025-09-30 8:25 ` Nutty.Liu
2025-09-20 20:38 ` [RFC PATCH v2 02/18] iommu/riscv: Move struct riscv_iommu_domain and info to iommu.h Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-30 8:26 ` Nutty.Liu
2025-09-30 8:26 ` Nutty.Liu
2025-09-30 8:26 ` Nutty.Liu
2025-09-20 20:38 ` [RFC PATCH v2 03/18] iommu/riscv: Use data structure instead of individual values Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-24 3:25 ` Nutty.Liu
2025-09-24 3:25 ` Nutty.Liu
2025-09-24 3:25 ` Nutty.Liu
2025-09-24 13:31 ` Andrew Jones
2025-09-24 13:31 ` Andrew Jones
2025-09-24 13:31 ` Andrew Jones
2025-09-20 20:38 ` [RFC PATCH v2 04/18] iommu/riscv: Add IRQ domain for interrupt remapping Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-28 9:30 ` Nutty.Liu
2025-09-28 9:30 ` Nutty.Liu
2025-09-28 9:30 ` Nutty.Liu
2025-09-29 15:50 ` Andrew Jones
2025-09-29 15:50 ` Andrew Jones
2025-09-29 15:50 ` Andrew Jones
2025-09-20 20:38 ` [RFC PATCH v2 05/18] iommu/riscv: Prepare to use MSI table Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-10-05 8:30 ` Nutty.Liu
2025-10-05 8:30 ` Nutty.Liu
2025-10-05 8:30 ` Nutty.Liu
2025-09-20 20:38 ` [RFC PATCH v2 06/18] iommu/riscv: Implement MSI table management functions Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-10-05 8:28 ` Nutty.Liu
2025-10-05 8:28 ` Nutty.Liu
2025-10-05 8:28 ` Nutty.Liu
2025-09-20 20:38 ` [RFC PATCH v2 07/18] iommu/riscv: Export phys_to_ppn and ppn_to_phys Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-10-05 8:39 ` Nutty.Liu
2025-10-05 8:39 ` Nutty.Liu
2025-10-05 8:39 ` Nutty.Liu
2025-09-20 20:38 ` [RFC PATCH v2 08/18] iommu/riscv: Use MSI table to enable IMSIC access Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-22 18:43 ` Jason Gunthorpe
2025-09-22 18:43 ` Jason Gunthorpe
2025-09-22 18:43 ` Jason Gunthorpe
2025-09-22 21:20 ` Andrew Jones
2025-09-22 21:20 ` Andrew Jones
2025-09-22 21:20 ` Andrew Jones
2025-09-22 23:56 ` Jason Gunthorpe
2025-09-22 23:56 ` Jason Gunthorpe
2025-09-22 23:56 ` Jason Gunthorpe
2025-09-23 10:12 ` Thomas Gleixner
2025-09-23 10:12 ` Thomas Gleixner
2025-09-23 10:12 ` Thomas Gleixner
2025-09-23 14:06 ` Jason Gunthorpe
2025-09-23 14:06 ` Jason Gunthorpe
2025-09-23 14:06 ` Jason Gunthorpe
2025-09-23 15:12 ` Andrew Jones
2025-09-23 15:12 ` Andrew Jones
2025-09-23 15:12 ` Andrew Jones
2025-09-23 15:27 ` Jason Gunthorpe
2025-09-23 15:27 ` Jason Gunthorpe
2025-09-23 15:27 ` Jason Gunthorpe
2025-09-23 15:50 ` Andrew Jones
2025-09-23 15:50 ` Andrew Jones
2025-09-23 15:50 ` Andrew Jones
2025-09-23 16:23 ` Jason Gunthorpe
2025-09-23 16:23 ` Jason Gunthorpe
2025-09-23 16:23 ` Jason Gunthorpe
2025-09-23 16:33 ` Andrew Jones
2025-09-23 16:33 ` Andrew Jones
2025-09-23 16:33 ` Andrew Jones
2026-03-24 9:12 ` Vincent Chen
2026-03-24 9:12 ` Vincent Chen
2026-03-24 9:12 ` Vincent Chen
2026-03-26 17:31 ` Andrew Jones
2026-03-26 17:31 ` Andrew Jones
2026-03-26 17:31 ` Andrew Jones
2025-09-23 14:37 ` Andrew Jones
2025-09-23 14:37 ` Andrew Jones
2025-09-23 14:37 ` Andrew Jones
2025-09-23 14:52 ` Jason Gunthorpe
2025-09-23 14:52 ` Jason Gunthorpe
2025-09-23 14:52 ` Jason Gunthorpe
2025-09-23 15:37 ` Andrew Jones
2025-09-23 15:37 ` Andrew Jones
2025-09-23 15:37 ` Andrew Jones
2025-10-23 13:47 ` Jinvas
2025-10-23 13:47 ` Jinvas
2025-10-23 13:47 ` Jinvas
2025-09-20 20:38 ` [RFC PATCH v2 09/18] iommu/dma: enable IOMMU_DMA for RISC-V Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-09-20 20:38 ` Andrew Jones
2025-10-05 8:40 ` Nutty.Liu
2025-10-05 8:40 ` Nutty.Liu
2025-10-05 8:40 ` Nutty.Liu
2025-09-20 20:39 ` [RFC PATCH v2 10/18] RISC-V: Define irqbypass vcpu_info Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-10-05 8:41 ` Nutty.Liu
2025-10-05 8:41 ` Nutty.Liu
2025-10-05 8:41 ` Nutty.Liu
2025-09-20 20:39 ` [RFC PATCH v2 11/18] iommu/riscv: Maintain each irq msitbl index with chip data Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` [RFC PATCH v2 12/18] iommu/riscv: Add guest file irqbypass support Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` [RFC PATCH v2 13/18] iommu/riscv: report iommu capabilities Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-10-05 8:43 ` Nutty.Liu
2025-10-05 8:43 ` Nutty.Liu
2025-10-05 8:43 ` Nutty.Liu
2025-09-20 20:39 ` [RFC PATCH v2 14/18] RISC-V: KVM: Enable KVM_VFIO interfaces on RISC-V arch Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-10-05 8:44 ` Nutty.Liu
2025-10-05 8:44 ` Nutty.Liu
2025-10-05 8:44 ` Nutty.Liu
2025-09-20 20:39 ` [RFC PATCH v2 15/18] RISC-V: KVM: Add guest file irqbypass support Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` [RFC PATCH v2 16/18] vfio: enable IOMMU_TYPE1 for RISC-V Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-10-05 8:44 ` Nutty.Liu
2025-10-05 8:44 ` Nutty.Liu
2025-10-05 8:44 ` Nutty.Liu
2025-09-20 20:39 ` [RFC PATCH v2 17/18] RISC-V: defconfig: Add VFIO modules Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-10-05 8:47 ` Nutty.Liu
2025-10-05 8:47 ` Nutty.Liu
2025-10-05 8:47 ` Nutty.Liu
2025-09-20 20:39 ` [RFC PATCH v2 18/18] DO NOT UPSTREAM: RISC-V: KVM: Workaround kvm_riscv_gstage_ioremap() bug Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-09-20 20:39 ` Andrew Jones
2025-10-20 13:12 ` fangyu.yu
2025-10-20 13:12 ` fangyu.yu
2025-10-20 13:12 ` fangyu.yu
2025-10-20 19:47 ` Daniel Henrique Barboza [this message]
2025-10-20 19:47 ` Daniel Henrique Barboza
2025-10-20 19:47 ` Daniel Henrique Barboza
2025-10-21 1:10 ` fangyu.yu
2025-10-21 1:10 ` fangyu.yu
2025-10-21 1:10 ` fangyu.yu
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=4d1e8b55-e404-466b-a2d6-b189de910637@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=ajones@ventanamicro.com \
--cc=alex.williamson@redhat.com \
--cc=alex@ghiti.fr \
--cc=anup@brainfault.org \
--cc=atish.patra@linux.dev \
--cc=fangyu.yu@linux.alibaba.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kvm-riscv@lists.infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=robin.murphy@arm.com \
--cc=tglx@linutronix.de \
--cc=tjeznach@rivosinc.com \
--cc=will@kernel.org \
--cc=zong.li@sifive.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.