Skip to content

Commit 400d213

Browse files
sean-jcbonzini
authored andcommitted
KVM: SVM: Return the local "r" variable from svm_set_msr()
Rename "r" to "ret" and actually return it from svm_set_msr() to reduce the probability of repeating the mistake of commit 723d5fb ("kvm: svm: Add IA32_FLUSH_CMD guest support"), which set "r" thinking that it would be propagated to the caller. Alternatively, the declaration of "r" could be moved into the handling of MSR_TSC_AUX, but that risks variable shadowing in the future. A wrapper for kvm_set_user_return_msr() would allow eliding a local variable, but that feels like delaying the inevitable. No functional change intended. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20230322011440.2195485-7-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent da3db16 commit 400d213

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

arch/x86/kvm/svm/svm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,7 @@ static int svm_set_vm_cr(struct kvm_vcpu *vcpu, u64 data)
28732873
static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
28742874
{
28752875
struct vcpu_svm *svm = to_svm(vcpu);
2876-
int r;
2876+
int ret = 0;
28772877

28782878
u32 ecx = msr->index;
28792879
u64 data = msr->data;
@@ -2995,10 +2995,10 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
29952995
* guest via direct_access_msrs, and switch it via user return.
29962996
*/
29972997
preempt_disable();
2998-
r = kvm_set_user_return_msr(tsc_aux_uret_slot, data, -1ull);
2998+
ret = kvm_set_user_return_msr(tsc_aux_uret_slot, data, -1ull);
29992999
preempt_enable();
3000-
if (r)
3001-
return 1;
3000+
if (ret)
3001+
break;
30023002

30033003
svm->tsc_aux = data;
30043004
break;
@@ -3056,7 +3056,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
30563056
default:
30573057
return kvm_set_msr_common(vcpu, msr);
30583058
}
3059-
return 0;
3059+
return ret;
30603060
}
30613061

30623062
static int msr_interception(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)