@@ -59,6 +59,7 @@
#include <linux/mem_encrypt.h>
#include <linux/entry-kvm.h>
#include <linux/suspend.h>
+#include <linux/dirty_quota_migration.h>
#include <trace/events/kvm.h>
@@ -10028,6 +10029,14 @@ static int vcpu_run(struct kvm_vcpu *vcpu)
return r;
vcpu->srcu_idx = srcu_read_lock(&kvm->srcu);
}
+
+ /* check for dirty quota migration exit condition if it is enabled */
+ if (vcpu->kvm->dirty_quota_migration_enabled &&
+ is_dirty_quota_full(vcpu->vCPUdqctx)) {
+ vcpu->run->exit_reason = KVM_EXIT_DIRTY_QUOTA_FULL;
+ r = 0;
+ break;
+ }
}
srcu_read_unlock(&kvm->srcu, vcpu->srcu_idx);
@@ -30,11 +30,17 @@ static inline struct page *kvm_dirty_quota_context_get_page(
return NULL;
}
+static inline bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx)
+{
+ return true;
+}
+
#else /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */
int kvm_vcpu_dirty_quota_alloc(struct vCPUDirtyQuotaContext **vCPUdqctx);
struct page *kvm_dirty_quota_context_get_page(
struct vCPUDirtyQuotaContext *vCPUdqctx, u32 offset);
+bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx);
#endif /* KVM_DIRTY_QUOTA_PAGE_OFFSET == 0 */
@@ -270,6 +270,7 @@ struct kvm_xen_exit {
#define KVM_EXIT_X86_BUS_LOCK 33
#define KVM_EXIT_XEN 34
#define KVM_EXIT_RISCV_SBI 35
+#define KVM_EXIT_DIRTY_QUOTA_FULL 36
/* For KVM_EXIT_INTERNAL_ERROR */
/* Emulate instruction failed. */
@@ -18,3 +18,8 @@ struct page *kvm_dirty_quota_context_get_page(
{
return vmalloc_to_page((void *)vCPUdqctx + offset * PAGE_SIZE);
}
+
+bool is_dirty_quota_full(struct vCPUDirtyQuotaContext *vCPUdqctx)
+{
+ return (vCPUdqctx->dirty_counter >= vCPUdqctx->dirty_quota);
+}