From: Arun Sharma <arun.sharma@intel.com>
To: Ian Pratt <Ian.Pratt@cl.cam.ac.uk>,
Keir Fraser <Keir.Fraser@cl.cam.ac.uk>
Cc: xen-devel@lists.xensource.com
Subject: [PATCH] vmx-mmio-2pages.patch
Date: Wed, 1 Jun 2005 16:12:44 -0700 [thread overview]
Message-ID: <20050601231243.GA6774@intel.com> (raw)
Handle the case where the MMIO instruction crosses a page boundary.
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
--- 1.21/xen/arch/x86/vmx_platform.c 2005-05-27 12:02:09 -07:00
+++ edited/arch/x86/vmx_platform.c 2005-06-01 13:45:41 -07:00
@@ -406,35 +406,49 @@
return DECODE_failure;
}
-int inst_copy_from_guest(unsigned char *buf, unsigned long guest_eip, int inst_len)
+int inst_copy_from_guest(unsigned char *buf, unsigned long guest_eip,
+ int inst_len)
{
l1_pgentry_t gpte;
unsigned long mfn;
unsigned long ma;
unsigned char * inst_start;
+ int remaining = 0;
if (inst_len > MAX_INST_LEN || inst_len <= 0) {
return 0;
}
- if ((guest_eip & PAGE_MASK) == ((guest_eip + inst_len) & PAGE_MASK)) {
- if (vmx_paging_enabled(current)) {
- gpte = gva_to_gpte(guest_eip);
- mfn = phys_to_machine_mapping(l1e_get_pfn(gpte));
- } else {
- mfn = phys_to_machine_mapping(guest_eip >> PAGE_SHIFT);
+ if (vmx_paging_enabled(current)) {
+ gpte = gva_to_gpte(guest_eip);
+ mfn = phys_to_machine_mapping(l1e_get_pfn(gpte));
+ /* Does this cross a page boundary ? */
+ if ((guest_eip & PAGE_MASK) != ((guest_eip + inst_len) & PAGE_MASK)) {
+ remaining = (guest_eip + inst_len) & ~PAGE_MASK;
+ inst_len -= remaining;
}
- ma = (mfn << PAGE_SHIFT) | (guest_eip & (PAGE_SIZE - 1));
+
+ } else {
+ mfn = phys_to_machine_mapping(guest_eip >> PAGE_SHIFT);
+ }
+ ma = (mfn << PAGE_SHIFT) | (guest_eip & (PAGE_SIZE - 1));
+ inst_start = (unsigned char *)map_domain_mem(ma);
+
+ memcpy((char *)buf, inst_start, inst_len);
+ unmap_domain_mem(inst_start);
+
+ if (remaining) {
+ gpte = gva_to_gpte(guest_eip+inst_len+remaining);
+ mfn = phys_to_machine_mapping(l1e_get_pfn(gpte));
+
+ ma = (mfn << PAGE_SHIFT);
inst_start = (unsigned char *)map_domain_mem(ma);
- memcpy((char *)buf, inst_start, inst_len);
+ memcpy((char *)buf+inst_len, inst_start, remaining);
unmap_domain_mem(inst_start);
- } else {
- // Todo: In two page frames
- BUG();
+
}
-
- return inst_len;
+ return inst_len+remaining;
}
static void init_instruction(struct instruction *mmio_inst)
reply other threads:[~2005-06-01 23:12 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=20050601231243.GA6774@intel.com \
--to=arun.sharma@intel.com \
--cc=Ian.Pratt@cl.cam.ac.uk \
--cc=Keir.Fraser@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.