[PATCH 03/13] KVM: nSVM: rename nested_sync_control_from_vmcb02 to nested_sync_int_ctl_from_vmcb02

Maxim Levitsky
2022-11-17T14:34:35Z

The nested_sync_control_from_vmcb02 name is misleading as there
are many fields which are modified by the CPU and need to be written back
to vmcb12.

This function only copies some int_ctl bits and thecevent_inj*
fields.

Make it copy only these int_ctl bits and rename the function.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
arch/x86/kvm/svm/nested.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 91a51e75717dca..54eb152e2b60b6 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -404,15 +404,13 @@ void nested_copy_vmcb_save_to_cache(struct vcpu_svm *svm,
}

/*
- * Synchronize fields that are written by the processor, so that
+ * Synchronize int_ctl fields that are written by the processor, so that
* they can be copied back into the vmcb12.
*/
-static void nested_sync_control_from_vmcb02(struct vcpu_svm *svm,
+static void nested_sync_int_ctl_from_vmcb02(struct vcpu_svm *svm,
struct vmcb *vmcb12)
{
u32 mask;
- vmcb12->control.event_inj = svm->vmcb->control.event_inj;
- vmcb12->control.event_inj_err = svm->vmcb->control.event_inj_err;

/* Only a few fields of int_ctl are written by the processor. */
mask = V_IRQ_MASK | V_TPR_MASK;
@@ -986,7 +984,10 @@ int nested_svm_vmexit(struct vcpu_svm *svm)
if (vmcb12->control.exit_code != SVM_EXIT_ERR)
nested_save_pending_event_to_vmcb12(svm, vmcb12);

- nested_sync_control_from_vmcb02(svm, vmcb12);
+ nested_sync_int_ctl_from_vmcb02(svm, vmcb12);
+
+ vmcb12->control.event_inj = svm->vmcb->control.event_inj;
+ vmcb12->control.event_inj_err = svm->vmcb->control.event_inj_err;

if (svm->nrips_enabled)
vmcb12->control.next_rip = vmcb02->control.next_rip;
--
2.34.3