On Fri, Aug 25, 2023 at 10:35:26AM +0100, Shameer Kolothum wrote: > From: Keqian Zhu <zhukeqian1@xxxxxxxxxx> > > This function write protects all PTEs between the ffs and fls of mask. > There may be unset bits between this range. It works well under pure > software dirty log, as software dirty log is not working during this > process. > > But it will unexpectly clear dirty status of PTE when hardware dirty > log is enabled. So change it to only write protect selected PTE. Ah, I did wonder about losing the dirty status. The equivalent to S1 would be for kvm_pgtable_stage2_wrprotect() to set a software dirty bit. I'm only superficially familiar with how KVM does dirty tracking for live migration. Does it need to first write-protect the pages and disable DBM? Is DBM re-enabled later? Or does stage2_wp_range() with your patches leave the DBM on? If the latter, the 'wp' aspect is a bit confusing since DBM basically means writeable (and maybe clean). So better to have something like stage2_clean_range(). -- Catalin