[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH V6 5/5] xen: Handle resumed instruction based on previous mem_event reply
On Thu, Sep 11, 2014 at 7:40 AM, Tamas K Lengyel <tamas.lengyel@xxxxxxxxxxxx> wrote:
Tamas, I think it's safe to assume Razvan's dom0 application is powerful enough to emulate the entire trapping instruction and not be victimized. For the sake of argument, what I'm going at is that after the mem_event has been handled and control is passed to hvm_emulate_one, Xen will start resolving gfn->mfn translations needed by the instruction emulation by internally walking the p2m (read EPT) table with get_page_from_gfn. This will not invoke p2m_mem_access_check (only happens for actual hw faults), so an instruction that reads or writes across pages will not have a mem event generated for the other pages. A rep stos across page boundaries would do that (key: the rep stos is emulated in Xen, and the eip is then moved silently forward, so the hardware actually doesn't get to execute the instruction). A harder to catch example is a qemu-based driver, which grabs guest pages via the mapcache buckets using xc_map_foreign_bulk. This resolves toÂMMU_NORMAL_PT_UPDATE, which will grab the target page with ... get_page_from_gfn. Basically, every page qemu reads/writes to/from will not result in a mem event. This is akin to an unrestricted DMA engine that can bypass the hardware PTE protection bits and do things behind the OS back. Grant mapping also uses get_page_from_gfn ... no mem access checks. The way to fix it is very laborious, that is why it hasn't happened. The root cause is that p2m->get_entry does not check any of the access bits. It could, and then you would be generating mem events from everywhere. But that brings two problems. First, repeated events, as the same gfn may be read multiple times -- I don't think anybody wants that. Second, you have to be able to sleep on a wait queue when the event ring fills up (unless you are comfortable dropping events). Sleeping on a wait queue pretty much means stopping everything you are doing, carefully unrolling your stack until you hold no spinlocks, going into the wait queue, and when you wake up dive back into business. HTH Andres
_______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |