From: Razvan Cojocaru <rcojocaru@bitdefender.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: kevin.tian@intel.com, ian.campbell@citrix.com,
stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com,
eddie.dong@intel.com, xen-devel@lists.xen.org,
jun.nakajima@intel.com, ian.jackson@eu.citrix.com
Subject: Re: [PATCH RFC V7 1/5] xen: Emulate with no writes
Date: Tue, 26 Aug 2014 17:45:29 +0300 [thread overview]
Message-ID: <53FC9D89.8010706@bitdefender.com> (raw)
In-Reply-To: <53FCB89A020000780002DB05@mail.emea.novell.com>
On 08/26/2014 05:40 PM, Jan Beulich wrote:
>>>> On 26.08.14 at 16:30, <rcojocaru@bitdefender.com> wrote:
>> On 08/26/2014 05:19 PM, Jan Beulich wrote:
>>>>>> On 26.08.14 at 16:01, <rcojocaru@bitdefender.com> wrote:
>>>> On 08/26/2014 04:56 PM, Jan Beulich wrote:
>>>>>>>> On 13.08.14 at 17:28, <rcojocaru@bitdefender.com> 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
prev parent reply other threads:[~2014-08-26 14:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-13 15:28 [PATCH RFC V7 1/5] xen: Emulate with no writes Razvan Cojocaru
2014-08-13 15:28 ` [PATCH RFC V7 2/5] xen: Optimize introspection access to guest state Razvan Cojocaru
2014-08-13 15:28 ` [PATCH RFC V7 3/5] xen, libxc: Force-enable relevant MSR events Razvan Cojocaru
2014-08-26 14:05 ` Jan Beulich
2014-08-13 15:28 ` [PATCH RFC V7 4/5] xen, libxc: Request page fault injection via libxc Razvan Cojocaru
2014-08-26 14:13 ` Jan Beulich
2014-08-26 14:24 ` Razvan Cojocaru
2014-08-26 14:44 ` Jan Beulich
2014-08-26 14:56 ` Razvan Cojocaru
2014-08-26 15:49 ` Jan Beulich
2014-08-26 16:59 ` Razvan Cojocaru
2014-08-27 0:54 ` Tian, Kevin
2014-08-27 6:58 ` Jan Beulich
2014-08-28 13:15 ` Tim Deegan
2014-08-28 13:19 ` Razvan Cojocaru
2014-08-27 11:54 ` Razvan Cojocaru
2014-08-27 12:10 ` Jan Beulich
2014-08-27 12:15 ` Razvan Cojocaru
2014-08-13 15:28 ` [PATCH RFC V7 5/5] xen: Handle resumed instruction based on previous mem_event reply Razvan Cojocaru
2014-08-26 13:56 ` [PATCH RFC V7 1/5] xen: Emulate with no writes Jan Beulich
2014-08-26 14:01 ` Razvan Cojocaru
2014-08-26 14:19 ` Jan Beulich
2014-08-26 14:30 ` Razvan Cojocaru
2014-08-26 14:40 ` Jan Beulich
2014-08-26 14:45 ` Razvan Cojocaru [this message]
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=53FC9D89.8010706@bitdefender.com \
--to=rcojocaru@bitdefender.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=eddie.dong@intel.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.