x86: kvm: hide the unused 'cpu' variable
PATCH 1/1 x86: kvm: hide the unused 'cpu' variable
The local variable was newly introduced but is only accessed in one place on x86_64, but not on 32-bit:
arch/x86/kvm/vmx.c: In function 'vmx_save_host_state':arch/x86/kvm/vmx.c:2175:6: error: unused variable 'cpu' [-Werror=unused-variable]
This puts it into another #ifdef.
--- arch/x86/kvm/vmx.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/vmx.c +2 -0
@@ -2357,7 +2357,9 @@ static unsigned long segment_base(u16 selector)static void vmx_save_host_state (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu); +#ifdef CONFIG_X86_64 int cpu =raw_smp_processor_id (); +#endif int i;if (vmx->host_state.loaded)
Signature · 1 line
2.9.0
Quoted 20 lines · Arnd Bergmann
The local variable was newly introduced but is only accessed in one place on
x86_64, but not on 32-bit:
arch/x86/kvm/vmx.c: In function 'vmx_save_host_state':arch/x86/kvm/vmx.c:2175:6: error: unused variable 'cpu' [-Werror=unused-variable]This puts it into another #ifdef.
Fixes 35060ed6a1ff ("x86/kvm/vmx: avoid expensive rdmsr for MSR_GS_BASE")Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/kvm/vmx.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/kvm/vmx.c +0
-0
arch/x86/kvm/vmx.c static unsigned long segment_base(u16 selector) · line 2365
Quoted 9 lines
arch/x86/kvm/vmx.c +2
-0@@ -2357,7 +2357,9 @@ static unsigned long segment_base(u16 selector)static void vmx_save_host_state (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu); +#ifdef CONFIG_X86_64 int cpu =raw_smp_processor_id (); +#endif int i;if (vmx->host_state.loaded)
Can't we get rid of the variable and just do it inline?
Anyhow, fixes the problem
Signature · 3 lines
Thanks, David / dhildenb
Paolo Bonzini
maintainerQuoted 28 lines · David Hildenbrand
Quoted 27 lines · Arnd Bergmann
The local variable was newly introduced but is only accessed in one place on
x86_64, but not on 32-bit:
arch/x86/kvm/vmx.c: In function 'vmx_save_host_state':arch/x86/kvm/vmx.c:2175:6: error: unused variable 'cpu' [-Werror=unused-variable]This puts it into another #ifdef.
Fixes 35060ed6a1ff ("x86/kvm/vmx: avoid expensive rdmsr for MSR_GS_BASE")Signed-off-by Arnd Bergmann <[email protected]>--- arch/x86/kvm/vmx.c | 2 ++ 1 file changed, 2 insertions(+)arch/x86/kvm/vmx.c +2
-0@@ -2357,7 +2357,9 @@ static unsigned long segment_base(u16 selector)static void vmx_save_host_state (struct kvm_vcpu *vcpu) {struct vcpu_vmx *vmx =to_vmx (vcpu); +#ifdef CONFIG_X86_64 int cpu =raw_smp_processor_id (); +#endif int i;
Quoted 4 lines
arch/x86/kvm/vmx.c static unsigned long segment_base(u16 selector) · line 2365
Quoted 2 lines
arch/x86/kvm/vmx.c +0
-0if (vmx->host_state.loaded)Can't we get rid of the variable and just do it inline?
Neither is particularly nice, but one thing we can do is simplify the #ifdef maze by combining conditionals that have no code in between.
Paolo
Quoted 4 lines
Anyhow, fixes the problem
Reviewed-by David Hildenbrand <[email protected]>