qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: "Daniel Henrique Barboza" <danielhb@linux.ibm.com>,
	qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
	qemu-devel@nongnu.org
Subject: Re: [PATCH for-5.2 1/5] spapr/xive: Fix xive->fd if kvm_create_device() fails
Date: Thu, 6 Aug 2020 15:05:32 +1000	[thread overview]
Message-ID: <20200806050532.GA100968@yekko.fritz.box> (raw)
In-Reply-To: <159664892278.638781.2910775856690967369.stgit@bahia.lan>

[-- Attachment #1: Type: text/plain, Size: 2087 bytes --]

On Wed, Aug 05, 2020 at 07:35:22PM +0200, Greg Kurz wrote:
> If the creation of the KVM XIVE device fails for some reasons, the
> negative errno ends up in xive->fd, but the rest of the code assumes
> that xive->fd either contains an open fd, ie. positive value, or -1.
> 
> This doesn't cause any misbehavior except kvmppc_xive_disconnect()
> that will try to close(xive->fd) during rollback and likely be
> rewarded with an EBADF.
> 
> Only set xive->fd with a open fd.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied to ppc-for-5.2.

> ---
>  hw/intc/spapr_xive_kvm.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
> index edb7ee0e74f1..d55ea4670e0e 100644
> --- a/hw/intc/spapr_xive_kvm.c
> +++ b/hw/intc/spapr_xive_kvm.c
> @@ -745,6 +745,7 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
>      size_t esb_len = (1ull << xsrc->esb_shift) * xsrc->nr_irqs;
>      size_t tima_len = 4ull << TM_SHIFT;
>      CPUState *cs;
> +    int fd;
>  
>      /*
>       * The KVM XIVE device already in use. This is the case when
> @@ -760,11 +761,12 @@ int kvmppc_xive_connect(SpaprInterruptController *intc, uint32_t nr_servers,
>      }
>  
>      /* First, create the KVM XIVE device */
> -    xive->fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_XIVE, false);
> -    if (xive->fd < 0) {
> -        error_setg_errno(errp, -xive->fd, "XIVE: error creating KVM device");
> +    fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_XIVE, false);
> +    if (fd < 0) {
> +        error_setg_errno(errp, -fd, "XIVE: error creating KVM device");
>          return -1;
>      }
> +    xive->fd = fd;
>  
>      /* Tell KVM about the # of VCPUs we may have */
>      if (kvm_device_check_attr(xive->fd, KVM_DEV_XIVE_GRP_CTRL,
> 
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2020-08-06 12:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 17:35 [PATCH for-5.2 0/5] spapr: Cleanups for XIVE and PHB Greg Kurz
2020-08-05 17:35 ` [PATCH for-5.2 1/5] spapr/xive: Fix xive->fd if kvm_create_device() fails Greg Kurz
2020-08-06  5:05   ` David Gibson [this message]
2020-08-05 17:35 ` [PATCH for-5.2 2/5] spapr/xive: Simplify kvmppc_xive_disconnect() Greg Kurz
2020-08-06  5:05   ` David Gibson
2020-08-05 17:35 ` [PATCH for-5.2 3/5] ppc/xive: Introduce dedicated kvm_irqchip_in_kernel() wrappers Greg Kurz
2020-08-06  5:08   ` David Gibson
2020-08-06  9:23     ` Greg Kurz
2020-08-05 17:35 ` [PATCH for-5.2 4/5] spapr/xive: Convert KVM device fd checks to assert() Greg Kurz
2020-08-06  5:09   ` David Gibson
2020-08-05 17:35 ` [PATCH for-5.2 5/5] spapr: Simplify error handling in spapr_phb_realize() Greg Kurz
2020-08-06  5:10   ` David Gibson
2020-08-05 17:43 ` [PATCH for-5.2 0/5] spapr: Cleanups for XIVE and PHB no-reply

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=20200806050532.GA100968@yekko.fritz.box \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=danielhb@linux.ibm.com \
    --cc=groug@kaod.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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).