qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [RFC PATCH] spapr/xive: Allocate vCPU IPIs from local context
Date: Fri, 1 Oct 2021 12:38:07 +0200	[thread overview]
Message-ID: <20211001123807.296ea878@bahia.huguette> (raw)
In-Reply-To: <3e375254-1f6f-f630-77f0-a73d50d3b7df@kaod.org>

On Fri, 1 Oct 2021 11:59:45 +0200
Cédric Le Goater <clg@kaod.org> wrote:

> >>> Maybe it would be simpler to call xive_source_is_initialized() instead of
> >>> xive_eas_is_valid() in cases like this, e.g. hcall code since it is shared
> >>> between emulation and KVM ?
> >>
> >> Yes but we need a better check than :
> >>
> >>       if (lisn < SPAPR_XIRQ_BASE) {
> >>           return !!xive_get_field64(EAS_END_INDEX, xive->eat[lisn].w);
> >>       }
> >>
> >> This is more an heuristic than a precise test on the "validity" of
> >> a source at the KVM level.
> >>
> > 
> > I guess we should be able to get kvmppc_xive_irq_state::valid from
> > KVM by making the KVM_DEV_XIVE_GRP_SOURCE attribute readable. Would
> > that be enough ?
> 
> A bit slow may be. Or an extra bit in the XiveSource 'status' field
> to reflect KVM initialization.
> 
> C.
> 

Something like this ?

diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c
index 42f72b68fc00..6eba58b0ff10 100644
--- a/hw/intc/spapr_xive_kvm.c
+++ b/hw/intc/spapr_xive_kvm.c
@@ -232,6 +232,7 @@ int kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp)
 {
     SpaprXive *xive = SPAPR_XIVE(xsrc->xive);
     uint64_t state = 0;
+    int ret;
 
     assert(xive->fd != -1);
 
@@ -242,8 +243,15 @@ int kvmppc_xive_source_reset_one(XiveSource *xsrc, int srcno, Error **errp)
         }
     }
 
-    return kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_SOURCE, srcno, &state,
-                             true, errp);
+    ret = kvm_device_access(xive->fd, KVM_DEV_XIVE_GRP_SOURCE, srcno, &state,
+                            true, errp);
+    if (ret < 0) {
+        return ret;
+    }
+
+    xsrc->status[srcno] |= XIVE_STATUS_KVM;
+
+    return 0;
 }
 
 static int kvmppc_xive_source_reset(XiveSource *xsrc, Error **errp)
diff --git a/include/hw/ppc/xive.h b/include/hw/ppc/xive.h
index 445eccfe6b73..d85520beb64a 100644
--- a/include/hw/ppc/xive.h
+++ b/include/hw/ppc/xive.h
@@ -252,6 +252,7 @@ static inline hwaddr xive_source_esb_mgmt(XiveSource *xsrc, int srcno)
  * When doing an EOI, the Q bit will indicate if the interrupt
  * needs to be re-triggered.
  */
+#define XIVE_STATUS_KVM       0x8  /* Set when initialized in KVM */
 #define XIVE_STATUS_ASSERTED  0x4  /* Extra bit for LSI */
 #define XIVE_ESB_VAL_P        0x2
 #define XIVE_ESB_VAL_Q        0x1



  reply	other threads:[~2021-10-01 10:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22 14:41 [RFC PATCH] spapr/xive: Allocate vCPU IPIs from local context Cédric Le Goater
2021-09-23  9:12 ` Greg Kurz
2021-09-24 12:40   ` Cédric Le Goater
2021-09-24 13:49     ` Greg Kurz
2021-09-24 14:58       ` Cédric Le Goater
2021-09-24 17:13         ` Greg Kurz
2021-09-27 16:50           ` Cédric Le Goater
2021-09-28  7:19             ` Greg Kurz
2021-10-01  9:59               ` Cédric Le Goater
2021-10-01 10:38                 ` Greg Kurz [this message]
2021-10-01 11:11                   ` Cédric Le Goater

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=20211001123807.296ea878@bahia.huguette \
    --to=groug@kaod.org \
    --cc=clg@kaod.org \
    --cc=danielhb413@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --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).