@@ -290,6 +290,8 @@ enum x86_intercept_stage;
#define PWALK_FORCE_SET_ACCESSED BIT(2)
#define PWALK_SET_ALL (PWALK_SET_ACCESSED | PWALK_SET_DIRTY)
+#define PWALK_STATUS_READ_ONLY_PTE_GPA BIT(0)
+
/* apic attention bits */
#define KVM_APIC_CHECK_VAPIC 0
/*
@@ -244,8 +244,11 @@ static int FNAME(update_accessed_dirty_bits)(struct kvm_vcpu *vcpu,
* overwrite the read-only memory to set the accessed and dirty
* bits.
*/
- if (unlikely(!walker->pte_writable[level - 1]))
+ if (unlikely(!walker->pte_writable[level - 1])) {
+ if (status)
+ *status |= PWALK_STATUS_READ_ONLY_PTE_GPA;
continue;
+ }
ret = __try_cmpxchg_user(ptep_user, &orig_pte, pte, fault);
if (ret)
Implement PWALK_STATUS_READ_ONLY_PTE_GPA in the page walker. This status flag is set when setting an accessed or dirty bit fails, because the memory of the page table entry was marked as read-only Signed-off-by: Nikolas Wipper <nikwip@amazon.de> --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/mmu/paging_tmpl.h | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-)