KVM: x86/mmu: Make dirty log size hook (PML) a value, not a function
authorSean Christopherson <seanjc@google.com>
Sat, 13 Feb 2021 00:50:09 +0000 (16:50 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 19 Feb 2021 08:08:33 +0000 (03:08 -0500)
Store the vendor-specific dirty log size in a variable, there's no need
to wrap it in a function since the value is constant after
hardware_setup() runs.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210213005015.1651772-9-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm-x86-ops.h
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu/mmu.c
arch/x86/kvm/vmx/vmx.c

index 355a2ab8fc090ed6da86d3dd3ae32d4d8242bbb0..28c07cc01474a91789bd66aae8652b5125f83116 100644 (file)
@@ -97,7 +97,6 @@ KVM_X86_OP_NULL(slot_enable_log_dirty)
 KVM_X86_OP_NULL(slot_disable_log_dirty)
 KVM_X86_OP_NULL(flush_log_dirty)
 KVM_X86_OP_NULL(enable_log_dirty_pt_masked)
-KVM_X86_OP_NULL(cpu_dirty_log_size)
 KVM_X86_OP_NULL(pre_block)
 KVM_X86_OP_NULL(post_block)
 KVM_X86_OP_NULL(vcpu_blocking)
index 84499aad01a468820a961568ee58682d6726938b..fb59933610d9d99740c36e8afd1206b111f0dabe 100644 (file)
@@ -1294,7 +1294,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);
+       int cpu_dirty_log_size;
 
        /* pmu operations of sub-arch */
        const struct kvm_pmu_ops *pmu_ops;
index 4f2dfd59f9a2ce537f3bf59e5b93244fd96ca661..0ed52397c2746fc41bf65744feaa4e6bc10446fc 100644 (file)
@@ -1294,10 +1294,7 @@ void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
 
 int kvm_cpu_dirty_log_size(void)
 {
-       if (kvm_x86_ops.cpu_dirty_log_size)
-               return static_call(kvm_x86_cpu_dirty_log_size)();
-
-       return 0;
+       return kvm_x86_ops.cpu_dirty_log_size;
 }
 
 bool kvm_mmu_slot_gfn_write_protect(struct kvm *kvm,
index 559a0f16263e67e6109843108a922bc57e1572b7..02456ab8fd0cd5d5e4731bb31b238c58c4f8554a 100644 (file)
@@ -7642,11 +7642,6 @@ static bool vmx_check_apicv_inhibit_reasons(ulong bit)
        return supported & BIT(bit);
 }
 
-static int vmx_cpu_dirty_log_size(void)
-{
-       return enable_pml ? PML_ENTITY_NUM : 0;
-}
-
 static struct kvm_x86_ops vmx_x86_ops __initdata = {
        .hardware_unsetup = hardware_unsetup,
 
@@ -7750,6 +7745,7 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
        .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 = PML_ENTITY_NUM,
 
        .pre_block = vmx_pre_block,
        .post_block = vmx_post_block,
@@ -7777,7 +7773,6 @@ static struct kvm_x86_ops vmx_x86_ops __initdata = {
 
        .msr_filter_changed = vmx_msr_filter_changed,
        .complete_emulated_msr = kvm_complete_insn_gp,
-       .cpu_dirty_log_size = vmx_cpu_dirty_log_size,
 
        .vcpu_deliver_sipi_vector = kvm_vcpu_deliver_sipi_vector,
 };
@@ -7899,7 +7894,7 @@ static __init int hardware_setup(void)
                vmx_x86_ops.slot_disable_log_dirty = NULL;
                vmx_x86_ops.flush_log_dirty = NULL;
                vmx_x86_ops.enable_log_dirty_pt_masked = NULL;
-               vmx_x86_ops.cpu_dirty_log_size = NULL;
+               vmx_x86_ops.cpu_dirty_log_size = 0;
        }
 
        if (!cpu_has_vmx_preemption_timer())