KVM: x86: Open code shared_msr_update() in its only caller
PATCH 1/1 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]>
--- arch/x86/kvm/x86.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)
arch/x86/kvm/x86.c +9 -20
@@ -262,23 +262,6 @@ static void kvm_on_user_return(struct user_return_notifier *urn) } } -static void shared_msr_update (unsigned slot,u32 msr) -{ -u64 value; -unsigned int cpu =smp_processor_id (); -struct kvm_shared_msrs *smsr =per_cpu_ptr (shared_msrs, cpu); - -/* only read, and nobody should modify it at this time, -* so don't need lock */ -if (slot >= shared_msrs_global.nr) { -printk (KERN_ERR "kvm: invalid MSR slot!" ); -return ; - } -rdmsrl_safe (msr, &value); - smsr->values[slot].host = value; - smsr->values[slot].curr = value; -} -void kvm_define_shared_msr (unsigned slot,u32 msr) {BUG_ON (slot >=KVM_NR_SHARED_MSRS );
@@ -290,10 +273,16 @@ EXPORT_SYMBOL_GPL(kvm_define_shared_msr);static void kvm_shared_msr_cpu_online (void ) { -unsigned i; +unsigned int cpu =smp_processor_id (); +struct kvm_shared_msrs *smsr =per_cpu_ptr (shared_msrs, cpu); +u64 value; +int i; -for (i =0 ; i < shared_msrs_global.nr; ++i) -shared_msr_update (i, shared_msrs_global.msrs[i]); +for (i =0 ; i < shared_msrs_global.nr; ++i) { +rdmsrl_safe (shared_msrs_global.msrs[i], &value); + smsr->values[i].host = value; + smsr->values[i].curr = value; + } }int kvm_set_shared_msr (unsigned slot,u64 value,u64 mask)
Signature · 1 line
2.24.0
Quoted 48 lines · Sean Christopherson
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]>--- arch/x86/kvm/x86.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-)arch/x86/kvm/x86.c +4
-18@@ -262,23 +262,6 @@ static void kvm_on_user_return(struct user_return_notifier *urn) } } -static void shared_msr_update (unsigned slot,u32 msr) -{ -u64 value; -unsigned int cpu =smp_processor_id (); -struct kvm_shared_msrs *smsr =per_cpu_ptr (shared_msrs, cpu); - -/* only read, and nobody should modify it at this time, -* so don't need lock */ -if (slot >= shared_msrs_global.nr) { -printk (KERN_ERR "kvm: invalid MSR slot!" ); -return ; - } -rdmsrl_safe (msr, &value); - smsr->values[slot].host = value; - smsr->values[slot].curr = value; -} -void kvm_define_shared_msr (unsigned slot,u32 msr) {BUG_ON (slot >=KVM_NR_SHARED_MSRS );@@ -290,10 +273,16 @@ EXPORT_SYMBOL_GPL(kvm_define_shared_msr);static void kvm_shared_msr_cpu_online (void ) { -unsigned i; +unsigned int cpu =smp_processor_id (); +struct kvm_shared_msrs *smsr =per_cpu_ptr (shared_msrs, cpu); +u64 value; +int i;
arch/x86/kvm/x86.c EXPORT_SYMBOL_GPL(kvm_define_shared_msr); · line 288
Quoted 10 lines
arch/x86/kvm/x86.c +5
-2-for (i =0 ; i < shared_msrs_global.nr; ++i) -shared_msr_update (i, shared_msrs_global.msrs[i]); +for (i =0 ; i < shared_msrs_global.nr; ++i) { +rdmsrl_safe (shared_msrs_global.msrs[i], &value); + smsr->values[i].host = value; + smsr->values[i].curr = value; + } }int kvm_set_shared_msr (unsigned slot,u64 value,u64 mask)
Queued, thanks.
Paolo