]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: VMX: refactor PML terminology
authorMaxim Levitsky <mlevitsk@redhat.com>
Thu, 19 Dec 2024 22:10:33 +0000 (17:10 -0500)
committerSean Christopherson <seanjc@google.com>
Wed, 8 Jan 2025 22:19:25 +0000 (14:19 -0800)
Rename PML_ENTITY_NUM to PML_LOG_NR_ENTRIES
Add PML_HEAD_INDEX to specify the first entry that CPU writes.

No functional change intended.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
Link: https://lore.kernel.org/r/20241219221034.903927-2-mlevitsk@redhat.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/vmx/main.c
arch/x86/kvm/vmx/nested.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/vmx/vmx.h

index d8614ffd0ef121c9195068f458695941bcfd5f4a..28360c350454c7e7045c49c211ab18103b9a3b3c 100644 (file)
@@ -125,7 +125,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
        .check_intercept = vmx_check_intercept,
        .handle_exit_irqoff = vmx_handle_exit_irqoff,
 
-       .cpu_dirty_log_size = PML_ENTITY_NUM,
+       .cpu_dirty_log_size = PML_LOG_NR_ENTRIES,
        .update_cpu_dirty_logging = vmx_update_cpu_dirty_logging,
 
        .nested_ops = &vmx_nested_ops,
index 42dd24e971cdf3c302cadf606bd5100d23082d97..a0ea5317cec8cfffac6ca39fc721d9f1ce15b241 100644 (file)
@@ -3442,7 +3442,7 @@ static int nested_vmx_write_pml_buffer(struct kvm_vcpu *vcpu, gpa_t gpa)
        if (!nested_cpu_has_pml(vmcs12))
                return 0;
 
-       if (vmcs12->guest_pml_index >= PML_ENTITY_NUM) {
+       if (vmcs12->guest_pml_index >= PML_LOG_NR_ENTRIES) {
                vmx->nested.pml_full = true;
                return 1;
        }
index edbed8ef2fe4a087a11fb727505f79873ddc6052..06cf7e01baf64fbeb393c1b871616e1fbf4922af 100644 (file)
@@ -4821,7 +4821,7 @@ static void init_vmcs(struct vcpu_vmx *vmx)
 
        if (enable_pml) {
                vmcs_write64(PML_ADDRESS, page_to_phys(vmx->pml_pg));
-               vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1);
+               vmcs_write16(GUEST_PML_INDEX, PML_HEAD_INDEX);
        }
 
        vmx_write_encls_bitmap(&vmx->vcpu, NULL);
@@ -6209,17 +6209,17 @@ static void vmx_flush_pml_buffer(struct kvm_vcpu *vcpu)
        pml_idx = vmcs_read16(GUEST_PML_INDEX);
 
        /* Do nothing if PML buffer is empty */
-       if (pml_idx == (PML_ENTITY_NUM - 1))
+       if (pml_idx == PML_HEAD_INDEX)
                return;
 
        /* PML index always points to next available PML buffer entity */
-       if (pml_idx >= PML_ENTITY_NUM)
+       if (pml_idx >= PML_LOG_NR_ENTRIES)
                pml_idx = 0;
        else
                pml_idx++;
 
        pml_buf = page_address(vmx->pml_pg);
-       for (; pml_idx < PML_ENTITY_NUM; pml_idx++) {
+       for (; pml_idx < PML_LOG_NR_ENTRIES; pml_idx++) {
                u64 gpa;
 
                gpa = pml_buf[pml_idx];
@@ -6228,7 +6228,7 @@ static void vmx_flush_pml_buffer(struct kvm_vcpu *vcpu)
        }
 
        /* reset PML index */
-       vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1);
+       vmcs_write16(GUEST_PML_INDEX, PML_HEAD_INDEX);
 }
 
 static void vmx_dump_sel(char *name, uint32_t sel)
index 892302022094a30f07e9f45dd15a96ab9bfe4e34..8b111ce1087c7daa5e2d2b7b9e6ae4e208193f57 100644 (file)
@@ -331,7 +331,10 @@ struct vcpu_vmx {
        bool ple_window_dirty;
 
        /* Support for PML */
-#define PML_ENTITY_NUM         512
+#define PML_LOG_NR_ENTRIES     512
+       /* PML is written backwards: this is the first entry written by the CPU */
+#define PML_HEAD_INDEX         (PML_LOG_NR_ENTRIES-1)
+
        struct page *pml_pg;
 
        /* apic deadline value in host tsc */