KVM: x86: Fix names of implemented kvm_x86_ops in VMX and SVM modules
PATCH 1/1 KVM: x86: Fix names of implemented kvm_x86_ops in VMX and SVM modules
There is no functional change. Just the names of the functions in the two modules have been made consistent with respect to each other and with respect to the kvm_x86_ops structure. This will help in better readability and maintenance.
[PATCH] KVM: x86: Fix names of implemented kvm_x86_ops in VMX and SVM
arch/x86/kvm/svm/avic.c | 4 ++-- arch/x86/kvm/svm/svm.c | 46 +++++++++++++++++++------------------- arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/vmx/nested.c | 4 ++-- arch/x86/kvm/vmx/vmx.c | 56 +++++++++++++++++++++++------------------------ arch/x86/kvm/vmx/vmx.h | 4 ++-- 6 files changed, 58 insertions(+), 58 deletions(-)
Krish Sadhukhan (1):
KVM: x86: Fix names of implemented kvm_x86_ops in VMX and SVM modules
PATCH 1/1 KVM: x86: Fix names of implemented kvm_x86_ops in VMX and SVM modules
Some of the names do not have a corresponding 'vmx_' or 'svm_' prefix. Also, the order of the words in some of the names is not the same as that in the kvm_x86_ops structure. Fixing the naming will help in better readability of the code and maintenance.
--- arch/x86/kvm/svm/avic.c | 4 +-- arch/x86/kvm/svm/svm.c | 46 ++++++++++++++++---------------- arch/x86/kvm/svm/svm.h | 2 +- arch/x86/kvm/vmx/nested.c | 4 +-- arch/x86/kvm/vmx/vmx.c | 56 +++++++++++++++++++-------------------- arch/x86/kvm/vmx/vmx.h | 4 +-- 6 files changed, 58 insertions(+), 58 deletions(-)
arch/x86/kvm/svm/avic.c +2 -2
@@ -579,7 +579,7 @@ int avic_init_vcpu(struct vcpu_svm *svm)return ret; } -void avic_post_state_restore (struct kvm_vcpu *vcpu) +void svm_avic_post_state_restore (struct kvm_vcpu *vcpu) {if (avic_handle_apic_id_update (vcpu) !=0 )return ;
@@ -660,7 +660,7 @@ void svm_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)* we need to check and update the AVIC logical APIC ID table * accordingly before re-activating. */ -avic_post_state_restore (vcpu); +svm_avic_post_state_restore (vcpu); vmcb->control.int_ctl |=AVIC_ENABLE_MASK ; }else { vmcb->control.int_ctl &= ~AVIC_ENABLE_MASK ;
arch/x86/kvm/svm/svm.c +23 -23
157 lines not on this page · raw message
arch/x86/kvm/svm/svm.h +1 -1
@@ -444,7 +444,7 @@ int avic_unaccelerated_access_interception(struct vcpu_svm *svm);int avic_init_vcpu (struct vcpu_svm *svm);void avic_vcpu_load (struct kvm_vcpu *vcpu,int cpu);void avic_vcpu_put (struct kvm_vcpu *vcpu); -void avic_post_state_restore (struct kvm_vcpu *vcpu); +void svm_avic_post_state_restore (struct kvm_vcpu *vcpu);void svm_set_virtual_apic_mode (struct kvm_vcpu *vcpu);void svm_refresh_apicv_exec_ctrl (struct kvm_vcpu *vcpu);bool svm_check_apicv_inhibit_reasons (ulong bit);
arch/x86/kvm/vmx/nested.c +2 -2
@@ -2514,7 +2514,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,* bitwise-or of what L1 wants to trap for L2, and what we want to * trap. Note that CR0.TS also needs updating - we do this later. */ -update_exception_bitmap (vcpu); +vmx_update_exception_bitmap (vcpu); vcpu->arch.cr0_guest_owned_bits &= ~vmcs12->cr0_guest_host_mask;vmcs_writel (CR0_GUEST_HOST_MASK , ~vcpu->arch.cr0_guest_owned_bits);
@@ -3016,7 +3016,7 @@ static int nested_vmx_check_vmentry_hw(struct kvm_vcpu *vcpu)preempt_disable (); -vmx_prepare_switch_to_guest (vcpu); +vmx_prepare_guest_switch (vcpu);/* * Induce a consistency check VMExit by clearing bit 1 in GUEST_RFLAGS,
arch/x86/kvm/vmx/vmx.c +28 -28
176 lines not on this page · raw message
arch/x86/kvm/vmx/vmx.h +2 -2
@@ -325,7 +325,7 @@ void vmx_vcpu_load_vmcs(struct kvm_vcpu *vcpu, int cpu,int allocate_vpid (void );void free_vpid (int vpid);void vmx_set_constant_host_state (struct vcpu_vmx *vmx); -void vmx_prepare_switch_to_guest (struct kvm_vcpu *vcpu); +void vmx_prepare_guest_switch (struct kvm_vcpu *vcpu);void vmx_set_host_fs_gs (struct vmcs_host_state *host,u16 fs_sel,u16 gs_sel,unsigned long fs_base,unsigned long gs_base);int vmx_get_cpl (struct kvm_vcpu *vcpu);
@@ -342,7 +342,7 @@ void ept_save_pdptrs(struct kvm_vcpu *vcpu);void vmx_get_segment (struct kvm_vcpu *vcpu,struct kvm_segment *var,int seg);void vmx_set_segment (struct kvm_vcpu *vcpu,struct kvm_segment *var,int seg);u64 construct_eptp (struct kvm_vcpu *vcpu,unsigned long root_hpa); -void update_exception_bitmap (struct kvm_vcpu *vcpu); +void vmx_update_exception_bitmap (struct kvm_vcpu *vcpu);void vmx_update_msr_bitmap (struct kvm_vcpu *vcpu);bool vmx_nmi_blocked (struct kvm_vcpu *vcpu);bool vmx_interrupt_blocked (struct kvm_vcpu *vcpu);
Signature · 1 line
2.20.1
Quoted 4 lines · Krish Sadhukhan
Some of the names do not have a corresponding '
vmx_' or 'svm_' prefix. Also, the order of the words in some of the names is not the same as that in thekvm_x86_opsstructure. Fixing the naming will help in better readability of the code and maintenance.
If we're going to do a massive rename, I would strongly prefer to simultaneously enforce the "correct" names by adding a macro to generate the kvm_x86_ops hooks[*] (sample patch below). I'd like to realize long term benefits if we're going to incur merge conflicts on everyone's in-flight development.
I had a series for this, but it got derailed when svm.c was fractured and I haven't found time to get back to it. Code is on
https://github.com/sean-jc/linux/tree/vmx/x86_ops_macros if you have bandwidth to pick it up.
[*] https://lkml.kernel.org/r/[email protected]
commit 83b835803554f6288af438a519be2c2559d77d89
Author: Sean Christopherson <[email protected]> Date: Fri Apr 3 14:12:28 2020 -0700
KVM: VMX: Fill in conforming vmx_x86_ops via macro
arch/x86/kvm/vmx/nested.c +9 -7
@@ -6279,14 +6279,16 @@ void nested_vmx_hardware_unsetup(void) } } +#define KVM_X86_NESTED_OP (name) .name = nested_vmx_##name +static struct kvm_x86_nested_ops vmx_nested_ops__initdata = { - .check_events = nested_vmx_check_events, - .get_state = nested_vmx_get_state, - .set_state = nested_vmx_set_state, - .get_vmcs12_pages = nested_vmx_get_vmcs12_pages, - .enable_evmcs = nested_vmx_enable_evmcs, - .get_evmcs_version = nested_vmx_get_evmcs_version, - .write_log_dirty = nested_vmx_write_log_dirty, +KVM_X86_NESTED_OP (check_events), +KVM_X86_NESTED_OP (get_state), +KVM_X86_NESTED_OP (set_state), +KVM_X86_NESTED_OP (get_vmcs12_pages), +KVM_X86_NESTED_OP (enable_evmcs), +KVM_X86_NESTED_OP (get_evmcs_version), +KVM_X86_NESTED_OP (write_log_dirty), }; __init int nested_vmx_hardware_setup(struct kvm_x86_nested_ops *nested_ops,
arch/x86/kvm/vmx/vmx.c +7 -5
@@ -7626,134 +7626,136 @@ static bool vmx_check_apicv_inhibit_reasons(ulong bit)return supported &BIT (bit); } +#define KVM_X86_OP (name) .name = vmx_##name +static struct kvm_x86_ops vmx_x86_ops__initdata = { - .hardware_unsetup = vmx_hardware_unsetup, +KVM_X86_OP (hardware_unsetup), - .hardware_enable = vmx_hardware_enable, - .hardware_disable = vmx_hardware_disable, - .cpu_has_accelerated_tpr = vmx_cpu_has_accelerated_tpr, - .has_emulated_msr = vmx_has_emulated_msr, +KVM_X86_OP (hardware_enable), +KVM_X86_OP (hardware_disable), +KVM_X86_OP (cpu_has_accelerated_tpr), +KVM_X86_OP (has_emulated_msr),
...