All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@arm.com>
To: sstabellini@kernel.org, xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Benjamin Sanda <ben.sanda@dornerworks.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
	Julien Grall <julien.grall@arm.com>,
	Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 1/8] xen/page_alloc: Move get_pg_owner()/put_pg_owner() from x86 to common code
Date: Tue,  6 Nov 2018 19:14:47 +0000	[thread overview]
Message-ID: <20181106191454.22143-2-julien.grall@arm.com> (raw)
In-Reply-To: <20181106191454.22143-1-julien.grall@arm.com>

From: Benjamin Sanda <ben.sanda@dornerworks.com>

get_pg_owner() and put_pg_owner() will be necessary in a follow-up
commit to support xentrace on Arm. So move the helper to common code.

Note that put_pg_owner() has been turned to a macro rather than static
inline because of inter-dependency between includes.

Signed-off-by: Benjamin Sanda <ben.sanda@dornerworks.com>
[julien: Rework commit title / turn put_pg_owner to a macro]
Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/arch/x86/mm.c       | 42 ------------------------------------------
 xen/common/page_alloc.c | 38 ++++++++++++++++++++++++++++++++++++++
 xen/include/xen/mm.h    |  3 +++
 3 files changed, 41 insertions(+), 42 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index f043e43ac7..9363e9bd96 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -3100,48 +3100,6 @@ static int vcpumask_to_pcpumask(
     }
 }
 
-static struct domain *get_pg_owner(domid_t domid)
-{
-    struct domain *pg_owner = NULL, *curr = current->domain;
-
-    if ( likely(domid == DOMID_SELF) )
-    {
-        pg_owner = rcu_lock_current_domain();
-        goto out;
-    }
-
-    if ( unlikely(domid == curr->domain_id) )
-    {
-        gdprintk(XENLOG_WARNING, "Cannot specify itself as foreign domain\n");
-        goto out;
-    }
-
-    switch ( domid )
-    {
-    case DOMID_IO:
-        pg_owner = rcu_lock_domain(dom_io);
-        break;
-    case DOMID_XEN:
-        pg_owner = rcu_lock_domain(dom_xen);
-        break;
-    default:
-        if ( (pg_owner = rcu_lock_domain_by_id(domid)) == NULL )
-        {
-            gdprintk(XENLOG_WARNING, "Unknown domain d%d\n", domid);
-            break;
-        }
-        break;
-    }
-
- out:
-    return pg_owner;
-}
-
-static void put_pg_owner(struct domain *pg_owner)
-{
-    rcu_unlock_domain(pg_owner);
-}
-
 long do_mmuext_op(
     XEN_GUEST_HANDLE_PARAM(mmuext_op_t) uops,
     unsigned int count,
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 16e1b0c357..ef1b4f596a 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -146,6 +146,7 @@
 #include <asm/guest.h>
 #include <asm/p2m.h>
 #include <asm/setup.h> /* for highmem_start only */
+#include <asm/paging.h>
 #else
 #define p2m_pod_offline_or_broken_hit(pg) 0
 #define p2m_pod_offline_or_broken_replace(pg) BUG_ON(pg != NULL)
@@ -2447,6 +2448,43 @@ static __init int register_heap_trigger(void)
 }
 __initcall(register_heap_trigger);
 
