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

Re: [Xen-devel] hvm_emulate_one() usage


  • To: xen-devel@xxxxxxxxxxxxx
  • From: Razvan Cojocaru <rzvncj@xxxxxxxxx>
  • Date: Sat, 29 Dec 2012 01:29:37 +0200
  • Delivery-date: Fri, 28 Dec 2012 23:30:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xen.org>

Hello, thanks for the reply!

> Not that I can help you with your problem specifically, but
> set_current() here ...
> 
>>
>>      hvm_emulate_prepare(ctx, guest_cpu_user_regs());
>>      hvm_emulate_one(ctx);
>>
>>      set_current(current_vcpu);
> 
> and here are absolutely wrong and will cause bad things to happen. (As
> demonstrated by the crash below)

Right.

> "current" is used everywhere in the Xen code, so your call to
> hvm_emulate_prepare is using the real "current" vcpus registers, with
> information from the wrong "current" cpu, including cs and ss segment
> registers, which is then going to be interpreted incorrectly as they
> will being used in the wrong vcms/gdt.

I see, that's what I was trying to avoid with the set_current() call - I
had hoped that it would tell guest_cpu_user_regs() what vcpu to use.

That was my only hope, as in the context of p2m_mem_access_resume() I
don't have the "struct cpu_user_regs *regs" parameter that I have access
to in p2m_mem_access_check().

> Can you describe exactly what behaviour you are attempting to achieve
> with this?  It seems to me that you are wanting to step a paused HVM
> vcpu on by one instruction based off a hypercall from dom0 ?

That's basically it, yes. In the hypervisor, tell dom0 that a mem_event
happened (a write attempt happened on a rx page), and let dom0 decide if
the write should happen or not (without dom0 setting the page to rwx and
losing future events on that same page). If dom0 decides that the write
should go ahead, it should signal this with a special flag in the
response it puts in the mem_event ring buffer, and the hypervisor should
then step the paused vcpu by one instruction (the write instruction).

This does work if I step in p2m_mem_access_check() (where I have access
to the "regs" parameter), before putting the mem_event request in the
ring buffer (and without any set_current() funny business), but that's
not acceptable behaviour because then dom0 gets notified _after_ the
write, and it's important for the notification to occur before the write
(so that dom0 could stop the write from happening if it needs to).

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