Skip to content

[PW_SID:968804] MMU related improvements for KVM RISC-V#474

Closed
linux-riscv-bot wants to merge 14 commits into
workflowfrom
pw968804
Closed

[PW_SID:968804] MMU related improvements for KVM RISC-V#474
linux-riscv-bot wants to merge 14 commits into
workflowfrom
pw968804

Conversation

@linux-riscv-bot
Copy link
Copy Markdown

PR for series 968804 applied to workflow

Name: MMU related improvements for KVM RISC-V
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=968804
Version: 1

Linux RISC-V bot and others added 14 commits June 5, 2025 04:27
As-per the SBI specification, an SBI remote fence operation applies
to the entire address space if either:
1) start_addr and size are both 0
2) size is equal to 2^XLEN-1

From the above, only #1 is checked by SBI SFENCE calls so fix the
size parameter check in SBI SFENCE calls to cover #2 as well.

Fixes: 13acfec ("RISC-V: KVM: Add remote HFENCE functions based on VCPU requests")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The SBI specification clearly states that SBI HFENCE calls should
return SBI_ERR_NOT_SUPPORTED when one of the target hart doesn’t
support hypervisor extension (aka nested virtualization in-case
of KVM RISC-V).

Fixes: c7fa3c4 ("RISC-V: KVM: Treat SBI HFENCE calls as NOPs")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The kvm_riscv_vcpu_alloc_vector_context() does return an error code
upon failure so don't ignore this in kvm_arch_vcpu_create().

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The kvm_riscv_vcpu_aia_init() does not return any failure so drop
the return value which is always zero.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The kvm_riscv_local_tlb_sanitize() deals with sanitizing current
VMID related TLB mappings when a VCPU is moved from one host CPU
to another.

Let's move kvm_riscv_local_tlb_sanitize() to VMID management
sources and rename it to kvm_riscv_gstage_vmid_sanitize().

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The KVM_REQ_HFENCE_GVMA_VMID_ALL is same as KVM_REQ_TLB_FLUSH so
to avoid confusion let's replace KVM_REQ_HFENCE_GVMA_VMID_ALL with
KVM_REQ_TLB_FLUSH. Also, rename kvm_riscv_hfence_gvma_vmid_all_process()
to kvm_riscv_tlb_flush_process().

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The gstage_set_pte() should flush remote TLB only when a leaf PTE
changes so that unnecessary remote TLB flushes can be avoided.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The kvm_arch_flush_remote_tlbs_range() expected by KVM core can be
easily implemented for RISC-V using kvm_riscv_hfence_gvma_vmid_gpa()
hence provide it.

Also with kvm_arch_flush_remote_tlbs_range() available for RISC-V, the
mmu_wp_memory_region() can happily use kvm_flush_remote_tlbs_memslot()
instead of kvm_flush_remote_tlbs().

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The MMU, TLB, and VMID management for KVM RISC-V already exists as
seprate sources so create separate headers along these lines. This
further simplifies asm/kvm_host.h header.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Introduce struct kvm_gstage_mapping which represents a g-stage
mapping at a particular page table level of the g-stage. Also,
update the kvm_riscv_gstage_map() to return the g-stage mapping
upon success.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Currently, the struct kvm_riscv_hfence does not have vmid field
and various hfence processing functions always pick vmid assigned
to the guest/VM. This prevents us from doing hfence operation on
arbitrary vmid hence add vmid field to struct kvm_riscv_hfence
and use it wherever applicable.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
The upcoming nested virtualization can share g-stage page table
management with the current host g-stage implementation hence
factor-out g-stage page table management into separate sources
and also use "kvm_riscv_mmu_" prefix for host g-stage functions.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
Currently, all kvm_riscv_hfence_xyz() APIs assume VMID to be the
host VMID of the Guest/VM which resticts use of these APIs only
for host TLB maintenance. Let's allow passing VMID as parameter
to all kvm_riscv_hfence_xyz() APIs so that they can be re-used
for nested virtualization related TLB maintenance.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 111.01 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 936.89 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1204.09 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 23.13 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 24.21 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.79 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 71.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
kdoc
Desc: Detects for kdoc errors
Duration: 0.81 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
module-param
Desc: Detect module_param changes
Duration: 0.25 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 1: "[01/13] RISC-V: KVM: Fix the size parameter check in SBI SFENCE calls"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 108.46 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 934.59 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1202.84 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 2: "[02/13] RISC-V: KVM: Don't treat SBI HFENCE calls as NOPs"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 22.65 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 12: "[12/13] RISC-V: KVM: Factor-out g-stage page table management"
module-param
Desc: Detect module_param changes
Duration: 0.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 12: "[12/13] RISC-V: KVM: Factor-out g-stage page table management"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 12: "[12/13] RISC-V: KVM: Factor-out g-stage page table management"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 1.82 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 108.51 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1012.39 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1295.56 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 22.01 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 23.27 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 1.66 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 71.11 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
kdoc
Desc: Detects for kdoc errors
Duration: 1.13 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.22 seconds
Result: PASS

@linux-riscv-bot
Copy link
Copy Markdown
Author

Patch 13: "[13/13] RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.31 seconds
Result: PASS

@linux-riscv-bot linux-riscv-bot force-pushed the workflow branch 12 times, most recently from 81a1dd8 to 5db9bbd Compare June 10, 2025 21:18
@linux-riscv-bot linux-riscv-bot deleted the pw968804 branch June 11, 2025 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants