RFC: shadow A/D-bit-setting changes
I am considering changing the way that guest pagetables get their _PAGE_ACCESSED and _PAGE_DIRTY bits set by the shadow code.
Currently, these bits are set when the corresponding entry is made in the shadow code -- e.g. when we make a shadow PTE with the _PAGE_RW set we make sure the guest PTE has the _PAGE_DIRTY bit set.
My plan is to have the pagetable walker (guest_walk_tables()) set the bits instead. This has two advantages:
- we don't need to carry around mappings to the guest pagetables in the pagefault handler, which makes things simpler;
- other users of the walker, such as the various emulators and HVM exit handlers, can have correct behaviour about setting these bits.
The disadvantages are, at least:
- we now need to check for rights at each level of a PT walk, to ensure that we don't set a _PAGE_DIRTY bit on a read-only mapping, for example;
- since guest_walk_tables() can be called without the shadow lock, and on pages that are not shadowed yet, we need to use locked cmpxchg to set these bits.
A draft patch is attached, which is incomplete (it doesn't cover callers of paging_gva_to_gfn, or the HAP walker, and is not optimised -- I am just starting to measure the performance impact) but smoke-tests OK for running Windows.
Any comments are welcome -- in particular will this cause problems for direct-MMIO, HAP or similar paging-related code?
Cheers,
Tim.
Signature · 2 lines
Tim Deegan <[email protected]>, XenSource UK Limited Registered office c/o EC2Y 5EB, UK; company number 05334508
xen/arch/x86/mm/p2m.c +3 -3
@@ -31,7 +31,7 @@/* Debugging and auditing of the P2M code? */ #define P2M_AUDIT 0 -#define P2M_DEBUGGING 1 +#define P2M_DEBUGGING 0/* * The P2M lock. This protects all updates to the p2m table.
@@ -288,11 +288,11 @@ int p2m_alloc_table(struct domain *d, void (*free_page)(struct domain *d, struct page_info *pg)) { -mfn_t mfn; +mfn_t mfn =_mfn (INVALID_MFN );struct list_head *entry;struct page_info *page, *p2m_top;unsigned int page_count =0 ; -unsigned long gfn; +unsigned long gfn =-1UL ;p2m_lock (d);
xen/arch/x86/mm/shadow/common.c +1 -4
@@ -150,10 +150,7 @@ hvm_read(enum x86_segment seg,return rc; *val =0 ; -// XXX -- this is WRONG. -// It entirely ignores the permissions in the page tables. -// In this case, that is only a user vs supervisor access check. -// +if ( (rc =hvm_copy_from_guest_virt (val, addr, bytes)) ==0 )return X86EMUL_OKAY ;
xen/arch/x86/mm/shadow/multi.c +273 -340
1,039 lines not on this page · raw message
xen/arch/x86/mm/shadow/types.h +23 -26
91 lines not on this page · raw message
xen/include/asm-x86/perfc_defn.h +2 -6
@@ -49,12 +49,8 @@ PERFCOUNTER(shadow_fault_fast_mmio, "sha PERFCOUNTER(shadow_fault_fast_mmio, "shadow_fault fast path mmio") PERFCOUNTER(shadow_fault_fast_fail, "shadow_fault fast path error") PERFCOUNTER(shadow_fault_bail_bad_gfn, "shadow_fault guest bad gfn") -PERFCOUNTER (shadow_fault_bail_not_present, - "shadow_fault guest not-present") -PERFCOUNTER(shadow_fault_bail_nx, "shadow_fault guest NX fault") -PERFCOUNTER(shadow_fault_bail_ro_mapping, "shadow_fault guest R/W fault") -PERFCOUNTER (shadow_fault_bail_user_supervisor, - "shadow_fault guest U/S fault") +PERFCOUNTER (shadow_fault_bail_real_fault, + "shadow_fault really guest fault") PERFCOUNTER(shadow_fault_emulate_read, "shadow_fault emulates a read") PERFCOUNTER(shadow_fault_emulate_write, "shadow_fault emulates a write")PERFCOUNTER (shadow_fault_emulate_failed,"shadow_fault emulator fails" )
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel