From: Xiaofeng Ling <xiaofeng.ling@intel.com>
To: Ian Pratt <m+Ian.Pratt@cl.cam.ac.uk>,
Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH][6/6] setup grant table share page for vmx guest
Date: Mon, 05 Sep 2005 18:41:54 +0800 [thread overview]
Message-ID: <431C20F2.50909@intel.com> (raw)
Setup grant table share page for vmx guest.
Unmodified linux can not use fix map to setup the grant table
share page. This patch put the grant table share page into
the guest phys_to_machine mapping, so that guest can use ioremap
to access these pages. The guest physical address is passed from
guest and it is in the event channel pci device mmio space.
By this way, no extra hypercall needed.
Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
diff -r 287d36b46fa3 xen/common/grant_table.c
--- a/xen/common/grant_table.c Tue Aug 30 20:36:49 2005
+++ b/xen/common/grant_table.c Fri Sep 2 22:46:13 2005
@@ -693,11 +693,30 @@
if ( op.nr_frames <= NR_GRANT_FRAMES )
{
ASSERT(d->grant_table != NULL);
- (void)put_user(GNTST_okay, &uop->status);
- for ( i = 0; i < op.nr_frames; i++ )
+ if(!shadow_mode_external(current->domain))
+ {
+ (void)put_user(GNTST_okay, &uop->status);
+ for ( i = 0; i < op.nr_frames; i++ )
(void)put_user(
(virt_to_phys(d->grant_table->shared) >> PAGE_SHIFT) + i,
&uop->frame_list[i]);
+ }
+ else
+ {
+ unsigned long mfn, gpa;
+ op.status = GNTST_okay;
+
+ gpa = (unsigned long)op.frame_list;
+ for ( i = 0; i < op.nr_frames; i++ )
+ {
+ mfn = (virt_to_phys(d->grant_table->shared) >> PAGE_SHIFT)
+ + i,
+ DPRINTK("gpa:%lx share mfn:%lx\n", gpa, mfn);
+ set_phystomachine(gpa >> PAGE_SHIFT, mfn);
+ gpa = gpa + PAGE_SIZE;
+ }
+ (void)copy_to_user(uop, &op, sizeof(op));
+ }
}
put_domain(d);
diff -r 287d36b46fa3 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Tue Aug 30 20:36:49 2005
+++ b/xen/arch/x86/mm.c Fri Sep 2 22:46:13 2005
@@ -3454,6 +3454,50 @@
map_pages_to_xen(fix_to_virt(idx), p >> PAGE_SHIFT, 1, flags);
}
+#define L2_PROT
(_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
+#define L1_PROT
(_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
+unsigned long add_new_p2m_page(unsigned long phys)
+{
+ l2_pgentry_t mpl2e;
+ l1_pgentry_t *vl2tab;
+ struct vcpu *v = current;
+ struct pfn_info *newpg;
+
+ mpl2e = v->arch.monitor_vtable[l2_table_offset(RO_MPT_VIRT_START)];
+ vl2tab = map_domain_page(l2e_get_pfn(mpl2e));
+ v->domain->max_pages++;
+ newpg = alloc_domheap_page(v->domain);
+ if(!newpg)
+ {
+ MEM_LOG("alloc_domheap_page fail\n");
+ return 0;
+ }
+ vl2tab[l2_table_offset(phys)] = l1e_from_paddr(page_to_phys(newpg),
L2_PROT);
+ unmap_domain_page(vl2tab);
+ return page_to_phys(newpg);
+}
+
+unsigned long set_phystomachine(unsigned long pfn,
+ unsigned long mfn)
+{
+ l1_pgentry_t pte;
+ unsigned long oldmfn;
+
+ if (__copy_from_user(&pte, (phys_to_machine_mapping + pfn),
+ sizeof(pte))) {
+ if(!add_new_p2m_page(pfn<<PAGE_SHIFT))
+ return INVALID_MFN;
+ }
+
+ oldmfn = l1e_get_pfn(pte);
+ pte = l1e_from_pfn(mfn, l1e_get_flags(pte)|_PAGE_PRESENT);
+
+ if(__copy_to_user((phys_to_machine_mapping + pfn), &pte, sizeof(pte)))
+ return INVALID_MFN;
+
+ return oldmfn;
+}
+
#ifdef MEMORY_GUARD
void memguard_init(void)
diff -r 287d36b46fa3 xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h Tue Aug 30 20:36:49 2005
+++ b/xen/include/asm-x86/mm.h Fri Sep 2 22:46:13 2005
@@ -289,6 +289,9 @@
return mfn;
}
+unsigned long set_phystomachine(unsigned long pfn,
+ unsigned long mfn);
+
#ifdef MEMORY_GUARD
void memguard_init(void);
void memguard_guard_range(void *p, unsigned long l);
reply other threads:[~2005-09-05 10:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=431C20F2.50909@intel.com \
--to=xiaofeng.ling@intel.com \
--cc=Keir.Fraser@cl.cam.ac.uk \
--cc=m+Ian.Pratt@cl.cam.ac.uk \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.