Xin, Xiaohui
2005-Oct-14 09:43 UTC
RE: [Xen-devel] Switching from writeable pagetable toshadowlog-dirtyat runtime
Keir, We found that in 32-bit code, the shadow_fault() do one more thing than 64-bit code. The following code in file shadow32.c checks the L1 page table with RW bit removed and make the shadow with RW bit, it does not inject the fault to guest. Does this is a work-around for switch from writable pagetable to shadow mode enable? Does this code makes sense to the writeable pagetable, and then may be one reason that 32bit log-dirty code can work? if ( regs->error_code & 2 ) { + int allow_writes = 0; + if ( unlikely(!(l1e_get_flags(gpte) & _PAGE_RW)) ) + { + if ( shadow_mode_page_writable(va, regs, l1e_get_pfn(gpte)) ) + { + allow_writes = 1; + l1e_add_flags(gpte, _PAGE_RW); + } + else + { + /* Write fault on a read-only mapping. */ + SH_VVLOG("shadow_fault - EXIT: wr fault on RO page (%" PRIpte ")", + l1e_get_intpte(gpte)); + perfc_incrc(shadow_fault_bail_ro_mapping); + goto fail; + } + } if ( !l1pte_write_fault(v, &gpte, &spte, va) ) { SH_VVLOG("shadow_fault - EXIT: l1pte_write_fault failed"); perfc_incrc(write_fault_bail); shadow_unlock(d); return 0; } + if ( allow_writes ) + l1e_remove_flags(gpte, _PAGE_RW); + } Thanks Xiaohui -----Original Message----- From: xen-devel-bounces@lists.xensource.com [mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Keir Fraser Sent: 2005年10月14日 16:44 To: Li, Chengyuan Cc: Ian Pratt; xen-devel@lists.xensource.com; Nakajima, Jun Subject: Re: [Xen-devel] Switching from writeable pagetable toshadowlog-dirtyat runtime On 14 Oct 2005, at 03:46, Li, Chengyuan wrote:> > I don''t see ptwr_flush() when shadow mode enable in both ia32 and > x86_64 code. Why plain ia32 log dirty shadow can work?Perhaps it can''t, properly. :-) The best fix will be to make domain_pause() call sync_pagetable_state(d). The main problem I can see is that the cleanup_writeable_pagetable() function is not currently safe to be called by other than the subject domain. For example, failure paths crash the calling domain rather than the subject domain! This needs fixing.> audit_adjust_pgtables() is for plain ia32 only and it doesn''t work for > both ia32 pae and x86_64, but this function only check the ref counts > and doesn''t update guest PTE entry, e.g. R/W bit. > > Another question is that how does guest update its guest page-table > after shadow mode is enabled? As writable-pagetable can''t be used > after shadow mode is enabled.Shadow pagetable code has its own quite separate writeable pagetable logic, I believe. Which is why the non-shadow wrpt state must be flushed before switching to shadow pagetables. -- Keir _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Khoa Huynh
2005-Oct-14 22:28 UTC
RE: [Xen-devel] Switching from writeable pagetable toshadowlog-dirtyat runtime
"Xin, Xiaohui" <xiaohui.xin@intel.com> wrote on 10/14/2005 04:43:07 AM:> > Keir, > We found that in 32-bit code, the shadow_fault() do one more thing > than 64-bit code. > The following code in file shadow32.c checks the L1 page table with > RW bit removed and make the shadow with RW bit, it does not inject > the fault to guest. > Does this is a work-around for switch from writable pagetable to > shadow mode enable? > Does this code makes sense to the writeable pagetable, and then may > be one reason that 32bit log-dirty code can work? >I don''t think we use log-dirty shadow mode - at least when setting up VMX domains; we only use shadow translate and external modes. See vmx_final_setup_guest() in xen/arch/x86/domain.c. I searched through the code for 32-bit x86, and I don''t recall ever seeing this log-dirty mode be enabled. When should we use log-dirty shadow mode ? Thanks. Khoa _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel