KVM: Add new exit reason for dirty ring full conditions
PATCH v3 4/5 KVM: Add new exit reason for dirty ring full conditions
In reply to a message not in the archiveAdd new exit reason KVM_EXIT_DIRTY_LOG_FULL.
Signed-off-by Lei Cao <[email protected]>
--- arch/x86/include/asm/kvm_host.h | 4 ++++ arch/x86/kvm/mmu.c | 7 +++++++ arch/x86/kvm/vmx.c | 7 +++++++ arch/x86/kvm/x86.c | 6 ++++++ include/uapi/linux/kvm.h | 1 + 5 files changed, 25 insertions(+)
arch/x86/include/asm/kvm_host.h +4 -0
@@ -74,6 +74,7 @@#define KVM_REQ_HV_RESET 28#define KVM_REQ_HV_EXIT 29#define KVM_REQ_HV_STIMER 30 +#define KVM_REQ_EXIT_DIRTY_LOG_FULL 31#define CR0_RESERVED_BITS \ (~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
@@ -1005,6 +1006,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;
@@ -1411,4 +1413,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
@@ -6705,6 +6705,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/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
Paolo Bonzini
maintainerarch/x86/include/asm/kvm_host.h line 77
Quoted 9 lines · Lei
arch/x86/include/asm/kvm_host.h +1
-0@@ -74,6 +74,7 @@#define KVM_REQ_HV_RESET 28#define KVM_REQ_HV_EXIT 29#define KVM_REQ_HV_STIMER 30 +#define KVM_REQ_EXIT_DIRTY_LOG_FULL 31
This is an architecture-independent bit, so add it to include/linux/kvm_host.h after KVM_REQ_UNHALT.
Paolo