From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xensource.com
Cc: olaf@aepfle.de, ian.campbell@citrix.com, andres@gridcentric.ca,
tim@xen.org, keir.xen@gmail.com, ian.jackson@citrix.com,
adin@gridcentric.ca
Subject: [PATCH 2 of 7] x86/hvm: refactor calls to prepare and tear down a helper ring
Date: Thu, 23 Feb 2012 01:05:07 -0500 [thread overview]
Message-ID: <99e6c9b9e97137ee7404.1329977107@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1329977105@xdev.gridcentric.ca>
xen/arch/x86/hvm/hvm.c | 48 ++++++++++++++++++++++++++++++++----------
xen/include/asm-x86/hvm/hvm.h | 7 ++++++
2 files changed, 43 insertions(+), 12 deletions(-)
These are currently used for the rings connecting Xen with qemu. Refactor them
so the same code can be later used for mem event rings.
Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
diff -r 3b24188d8815 -r 99e6c9b9e971 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -331,6 +331,19 @@ static void hvm_init_ioreq_page(
domain_pause(d);
}
+void destroy_ring_for_helper(
+ void **_va, struct page_info *page)
+{
+ void *va = *_va;
+
+ if ( va != NULL )
+ {
+ unmap_domain_page_global(va);
+ put_page_and_type(page);
+ *_va = NULL;
+ }
+}
+
static void hvm_destroy_ioreq_page(
struct domain *d, struct hvm_ioreq_page *iorp)
{
@@ -338,18 +351,14 @@ static void hvm_destroy_ioreq_page(
ASSERT(d->is_dying);
- if ( iorp->va != NULL )
- {
- unmap_domain_page_global(iorp->va);
- put_page_and_type(iorp->page);
- iorp->va = NULL;
- }
+ destroy_ring_for_helper(&iorp->va, iorp->page);
spin_unlock(&iorp->lock);
}
-static int hvm_set_ioreq_page(
- struct domain *d, struct hvm_ioreq_page *iorp, unsigned long gmfn)
+int prepare_ring_for_helper(
+ struct domain *d, unsigned long gmfn, struct page_info **_page,
+ void **_va)
{
struct page_info *page;
p2m_type_t p2mt;
@@ -390,14 +399,30 @@ static int hvm_set_ioreq_page(
return -ENOMEM;
}
+ *_va = va;
+ *_page = page;
+
+ put_gfn(d, gmfn);
+
+ return 0;
+}
+
+static int hvm_set_ioreq_page(
+ struct domain *d, struct hvm_ioreq_page *iorp, unsigned long gmfn)
+{
+ struct page_info *page;
+ void *va;
+ int rc;
+
+ if ( (rc = prepare_ring_for_helper(d, gmfn, &page, &va)) )
+ return rc;
+
spin_lock(&iorp->lock);
if ( (iorp->va != NULL) || d->is_dying )
{
+ destroy_ring_for_helper(&iorp->va, iorp->page);
spin_unlock(&iorp->lock);
- unmap_domain_page_global(va);
- put_page_and_type(mfn_to_page(mfn));
- put_gfn(d, gmfn);
return -EINVAL;
}
@@ -405,7 +430,6 @@ static int hvm_set_ioreq_page(
iorp->page = page;
spin_unlock(&iorp->lock);
- put_gfn(d, gmfn);
domain_unpause(d);
diff -r 3b24188d8815 -r 99e6c9b9e971 xen/include/asm-x86/hvm/hvm.h
--- a/xen/include/asm-x86/hvm/hvm.h
+++ b/xen/include/asm-x86/hvm/hvm.h
@@ -26,6 +26,7 @@
#include <asm/hvm/asid.h>
#include <public/domctl.h>
#include <public/hvm/save.h>
+#include <asm/mm.h>
/* Interrupt acknowledgement sources. */
enum hvm_intsrc {
@@ -191,6 +192,12 @@ int hvm_vcpu_cacheattr_init(struct vcpu
void hvm_vcpu_cacheattr_destroy(struct vcpu *v);
void hvm_vcpu_reset_state(struct vcpu *v, uint16_t cs, uint16_t ip);
+/* Prepare/destroy a ring for a dom0 helper. Helper with talk
+ * with Xen on behalf of this hvm domain. */
+int prepare_ring_for_helper(struct domain *d, unsigned long gmfn,
+ struct page_info **_page, void **_va);
+void destroy_ring_for_helper(void **_va, struct page_info *page);
+
bool_t hvm_send_assist_req(struct vcpu *v);
void hvm_set_guest_tsc(struct vcpu *v, u64 guest_tsc);
next prev parent reply other threads:[~2012-02-23 6:05 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-23 6:05 [PATCH 0 of 7] Mem event ring setup interface update Andres Lagar-Cavilla
2012-02-23 6:05 ` [PATCH 1 of 7] Tools: Sanitize mem_event/access/paging interfaces Andres Lagar-Cavilla
2012-02-23 14:29 ` Olaf Hering
2012-02-28 12:56 ` Ian Campbell
2012-02-28 15:14 ` Andres Lagar-Cavilla
2012-02-23 6:05 ` Andres Lagar-Cavilla [this message]
2012-02-23 6:05 ` [PATCH 3 of 7] Use a reserved pfn in the guest address space to store mem event rings Andres Lagar-Cavilla
2012-02-28 13:01 ` Ian Campbell
2012-02-28 15:19 ` Andres Lagar-Cavilla
2012-03-01 7:47 ` Ian Campbell
2012-03-01 15:17 ` Tim Deegan
2012-03-01 16:26 ` Andres Lagar-Cavilla
2012-03-01 16:30 ` Andres Lagar-Cavilla
2012-03-01 17:32 ` Tim Deegan
2012-03-01 17:44 ` Andres Lagar-Cavilla
2012-03-01 17:52 ` [PATCH 3 of 7] Use a reserved pfn in the guest address space to store mem event ringsg Tim Deegan
2012-03-06 19:27 ` Andres Lagar-Cavilla
2012-03-01 2:29 ` [PATCH 3 of 7] Use a reserved pfn in the guest address space to store mem event rings Andres Lagar-Cavilla
2012-02-23 6:05 ` [PATCH 4 of 7] x86/mm: wire up sharing ring Andres Lagar-Cavilla
2012-02-23 6:05 ` [PATCH 5 of 7] Tools: libxc side for setting up the mem " Andres Lagar-Cavilla
2012-02-28 13:02 ` Ian Campbell
2012-02-23 6:05 ` [PATCH 6 of 7] x86/mm: Clean up mem event structures on domain destruction Andres Lagar-Cavilla
2012-02-23 14:32 ` Olaf Hering
2012-02-23 6:05 ` [PATCH 7 of 7] x86/mm: Fix mem event error message typos Andres Lagar-Cavilla
2012-02-23 16:07 ` [PATCH 0 of 7] Mem event ring setup interface update Tim Deegan
2012-02-27 22:43 ` Andres Lagar-Cavilla
-- strict thread matches above, loose matches on Subject: below --
2012-03-01 2:43 [PATCH 0 of 7] Mem event ring interface setup update, V2 Andres Lagar-Cavilla
2012-03-01 2:43 ` [PATCH 2 of 7] x86/hvm: refactor calls to prepare and tear down a helper ring Andres Lagar-Cavilla
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=99e6c9b9e97137ee7404.1329977107@xdev.gridcentric.ca \
--to=andres@lagarcavilla.org \
--cc=adin@gridcentric.ca \
--cc=andres@gridcentric.ca \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@citrix.com \
--cc=keir.xen@gmail.com \
--cc=olaf@aepfle.de \
--cc=tim@xen.org \
--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 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).