From: sos22@douglas.cl.cam.ac.uk Date: Thu, 26 Jan 2006 13:33:20 +0000 (+0100) Subject: Get the network interface working in shadow translate mode. This X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16529 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=99701fa9346a514d2e1316cd9856a22cba59e003;p=xen.git Get the network interface working in shadow translate mode. This required a few extra __gpfn_to_mfn translations, and also required a minor change in the grant tables interface: if we're in shadow translate mode, then shared->frame is supposed to be the pfn you want to map the new mfn to when accepting a grant transfer, and Xen handles updating the M2P and P2M tables for you. Signed-off-by: Steven Smith, sos22@cam.ac.uk --- diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c index 3f788ca34f..6bdbca6269 100644 --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -711,6 +711,7 @@ gnttab_transfer( int i; grant_entry_t *sha; gnttab_transfer_t gop; + unsigned long real_mfn; for ( i = 0; i < count; i++ ) { @@ -731,7 +732,8 @@ gnttab_transfer( continue; } - page = pfn_to_page(gop.mfn); + real_mfn = __gpfn_to_mfn(d, gop.mfn); + page = pfn_to_page(real_mfn); if ( unlikely(IS_XEN_HEAP_FRAME(page)) ) { DPRINTK("gnttab_transfer: xen frame %lx\n", @@ -792,7 +794,21 @@ gnttab_transfer( /* Tell the guest about its new page frame. */ sha = &e->grant_table->shared[gop.ref]; - sha->frame = gop.mfn; + if (shadow_mode_translate(e)) { + struct domain_mmap_cache c1, c2; + unsigned long pfn = sha->frame; + domain_mmap_cache_init(&c1); + domain_mmap_cache_init(&c2); + shadow_lock(e); + shadow_sync_and_drop_references(e, page); + set_p2m_entry(e, pfn, real_mfn, &c1, &c2); + set_pfn_from_mfn(real_mfn, pfn); + shadow_unlock(e); + domain_mmap_cache_destroy(&c1); + domain_mmap_cache_destroy(&c2); + } else { + sha->frame = real_mfn; + } wmb(); sha->flags |= GTF_transfer_completed; diff --git a/xen/common/memory.c b/xen/common/memory.c index ddad691d29..c521071054 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -76,7 +76,7 @@ decrease_reservation( int *preempted) { struct pfn_info *page; - unsigned long i, j, mpfn; + unsigned long i, j, mpfn, mfn; if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) ) return 0; @@ -94,14 +94,15 @@ decrease_reservation( for ( j = 0; j < (1 << extent_order); j++ ) { - if ( unlikely((mpfn + j) >= max_page) ) + mfn = __gpfn_to_mfn(d, mpfn + j); + if ( unlikely(mfn >= max_page) ) { DPRINTK("Domain %u page number out of range (%lx >= %lx)\n", - d->domain_id, mpfn + j, max_page); + d->domain_id, mfn, max_page); return i; } - page = pfn_to_page(mpfn + j); + page = pfn_to_page(mfn); if ( unlikely(!get_page(page, d)) ) { DPRINTK("Bad page free for domain %u\n", d->domain_id);