diff mbox series

x86: kvm: hide the unused 'cpu' variable

Message ID 20180404104449.113197-1-arnd@arndb.de
State Accepted
Commit 51e8a8cc2f2d4295703f9c7ff66dead565dfea9a
Headers show
Series x86: kvm: hide the unused 'cpu' variable | expand

Commit Message

Arnd Bergmann April 4, 2018, 10:44 a.m. UTC
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 <arnd@arndb.de>

---
 arch/x86/kvm/vmx.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.9.0

Comments

David Hildenbrand April 4, 2018, 11:51 a.m. UTC | #1
On 04.04.2018 12:44, Arnd Bergmann wrote:
> 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 <arnd@arndb.de>

> ---

>  arch/x86/kvm/vmx.c | 2 ++

>  1 file changed, 2 insertions(+)

> 

> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

> index 8307f625ea99..7399a4a17f78 100644

> --- a/arch/x86/kvm/vmx.c

> +++ b/arch/x86/kvm/vmx.c

> @@ -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

Reviewed-by: David Hildenbrand <david@redhat.com>


-- 

Thanks,

David / dhildenb
Paolo Bonzini April 4, 2018, 5 p.m. UTC | #2
On 04/04/2018 13:51, David Hildenbrand wrote:
> On 04.04.2018 12:44, Arnd Bergmann wrote:

>> 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 <arnd@arndb.de>

>> ---

>>  arch/x86/kvm/vmx.c | 2 ++

>>  1 file changed, 2 insertions(+)

>>

>> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c

>> index 8307f625ea99..7399a4a17f78 100644

>> --- a/arch/x86/kvm/vmx.c

>> +++ b/arch/x86/kvm/vmx.c

>> @@ -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?


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

> Anyhow, fixes the problem

> 

> Reviewed-by: David Hildenbrand <david@redhat.com>

>
diff mbox series

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 8307f625ea99..7399a4a17f78 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -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)