From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xen.org
Cc: "Zhang, Yang Z" <yang.z.zhang@intel.com>,
keir@xen.org, andres@gridcentric.ca, tim@xen.org
Subject: [PATCH 3 of 3] x86/emulation: No need to get_gfn on zero ram_gpa
Date: Tue, 24 Apr 2012 15:34:13 -0400 [thread overview]
Message-ID: <7a7443e80b9906908dfa.1335296053@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1335296050@xdev.gridcentric.ca>
xen/arch/x86/hvm/emulate.c | 48 ++++++++++++++++++++++++---------------------
1 files changed, 26 insertions(+), 22 deletions(-)
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
diff -r 2ffc676120b8 -r 7a7443e80b99 xen/arch/x86/hvm/emulate.c
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -60,33 +60,37 @@ static int hvmemul_do_io(
ioreq_t *p = get_ioreq(curr);
unsigned long ram_gfn = paddr_to_pfn(ram_gpa);
p2m_type_t p2mt;
- mfn_t ram_mfn;
+ mfn_t ram_mfn = _mfn(INVALID_MFN);
int rc;
- /* Check for paged out page */
- ram_mfn = get_gfn_unshare(curr->domain, ram_gfn, &p2mt);
- if ( p2m_is_paging(p2mt) )
- {
- put_gfn(curr->domain, ram_gfn);
- p2m_mem_paging_populate(curr->domain, ram_gfn);
- return X86EMUL_RETRY;
- }
- if ( p2m_is_shared(p2mt) )
- {
- put_gfn(curr->domain, ram_gfn);
- return X86EMUL_RETRY;
- }
-
- /* Maintain a ref on the mfn to ensure liveness. Put the gfn
- * to avoid potential deadlock wrt event channel lock, later. */
- if ( mfn_valid(mfn_x(ram_mfn)) )
- if ( !get_page(mfn_to_page(mfn_x(ram_mfn)),
- curr->domain) )
+ /* Many callers pass a stub zero ram_gpa address. */
+ if ( ram_gfn != 0 )
+ {
+ /* Check for paged out page */
+ ram_mfn = get_gfn_unshare(curr->domain, ram_gfn, &p2mt);
+ if ( p2m_is_paging(p2mt) )
{
- put_gfn(curr->domain, ram_gfn);
+ put_gfn(curr->domain, ram_gfn);
+ p2m_mem_paging_populate(curr->domain, ram_gfn);
return X86EMUL_RETRY;
}
- put_gfn(curr->domain, ram_gfn);
+ if ( p2m_is_shared(p2mt) )
+ {
+ put_gfn(curr->domain, ram_gfn);
+ return X86EMUL_RETRY;
+ }
+
+ /* Maintain a ref on the mfn to ensure liveness. Put the gfn
+ * to avoid potential deadlock wrt event channel lock, later. */
+ if ( mfn_valid(mfn_x(ram_mfn)) )
+ if ( !get_page(mfn_to_page(mfn_x(ram_mfn)),
+ curr->domain) )
+ {
+ put_gfn(curr->domain, ram_gfn);
+ return X86EMUL_RETRY;
+ }
+ put_gfn(curr->domain, ram_gfn);
+ }
/*
* Weird-sized accesses have undefined behaviour: we discard writes
next prev parent reply other threads:[~2012-04-24 19:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-24 19:34 [PATCH 0 of 3] x86/mm: Relieve contention of p2m lock on three hot paths Andres Lagar-Cavilla
2012-04-24 19:34 ` [PATCH 1 of 3] x86/mm: Relieve contention for p2m lock in gva_to_gfn Andres Lagar-Cavilla
2012-04-25 12:51 ` Tim Deegan
2012-04-25 15:33 ` Andres Lagar-Cavilla
2012-04-24 19:34 ` [PATCH 2 of 3] x86/emulate: Relieve contention of p2m lock in emulation of rep movs Andres Lagar-Cavilla
2012-04-25 12:54 ` Tim Deegan
2012-04-24 19:34 ` Andres Lagar-Cavilla [this message]
2012-04-25 13:11 ` [PATCH 3 of 3] x86/emulation: No need to get_gfn on zero ram_gpa Tim Deegan
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=7a7443e80b9906908dfa.1335296053@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=andres@gridcentric.ca \
--cc=keir@xen.org \
--cc=tim@xen.org \
--cc=xen-devel@lists.xen.org \
--cc=yang.z.zhang@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).