On Wed, Feb 21, 2024, Shivam Kumar wrote: > @@ -1291,6 +1293,13 @@ struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn); > bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn); > bool kvm_vcpu_is_visible_gfn(struct kvm_vcpu *vcpu, gfn_t gfn); > unsigned long kvm_host_page_size(struct kvm_vcpu *vcpu, gfn_t gfn); > +#ifdef CONFIG_HAVE_KVM_DIRTY_QUOTA > +void update_dirty_quota(struct kvm *kvm, unsigned long page_size_bytes); > +#else > +static inline void update_dirty_quota(struct kvm *kvm, unsigned long page_size_bytes) > +{ > +} > +#endif > void mark_page_dirty_in_slot(struct kvm *kvm, const struct kvm_memory_slot *memslot, gfn_t gfn); > void mark_page_dirty(struct kvm *kvm, gfn_t gfn); > > diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h > index c3308536482b..217f19100003 100644 > --- a/include/uapi/linux/kvm.h > +++ b/include/uapi/linux/kvm.h > @@ -210,6 +210,7 @@ struct kvm_xen_exit { > #define KVM_EXIT_NOTIFY 37 > #define KVM_EXIT_LOONGARCH_IOCSR 38 > #define KVM_EXIT_MEMORY_FAULT 39 > +#define KVM_EXIT_DIRTY_QUOTA_EXHAUSTED 40 > > /* For KVM_EXIT_INTERNAL_ERROR */ > /* Emulate instruction failed. */ > @@ -491,6 +492,12 @@ struct kvm_run { > struct kvm_sync_regs regs; > char padding[SYNC_REGS_SIZE_BYTES]; > } s; > + /* > + * Number of bytes the vCPU is allowed to dirty if KVM_CAP_DIRTY_QUOTA is > + * enabled. KVM_RUN exits with KVM_EXIT_DIRTY_QUOTA_EXHAUSTED if this quota > + * is exhausted, i.e. dirty_quota_bytes <= 0. > + */ > + long dirty_quota_bytes; This needs to be a u64 so that the size is consistent for 32-bit and 64-bit userspace vs. kernel.