A further thinking is can we move it to mmu_need_write_protect? Passing can_unsync as parameter toBtw I also think this patch can be merged with patch 6.
kvm_unsync_pages sounds a little bit odd.
+How about large page mapping? Such as if guest uses 2M mapping and its shadow is indirect, does
if (s->unsync)
continue;
WARN_ON(s->role.level != PT_PAGE_TABLE_LEVEL);
above WARN_ON still meet? As you removed the PT level check in mmu_need_write_protect.
Thanks,
-Kai