* [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay
@ 2017-01-16 2:19 Benjamin Herrenschmidt
2017-01-16 16:07 ` Balbir Singh
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2017-01-16 2:19 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Paul Mackerras
The icp-opal call is missing the code from icp-native to recover
interrupts snatched by KVM. Without that, when running KVM, we can
get into a situation where an interrupt is lost and the CPU stuck
with an elevated CPPR.
Also harden replay by always checking the return from opal_int_eoi
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/sysdev/xics/icp-opal.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
index d38e86f..60c5765 100644
--- a/arch/powerpc/sysdev/xics/icp-opal.c
+++ b/arch/powerpc/sysdev/xics/icp-opal.c
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
static void icp_opal_teardown_cpu(void)
{
@@ -39,7 +40,26 @@ static void icp_opal_flush_ipi(void)
* Should we be flagging idle loop instead?
* Or creating some task to be scheduled?
*/
- opal_int_eoi((0x00 << 24) | XICS_IPI);
+ if (opal_int_eoi((0x00 << 24) | XICS_IPI) > 0)
+ force_external_irq_replay();
+}
+
+static unsigned int icp_opal_get_xirr(void)
+{
+ unsigned int kvm_xirr;
+ __be32 hw_xirr;
+ int64_t rc;
+
+ /* Handle an interrupt latched by KVM first */
+ kvm_xirr = kvmppc_get_xics_latch();
+ if (kvm_xirr)
+ return kvm_xirr;
+
+ /* Then ask OPAL */
+ rc = opal_int_get_xirr(&hw_xirr, false);
+ if (rc < 0)
+ return 0;
+ return be32_to_cpu(hw_xirr);
}
static unsigned int icp_opal_get_irq(void)
@@ -47,12 +67,8 @@ static unsigned int icp_opal_get_irq(void)
unsigned int xirr;
unsigned int vec;
unsigned int irq;
- int64_t rc;
- rc = opal_int_get_xirr(&xirr, false);
- if (rc < 0)
- return 0;
- xirr = be32_to_cpu(xirr);
+ xirr = icp_opal_get_xirr();
vec = xirr & 0x00ffffff;
if (vec == XICS_IRQ_SPURIOUS)
return 0;
@@ -67,7 +83,8 @@ static unsigned int icp_opal_get_irq(void)
xics_mask_unknown_vec(vec);
/* We might learn about it later, so EOI it */
- opal_int_eoi(xirr);
+ if (opal_int_eoi(xirr) > 0)
+ force_external_irq_replay();
return 0;
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay
2017-01-16 2:19 [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay Benjamin Herrenschmidt
@ 2017-01-16 16:07 ` Balbir Singh
2017-01-16 17:57 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 5+ messages in thread
From: Balbir Singh @ 2017-01-16 16:07 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras
On Sun, Jan 15, 2017 at 08:19:31PM -0600, Benjamin Herrenschmidt wrote:
> The icp-opal call is missing the code from icp-native to recover
> interrupts snatched by KVM. Without that, when running KVM, we can
> get into a situation where an interrupt is lost and the CPU stuck
> with an elevated CPPR.
>
> Also harden replay by always checking the return from opal_int_eoi
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
> arch/powerpc/sysdev/xics/icp-opal.c | 31 ++++++++++++++++++++++++-------
> 1 file changed, 24 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
> index d38e86f..60c5765 100644
> --- a/arch/powerpc/sysdev/xics/icp-opal.c
> +++ b/arch/powerpc/sysdev/xics/icp-opal.c
> @@ -20,6 +20,7 @@
> #include
> #include
> #include
> +#include
>
??
<snip>
> @@ -39,7 +40,26 @@ static void icp_opal_flush_ipi(void)
> * Should we be flagging idle loop instead?
> * Or creating some task to be scheduled?
> */
> - opal_int_eoi((0x00 << 24) | XICS_IPI);
> + if (opal_int_eoi((0x00 << 24) | XICS_IPI) > 0)
> + force_external_irq_replay();
> +}
Shouldn't we also update kvm bits on icp_native_ipi_action
and icp_native_cause_ipi?
Balbir Singh.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay
2017-01-16 16:07 ` Balbir Singh
@ 2017-01-16 17:57 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2017-01-16 17:57 UTC (permalink / raw)
To: Balbir Singh; +Cc: linuxppc-dev, Paul Mackerras
On Mon, 2017-01-16 at 21:37 +0530, Balbir Singh wrote:
> ??
>
> <snip>
>
> > @@ -39,7 +40,2
Ah evolution bug ... fixed upstream but fix hasn't made it to Fedora
yet.
I'll attach in the meantime.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay
2017-01-16 17:58 Benjamin Herrenschmidt
@ 2017-01-17 6:38 ` Balbir Singh
0 siblings, 0 replies; 5+ messages in thread
From: Balbir Singh @ 2017-01-17 6:38 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras
On Mon, Jan 16, 2017 at 11:58:53AM -0600, Benjamin Herrenschmidt wrote:
> The icp-opal call is missing the code from icp-native to recover
> interrupts snatched by KVM. Without that, when running KVM, we can
> get into a situation where an interrupt is lost and the CPU stuck
> with an elevated CPPR.
>
> Also harden replay by always checking the return from opal_int_eoi
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
Looks good to me
Acked-by: Balbir Singh <bsingharora@gmail.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay
@ 2017-01-16 17:58 Benjamin Herrenschmidt
2017-01-17 6:38 ` Balbir Singh
0 siblings, 1 reply; 5+ messages in thread
From: Benjamin Herrenschmidt @ 2017-01-16 17:58 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Paul Mackerras, Benjamin Herrenschmidt
The icp-opal call is missing the code from icp-native to recover
interrupts snatched by KVM. Without that, when running KVM, we can
get into a situation where an interrupt is lost and the CPU stuck
with an elevated CPPR.
Also harden replay by always checking the return from opal_int_eoi
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/sysdev/xics/icp-opal.c | 31 ++++++++++++++++++++++++-------
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/arch/powerpc/sysdev/xics/icp-opal.c b/arch/powerpc/sysdev/xics/icp-opal.c
index d38e86f..60c5765 100644
--- a/arch/powerpc/sysdev/xics/icp-opal.c
+++ b/arch/powerpc/sysdev/xics/icp-opal.c
@@ -20,6 +20,7 @@
#include <asm/xics.h>
#include <asm/io.h>
#include <asm/opal.h>
+#include <asm/kvm_ppc.h>
static void icp_opal_teardown_cpu(void)
{
@@ -39,7 +40,26 @@ static void icp_opal_flush_ipi(void)
* Should we be flagging idle loop instead?
* Or creating some task to be scheduled?
*/
- opal_int_eoi((0x00 << 24) | XICS_IPI);
+ if (opal_int_eoi((0x00 << 24) | XICS_IPI) > 0)
+ force_external_irq_replay();
+}
+
+static unsigned int icp_opal_get_xirr(void)
+{
+ unsigned int kvm_xirr;
+ __be32 hw_xirr;
+ int64_t rc;
+
+ /* Handle an interrupt latched by KVM first */
+ kvm_xirr = kvmppc_get_xics_latch();
+ if (kvm_xirr)
+ return kvm_xirr;
+
+ /* Then ask OPAL */
+ rc = opal_int_get_xirr(&hw_xirr, false);
+ if (rc < 0)
+ return 0;
+ return be32_to_cpu(hw_xirr);
}
static unsigned int icp_opal_get_irq(void)
@@ -47,12 +67,8 @@ static unsigned int icp_opal_get_irq(void)
unsigned int xirr;
unsigned int vec;
unsigned int irq;
- int64_t rc;
- rc = opal_int_get_xirr(&xirr, false);
- if (rc < 0)
- return 0;
- xirr = be32_to_cpu(xirr);
+ xirr = icp_opal_get_xirr();
vec = xirr & 0x00ffffff;
if (vec == XICS_IRQ_SPURIOUS)
return 0;
@@ -67,7 +83,8 @@ static unsigned int icp_opal_get_irq(void)
xics_mask_unknown_vec(vec);
/* We might learn about it later, so EOI it */
- opal_int_eoi(xirr);
+ if (opal_int_eoi(xirr) > 0)
+ force_external_irq_replay();
return 0;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-17 6:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-16 2:19 [PATCH] powerpc/icp-opal: Fix missing KVM case and harden replay Benjamin Herrenschmidt
2017-01-16 16:07 ` Balbir Singh
2017-01-16 17:57 ` Benjamin Herrenschmidt
2017-01-16 17:58 Benjamin Herrenschmidt
2017-01-17 6:38 ` Balbir Singh
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.