From: Paolo Bonzini <pbonzini@redhat.com>
To: "Toralf Förster" <toralf.foerster@gmx.de>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 1/2] arch/x86/kvm/x86.c: remove superflous check condition
Date: Sun, 27 Apr 2014 16:41:33 +0200 [thread overview]
Message-ID: <535D171D.7020809@redhat.com> (raw)
In-Reply-To: <535CECB6.5070802@gmx.de>
Il 27/04/2014 13:40, Toralf Förster ha scritto:
> On 04/27/2014 12:45 PM, Paolo Bonzini wrote:
>> Il 27/04/2014 12:30, Toralf Förster ha scritto:
>>> Signed-off-by: Toralf Förster <toralf.foerster@gmx.de>
>>> ---
>>> arch/x86/kvm/x86.c | 23 ++++++++++-------------
>>> 1 file changed, 10 insertions(+), 13 deletions(-)
>>>
>>> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
>>> index 8b8fc0b..93cf454 100644
>>> --- a/arch/x86/kvm/x86.c
>>> +++ b/arch/x86/kvm/x86.c
>>> @@ -5680,20 +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;
>>>
>>> - if (!longmode) {
>>> - 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);
>>> - outgpa = kvm_register_read(vcpu, VCPU_REGS_R8);
>>> - }
>>> + param = kvm_register_read(vcpu, VCPU_REGS_RCX);
>>> + ingpa = kvm_register_read(vcpu, VCPU_REGS_RDX);
>>> + outgpa = kvm_register_read(vcpu, VCPU_REGS_R8);
>>> +#else
>>> + 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);
>>> #endif
>>>
>>> code = param & 0xffff;
>>>
>>
>> No, wait, it's only superfluous in the sense that you don't need
>> longmode for !CONFIG_X86_64. It's definitely needed for CONFIG_X86_64,
>> because the guest can run in 32-bit mode.
>>
>> Paolo
>>
>
> Ah, so the following would work, but looks too ugly, right ? :
>
>
> #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);
> outgpa = kvm_register_read(vcpu, VCPU_REGS_R8);
> }
> #endif
>
Yep. :) Note that GCC correctly reports no warning, because it looks
through is_long_mode. In the end, #ifdef in the code can just be
removed. Please compile-test it on 32-bit though (well, I will too
before committing but...).
Paolo
next prev parent reply other threads:[~2014-04-27 14:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-27 10:30 [PATCH 1/2] arch/x86/kvm/x86.c: remove superflous check condition Toralf Förster
2014-04-27 10:30 ` [PATCH 2/2] arch/x86/kvm/x86.c: variable longmode ist just used in one place, remove it therefore Toralf Förster
2014-04-27 10:45 ` [PATCH 1/2] arch/x86/kvm/x86.c: remove superflous check condition Paolo Bonzini
2014-04-27 11:40 ` Toralf Förster
2014-04-27 14:41 ` Paolo Bonzini [this message]
2014-04-27 15:29 ` Toralf Förster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=535D171D.7020809@redhat.com \
--to=pbonzini@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=toralf.foerster@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox