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

Re: [Xen-devel] hvm_emulate_one() usage


At 16:34 +0200 on 28 Dec (1356712445), Razvan Cojocaru wrote:
> Hello,
> I have a dom0 userspace application that receives mem_events. Mem_events 
> are being received if a page fault occurs, and until I clear the page 
> access rights I keep receiving the event in a loop. If I do clear the 
> page access rights, I will no longer receive mem_events for said page.
> What I thought I'd do was to add a new flag to the mem_event response 
> (MEM_EVENT_FLAG_EMULATE_WRITE), and have this code execute in 
> p2m_mem_access_resume() in xen/arch/x86/mm/p2m.c:
> mem_event_get_response(d, &rsp);
> if ( rsp.flags & MEM_EVENT_FLAG_EMULATE_WRITE )
> {
>     struct hvm_emulate_ctxt ctx[1] = {};
>     struct vcpu *current_vcpu = current;
>     set_current(d->vcpu[rsp.vcpu_id]);

This won't work -- as Andrew pointed out, set_current() can only happen
safely as part of a proper context switch.  If you want to cause the
vcpu to single-step, I think it's better to follow the existing debugger
code, which marks the vcpu for single-stepping and the schedules it as

How about (from your user-space tool):
 - use XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON to enable single-stepping.
 - respond to the mem_event that you're handling, causing the vcpu to be
Then when the vcpu is scheduled, it will single-step in its own context,
and you'll get another mem_event (assuming you've set
 - use XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF to disable single-stepping.
 - respond to that event to unpause the vcpu. 

I guess if you're tyring to have some special case in the single-step
handler that allows it to write to a page that it normally coudn't you
might need to add an interface for controlling that.



Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.