[PW_SID:1061157] RISC-V: KVM: Fix hugepage mapping handling during dirty logging#1555
[PW_SID:1061157] RISC-V: KVM: Fix hugepage mapping handling during dirty logging#1555linux-riscv-bot wants to merge 3 commits into
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. Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn> 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. This ensures that dirty logging works correctly with huge pages. Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 1: "[v2,1/3] RISC-V: KVM: Fix lost write protection on huge pages during dirty logging" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 2: "[v2,2/3] RISC-V: KVM: Allow splitting huge pages to arbitrary level" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
|
Patch 3: "[v2,3/3] RISC-V: KVM: Split huge pages during fault handling for dirty logging" |
PR for series 1061157 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=1061157
Version: 2