From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Nathan Chancellor <nathan@kernel.org>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
Jim Mattson <jmattson@google.com>
Subject: [PATCH 6/6] KVM: SVM: Return the local "r" variable from svm_set_msr()
Date: Tue, 21 Mar 2023 18:14:40 -0700 [thread overview]
Message-ID: <20230322011440.2195485-7-seanjc@google.com> (raw)
In-Reply-To: <20230322011440.2195485-1-seanjc@google.com>
Rename "r" to "ret" and actually return it from svm_set_msr() to reduce
the probability of repeating the mistake of commit 723d5fb0ffe4 ("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>
---
arch/x86/kvm/svm/svm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index b32edaf5a74b..57f241c5a371 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -2873,7 +2873,7 @@ static int svm_set_vm_cr(struct kvm_vcpu *vcpu, u64 data)
static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
{
struct vcpu_svm *svm = to_svm(vcpu);
- int r;
+ int ret = 0;
u32 ecx = msr->index;
u64 data = msr->data;
@@ -2995,10 +2995,10 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
* guest via direct_access_msrs, and switch it via user return.
*/
preempt_disable();
- r = kvm_set_user_return_msr(tsc_aux_uret_slot, data, -1ull);
+ ret = kvm_set_user_return_msr(tsc_aux_uret_slot, data, -1ull);
preempt_enable();
- if (r)
- return 1;
+ if (ret)
+ break;
svm->tsc_aux = data;
break;
@@ -3056,7 +3056,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
default:
return kvm_set_msr_common(vcpu, msr);
}
- return 0;
+ return ret;
}
static int msr_interception(struct kvm_vcpu *vcpu)
--
2.40.0.rc2.332.ga46443480c-goog
next prev parent reply other threads:[~2023-03-22 1:16 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-22 1:14 [PATCH 0/6] KVM: x86: Unhost the *_CMD MSR mess Sean Christopherson
2023-03-22 1:14 ` [PATCH 1/6] KVM: x86: Revert MSR_IA32_FLUSH_CMD.FLUSH_L1D enabling Sean Christopherson
2023-03-22 8:15 ` Mathias Krause
2023-03-22 1:14 ` [PATCH 2/6] KVM: VMX: Passthrough MSR_IA32_PRED_CMD based purely on host+guest CPUID Sean Christopherson
2023-03-27 3:46 ` Xiaoyao Li
2023-03-22 1:14 ` [PATCH 3/6] KVM: SVM: " Sean Christopherson
2023-03-22 1:14 ` [PATCH 4/6] KVM: x86: Move MSR_IA32_PRED_CMD WRMSR emulation to common code Sean Christopherson
2023-03-27 6:41 ` Xiaoyao Li
2023-03-22 1:14 ` [PATCH 5/6] KVM: x86: Virtualize FLUSH_L1D and passthrough MSR_IA32_FLUSH_CMD Sean Christopherson
2023-03-23 5:07 ` Pawan Gupta
2023-03-23 22:17 ` Sean Christopherson
2023-03-24 8:48 ` Zhi Wang
2023-03-27 3:33 ` Xiaoyao Li
2023-03-27 15:37 ` Jim Mattson
2023-03-27 16:00 ` Sean Christopherson
2023-03-22 1:14 ` Sean Christopherson [this message]
2023-03-23 22:46 ` [PATCH 0/6] KVM: x86: Unhost the *_CMD MSR mess Sean Christopherson
2023-03-27 15:19 ` Paolo Bonzini
2023-03-27 15:28 ` Sean Christopherson
2023-03-27 15:46 ` Paolo Bonzini
2023-04-12 19:49 ` Paolo Bonzini
2023-04-12 20:00 ` Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230322011440.2195485-7-seanjc@google.com \
--to=seanjc@google.com \
--cc=eesposit@redhat.com \
--cc=jmattson@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®