[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC 1/9] xen: Emulate with no writes; compute current instruction length


  • To: Jan Beulich <JBeulich@xxxxxxxx>
  • From: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
  • Date: Wed, 02 Jul 2014 18:43:11 +0300
  • Cc: tim@xxxxxxx, xen-devel@xxxxxxxxxxxxx
  • Comment: DomainKeys? See http://domainkeys.sourceforge.net/
  • Delivery-date: Wed, 02 Jul 2014 15:42:32 +0000
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=Ndm8/u1hjqTVrmLPpHeaAXvhn8IGuxVnAEb/OiWsoGU82wQypZiK1CfVDpNts0oKRg6r6U67AKiAN3X4+NeJo8QPn9woN8FJY4BwqfWNAar+tmZb8CHVJEMQA7l450cS8fPGdGrLELoDXR+bkIfeJ/JSxuBQpGf1nlGDD5mBwpkrNbOJN0dphqXjrlbLLHCEgWvBGlkJ+jn94i9axnEr1oMuTcLBVAmx9s1ZZb/UxPcQm/TAmb7q731NC97d7I9NiWqns+WsFAyo3iiviJyHl52NjYEbxURxQPaSUyB2KdUTVUfPGTOg8gZbe6MmEPSljF2kCLGK7d5/VON90rTvcQ==; h=Received:Received:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding:X-BitDefender-Scanner:X-BitDefender-Spam:X-BitDefender-SpamStamp:X-BitDefender-CF-Stamp;
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

On 07/02/2014 06:21 PM, Jan Beulich wrote:
>> +    struct x86_emulate_ctxt __attribute__((unused)) *ctxt)
> 
> We don't mark unused function arguments like this (and if we did,
> we'd want you to use __maybe_unused).

OK, thanks. What's the proper way to mark them? Should I go with
__maybe_unused then?

>> +int hvm_emulate_one_no_write(
>> +    struct hvm_emulate_ctxt *hvmemul_ctxt)
>> +{
> 
> This must be pretty redundant with hvm_emulate_one(), and hence
> most if not all of the redundancy should be factored out.

Will do.

>> +void hvm_emulate_one_full(bool_t nowrite)
>> +{
>> +    struct hvm_emulate_ctxt ctx[1] = {};
>> +    int rc = X86EMUL_RETRY;
>> +
>> +    hvm_emulate_prepare(ctx, guest_cpu_user_regs());
>> +
>> +    while ( rc == X86EMUL_RETRY )
>> +    {
>> +        if ( nowrite )
>> +            rc = hvm_emulate_one_no_write(ctx);
>> +        else
>> +            rc = hvm_emulate_one(ctx);
>> +    }
>> +
>> +    switch ( rc )
>> +    {
>> +    case X86EMUL_UNHANDLEABLE:
>> +        hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
> 
> Is it certain that #UD is always the right exception here?

For our purposes, yes.

>> +int hvm_get_insn_length(
>> +    struct hvm_emulate_ctxt *hvmemul_ctxt)
>> +{
> 
> There again looks to be quite a bit of redundancy here. Please let's
> avoid having n copies of (almost) the same code.

Will factor it out.

>> --- /dev/null
>> +++ b/xen/arch/x86/inat-tables.c
> 
> I'm not going to look at this in much detail, just a couple of general
> notes:
> - at least some of the information is redundant with the full x86
>   emulator; as before redundancy should be avoided
> - many if not all of the arrays here appear to only be used locally,
>   and hence ought to be static
> - some of the tables are extremely sparse (take
>   inat_escape_table_3_3[] as an example); would be nice to collapse
>   those
> - making future changes/additions to these tables is going to be
>   pretty hard with them having neither suitable names nor comments
> - coding style (also elsewhere) seems to be Linux'es, yet you don't
>   mention in the description that they come from Linux (and if they
>   don't you'd be asked to convert them to Xen style)

Yes, the files do come from Linux, hence the coding style and the rest
of the issues. We've left them as they are on purpose, to try to reflect
that. I was under the impression that at least some of them say so at
the beginning of the file.

I'll make sure to mention this explicitly in subsequent retries.

Of course, that means that I can't really explain what the original
author intended (related to the rest of your critique).


Thanks,
Razvan Cojocaru

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.