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

Re: [Xen-devel] [PATCH RFC V7 1/5] xen: Emulate with no writes


  • To: Jan Beulich <JBeulich@xxxxxxxx>
  • From: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>
  • Date: Tue, 26 Aug 2014 17:45:29 +0300
  • Cc: kevin.tian@xxxxxxxxx, ian.campbell@xxxxxxxxxx, stefano.stabellini@xxxxxxxxxxxxx, andrew.cooper3@xxxxxxxxxx, eddie.dong@xxxxxxxxx, xen-devel@xxxxxxxxxxxxx, jun.nakajima@xxxxxxxxx, ian.jackson@xxxxxxxxxxxxx
  • Comment: DomainKeys? See http://domainkeys.sourceforge.net/
  • Delivery-date: Tue, 26 Aug 2014 14:45:15 +0000
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=bitdefender.com; b=WeCnfqnZ8V3KdODl4bL0qeW1n3sOF8SxjZPMaN7Xb0HYEDvJOFlJytlliUdR6o3IHZJqHgNyXsYuS5VmzTPlxabC+dahZ2y63NRmZJyP6U0+ObvRRvPCsVjjPvB1NE5NC/Ck65IEL2tYe/zl85JYKuVT4Vioks4DyfQvCXLsGsi9m2nBVThaRD2PWap2l2hH2J8vbuY0+FBgAs3oDDp4R3YshydUHTv6mEuBkPDhBdqMdLwF0FLeSGtETaNoQ0muaE6SQCd+XOfw4kUfgvKZ4Eh4nJoyz/dvviZJLOuwJ/PC/YcysOCrYrSeqVHNMrK2NPMAE4EUodKyRec0Uq5xQg==; 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 08/26/2014 05:40 PM, Jan Beulich wrote:
>>>> On 26.08.14 at 16:30, <rcojocaru@xxxxxxxxxxxxxxx> wrote:
>> On 08/26/2014 05:19 PM, Jan Beulich wrote:
>>>>>> On 26.08.14 at 16:01, <rcojocaru@xxxxxxxxxxxxxxx> wrote:
>>>> On 08/26/2014 04:56 PM, Jan Beulich wrote:
>>>>>>>> On 13.08.14 at 17:28, <rcojocaru@xxxxxxxxxxxxxxx> wrote:
>>>>>> +void hvm_emulate_one_full(bool_t nowrite, unsigned int trapnr,
>>>>>> +    unsigned int errcode)
>>>>>> +{
>>>>>> +    struct hvm_emulate_ctxt ctx = {{ 0 }};
>>>>>> +    int rc;
>>>>>> +
>>>>>> +    hvm_emulate_prepare(&ctx, guest_cpu_user_regs());
>>>>>> +
>>>>>> +    if ( nowrite )
>>>>>> +        rc = hvm_emulate_one_no_write(&ctx);
>>>>>> +    else
>>>>>> +        rc = hvm_emulate_one(&ctx);
>>>>>> +
>>>>>> +    switch ( rc )
>>>>>> +    {
>>>>>> +    case X86EMUL_UNHANDLEABLE:
>>>>>> +        gdprintk(XENLOG_DEBUG, "Emulation failed @ %04x:%lx: "
>>>>>> +               "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
>>>>>> +               hvmemul_get_seg_reg(x86_seg_cs, &ctx)->sel,
>>>>>> +               ctx.insn_buf_eip,
>>>>>> +               ctx.insn_buf[0], ctx.insn_buf[1],
>>>>>> +               ctx.insn_buf[2], ctx.insn_buf[3],
>>>>>> +               ctx.insn_buf[4], ctx.insn_buf[5],
>>>>>> +               ctx.insn_buf[6], ctx.insn_buf[7],
>>>>>> +               ctx.insn_buf[8], ctx.insn_buf[9]);
>>>>>> +        hvm_inject_hw_exception(trapnr, errcode);
>>>>>> +        break;
>>>>>> +    case X86EMUL_EXCEPTION:
>>>>>> +        if ( ctx.exn_pending )
>>>>>> +            hvm_inject_hw_exception(ctx.exn_vector, ctx.exn_error_code);
>>>>>> +        break;
>>>>>
>>>>> Shouldn't you act on X86EMUL_RETRY here? Or at least not fall through
>>>>> to the writeback below?
>>>>
>>>> Thanks for the review, I did initially loop around hvm_emulate_one()
>>>> until rc != X86EMUL_RETRY, but I've been told that that might block
>>>> against time calibration rendezvous points.
>>>
>>> In any event it strikes me as odd that you ignore that state
>>> altogether rather than propagating it back up, so that someone
>>> in suitable position to do the retry can invoke it.
>>
>> Since it's being called in the context of handling a mem_event response,
>> the X86EMUL_RETRY case would lead to a retry anyway (since we couldn't
>> emulate the current instruction, and we haven't lifted the page access
>> restrictions). So if we've failed to somehow modify the guest's EIP, the
>> instruction will hit the page again, cause a new mem_event and a new
>> attempt to emulate it - so that would seem to fit with the spirit of
>> X86EMUL_RETRY.
> 
> Makes sense. Please add a brief comment to this effect when you
> add this specific case (bailing without writeback). One thing to
> consider though is which function you're in: Based on its name it
> has no connection to the specific mem-access use, and hence - with
> the behavior you intend to have here not being generically usable -
> renaming the function may be a good idea.

Will do, thank you very much for your comments!


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®.