From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Paul Durrant <paul.durrant@citrix.com>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH 1/4] x86/hvm: stop passing explicit domid to hvm_create_ioreq_server()
Date: Fri, 16 Mar 2018 11:45:36 +0000 [thread overview]
Message-ID: <20180316114539.16870-2-paul.durrant@citrix.com> (raw)
In-Reply-To: <20180316114539.16870-1-paul.durrant@citrix.com>
There are only two call-sites for this function:
- The 'default' call site, which sets the is_default argument to true
and passes the value of HVM_PARAM_DM_DOMAIN as domid.
- The 'dm op' call site, which sets the is_default argument to false
and passes current->domain->domain_id as domid.
Clearly the correct value of domid can be discerned from the is_default
argument so this patch modifies hvm_create_ioreq_server() to do that
internally, negating the need for the domid argument.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/arch/x86/hvm/dm.c | 5 ++---
xen/arch/x86/hvm/hvm.c | 4 +---
xen/arch/x86/hvm/ioreq.c | 17 +++++++++--------
xen/include/asm-x86/hvm/ioreq.h | 5 ++---
4 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 7788577a73..96b0d13f2f 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -402,7 +402,6 @@ static int dm_op(const struct dmop_args *op_args)
{
case XEN_DMOP_create_ioreq_server:
{
- struct domain *curr_d = current->domain;
struct xen_dm_op_create_ioreq_server *data =
&op.u.create_ioreq_server;
@@ -412,8 +411,8 @@ static int dm_op(const struct dmop_args *op_args)
if ( data->pad[0] || data->pad[1] || data->pad[2] )
break;
- rc = hvm_create_ioreq_server(d, curr_d->domain_id, false,
- data->handle_bufioreq, &data->id);
+ rc = hvm_create_ioreq_server(d, false, data->handle_bufioreq,
+ &data->id);
break;
}
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 91bc3e8b27..42a294a6cc 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4443,9 +4443,7 @@ static int hvmop_get_param(
*/
if ( !d->creation_finished )
{
- domid_t domid = d->arch.hvm_domain.params[HVM_PARAM_DM_DOMAIN];
-
- rc = hvm_create_ioreq_server(d, domid, true,
+ rc = hvm_create_ioreq_server(d, true,
HVM_IOREQSRV_BUFIOREQ_LEGACY, NULL);
if ( rc != 0 && rc != -EEXIST )
goto out;
diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
index 7e66965bcd..ee5f47de65 100644
--- a/xen/arch/x86/hvm/ioreq.c
+++ b/xen/arch/x86/hvm/ioreq.c
@@ -599,16 +599,18 @@ static void hvm_ioreq_server_disable(struct hvm_ioreq_server *s,
}
static int hvm_ioreq_server_init(struct hvm_ioreq_server *s,
- struct domain *d, domid_t domid,
- bool is_default, int bufioreq_handling,
- ioservid_t id)
+ struct domain *d, bool is_default,
+ int bufioreq_handling, ioservid_t id)
{
struct vcpu *v;
int rc;
s->id = id;
s->domain = d;
- s->domid = domid;
+
+ s->domid = is_default ?
+ d->arch.hvm_domain.params[HVM_PARAM_DM_DOMAIN] :
+ current->domain->domain_id;
spin_lock_init(&s->lock);
INIT_LIST_HEAD(&s->ioreq_vcpu_list);
@@ -680,9 +682,8 @@ static ioservid_t next_ioservid(struct domain *d)
return id;
}
-int hvm_create_ioreq_server(struct domain *d, domid_t domid,
- bool is_default, int bufioreq_handling,
- ioservid_t *id)
+int hvm_create_ioreq_server(struct domain *d, bool is_default,
+ int bufioreq_handling, ioservid_t *id)
{
struct hvm_ioreq_server *s;
int rc;
@@ -702,7 +703,7 @@ int hvm_create_ioreq_server(struct domain *d, domid_t domid,
if ( is_default && d->arch.hvm_domain.default_ioreq_server != NULL )
goto fail2;
- rc = hvm_ioreq_server_init(s, d, domid, is_default, bufioreq_handling,
+ rc = hvm_ioreq_server_init(s, d, is_default, bufioreq_handling,
next_ioservid(d));
if ( rc )
goto fail3;
diff --git a/xen/include/asm-x86/hvm/ioreq.h b/xen/include/asm-x86/hvm/ioreq.h
index 1829fcf43e..0048a7c41c 100644
--- a/xen/include/asm-x86/hvm/ioreq.h
+++ b/xen/include/asm-x86/hvm/ioreq.h
@@ -23,9 +23,8 @@ bool hvm_io_pending(struct vcpu *v);
bool handle_hvm_io_completion(struct vcpu *v);
bool is_ioreq_server_page(struct domain *d, const struct page_info *page);
-int hvm_create_ioreq_server(struct domain *d, domid_t domid,
- bool is_default, int bufioreq_handling,
- ioservid_t *id);
+int hvm_create_ioreq_server(struct domain *d, bool is_default,
+ int bufioreq_handling, ioservid_t *id);
int hvm_destroy_ioreq_server(struct domain *d, ioservid_t id);
int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id,
unsigned long *ioreq_gfn,
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-03-16 11:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 11:45 [PATCH 0/4] stricter ioreq server permissions checks Paul Durrant
2018-03-16 11:45 ` Paul Durrant [this message]
2018-03-16 11:45 ` [PATCH 2/4] x86/hvm: take a reference on ioreq server emulating domain Paul Durrant
2018-03-16 11:45 ` [PATCH 3/4] x86/hvm: re-structure some of the ioreq server look-up loops Paul Durrant
2018-03-16 11:45 ` [PATCH 4/4] x86/hvm: add stricter permissions checks to ioreq server control plane Paul Durrant
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=20180316114539.16870-2-paul.durrant@citrix.com \
--to=paul.durrant@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.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 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).