Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2018-10-31 12:36:54 +0100
committerMichal Suchanek <msuchanek@suse.de>2018-10-31 23:28:35 +0100
commit602b4b726ef5cca33a09efed1d023971933f6a0e (patch)
tree0e35608b1aafa29921e9ec5feec78c671d487fa4
parent7302b20ff5c1059d728ab9397a8fdc79d12282dd (diff)
KVM: PPC: Book3S HV: Don't use existing "prodded" flag for
XIVE escalations (bsc#1061840).
-rw-r--r--patches.arch/KVM-PPC-Book3S-HV-Don-t-use-existing-prodded-flag-fo.patch104
-rw-r--r--series.conf1
2 files changed, 105 insertions, 0 deletions
diff --git a/patches.arch/KVM-PPC-Book3S-HV-Don-t-use-existing-prodded-flag-fo.patch b/patches.arch/KVM-PPC-Book3S-HV-Don-t-use-existing-prodded-flag-fo.patch
new file mode 100644
index 0000000000..f339b8f35c
--- /dev/null
+++ b/patches.arch/KVM-PPC-Book3S-HV-Don-t-use-existing-prodded-flag-fo.patch
@@ -0,0 +1,104 @@
+From 2267ea7661798a42f0da648a2970e2a03f4bc370 Mon Sep 17 00:00:00 2001
+From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Date: Fri, 12 Jan 2018 13:37:13 +1100
+Subject: [PATCH] KVM: PPC: Book3S HV: Don't use existing "prodded" flag for
+ XIVE escalations
+
+References: bsc#1061840
+Patch-mainline: v4.16-rc1
+Git-commit: 2267ea7661798a42f0da648a2970e2a03f4bc370
+
+The prodded flag is only cleared at the beginning of H_CEDE,
+so every time we have an escalation, we will cause the *next*
+H_CEDE to return immediately.
+
+Instead use a dedicated "irq_pending" flag to indicate that
+a guest interrupt is pending for the VCPU. We don't reuse the
+existing exception bitmap so as to avoid expensive atomic ops.
+
+Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
+Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
+Acked-by: Michal Suchanek <msuchanek@suse.de>
+---
+ arch/powerpc/include/asm/kvm_host.h | 1 +
+ arch/powerpc/kernel/asm-offsets.c | 1 +
+ arch/powerpc/kvm/book3s_hv.c | 2 +-
+ arch/powerpc/kvm/book3s_hv_rmhandlers.S | 10 ++++++++++
+ arch/powerpc/kvm/book3s_xive.c | 3 +--
+ 5 files changed, 14 insertions(+), 3 deletions(-)
+
+diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
+index 3aa5b577cd60..bfe51356af5e 100644
+--- a/arch/powerpc/include/asm/kvm_host.h
++++ b/arch/powerpc/include/asm/kvm_host.h
+@@ -709,6 +709,7 @@ struct kvm_vcpu_arch {
+ u8 ceded;
+ u8 prodded;
+ u8 doorbell_request;
++ u8 irq_pending; /* Used by XIVE to signal pending guest irqs */
+ u32 last_inst;
+
+ struct swait_queue_head *wqp;
+diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
+index 6b958414b4e0..825089cf3e23 100644
+--- a/arch/powerpc/kernel/asm-offsets.c
++++ b/arch/powerpc/kernel/asm-offsets.c
+@@ -514,6 +514,7 @@ int main(void)
+ OFFSET(VCPU_PENDING_EXC, kvm_vcpu, arch.pending_exceptions);
+ OFFSET(VCPU_CEDED, kvm_vcpu, arch.ceded);
+ OFFSET(VCPU_PRODDED, kvm_vcpu, arch.prodded);
++ OFFSET(VCPU_IRQ_PENDING, kvm_vcpu, arch.irq_pending);
+ OFFSET(VCPU_DBELL_REQ, kvm_vcpu, arch.doorbell_request);
+ OFFSET(VCPU_MMCR, kvm_vcpu, arch.mmcr);
+ OFFSET(VCPU_PMC, kvm_vcpu, arch.pmc);
+diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
+index 76cf48051eb3..e5f81fc108e0 100644
+--- a/arch/powerpc/kvm/book3s_hv.c
++++ b/arch/powerpc/kvm/book3s_hv.c
+@@ -2999,7 +2999,7 @@ static inline bool xive_interrupt_pending(struct kvm_vcpu *vcpu)
+ {
+ if (!xive_enabled())
+ return false;
+- return vcpu->arch.xive_saved_state.pipr <
++ return vcpu->arch.irq_pending || vcpu->arch.xive_saved_state.pipr <
+ vcpu->arch.xive_saved_state.cppr;
+ }
+ #else
+diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+index 7daf21be33d0..34dbab7deb39 100644
+--- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S
++++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S
+@@ -1035,6 +1035,16 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_300)
+ li r9, 1
+ stw r9, VCPU_XIVE_PUSHED(r4)
+ eieio
++
++ /*
++ * We clear the irq_pending flag. There is a small chance of a
++ * race vs. the escalation interrupt happening on another
++ * processor setting it again, but the only consequence is to
++ * cause a spurrious wakeup on the next H_CEDE which is not an
++ * issue.
++ */
++ li r0,0
++ stb r0, VCPU_IRQ_PENDING(r4)
+ no_xive:
+ #endif /* CONFIG_KVM_XICS */
+
+diff --git a/arch/powerpc/kvm/book3s_xive.c b/arch/powerpc/kvm/book3s_xive.c
+index a102efeabf05..eef9ccafdc09 100644
+--- a/arch/powerpc/kvm/book3s_xive.c
++++ b/arch/powerpc/kvm/book3s_xive.c
+@@ -84,8 +84,7 @@ static irqreturn_t xive_esc_irq(int irq, void *data)
+ {
+ struct kvm_vcpu *vcpu = data;
+
+- /* We use the existing H_PROD mechanism to wake up the target */
+- vcpu->arch.prodded = 1;
++ vcpu->arch.irq_pending = 1;
+ smp_mb();
+ if (vcpu->arch.ceded)
+ kvmppc_fast_vcpu_kick(vcpu);
+--
+2.13.7
+
diff --git a/series.conf b/series.conf
index ee65ca1bc4..ba0e6acca8 100644
--- a/series.conf
+++ b/series.conf
@@ -13232,6 +13232,7 @@
patches.arch/KVM-PPC-Book3S-HV-Do-SLB-load-unload-with-guest-LPCR.patch
patches.arch/KVM-PPC-Book3S-HV-Allow-HPT-and-radix-on-the-same-co.patch
patches.arch/KVM-PPC-Book3S-HV-Enable-use-of-the-new-XIVE-single-.patch
+ patches.arch/KVM-PPC-Book3S-HV-Don-t-use-existing-prodded-flag-fo.patch
patches.arch/KVM-PPC-Book3S-HV-Drop-locks-before-reading-guest-me.patch
patches.fixes/KVM-PPC-Book3S-PR-Fix-svcpu-copying-with-preemption-.patch
patches.arch/KVM-PPC-Book3S-PR-Fix-broken-select-due-to-misspelli.patch