Skip to content

Commit 05c19c2

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: x86: Open code shared_msr_update() in its only caller
Fold shared_msr_update() into its sole user to eliminate its pointless bounds check, its godawful printk, its misleading comment (it's called under a global lock), and its woefully inaccurate name. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent faf0be2 commit 05c19c2

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

arch/x86/kvm/x86.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,6 @@ static void kvm_on_user_return(struct user_return_notifier *urn)
262262
}
263263
}
264264

265-
static void shared_msr_update(unsigned slot, u32 msr)
266-
{
267-
u64 value;
268-
unsigned int cpu = smp_processor_id();
269-
struct kvm_shared_msrs *smsr = per_cpu_ptr(shared_msrs, cpu);
270-
271-
/* only read, and nobody should modify it at this time,
272-
* so don't need lock */
273-
if (slot >= shared_msrs_global.nr) {
274-
printk(KERN_ERR "kvm: invalid MSR slot!");
275-
return;
276-
}
277-
rdmsrl_safe(msr, &value);
278-
smsr->values[slot].host = value;
279-
smsr->values[slot].curr = value;
280-
}
281-
282265
void kvm_define_shared_msr(unsigned slot, u32 msr)
283266
{
284267
BUG_ON(slot >= KVM_NR_SHARED_MSRS);
@@ -290,10 +273,16 @@ EXPORT_SYMBOL_GPL(kvm_define_shared_msr);
290273

291274
static void kvm_shared_msr_cpu_online(void)
292275
{
293-
unsigned i;
276+
unsigned int cpu = smp_processor_id();
277+
struct kvm_shared_msrs *smsr = per_cpu_ptr(shared_msrs, cpu);
278+
u64 value;
279+
int i;
294280

295-
for (i = 0; i < shared_msrs_global.nr; ++i)
296-
shared_msr_update(i, shared_msrs_global.msrs[i]);
281+
for (i = 0; i < shared_msrs_global.nr; ++i) {
282+
rdmsrl_safe(shared_msrs_global.msrs[i], &value);
283+
smsr->values[i].host = value;
284+
smsr->values[i].curr = value;
285+
}
297286
}
298287

299288
int kvm_set_shared_msr(unsigned slot, u64 value, u64 mask)

0 commit comments

Comments
 (0)