KVM: Add new exit reason for dirty ring full conditions
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v4 3/4 KVM: Add new exit reason for dirty ring full conditions
Add new KVM exit reason KVM_EXIT_DIRTY_LOG_FULL.
Signed-off-by Lei Cao <[email protected]>
--- arch/x86/include/asm/kvm_host.h | 3 +++ arch/x86/kvm/mmu.c | 7 +++++++ arch/x86/kvm/vmx.c | 7 +++++++ arch/x86/kvm/x86.c | 6 ++++++ include/linux/kvm_host.h | 1 + include/uapi/linux/kvm.h | 1 + 6 files changed, 25 insertions(+)
arch/x86/include/asm/kvm_host.h +3 -0
@@ -1002,6 +1002,7 @@ struct kvm_x86_ops {void (*enable_log_dirty_pt_masked)(struct kvm *kvm,struct kvm_memory_slot *slot,gfn_t offset,unsigned long mask); +int (*cpu_dirty_log_size)(void );/* pmu operations of sub-arch */ const struct kvm_pmu_ops *pmu_ops;
@@ -1408,4 +1409,6 @@ static inline int kvm_cpu_get_apicid(int mps_cpu) #endif } +int kvm_cpu_dirty_log_size (void ); +#endif /* _ASM_X86_KVM_HOST_H */
arch/x86/kvm/mmu.c +7 -0
@@ -1357,6 +1357,13 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,kvm_mmu_write_protect_pt_masked (kvm, slot, gfn_offset, mask); } +int kvm_cpu_dirty_log_size (void ) +{ +if (kvm_x86_ops->cpu_dirty_log_size) +return kvm_x86_ops->cpu_dirty_log_size (); +return 0 ; +} +bool kvm_mmu_slot_gfn_write_protect (struct kvm *kvm,struct kvm_memory_slot *slot,u64 gfn) {
arch/x86/kvm/vmx.c +7 -0
@@ -6723,6 +6723,7 @@ static __init int hardware_setup(void) kvm_x86_ops->slot_disable_log_dirty =NULL ; kvm_x86_ops->flush_log_dirty =NULL ; kvm_x86_ops->enable_log_dirty_pt_masked =NULL ; + kvm_x86_ops->cpu_dirty_log_size =NULL ; }if (cpu_has_vmx_preemption_timer () && enable_preemption_timer) {
@@ -11497,6 +11498,11 @@ static void vmx_setup_mce(struct kvm_vcpu *vcpu) ~FEATURE_CONTROL_LMCE ; } +static int vmx_cpu_dirty_log_size (void ) +{ +return PML_ENTITY_NUM ; +} +static struct kvm_x86_ops vmx_x86_ops__ro_after_init = { .cpu_has_kvm_support = cpu_has_kvm_support, .disabled_by_bios = vmx_disabled_by_bios,
@@ -11611,6 +11617,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = { .slot_disable_log_dirty = vmx_slot_disable_log_dirty, .flush_log_dirty = vmx_flush_log_dirty, .enable_log_dirty_pt_masked = vmx_enable_log_dirty_pt_masked, + .cpu_dirty_log_size = vmx_cpu_dirty_log_size, .pre_block = vmx_pre_block, .post_block = vmx_post_block,
arch/x86/kvm/x86.c +6 -0
@@ -6706,6 +6706,12 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)*/ if (kvm_check_request (KVM_REQ_HV_STIMER , vcpu))kvm_hv_process_stimers (vcpu); + +if (kvm_check_request (KVM_REQ_EXIT_DIRTY_LOG_FULL , vcpu)) { + vcpu->run->exit_reason =KVM_EXIT_DIRTY_LOG_FULL ; + r = -EINTR ; + goto out; + } }/*
include/linux/kvm_host.h +1 -0
@@ -123,6 +123,7 @@ static inline bool is_error_page(struct page *page)#define KVM_REQ_MMU_RELOAD 1#define KVM_REQ_PENDING_TIMER 2#define KVM_REQ_UNHALT 3 +#define KVM_REQ_EXIT_DIRTY_LOG_FULL 4#define KVM_USERSPACE_IRQ_SOURCE_ID 0#define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID 1
include/uapi/linux/kvm.h +1 -0
@@ -205,6 +205,7 @@ struct kvm_hyperv_exit {#define KVM_EXIT_S390_STSI 25#define KVM_EXIT_IOAPIC_EOI 26#define KVM_EXIT_HYPERV 27 +#define KVM_EXIT_DIRTY_LOG_FULL 28/* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */
Signature · 1 line
2.5.0