diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 009cef2477f0..d3030c99dba3 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -3232,10 +3232,12 @@ static int bus_lock_exit(struct kvm_vcpu *vcpu) void svm_update_cpu_dirty_logging(struct kvm_vcpu *vcpu, bool enable) { + struct vcpu_svm *svm = to_svm(vcpu); + if (enable) - svm->vmcb->control.nested_ctl |= svm_nested_ctl_pml_enable; + svm->vmcb->control.nested_ctl |= SVM_NESTED_CTL_PML_ENABLE; else - svm->vmcb->control.nested_ctl &= ~svm_nested_ctl_pml_enable; + svm->vmcb->control.nested_ctl &= ~SVM_NESTED_CTL_PML_ENABLE; } static void svm_flush_pml_buffer(struct kvm_vcpu *vcpu) @@ -3628,7 +3630,7 @@ static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath) * dirty bitmap current by processing logged GPAs rather than waiting for * PML_FULL exit. */ - if (pml && !is_guest_mode(vcpu)) + if (enable_pml && !is_guest_mode(vcpu)) svm_flush_pml_buffer(vcpu); /* SEV-ES guests must use the CR write traps to track CR registers. */ @@ -5097,7 +5099,7 @@ static int svm_vm_init(struct kvm *kvm) return ret; } - if (pml) + if (enable_pml) kvm->arch.cpu_dirty_log_size = PML_LOG_NR_ENTRIES; svm_srso_vm_init(); @@ -5457,7 +5459,7 @@ static __init int svm_hardware_setup(void) nrips = nrips && boot_cpu_has(X86_FEATURE_NRIPS); enable_pml = enable_pml && npt_enabled && cpu_feature_enabled(X86_FEATURE_PML); - if (pml) + if (enable_pml) pr_info("Page modification logging supported\n"); if (lbrv) { diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h index ce38f4a885d3..a73306592f18 100644 --- a/arch/x86/kvm/svm/svm.h +++ b/arch/x86/kvm/svm/svm.h @@ -51,6 +51,7 @@ extern bool intercept_smi; extern bool x2avic_enabled; extern bool vnmi; extern int lbrv; +extern bool __read_mostly enable_pml; /* * Clean bits in VMCB. @@ -216,9 +217,6 @@ struct svm_nested_state { * on its side. */ bool force_msr_bitmap_recalc; - - /* Indicates whether dirty logging changed while nested guest ran */ - bool update_vmcb01_cpu_dirty_logging; }; struct vcpu_sev_es_state { @@ -720,7 +718,7 @@ static inline void svm_enable_intercept_for_msr(struct kvm_vcpu *vcpu, svm_set_intercept_for_msr(vcpu, msr, type, true); } -void svm_update_cpu_dirty_logging(struct kvm_vcpu *vcpu); +void svm_update_cpu_dirty_logging(struct kvm_vcpu *vcpu, bool enable); /* nested.c */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 95843c854b11..35a748b0d4af 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -146,6 +146,7 @@ struct kvm_x86_ops kvm_x86_ops __read_mostly; #include EXPORT_STATIC_CALL_GPL(kvm_x86_get_cs_db_l_bits); EXPORT_STATIC_CALL_GPL(kvm_x86_cache_reg); +EXPORT_STATIC_CALL_GPL(kvm_x86_update_cpu_dirty_logging); static bool __read_mostly ignore_msrs = 0; module_param(ignore_msrs, bool, 0644);