+struct domain *get_pg_owner(domid_t domid)
+{
+    struct domain *pg_owner = NULL, *curr = current->domain;
+
+    if ( likely(domid == DOMID_SELF) )
+    {
+        pg_owner = rcu_lock_current_domain();
+        goto out;
+    }
+
+    if ( unlikely(domid == curr->domain_id) )
+    {
+        gdprintk(XENLOG_WARNING, "Cannot specify itself as foreign domain\n");
+        goto out;
+    }
+
+    switch ( domid )
+    {
+    case DOMID_IO:
+        pg_owner = rcu_lock_domain(dom_io);
+        break;
+    case DOMID_XEN:
+        pg_owner = rcu_lock_domain(dom_xen);
+        break;
+    default:
+        if ( (pg_owner = rcu_lock_domain_by_id(domid)) == NULL )
+        {
+            gdprintk(XENLOG_WARNING, "Unknown domain d%d\n", domid);
+            break;
+        }
+        break;
+    }
+
+ out:
+    return pg_owner;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 054d02e6c0..dd4d990ae3 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -589,6 +589,9 @@ int xenmem_add_to_physmap_one(struct domain *d, unsigned int space,
 int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,
                           unsigned int start);
 
+struct domain *get_pg_owner(domid_t domid);
+#define put_pg_owner(pg_owner) rcu_unlock_domain(pg_owner)
+
 /* Return 0 on success, or negative on error. */
 int __must_check guest_remove_page(struct domain *d, unsigned long gmfn);
 int __must_check steal_page(struct domain *d, struct page_info *page,
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-11-06 19:15 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 19:14 [PATCH 0/8] xen/arm: Add xentrace support Julien Grall
2018-11-06 19:14 ` Julien Grall [this message]
2018-11-07  9:28   ` [PATCH 1/8] xen/page_alloc: Move get_pg_owner()/put_pg_owner() from x86 to common code Jan Beulich
2018-11-09 18:06     ` Julien Grall
2018-11-06 19:14 ` [PATCH 2/8] xen/arm: p2m: Introduce p2m_get_page_from_gfn Julien Grall
2018-11-15 13:31   ` Andrii Anisov
2018-11-15 13:35     ` Andrii Anisov
2018-11-15 15:22     ` Julien Grall
2018-12-20 11:20       ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 3/8] xen/arm: Rename p2m_map_foreign to p2m_map_foreign_rw Julien Grall
2018-11-15 11:42   ` Andrii Anisov
2018-11-15 12:07     ` Julien Grall
2018-11-06 19:14 ` [PATCH 4/8] xen/arm: Add support for read-only foreign mappings Julien Grall
2018-11-15 11:33   ` Andrii Anisov
2018-11-15 11:40     ` Julien Grall
2018-11-15 12:02       ` Andrii Anisov
2018-11-15 12:09         ` Julien Grall
2018-11-15 13:19           ` Andrii Anisov
2018-11-15 15:05             ` Julien Grall
2018-11-15 18:44               ` Stefano Stabellini
2018-11-15 19:06                 ` Julien Grall
2018-11-15 19:48                   ` Stefano Stabellini
2018-11-15 20:20                     ` Julien Grall
2018-11-16  9:05                       ` Andrii Anisov
2018-11-16  8:37               ` Andrii Anisov
2018-11-20 15:27               ` Andrii Anisov
2018-12-20 11:21               ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 5/8] xen/arm: Allow a privileged domain to map foreign page from DOMID_XEN Julien Grall
2018-11-15 13:45   ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 6/8] xen/arm: Initialize trace buffer Julien Grall
2018-11-15 13:49   ` Andrii Anisov
2018-11-06 19:14 ` [PATCH 7/8] xenalyze: Build for Both ARM and x86 Platforms Julien Grall
2018-11-07 13:04   ` Wei Liu
2018-11-06 19:14 ` [PATCH 8/8] xen: Swich parameter in get_page_from_gfn to use typesafe gfn Julien Grall
2018-11-06 20:11   ` Andrew Cooper
2018-11-07  8:57     ` Paul Durrant
2018-11-07 13:08       ` Andrew Cooper
2018-11-07 13:08     ` Julien Grall
2018-11-07  9:24   ` Paul Durrant
2018-11-07 13:05     ` Julien Grall
2018-11-12 16:49   ` Andrii Anisov
2018-11-12 16:52     ` Julien Grall
2018-11-12 16:58       ` Andrii Anisov
2018-11-12 17:09         ` Julien Grall

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=20181106191454.22143-2-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ben.sanda@dornerworks.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /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.