[PW_SID:1067132] RISC-V: KVM: Fix hugepage mapping handling during dirty logging#1638
[PW_SID:1067132] RISC-V: KVM: Fix hugepage mapping handling during dirty logging#1638linux-riscv-bot wants to merge 3 commits intoworkflow__riscv__fixesfrom
Conversation
…ging When enabling dirty log in small chunks (e.g., QEMU default chunk size of 256K), the chunk size is always smaller than the page size of huge pages (1G or 2M) used in the gstage page tables. This caused the write protection to be incorrectly skipped for huge PTEs because the condition `(end - addr) >= page_size` was not satisfied. Remove the size check in `kvm_riscv_gstage_wp_range()` to ensure huge PTEs are always write-protected regardless of the chunk size. Additionally, explicitly align the address down to the page size before invoking `kvm_riscv_gstage_op_pte()` to guarantee that the address passed to the operation function is page-aligned. This fixes the issue where dirty pages might not be tracked correctly when using huge pages. Fixes: 9d05c1f ("RISC-V: KVM: Implement stage2 page table programming") Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn> Reviewed-by: Nutty Liu <nutty.liu@hotmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
This patch introduces the function kvm_riscv_gstage_split_huge(). It splits the huge page covering a given guest physical address down to a specified target level (e.g., from 1G to 2M or 4K). The caller provides a memory cache for allocating any intermediate page tables and may request a TLB flush after the split. This functionality will be used by subsequent patches to split huge pages before handling the write-protection fault, or for other operations that require page-level granularity. Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
During dirty logging, all huge pages are write-protected. When the guest writes to a write-protected huge page, a page fault is triggered. Before recovering the write permission, the huge page must be split into smaller pages (e.g., 4K). After splitting, the normal mapping process proceeds, allowing write permission to be restored at the smaller page granularity. If dirty logging is disabled because migration failed or was cancelled, only recover the write permission at the 4K level, and skip recovering the huge page mapping at this time to avoid the overhead of freeing page tables. The huge page mapping can be recovered in the ioctl context, similar to x86, in a later patch. Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v3,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v3,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v3,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
PR for series 1067132 applied to workflow__riscv__fixes
Name: RISC-V: KVM: Fix hugepage mapping handling during dirty logging
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1067132
Version: 3