public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Chen, Tiejun" <tiejun.chen@intel.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] kvm: x86: vmx: avoid returning bool to distinguish success from error
Date: Wed, 05 Nov 2014 09:50:40 +0800	[thread overview]
Message-ID: <54598270.2050302@intel.com> (raw)
In-Reply-To: <545980A9.8030405@intel.com>

On 2014/11/5 9:43, Chen, Tiejun wrote:
> On 2014/11/5 1:33, Paolo Bonzini wrote:
>> Return a negative error code instead, and WARN() when we should be
>> covering
>> the entire 2-bit space of vmcs_field_type's return value.  For increased
>> robustness, add a BUILD_BUG_ON checking the range of
>> vmcs_field_to_offset.
>>
>> Suggested-by: Tiejun Chen <tiejun.chen@intel.com>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>   arch/x86/kvm/vmx.c | 51

[snip]

>> @@ -6576,6 +6581,9 @@ static void copy_shadow_to_vmcs12(struct
>> vcpu_vmx *vmx)
>>           case VMCS_FIELD_TYPE_NATURAL_WIDTH:
>>               field_value = vmcs_readl(field);
>>               break;
>> +        default:
>> +            WARN_ON(1);
>> +            continue;
>
> 'continue' versus 'break'?
>
> Thanks
> Tiejun
>
>>           }
>>           vmcs12_write_any(&vmx->vcpu, field, field_value);
>>       }
>> @@ -6621,6 +6629,9 @@ static void copy_vmcs12_to_shadow(struct
>> vcpu_vmx *vmx)
>>               case VMCS_FIELD_TYPE_NATURAL_WIDTH:
>>                   vmcs_writel(field, (long)field_value);
>>                   break;
>> +            default:
>> +                WARN_ON(1);
>> +                break;
>>               }
>>           }
>>       }
>> @@ -6659,7 +6670,7 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
>>       /* Decode instruction info and find the field to read */
>>       field = kvm_register_readl(vcpu, (((vmx_instruction_info) >> 28)
>> & 0xf));
>>       /* Read the field, zero-extended to a u64 field_value */
>> -    if (!vmcs12_read_any(vcpu, field, &field_value)) {
>> +    if (vmcs12_read_any(vcpu, field, &field_value) < 0) {
>>           nested_vmx_failValid(vcpu, VMXERR_UNSUPPORTED_VMCS_COMPONENT);
>>           skip_emulated_instruction(vcpu);
>>           return 1;
>>

Looks we're missing another place,

--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -6601,7 +6601,7 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
                 return 1;
         }

-       if (!vmcs12_write_any(vcpu, field, field_value)) {
+       if (vmcs12_write_any(vcpu, field, field_value) < 0) {
                 nested_vmx_failValid(vcpu, 
VMXERR_UNSUPPORTED_VMCS_COMPONENT);
                 skip_emulated_instruction(vcpu);
                 return 1;
Thanks
Tiejun

  reply	other threads:[~2014-11-05  1:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-04 17:33 [PATCH] kvm: x86: vmx: avoid returning bool to distinguish success from error Paolo Bonzini
2014-11-05  1:43 ` Chen, Tiejun
2014-11-05  1:50   ` Chen, Tiejun [this message]
2014-11-05  9:37   ` Paolo Bonzini

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=54598270.2050302@intel.com \
    --to=tiejun.chen@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /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