Re: [RFC PATCH v3 0/4] Real mode interrupt injection

Mohammed Gamal
2010-08-16T15:43:37Z

2010/8/16 Gleb Natapov <gleb@redhat.com>:
> On Mon, Aug 16, 2010 at 06:23:18PM +0300, Mohammed Gamal wrote:
>> On Mon, Aug 16, 2010 at 5:47 PM, Avi Kivity <avi@redhat.com> wrote:
>> >  On 08/16/2010 05:29 PM, Gleb Natapov wrote:
>> >>
>> >>> I wrote a push_std() that uses ->write_std() instead of
>> >>> ->write_emulated() and can be used back-to-back.  Long term we'll
>> >>> need a write queue but for the short term this will do.
>> >>>
>> >> Why not just call writeback() after the emulate_push()? emulate_pusha()
>> >> does it.
>> >
>> > Good idea.  I'll do that.
>>
>> I tried it, but it doesn't seem to make any difference.
>>
> It should. Can you post what you've tried?
>
arch/x86/kvm/emulate.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 32498e3..4002c87 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -1219,14 +1219,23 @@ int emulate_int_real(struct x86_emulate_ctxt *ctxt,
/* TODO: Add limit checks */
c->src.val = ctxt->eflags;
emulate_push(ctxt, ops);
+ rc = writeback(ctxt, ops);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;

ctxt->eflags &= ~(EFLG_IF | EFLG_TF | EFLG_AC);

c->src.val = ops->get_segment_selector(VCPU_SREG_CS, ctxt->vcpu);
emulate_push(ctxt, ops);
+ rc = writeback(ctxt, ops);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;

c->src.val = c->eip;
emulate_push(ctxt, ops);
+ rc = writeback(ctxt, ops);
+ if (rc != X86EMUL_CONTINUE)
+ return rc;

I also added some trace_printk()'s and the values for RSP are not
updated after writeback.