--- /dev/null
+From c0e7bb38c07cbd8269549ee0a0566021a3c729de Mon Sep 17 00:00:00 2001
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+Date: Mon, 15 May 2017 14:11:03 +0200
+Subject: s390/kvm: do not rely on the ILC on kvm host protection fauls
+
+From: Christian Borntraeger <borntraeger@de.ibm.com>
+
+commit c0e7bb38c07cbd8269549ee0a0566021a3c729de upstream.
+
+For most cases a protection exception in the host (e.g. copy
+on write or dirty tracking) on the sie instruction will indicate
+an instruction length of 4. Turns out that there are some corner
+cases (e.g. runtime instrumentation) where this is not necessarily
+true and the ILC is unpredictable.
+
+Let's replace our 4 byte rewind_pad with 3 byte nops to prepare for
+all possible ILCs.
+
+Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
+Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/s390/kernel/entry.S | 19 +++++++++++++------
+ 1 file changed, 13 insertions(+), 6 deletions(-)
+
+--- a/arch/s390/kernel/entry.S
++++ b/arch/s390/kernel/entry.S
+@@ -229,12 +229,17 @@ ENTRY(sie64a)
+ lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
+ .Lsie_done:
+ # some program checks are suppressing. C code (e.g. do_protection_exception)
+-# will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other
+-# instructions between sie64a and .Lsie_done should not cause program
+-# interrupts. So lets use a nop (47 00 00 00) as a landing pad.
++# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There
++# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable.
++# Other instructions between sie64a and .Lsie_done should not cause program
++# interrupts. So lets use 3 nops as a landing pad for all possible rewinds.
+ # See also .Lcleanup_sie
+-.Lrewind_pad:
+- nop 0
++.Lrewind_pad6:
++ nopr 7
++.Lrewind_pad4:
++ nopr 7
++.Lrewind_pad2:
++ nopr 7
+ .globl sie_exit
+ sie_exit:
+ lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
+@@ -247,7 +252,9 @@ sie_exit:
+ stg %r14,__SF_EMPTY+16(%r15) # set exit reason code
+ j sie_exit
+
+- EX_TABLE(.Lrewind_pad,.Lsie_fault)
++ EX_TABLE(.Lrewind_pad6,.Lsie_fault)
++ EX_TABLE(.Lrewind_pad4,.Lsie_fault)
++ EX_TABLE(.Lrewind_pad2,.Lsie_fault)
+ EX_TABLE(sie_exit,.Lsie_fault)
+ #endif
+
--- /dev/null
+From e5c86679d5e864947a52fb31e45a425dea3e7fa9 Mon Sep 17 00:00:00 2001
+From: Max Filippov <jcmvbkbc@gmail.com>
+Date: Mon, 5 Jun 2017 02:43:51 -0700
+Subject: xtensa: don't use linux IRQ #0
+
+From: Max Filippov <jcmvbkbc@gmail.com>
+
+commit e5c86679d5e864947a52fb31e45a425dea3e7fa9 upstream.
+
+Linux IRQ #0 is reserved for error reporting and may not be used.
+Increase NR_IRQS for one additional slot and increase
+irq_domain_add_legacy parameter first_irq value to 1, so that linux
+IRQ #0 is not associated with hardware IRQ #0 in legacy IRQ domains.
+Introduce macro XTENSA_PIC_LINUX_IRQ for static translation of xtensa
+PIC hardware IRQ # to linux IRQ #. Use this macro in XTFPGA platform
+data definitions.
+
+This fixes inability to use hardware IRQ #0 in configurations that don't
+use device tree and allows for non-identity mapping between linux IRQ #
+and hardware IRQ #.
+
+Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/xtensa/include/asm/irq.h | 3 ++-
+ arch/xtensa/kernel/irq.c | 5 -----
+ arch/xtensa/platforms/xtfpga/include/platform/hardware.h | 6 ++++--
+ arch/xtensa/platforms/xtfpga/setup.c | 10 +++++-----
+ drivers/irqchip/irq-xtensa-mx.c | 2 +-
+ drivers/irqchip/irq-xtensa-pic.c | 2 +-
+ 6 files changed, 13 insertions(+), 15 deletions(-)
+
+--- a/arch/xtensa/include/asm/irq.h
++++ b/arch/xtensa/include/asm/irq.h
+@@ -29,7 +29,8 @@ static inline void variant_irq_disable(u
+ # define PLATFORM_NR_IRQS 0
+ #endif
+ #define XTENSA_NR_IRQS XCHAL_NUM_INTERRUPTS
+-#define NR_IRQS (XTENSA_NR_IRQS + VARIANT_NR_IRQS + PLATFORM_NR_IRQS)
++#define NR_IRQS (XTENSA_NR_IRQS + VARIANT_NR_IRQS + PLATFORM_NR_IRQS + 1)
++#define XTENSA_PIC_LINUX_IRQ(hwirq) ((hwirq) + 1)
+
+ #if VARIANT_NR_IRQS == 0
+ static inline void variant_init_irq(void) { }
+--- a/arch/xtensa/kernel/irq.c
++++ b/arch/xtensa/kernel/irq.c
+@@ -34,11 +34,6 @@ asmlinkage void do_IRQ(int hwirq, struct
+ {
+ int irq = irq_find_mapping(NULL, hwirq);
+
+- if (hwirq >= NR_IRQS) {
+- printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
+- __func__, hwirq);
+- }
+-
+ #ifdef CONFIG_DEBUG_STACKOVERFLOW
+ /* Debugging check for stack overflow: is there less than 1KB free? */
+ {
+--- a/arch/xtensa/platforms/xtfpga/include/platform/hardware.h
++++ b/arch/xtensa/platforms/xtfpga/include/platform/hardware.h
+@@ -24,16 +24,18 @@
+
+ /* Interrupt configuration. */
+
+-#define PLATFORM_NR_IRQS 10
++#define PLATFORM_NR_IRQS 0
+
+ /* Default assignment of LX60 devices to external interrupts. */
+
+ #ifdef CONFIG_XTENSA_MX
+ #define DUART16552_INTNUM XCHAL_EXTINT3_NUM
+ #define OETH_IRQ XCHAL_EXTINT4_NUM
++#define C67X00_IRQ XCHAL_EXTINT8_NUM
+ #else
+ #define DUART16552_INTNUM XCHAL_EXTINT0_NUM
+ #define OETH_IRQ XCHAL_EXTINT1_NUM
++#define C67X00_IRQ XCHAL_EXTINT5_NUM
+ #endif
+
+ /*
+@@ -63,5 +65,5 @@
+
+ #define C67X00_PADDR (XCHAL_KIO_PADDR + 0x0D0D0000)
+ #define C67X00_SIZE 0x10
+-#define C67X00_IRQ 5
++
+ #endif /* __XTENSA_XTAVNET_HARDWARE_H */
+--- a/arch/xtensa/platforms/xtfpga/setup.c
++++ b/arch/xtensa/platforms/xtfpga/setup.c
+@@ -209,8 +209,8 @@ static struct resource ethoc_res[] = {
+ .flags = IORESOURCE_MEM,
+ },
+ [2] = { /* IRQ number */
+- .start = OETH_IRQ,
+- .end = OETH_IRQ,
++ .start = XTENSA_PIC_LINUX_IRQ(OETH_IRQ),
++ .end = XTENSA_PIC_LINUX_IRQ(OETH_IRQ),
+ .flags = IORESOURCE_IRQ,
+ },
+ };
+@@ -246,8 +246,8 @@ static struct resource c67x00_res[] = {
+ .flags = IORESOURCE_MEM,
+ },
+ [1] = { /* IRQ number */
+- .start = C67X00_IRQ,
+- .end = C67X00_IRQ,
++ .start = XTENSA_PIC_LINUX_IRQ(C67X00_IRQ),
++ .end = XTENSA_PIC_LINUX_IRQ(C67X00_IRQ),
+ .flags = IORESOURCE_IRQ,
+ },
+ };
+@@ -280,7 +280,7 @@ static struct resource serial_resource =
+ static struct plat_serial8250_port serial_platform_data[] = {
+ [0] = {
+ .mapbase = DUART16552_PADDR,
+- .irq = DUART16552_INTNUM,
++ .irq = XTENSA_PIC_LINUX_IRQ(DUART16552_INTNUM),
+ .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
+ UPF_IOREMAP,
+ .iotype = UPIO_MEM32,
+--- a/drivers/irqchip/irq-xtensa-mx.c
++++ b/drivers/irqchip/irq-xtensa-mx.c
+@@ -142,7 +142,7 @@ static struct irq_chip xtensa_mx_irq_chi
+ int __init xtensa_mx_init_legacy(struct device_node *interrupt_parent)
+ {
+ struct irq_domain *root_domain =
+- irq_domain_add_legacy(NULL, NR_IRQS, 0, 0,
++ irq_domain_add_legacy(NULL, NR_IRQS - 1, 1, 0,
+ &xtensa_mx_irq_domain_ops,
+ &xtensa_mx_irq_chip);
+ irq_set_default_host(root_domain);
+--- a/drivers/irqchip/irq-xtensa-pic.c
++++ b/drivers/irqchip/irq-xtensa-pic.c
+@@ -89,7 +89,7 @@ static struct irq_chip xtensa_irq_chip =
+ int __init xtensa_pic_init_legacy(struct device_node *interrupt_parent)
+ {
+ struct irq_domain *root_domain =
+- irq_domain_add_legacy(NULL, NR_IRQS, 0, 0,
++ irq_domain_add_legacy(NULL, NR_IRQS - 1, 1, 0,
+ &xtensa_irq_domain_ops, &xtensa_irq_chip);
+ irq_set_default_host(root_domain);
+ return 0;