From: Paul Durrant <Paul.Durrant@citrix.com>
To: "suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
George Dunlap <George.Dunlap@citrix.com>,
"jbeulich@suse.com" <jbeulich@suse.com>
Subject: Re: [PATCH V2 1/2] x86/hvm: Add check when register io handler
Date: Mon, 16 May 2016 08:01:53 +0000 [thread overview]
Message-ID: <d36049fbb37f4e8e8bd4fa4a96146293@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <1463168217-16080-2-git-send-email-suravee.suthikulpanit@amd.com>
> -----Original Message-----
> From: suravee.suthikulpanit@amd.com
> [mailto:suravee.suthikulpanit@amd.com]
> Sent: 13 May 2016 20:37
> To: xen-devel@lists.xen.org; George Dunlap; jbeulich@suse.com
> Cc: Paul Durrant; Suravee Suthikulpanit; Suravee Suthikulpanit
> Subject: [PATCH V2 1/2] x86/hvm: Add check when register io handler
>
> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>
> At the time of registering HVM I/O handler, the HVM domain might
> not have been initialized,
I/O handler registration is internal to Xen so any caller that attempt to register before domain initialization should be removed and replaced with one that does it at the right time.
> which means the hvm_domain.io_handler
> would be NULL. In the hvm_next_io_handler(), this should be checked
> before returning and referencing the array. Also, the io_handler_count
> should only be incremented on success.
>
> So, this patch adds error handling in hvm_next_io_handler.
>
This isn't necessary. An ASSERT would be preferable so that buggy callers can be easily caught.
Paul
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> ---
> xen/arch/x86/hvm/intercept.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/x86/hvm/intercept.c b/xen/arch/x86/hvm/intercept.c
> index 7096d74..b837f5f 100644
> --- a/xen/arch/x86/hvm/intercept.c
> +++ b/xen/arch/x86/hvm/intercept.c
> @@ -248,7 +248,10 @@ int hvm_io_intercept(ioreq_t *p)
>
> struct hvm_io_handler *hvm_next_io_handler(struct domain *d)
> {
> - unsigned int i = d->arch.hvm_domain.io_handler_count++;
> + unsigned int i = d->arch.hvm_domain.io_handler_count;
> +
> + if ( !d->arch.hvm_domain.io_handler )
> + return NULL;
>
> if ( i == NR_IO_HANDLERS )
> {
> @@ -256,6 +259,7 @@ struct hvm_io_handler *hvm_next_io_handler(struct
> domain *d)
> return NULL;
> }
>
> + d->arch.hvm_domain.io_handler_count++;
> return &d->arch.hvm_domain.io_handler[i];
> }
>
> --
> 1.9.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-05-16 8:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 19:36 [PATCH V2 0/2] Fix xen crash when starting HVM guest due to missing io handler suravee.suthikulpanit
2016-05-13 19:36 ` [PATCH V2 1/2] x86/hvm: Add check when register " suravee.suthikulpanit
2016-05-16 8:01 ` Paul Durrant [this message]
2016-05-16 16:03 ` Suravee Suthikulpanit
2016-05-16 16:07 ` Paul Durrant
2016-05-13 19:36 ` [PATCH V2 2/2] svm: iommu: Only call guest_iommu_init() after initialized HVM domain suravee.suthikulpanit
2016-05-16 8:19 ` Paul Durrant
2016-05-19 5:22 ` Suravee Suthikulpanit
2016-05-19 6:03 ` Jan Beulich
2016-05-19 7:52 ` Paul Durrant
2016-05-19 8:59 ` Jan Beulich
2016-05-19 9:06 ` 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=d36049fbb37f4e8e8bd4fa4a96146293@AMSPEX02CL03.citrite.net \
--to=paul.durrant@citrix.com \
--cc=George.Dunlap@citrix.com \
--cc=jbeulich@suse.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=xen-devel@lists.xen.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).