Skip to content

Commit ae81ce9

Browse files
Maxim Levitskysean-jc
authored andcommitted
KVM: VMX: refactor PML terminology
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>
1 parent 4d141e4 commit ae81ce9

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

arch/x86/kvm/vmx/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
125125
.check_intercept = vmx_check_intercept,
126126
.handle_exit_irqoff = vmx_handle_exit_irqoff,
127127

128-
.cpu_dirty_log_size = PML_ENTITY_NUM,
128+
.cpu_dirty_log_size = PML_LOG_NR_ENTRIES,
129129
.update_cpu_dirty_logging = vmx_update_cpu_dirty_logging,
130130

131131
.nested_ops = &vmx_nested_ops,

arch/x86/kvm/vmx/nested.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3442,7 +3442,7 @@ static int nested_vmx_write_pml_buffer(struct kvm_vcpu *vcpu, gpa_t gpa)
34423442
if (!nested_cpu_has_pml(vmcs12))
34433443
return 0;
34443444

3445-
if (vmcs12->guest_pml_index >= PML_ENTITY_NUM) {
3445+
if (vmcs12->guest_pml_index >= PML_LOG_NR_ENTRIES) {
34463446
vmx->nested.pml_full = true;
34473447
return 1;
34483448
}

arch/x86/kvm/vmx/vmx.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4821,7 +4821,7 @@ static void init_vmcs(struct vcpu_vmx *vmx)
48214821

48224822
if (enable_pml) {
48234823
vmcs_write64(PML_ADDRESS, page_to_phys(vmx->pml_pg));
4824-
vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1);
4824+
vmcs_write16(GUEST_PML_INDEX, PML_HEAD_INDEX);
48254825
}
48264826

48274827
vmx_write_encls_bitmap(&vmx->vcpu, NULL);
@@ -6209,17 +6209,17 @@ static void vmx_flush_pml_buffer(struct kvm_vcpu *vcpu)
62096209
pml_idx = vmcs_read16(GUEST_PML_INDEX);
62106210

62116211
/* Do nothing if PML buffer is empty */
6212-
if (pml_idx == (PML_ENTITY_NUM - 1))
6212+
if (pml_idx == PML_HEAD_INDEX)
62136213
return;
62146214

62156215
/* PML index always points to next available PML buffer entity */
6216-
if (pml_idx >= PML_ENTITY_NUM)
6216+
if (pml_idx >= PML_LOG_NR_ENTRIES)
62176217
pml_idx = 0;
62186218
else
62196219
pml_idx++;
62206220

62216221
pml_buf = page_address(vmx->pml_pg);
6222-
for (; pml_idx < PML_ENTITY_NUM; pml_idx++) {
6222+
for (; pml_idx < PML_LOG_NR_ENTRIES; pml_idx++) {
62236223
u64 gpa;
62246224

62256225
gpa = pml_buf[pml_idx];
@@ -6228,7 +6228,7 @@ static void vmx_flush_pml_buffer(struct kvm_vcpu *vcpu)
62286228
}
62296229

62306230
/* reset PML index */
6231-
vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1);
6231+
vmcs_write16(GUEST_PML_INDEX, PML_HEAD_INDEX);
62326232
}
62336233

62346234
static void vmx_dump_sel(char *name, uint32_t sel)

arch/x86/kvm/vmx/vmx.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,10 @@ struct vcpu_vmx {
331331
bool ple_window_dirty;
332332

333333
/* Support for PML */
334-
#define PML_ENTITY_NUM 512
334+
#define PML_LOG_NR_ENTRIES 512
335+
/* PML is written backwards: this is the first entry written by the CPU */
336+
#define PML_HEAD_INDEX (PML_LOG_NR_ENTRIES-1)
337+
335338
struct page *pml_pg;
336339

337340
/* apic deadline value in host tsc */

0 commit comments

Comments
 (0)