xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>, Euan Harris <euan.harris@citrix.com>
Cc: xen-devel@lists.xenproject.org, kevin.tian@intel.com,
	jun.nakajima@intel.com
Subject: Re: [PATCH 3/9] x86/vvmx: Extract operand reading logic into operand_read()
Date: Mon, 27 Nov 2017 18:08:07 +0000	[thread overview]
Message-ID: <07b92a94-279d-24dd-fab8-980da55ec59e@citrix.com> (raw)
In-Reply-To: <5A1C530D02000078001927B4@prv-mh.provo.novell.com>

On 27/11/17 17:01, Jan Beulich wrote:
>>>> On 26.10.17 at 19:03, <euan.harris@citrix.com> wrote:
>> --- a/xen/arch/x86/hvm/vmx/vvmx.c
>> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
>> @@ -361,6 +361,40 @@ static void reg_write(struct cpu_user_regs *regs,
>>      *pval = value;
>>  }
>>  
>> +static int operand_read(void *buf, struct vmx_inst_op *op,
>> +                        struct cpu_user_regs *regs, unsigned int bytes)
>> +{
>> +    if ( op->type == VMX_INST_MEMREG_TYPE_REG )
>> +    {
>> +        switch ( bytes )
>> +        {
>> +        case 4:
>> +            *(uint32_t *)buf = reg_read(regs, op->reg_idx);
>> +
>> +        case 8:
>> +            *(uint64_t *)buf = reg_read(regs, op->reg_idx);
>> +
>> +        default:
>> +            ASSERT_UNREACHABLE();
>> +            return X86EMUL_UNHANDLEABLE;
>> +        }
> Looks like there are two missing break statements up there.

I fixed these up x86-next.  (Although it was only because Coverity
noticed and complained at me...)

>
>> +        return X86EMUL_OKAY;
> This and ...
>
>> +    }
>> +    else
>> +    {
>> +        pagefault_info_t pfinfo;
>> +        int rc = hvm_copy_from_guest_linear(buf, op->mem, bytes, 0, &pfinfo);
>> +
>> +        if ( rc == HVMTRANS_bad_linear_to_gfn )
>> +            hvm_inject_page_fault(pfinfo.ec, pfinfo.linear);
>> +        if ( rc != HVMTRANS_okay )
>> +            return X86EMUL_EXCEPTION;
>> +
>> +        return X86EMUL_OKAY;
> ... this should become a uniform ...
>
>> +    }
> ... return here.

I tried this, but later patches in the series need them to move back. 
Overall, this layout reduces the code churn across the series.

>
>> @@ -440,7 +474,12 @@ static int decode_vmx_inst(struct cpu_user_regs *regs,
>>          decode->op[0].type = VMX_INST_MEMREG_TYPE_REG;
>>          decode->op[0].reg_idx = info.fields.reg1;
>>          if ( poperandS != NULL )
>> -            *poperandS = reg_read(regs, decode->op[0].reg_idx);
>> +        {
>> +            int rc = operand_read(poperandS, &decode->op[0], regs,
>> +                                  decode->op[0].len);
>> +            if ( rc != X86EMUL_OKAY )
> Blank line between declaration(s) and statement(s) please.

I can fix this.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2017-11-27 18:08 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26 17:03 [PATCH 0/9] x86/vvmx: Read instruction operands correctly on VM exit Euan Harris
2017-10-26 17:03 ` [PATCH 1/9] x86/vvmx: Remove enum vmx_regs_enc Euan Harris
2017-10-26 17:03 ` [PATCH 2/9] x86/vvmx: Unify operands in struct vmx_inst_decoded Euan Harris
2017-10-26 17:03 ` [PATCH 3/9] x86/vvmx: Extract operand reading logic into operand_read() Euan Harris
2017-11-27 17:01   ` Jan Beulich
2017-11-27 18:08     ` Andrew Cooper [this message]
2017-11-28  8:40       ` Jan Beulich
2017-11-28  8:14   ` Jan Beulich
2017-10-26 17:03 ` [PATCH 4/9] x86/vvmx: Remove unnecessary VMX operand reads Euan Harris
2017-11-02  7:07   ` Tian, Kevin
2017-11-27 17:03   ` Jan Beulich
2017-10-26 17:03 ` [PATCH 5/9] x86/vvmx: Replace direct calls to reg_read() with operand_read() Euan Harris
2017-10-26 17:03 ` [PATCH 6/9] x86/vvmx: Remove operand reading from decode_vmx_inst() Euan Harris
2017-10-26 17:03 ` [PATCH 7/9] x86/vvmx: Use correct sizes when reading operands Euan Harris
2017-11-28  8:32   ` Jan Beulich
2017-12-01 18:45     ` Andrew Cooper
2017-12-04  8:55       ` Jan Beulich
2017-10-26 17:03 ` [PATCH 8/9] x86/hvm: Add hvm_copy_{to, from}_guest_virt() helpers Euan Harris
2017-11-28  8:38   ` Jan Beulich
2017-10-26 17:03 ` [PATCH 9/9] x86/vvmx: Use hvm_copy_{to, from}_guest_virt() to read operands Euan Harris
2017-11-28  8:49   ` Jan Beulich
2017-10-26 17:59 ` [PATCH 0/9] x86/vvmx: Read instruction operands correctly on VM exit Andrew Cooper
2017-11-02  7:23   ` Tian, Kevin
2017-11-02 18:39     ` Andrew Cooper

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=07b92a94-279d-24dd-fab8-980da55ec59e@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=euan.harris@citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xenproject.org \
    /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;
as well as URLs for NNTP newsgroup(s).