All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arch/x86/kvm/x86.c: remove a superfluous test for !X86_64
@ 2014-04-27 15:32 Toralf Förster
  2014-04-27 15:40 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Toralf Förster @ 2014-04-27 15:32 UTC (permalink / raw)
  To: pbonzini; +Cc: kvm, Toralf Förster

compile and runtime tested

Signed-off-by: Toralf Förster <toralf.foerster@gmx.de>
---
 arch/x86/kvm/x86.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 8b8fc0b..a6ca7e0 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5680,15 +5680,17 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 	kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
 	longmode = is_long_mode(vcpu) && cs_l == 1;
 
+#ifdef CONFIG_X86_64
 	if (!longmode) {
+#endif
 		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffffff);
 		ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffffff);
 		outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
 			(kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffffff);
-	}
 #ifdef CONFIG_X86_64
+	}
 	else {
 		param = kvm_register_read(vcpu, VCPU_REGS_RCX);
 		ingpa = kvm_register_read(vcpu, VCPU_REGS_RDX);
-- 
1.9.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arch/x86/kvm/x86.c: remove a superfluous test for !X86_64
  2014-04-27 15:32 [PATCH] arch/x86/kvm/x86.c: remove a superfluous test for !X86_64 Toralf Förster
@ 2014-04-27 15:40 ` Paolo Bonzini
  2014-04-27 17:01   ` Toralf Förster
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2014-04-27 15:40 UTC (permalink / raw)
  To: Toralf Förster; +Cc: kvm

Il 27/04/2014 17:32, Toralf Förster ha scritto:
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 8b8fc0b..a6ca7e0 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -5680,15 +5680,17 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
>  	kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
>  	longmode = is_long_mode(vcpu) && cs_l == 1;
>
> +#ifdef CONFIG_X86_64
>  	if (!longmode) {
> +#endif

This is ugly...

>  		param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
>  			(kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffffff);
>  		ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
>  			(kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffffff);
>  		outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
>  			(kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffffff);
> -	}
>  #ifdef CONFIG_X86_64

... can you just remove this #ifdef instead?  It will be dead code, but 
the compiler will detect it as such and remove it.

Paolo

> +	}
>  	else {
>  		param = kvm_register_read(vcpu, VCPU_REGS_RCX);
>  		ingpa = kvm_register_read(vcpu, VCPU_REGS_RDX);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arch/x86/kvm/x86.c: remove a superfluous test for !X86_64
  2014-04-27 15:40 ` Paolo Bonzini
@ 2014-04-27 17:01   ` Toralf Förster
  2014-04-28  8:41     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Toralf Förster @ 2014-04-27 17:01 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm

On 04/27/2014 05:40 PM, Paolo Bonzini wrote:
> Il 27/04/2014 17:32, Toralf Förster ha scritto:
>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>> index 8b8fc0b..a6ca7e0 100644
>> --- a/arch/x86/kvm/x86.c
>> +++ b/arch/x86/kvm/x86.c
>> @@ -5680,15 +5680,17 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
>>      kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
>>      longmode = is_long_mode(vcpu) && cs_l == 1;
>>
>> +#ifdef CONFIG_X86_64
>>      if (!longmode) {
>> +#endif
> 
> This is ugly...
+1

> 
>>          param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
>>              (kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffffff);
>>          ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
>>              (kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffffff);
>>          outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
>>              (kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffffff);
>> -    }
>>  #ifdef CONFIG_X86_64
> 
> ... can you just remove this #ifdef instead?  It will be dead code, but
> the compiler will detect it as such and remove it.
> 

ok, but VCPU_REGS_R8 is #ifdef'ed in arch/x86/include/asm/kvm_host.h around line 120 and therefore I get :

tfoerste@n22 ~/devel/linux $ sudo make modules
...
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CC [M]  arch/x86/kvm/x86.o
arch/x86/kvm/x86.c: In function ‘kvm_hv_hypercall’:
arch/x86/kvm/x86.c:5694:36: error: ‘VCPU_REGS_R8’ undeclared (first use in this function)
arch/x86/kvm/x86.c:5694:36: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [arch/x86/kvm/x86.o] Error 1
make[1]: *** [arch/x86/kvm] Error 2
make: *** [arch/x86] Error 2


> Paolo
> 
>> +    }
>>      else {
>>          param = kvm_register_read(vcpu, VCPU_REGS_RCX);
>>          ingpa = kvm_register_read(vcpu, VCPU_REGS_RDX);
> 
> 


-- 
Toralf


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arch/x86/kvm/x86.c: remove a superfluous test for !X86_64
  2014-04-27 17:01   ` Toralf Förster
@ 2014-04-28  8:41     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2014-04-28  8:41 UTC (permalink / raw)
  To: Toralf Förster; +Cc: kvm

Il 27/04/2014 19:01, Toralf Förster ha scritto:
> On 04/27/2014 05:40 PM, Paolo Bonzini wrote:
>> Il 27/04/2014 17:32, Toralf Förster ha scritto:
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index 8b8fc0b..a6ca7e0 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>> @@ -5680,15 +5680,17 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
>>>      kvm_x86_ops->get_cs_db_l_bits(vcpu, &cs_db, &cs_l);
>>>      longmode = is_long_mode(vcpu) && cs_l == 1;
>>>
>>> +#ifdef CONFIG_X86_64
>>>      if (!longmode) {
>>> +#endif
>>
>> This is ugly...
> +1
>
>>
>>>          param = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDX) << 32) |
>>>              (kvm_register_read(vcpu, VCPU_REGS_RAX) & 0xffffffff);
>>>          ingpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RBX) << 32) |
>>>              (kvm_register_read(vcpu, VCPU_REGS_RCX) & 0xffffffff);
>>>          outgpa = ((u64)kvm_register_read(vcpu, VCPU_REGS_RDI) << 32) |
>>>              (kvm_register_read(vcpu, VCPU_REGS_RSI) & 0xffffffff);
>>> -    }
>>>  #ifdef CONFIG_X86_64
>>
>> ... can you just remove this #ifdef instead?  It will be dead code, but
>> the compiler will detect it as such and remove it.
>>
>
> ok, but VCPU_REGS_R8 is #ifdef'ed in arch/x86/include/asm/kvm_host.h around line 120 and therefore I get :
>
> tfoerste@n22 ~/devel/linux $ sudo make modules
> ...
>   CHK     include/config/kernel.release
>   CHK     include/generated/uapi/linux/version.h
>   CHK     include/generated/utsrelease.h
>   CALL    scripts/checksyscalls.sh
>   CC [M]  arch/x86/kvm/x86.o
> arch/x86/kvm/x86.c: In function ‘kvm_hv_hypercall’:
> arch/x86/kvm/x86.c:5694:36: error: ‘VCPU_REGS_R8’ undeclared (first use in this function)
> arch/x86/kvm/x86.c:5694:36: note: each undeclared identifier is reported only once for each function it appears in
> make[2]: *** [arch/x86/kvm/x86.o] Error 1
> make[1]: *** [arch/x86/kvm] Error 2
> make: *** [arch/x86] Error 2

You can just BUG() in the #else then if you really feel like fixing this:

	} else {
#ifdef CONFIG_X86_64
		...
#else
		BUG();
#endif

Paolo

>
>> Paolo
>>
>>> +    }
>>>      else {
>>>          param = kvm_register_read(vcpu, VCPU_REGS_RCX);
>>>          ingpa = kvm_register_read(vcpu, VCPU_REGS_RDX);
>>
>>
>
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-28  8:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-27 15:32 [PATCH] arch/x86/kvm/x86.c: remove a superfluous test for !X86_64 Toralf Förster
2014-04-27 15:40 ` Paolo Bonzini
2014-04-27 17:01   ` Toralf Förster
2014-04-28  8:41     ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.