diff mbox series

[07/15] KVM: x86/mmu: Implement PWALK_SET_DIRTY in page walker

Message ID 20240910152207.38974-8-nikwip@amazon.de
State Handled Elsewhere
Headers show
Series KVM: x86: Introduce new ioctl KVM_TRANSLATE2 | expand

Commit Message

Nikolas Wipper Sept. 10, 2024, 3:21 p.m. UTC
Implement PWALK_SET_DIRTY in the page walker. This flag allows controlling,
whether the page walker will set the dirty bit after a successful page
walk. If the page walk fails for any reason, the dirty flag is not set.

Signed-off-by: Nikolas Wipper <nikwip@amazon.de>
---
 arch/x86/kvm/mmu/paging_tmpl.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h
index eed6e2c653ba..b6897f7fbf52 100644
--- a/arch/x86/kvm/mmu/paging_tmpl.h
+++ b/arch/x86/kvm/mmu/paging_tmpl.h
@@ -318,6 +318,7 @@  static int FNAME(walk_addr_generic)(struct guest_walker *walker,
 	const int user_fault  = access & PFERR_USER_MASK;
 	const int fetch_fault = access & PFERR_FETCH_MASK;
 	const int set_accessed = flags & PWALK_SET_ACCESSED;
+	const int set_dirty = flags & PWALK_SET_DIRTY;
 	u16 errcode = 0;
 	gpa_t real_gpa;
 	gfn_t gfn;
@@ -471,7 +472,7 @@  static int FNAME(walk_addr_generic)(struct guest_walker *walker,
 
 	if (unlikely(set_accessed && !accessed_dirty)) {
 		ret = FNAME(update_accessed_dirty_bits)(vcpu, mmu, walker, addr,
-							write_fault);
+							write_fault && set_dirty);
 		if (unlikely(ret < 0))
 			goto error;
 		else if (ret)