Skip to content

Commit 2bb16be

Browse files
vittyvkbonzini
authored andcommitted
KVM: nSVM: Swap the parameter order for svm_copy_vmrun_state()/svm_copy_vmloadsave_state()
Make svm_copy_vmrun_state()/svm_copy_vmloadsave_state() interface match 'memcpy(dest, src)' to avoid any confusion. No functional change intended. Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Vitaly Kuznetsov <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9a9e748 commit 2bb16be

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

arch/x86/kvm/svm/nested.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu)
702702
}
703703

704704
/* Copy state save area fields which are handled by VMRUN */
705-
void svm_copy_vmrun_state(struct vmcb_save_area *from_save,
706-
struct vmcb_save_area *to_save)
705+
void svm_copy_vmrun_state(struct vmcb_save_area *to_save,
706+
struct vmcb_save_area *from_save)
707707
{
708708
to_save->es = from_save->es;
709709
to_save->cs = from_save->cs;
@@ -722,7 +722,7 @@ void svm_copy_vmrun_state(struct vmcb_save_area *from_save,
722722
to_save->cpl = 0;
723723
}
724724

725-
void svm_copy_vmloadsave_state(struct vmcb *from_vmcb, struct vmcb *to_vmcb)
725+
void svm_copy_vmloadsave_state(struct vmcb *to_vmcb, struct vmcb *from_vmcb)
726726
{
727727
to_vmcb->save.fs = from_vmcb->save.fs;
728728
to_vmcb->save.gs = from_vmcb->save.gs;
@@ -1385,7 +1385,7 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
13851385

13861386
svm->nested.vmcb12_gpa = kvm_state->hdr.svm.vmcb_pa;
13871387

1388-
svm_copy_vmrun_state(save, &svm->vmcb01.ptr->save);
1388+
svm_copy_vmrun_state(&svm->vmcb01.ptr->save, save);
13891389
nested_load_control_from_vmcb12(svm, ctl);
13901390

13911391
svm_switch_vmcb(svm, &svm->nested.vmcb02);

arch/x86/kvm/svm/svm.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,11 +2147,11 @@ static int vmload_vmsave_interception(struct kvm_vcpu *vcpu, bool vmload)
21472147
ret = kvm_skip_emulated_instruction(vcpu);
21482148

21492149
if (vmload) {
2150-
svm_copy_vmloadsave_state(vmcb12, svm->vmcb);
2150+
svm_copy_vmloadsave_state(svm->vmcb, vmcb12);
21512151
svm->sysenter_eip_hi = 0;
21522152
svm->sysenter_esp_hi = 0;
21532153
} else {
2154-
svm_copy_vmloadsave_state(svm->vmcb, vmcb12);
2154+
svm_copy_vmloadsave_state(vmcb12, svm->vmcb);
21552155
}
21562156

21572157
kvm_vcpu_unmap(vcpu, &map, true);
@@ -4345,8 +4345,8 @@ static int svm_enter_smm(struct kvm_vcpu *vcpu, char *smstate)
43454345

43464346
BUILD_BUG_ON(offsetof(struct vmcb, save) != 0x400);
43474347

4348-
svm_copy_vmrun_state(&svm->vmcb01.ptr->save,
4349-
map_save.hva + 0x400);
4348+
svm_copy_vmrun_state(map_save.hva + 0x400,
4349+
&svm->vmcb01.ptr->save);
43504350

43514351
kvm_vcpu_unmap(vcpu, &map_save, true);
43524352
}
@@ -4394,8 +4394,8 @@ static int svm_leave_smm(struct kvm_vcpu *vcpu, const char *smstate)
43944394
&map_save) == -EINVAL)
43954395
return 1;
43964396

4397-
svm_copy_vmrun_state(map_save.hva + 0x400,
4398-
&svm->vmcb01.ptr->save);
4397+
svm_copy_vmrun_state(&svm->vmcb01.ptr->save,
4398+
map_save.hva + 0x400);
43994399

44004400
kvm_vcpu_unmap(vcpu, &map_save, true);
44014401
}

arch/x86/kvm/svm/svm.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ void svm_leave_nested(struct vcpu_svm *svm);
464464
void svm_free_nested(struct vcpu_svm *svm);
465465
int svm_allocate_nested(struct vcpu_svm *svm);
466466
int nested_svm_vmrun(struct kvm_vcpu *vcpu);
467-
void svm_copy_vmrun_state(struct vmcb_save_area *from_save,
468-
struct vmcb_save_area *to_save);
469-
void svm_copy_vmloadsave_state(struct vmcb *from_vmcb, struct vmcb *to_vmcb);
467+
void svm_copy_vmrun_state(struct vmcb_save_area *to_save,
468+
struct vmcb_save_area *from_save);
469+
void svm_copy_vmloadsave_state(struct vmcb *to_vmcb, struct vmcb *from_vmcb);
470470
int nested_svm_vmexit(struct vcpu_svm *svm);
471471

472472
static inline int nested_svm_simple_vmexit(struct vcpu_svm *svm, u32 exit_code)

0 commit comments

Comments
 (0)