--- /dev/null
+From f1f99adf05f2138ff2646d756d4674e302e8d02d Mon Sep 17 00:00:00 2001
+From: Sid Manning <sidneym@codeaurora.org>
+Date: Tue, 13 Oct 2020 16:17:50 -0500
+Subject: Hexagon: add target builtins to kernel
+
+From: Sid Manning <sidneym@codeaurora.org>
+
+commit f1f99adf05f2138ff2646d756d4674e302e8d02d upstream.
+
+Add the compiler-rt builtins like memcpy to the hexagon kernel.
+
+Signed-off-by: Sid Manning <sidneym@codeaurora.org>
+Add SYM_FUNC_START/END, ksyms exports
+Signed-off-by: Brian Cain <bcain@codeaurora.org>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Tested-by: Nick Desaulniers <ndesaulniers@google.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/hexagon/Makefile | 3 -
+ arch/hexagon/kernel/hexagon_ksyms.c | 8 +--
+ arch/hexagon/lib/Makefile | 3 -
+ arch/hexagon/lib/divsi3.S | 67 +++++++++++++++++++++++++++++++
+ arch/hexagon/lib/memcpy_likely_aligned.S | 56 +++++++++++++++++++++++++
+ arch/hexagon/lib/modsi3.S | 46 +++++++++++++++++++++
+ arch/hexagon/lib/udivsi3.S | 38 +++++++++++++++++
+ arch/hexagon/lib/umodsi3.S | 36 ++++++++++++++++
+ 8 files changed, 249 insertions(+), 8 deletions(-)
+
+--- a/arch/hexagon/Makefile
++++ b/arch/hexagon/Makefile
+@@ -33,9 +33,6 @@ TIR_NAME := r19
+ KBUILD_CFLAGS += -ffixed-$(TIR_NAME) -DTHREADINFO_REG=$(TIR_NAME) -D__linux__
+ KBUILD_AFLAGS += -DTHREADINFO_REG=$(TIR_NAME)
+
+-LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name 2>/dev/null)
+-libs-y += $(LIBGCC)
+-
+ head-y := arch/hexagon/kernel/head.o
+
+ core-y += arch/hexagon/kernel/ \
+--- a/arch/hexagon/kernel/hexagon_ksyms.c
++++ b/arch/hexagon/kernel/hexagon_ksyms.c
+@@ -35,8 +35,8 @@ EXPORT_SYMBOL(_dflt_cache_att);
+ DECLARE_EXPORT(__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes);
+
+ /* Additional functions */
+-DECLARE_EXPORT(__divsi3);
+-DECLARE_EXPORT(__modsi3);
+-DECLARE_EXPORT(__udivsi3);
+-DECLARE_EXPORT(__umodsi3);
++DECLARE_EXPORT(__hexagon_divsi3);
++DECLARE_EXPORT(__hexagon_modsi3);
++DECLARE_EXPORT(__hexagon_udivsi3);
++DECLARE_EXPORT(__hexagon_umodsi3);
+ DECLARE_EXPORT(csum_tcpudp_magic);
+--- a/arch/hexagon/lib/Makefile
++++ b/arch/hexagon/lib/Makefile
+@@ -2,4 +2,5 @@
+ #
+ # Makefile for hexagon-specific library files.
+ #
+-obj-y = checksum.o io.o memcpy.o memset.o
++obj-y = checksum.o io.o memcpy.o memset.o memcpy_likely_aligned.o \
++ divsi3.o modsi3.o udivsi3.o umodsi3.o
+--- /dev/null
++++ b/arch/hexagon/lib/divsi3.S
+@@ -0,0 +1,67 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/*
++ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
++ */
++
++#include <linux/linkage.h>
++
++SYM_FUNC_START(__hexagon_divsi3)
++ {
++ p0 = cmp.gt(r0,#-1)
++ p1 = cmp.gt(r1,#-1)
++ r3:2 = vabsw(r1:0)
++ }
++ {
++ p3 = xor(p0,p1)
++ r4 = sub(r2,r3)
++ r6 = cl0(r2)
++ p0 = cmp.gtu(r3,r2)
++ }
++ {
++ r0 = mux(p3,#-1,#1)
++ r7 = cl0(r3)
++ p1 = cmp.gtu(r3,r4)
++ }
++ {
++ r0 = mux(p0,#0,r0)
++ p0 = or(p0,p1)
++ if (p0.new) jumpr:nt r31
++ r6 = sub(r7,r6)
++ }
++ {
++ r7 = r6
++ r5:4 = combine(#1,r3)
++ r6 = add(#1,lsr(r6,#1))
++ p0 = cmp.gtu(r6,#4)
++ }
++ {
++ r5:4 = vaslw(r5:4,r7)
++ if (!p0) r6 = #3
++ }
++ {
++ loop0(1f,r6)
++ r7:6 = vlsrw(r5:4,#1)
++ r1:0 = #0
++ }
++ .falign
++1:
++ {
++ r5:4 = vlsrw(r5:4,#2)
++ if (!p0.new) r0 = add(r0,r5)
++ if (!p0.new) r2 = sub(r2,r4)
++ p0 = cmp.gtu(r4,r2)
++ }
++ {
++ r7:6 = vlsrw(r7:6,#2)
++ if (!p0.new) r0 = add(r0,r7)
++ if (!p0.new) r2 = sub(r2,r6)
++ p0 = cmp.gtu(r6,r2)
++ }:endloop0
++ {
++ if (!p0) r0 = add(r0,r7)
++ }
++ {
++ if (p3) r0 = sub(r1,r0)
++ jumpr r31
++ }
++SYM_FUNC_END(__hexagon_divsi3)
+--- /dev/null
++++ b/arch/hexagon/lib/memcpy_likely_aligned.S
+@@ -0,0 +1,56 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/*
++ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
++ */
++
++#include <linux/linkage.h>
++
++SYM_FUNC_START(__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes)
++ {
++ p0 = bitsclr(r1,#7)
++ p0 = bitsclr(r0,#7)
++ if (p0.new) r5:4 = memd(r1)
++ if (p0.new) r7:6 = memd(r1+#8)
++ }
++ {
++ if (!p0) jump:nt .Lmemcpy_call
++ if (p0) r9:8 = memd(r1+#16)
++ if (p0) r11:10 = memd(r1+#24)
++ p0 = cmp.gtu(r2,#64)
++ }
++ {
++ if (p0) jump:nt .Lmemcpy_call
++ if (!p0) memd(r0) = r5:4
++ if (!p0) memd(r0+#8) = r7:6
++ p0 = cmp.gtu(r2,#32)
++ }
++ {
++ p1 = cmp.gtu(r2,#40)
++ p2 = cmp.gtu(r2,#48)
++ if (p0) r13:12 = memd(r1+#32)
++ if (p1.new) r15:14 = memd(r1+#40)
++ }
++ {
++ memd(r0+#16) = r9:8
++ memd(r0+#24) = r11:10
++ }
++ {
++ if (p0) memd(r0+#32) = r13:12
++ if (p1) memd(r0+#40) = r15:14
++ if (!p2) jumpr:t r31
++ }
++ {
++ p0 = cmp.gtu(r2,#56)
++ r5:4 = memd(r1+#48)
++ if (p0.new) r7:6 = memd(r1+#56)
++ }
++ {
++ memd(r0+#48) = r5:4
++ if (p0) memd(r0+#56) = r7:6
++ jumpr r31
++ }
++
++.Lmemcpy_call:
++ jump memcpy
++
++SYM_FUNC_END(__hexagon_memcpy_likely_aligned_min32bytes_mult8bytes)
+--- /dev/null
++++ b/arch/hexagon/lib/modsi3.S
+@@ -0,0 +1,46 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/*
++ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
++ */
++
++#include <linux/linkage.h>
++
++SYM_FUNC_START(__hexagon_modsi3)
++ {
++ p2 = cmp.ge(r0,#0)
++ r2 = abs(r0)
++ r1 = abs(r1)
++ }
++ {
++ r3 = cl0(r2)
++ r4 = cl0(r1)
++ p0 = cmp.gtu(r1,r2)
++ }
++ {
++ r3 = sub(r4,r3)
++ if (p0) jumpr r31
++ }
++ {
++ p1 = cmp.eq(r3,#0)
++ loop0(1f,r3)
++ r0 = r2
++ r2 = lsl(r1,r3)
++ }
++ .falign
++1:
++ {
++ p0 = cmp.gtu(r2,r0)
++ if (!p0.new) r0 = sub(r0,r2)
++ r2 = lsr(r2,#1)
++ if (p1) r1 = #0
++ }:endloop0
++ {
++ p0 = cmp.gtu(r2,r0)
++ if (!p0.new) r0 = sub(r0,r1)
++ if (p2) jumpr r31
++ }
++ {
++ r0 = neg(r0)
++ jumpr r31
++ }
++SYM_FUNC_END(__hexagon_modsi3)
+--- /dev/null
++++ b/arch/hexagon/lib/udivsi3.S
+@@ -0,0 +1,38 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/*
++ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
++ */
++
++#include <linux/linkage.h>
++
++SYM_FUNC_START(__hexagon_udivsi3)
++ {
++ r2 = cl0(r0)
++ r3 = cl0(r1)
++ r5:4 = combine(#1,#0)
++ p0 = cmp.gtu(r1,r0)
++ }
++ {
++ r6 = sub(r3,r2)
++ r4 = r1
++ r1:0 = combine(r0,r4)
++ if (p0) jumpr r31
++ }
++ {
++ r3:2 = vlslw(r5:4,r6)
++ loop0(1f,r6)
++ }
++ .falign
++1:
++ {
++ p0 = cmp.gtu(r2,r1)
++ if (!p0.new) r1 = sub(r1,r2)
++ if (!p0.new) r0 = add(r0,r3)
++ r3:2 = vlsrw(r3:2,#1)
++ }:endloop0
++ {
++ p0 = cmp.gtu(r2,r1)
++ if (!p0.new) r0 = add(r0,r3)
++ jumpr r31
++ }
++SYM_FUNC_END(__hexagon_udivsi3)
+--- /dev/null
++++ b/arch/hexagon/lib/umodsi3.S
+@@ -0,0 +1,36 @@
++/* SPDX-License-Identifier: GPL-2.0-only */
++/*
++ * Copyright (c) 2021, The Linux Foundation. All rights reserved.
++ */
++
++#include <linux/linkage.h>
++
++SYM_FUNC_START(__hexagon_umodsi3)
++ {
++ r2 = cl0(r0)
++ r3 = cl0(r1)
++ p0 = cmp.gtu(r1,r0)
++ }
++ {
++ r2 = sub(r3,r2)
++ if (p0) jumpr r31
++ }
++ {
++ loop0(1f,r2)
++ p1 = cmp.eq(r2,#0)
++ r2 = lsl(r1,r2)
++ }
++ .falign
++1:
++ {
++ p0 = cmp.gtu(r2,r0)
++ if (!p0.new) r0 = sub(r0,r2)
++ r2 = lsr(r2,#1)
++ if (p1) r1 = #0
++ }:endloop0
++ {
++ p0 = cmp.gtu(r2,r0)
++ if (!p0.new) r0 = sub(r0,r1)
++ jumpr r31
++ }
++SYM_FUNC_END(__hexagon_umodsi3)
--- /dev/null
+From 6fff7410f6befe5744d54f0418d65a6322998c09 Mon Sep 17 00:00:00 2001
+From: Sid Manning <sidneym@codeaurora.org>
+Date: Mon, 26 Apr 2021 13:51:53 -0500
+Subject: Hexagon: change jumps to must-extend in futex_atomic_*
+
+From: Sid Manning <sidneym@codeaurora.org>
+
+commit 6fff7410f6befe5744d54f0418d65a6322998c09 upstream.
+
+Cross-section jumps from .fixup section must be extended.
+
+Signed-off-by: Sid Manning <sidneym@codeaurora.org>
+Signed-off-by: Brian Cain <bcain@codeaurora.org>
+Tested-by: Nick Desaulniers <ndesaulniers@google.com>
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/hexagon/include/asm/futex.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/arch/hexagon/include/asm/futex.h
++++ b/arch/hexagon/include/asm/futex.h
+@@ -21,7 +21,7 @@
+ "3:\n" \
+ ".section .fixup,\"ax\"\n" \
+ "4: %1 = #%5;\n" \
+- " jump 3b\n" \
++ " jump ##3b\n" \
+ ".previous\n" \
+ ".section __ex_table,\"a\"\n" \
+ ".long 1b,4b,2b,4b\n" \
+@@ -90,7 +90,7 @@ futex_atomic_cmpxchg_inatomic(u32 *uval,
+ "3:\n"
+ ".section .fixup,\"ax\"\n"
+ "4: %0 = #%6\n"
+- " jump 3b\n"
++ " jump ##3b\n"
+ ".previous\n"
+ ".section __ex_table,\"a\"\n"
+ ".long 1b,4b,2b,4b\n"
--- /dev/null
+From 788dcee0306e1bdbae1a76d1b3478bb899c5838e Mon Sep 17 00:00:00 2001
+From: Sid Manning <sidneym@codeaurora.org>
+Date: Fri, 23 Apr 2021 15:06:58 -0500
+Subject: Hexagon: fix build errors
+
+From: Sid Manning <sidneym@codeaurora.org>
+
+commit 788dcee0306e1bdbae1a76d1b3478bb899c5838e upstream.
+
+Fix type-o in ptrace.c.
+Add missing include: asm/hexagon_vm.h
+Remove superfluous cast.
+Replace 'p3_0' with 'preds'.
+
+Signed-off-by: Sid Manning <sidneym@codeaurora.org>
+Add -mlong-calls to build flags.
+Signed-off-by: Brian Cain <bcain@codeaurora.org>
+Tested-by: Nick Desaulniers <ndesaulniers@google.com>
+Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/hexagon/Makefile | 3 +++
+ arch/hexagon/include/asm/timex.h | 3 ++-
+ arch/hexagon/kernel/ptrace.c | 4 ++--
+ 3 files changed, 7 insertions(+), 3 deletions(-)
+
+--- a/arch/hexagon/Makefile
++++ b/arch/hexagon/Makefile
+@@ -10,6 +10,9 @@ LDFLAGS_vmlinux += -G0
+ # Do not use single-byte enums; these will overflow.
+ KBUILD_CFLAGS += -fno-short-enums
+
++# We must use long-calls:
++KBUILD_CFLAGS += -mlong-calls
++
+ # Modules must use either long-calls, or use pic/plt.
+ # Use long-calls for now, it's easier. And faster.
+ # KBUILD_CFLAGS_MODULE += -fPIC
+--- a/arch/hexagon/include/asm/timex.h
++++ b/arch/hexagon/include/asm/timex.h
+@@ -8,6 +8,7 @@
+
+ #include <asm-generic/timex.h>
+ #include <asm/timer-regs.h>
++#include <asm/hexagon_vm.h>
+
+ /* Using TCX0 as our clock. CLOCK_TICK_RATE scheduled to be removed. */
+ #define CLOCK_TICK_RATE TCX0_CLK_RATE
+@@ -16,7 +17,7 @@
+
+ static inline int read_current_timer(unsigned long *timer_val)
+ {
+- *timer_val = (unsigned long) __vmgettime();
++ *timer_val = __vmgettime();
+ return 0;
+ }
+
+--- a/arch/hexagon/kernel/ptrace.c
++++ b/arch/hexagon/kernel/ptrace.c
+@@ -35,7 +35,7 @@ void user_disable_single_step(struct tas
+
+ static int genregs_get(struct task_struct *target,
+ const struct user_regset *regset,
+- srtuct membuf to)
++ struct membuf to)
+ {
+ struct pt_regs *regs = task_pt_regs(target);
+
+@@ -54,7 +54,7 @@ static int genregs_get(struct task_struc
+ membuf_store(&to, regs->m0);
+ membuf_store(&to, regs->m1);
+ membuf_store(&to, regs->usr);
+- membuf_store(&to, regs->p3_0);
++ membuf_store(&to, regs->preds);
+ membuf_store(&to, regs->gp);
+ membuf_store(&to, regs->ugp);
+ membuf_store(&to, pt_elr(regs)); // pc
--- /dev/null
+From 25edcc50d76c834479d11fcc7de46f3da4d95121 Mon Sep 17 00:00:00 2001
+From: Fabiano Rosas <farosas@linux.ibm.com>
+Date: Thu, 4 Feb 2021 17:05:17 -0300
+Subject: KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
+
+From: Fabiano Rosas <farosas@linux.ibm.com>
+
+commit 25edcc50d76c834479d11fcc7de46f3da4d95121 upstream.
+
+The Facility Status and Control Register is a privileged SPR that
+defines the availability of some features in problem state. Since it
+can be written by the guest, we must restore it to the previous host
+value after guest exit.
+
+This restoration is currently done by taking the value from
+current->thread.fscr, which in the P9 path is not enough anymore
+because the guest could context switch the QEMU thread, causing the
+guest-current value to be saved into the thread struct.
+
+The above situation manifested when running a QEMU linked against a
+libc with System Call Vectored support, which causes scv
+instructions to be run by QEMU early during the guest boot (during
+SLOF), at which point the FSCR is 0 due to guest entry. After a few
+scv calls (1 to a couple hundred), the context switching happens and
+the QEMU thread runs with the guest value, resulting in a Facility
+Unavailable interrupt.
+
+This patch saves and restores the host value of FSCR in the inner
+guest entry loop in a way independent of current->thread.fscr. The old
+way of doing it is still kept in place because it works for the old
+entry path.
+
+Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
+Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
+Cc: Georgy Yakovlev <gyakovlev@gentoo.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ arch/powerpc/kvm/book3s_hv.c | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+--- a/arch/powerpc/kvm/book3s_hv.c
++++ b/arch/powerpc/kvm/book3s_hv.c
+@@ -3583,6 +3583,7 @@ static int kvmhv_p9_guest_entry(struct k
+ unsigned long host_tidr = mfspr(SPRN_TIDR);
+ unsigned long host_iamr = mfspr(SPRN_IAMR);
+ unsigned long host_amr = mfspr(SPRN_AMR);
++ unsigned long host_fscr = mfspr(SPRN_FSCR);
+ s64 dec;
+ u64 tb;
+ int trap, save_pmu;
+@@ -3726,6 +3727,9 @@ static int kvmhv_p9_guest_entry(struct k
+ if (host_amr != vcpu->arch.amr)
+ mtspr(SPRN_AMR, host_amr);
+
++ if (host_fscr != vcpu->arch.fscr)
++ mtspr(SPRN_FSCR, host_fscr);
++
+ msr_check_and_set(MSR_FP | MSR_VEC | MSR_VSX);
+ store_fp_state(&vcpu->arch.fp);
+ #ifdef CONFIG_ALTIVEC
--- /dev/null
+From 4ca052b4ea621d0002a5e5feace51f60ad5e6b23 Mon Sep 17 00:00:00 2001
+From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Date: Mon, 8 Mar 2021 11:31:28 +0100
+Subject: media: uvcvideo: Support devices that report an OT as an entity source
+
+From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+
+commit 4ca052b4ea621d0002a5e5feace51f60ad5e6b23 upstream.
+
+Some devices reference an output terminal as the source of extension
+units. This is incorrect, as output terminals only have an input pin,
+and thus can't be connected to any entity in the forward direction. The
+resulting topology would cause issues when registering the media
+controller graph. To avoid this problem, connect the extension unit to
+the source of the output terminal instead.
+
+While at it, and while no device has been reported to be affected by
+this issue, also handle forward scans where two output terminals would
+be connected together, and skip the terminals found through such an
+invalid connection.
+
+Reported-and-tested-by: John Nealy <jnealy3@yahoo.com>
+
+Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+Signed-off-by: Hans de Goede <hdegoede@redhat.com>
+Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/media/usb/uvc/uvc_driver.c | 32 ++++++++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+--- a/drivers/media/usb/uvc/uvc_driver.c
++++ b/drivers/media/usb/uvc/uvc_driver.c
+@@ -1588,6 +1588,31 @@ static int uvc_scan_chain_forward(struct
+ return -EINVAL;
+ }
+
++ /*
++ * Some devices reference an output terminal as the
++ * source of extension units. This is incorrect, as
++ * output terminals only have an input pin, and thus
++ * can't be connected to any entity in the forward
++ * direction. The resulting topology would cause issues
++ * when registering the media controller graph. To
++ * avoid this problem, connect the extension unit to
++ * the source of the output terminal instead.
++ */
++ if (UVC_ENTITY_IS_OTERM(entity)) {
++ struct uvc_entity *source;
++
++ source = uvc_entity_by_id(chain->dev,
++ entity->baSourceID[0]);
++ if (!source) {
++ uvc_trace(UVC_TRACE_DESCR,
++ "Can't connect extension unit %u in chain\n",
++ forward->id);
++ break;
++ }
++
++ forward->baSourceID[0] = source->id;
++ }
++
+ list_add_tail(&forward->chain, &chain->entities);
+ if (uvc_trace_param & UVC_TRACE_PROBE) {
+ if (!found)
+@@ -1608,6 +1633,13 @@ static int uvc_scan_chain_forward(struct
+ return -EINVAL;
+ }
+
++ if (UVC_ENTITY_IS_OTERM(entity)) {
++ uvc_trace(UVC_TRACE_DESCR,
++ "Unsupported connection between output terminals %u and %u\n",
++ entity->id, forward->id);
++ break;
++ }
++
+ list_add_tail(&forward->chain, &chain->entities);
+ if (uvc_trace_param & UVC_TRACE_PROBE) {
+ if (!found)
--- /dev/null
+kvm-ppc-book3s-hv-save-and-restore-fscr-in-the-p9-path.patch
+media-uvcvideo-support-devices-that-report-an-ot-as-an-entity-source.patch
+hexagon-fix-build-errors.patch
+hexagon-add-target-builtins-to-kernel.patch
+hexagon-change-jumps-to-must-extend-in-futex_atomic_.patch
+xen-events-reset-active-flag-for-lateeoi-events-later.patch
--- /dev/null
+From 3de218ff39b9e3f0d453fe3154f12a174de44b25 Mon Sep 17 00:00:00 2001
+From: Juergen Gross <jgross@suse.com>
+Date: Wed, 23 Jun 2021 15:09:13 +0200
+Subject: xen/events: reset active flag for lateeoi events later
+
+From: Juergen Gross <jgross@suse.com>
+
+commit 3de218ff39b9e3f0d453fe3154f12a174de44b25 upstream.
+
+In order to avoid a race condition for user events when changing
+cpu affinity reset the active flag only when EOI-ing the event.
+
+This is working fine as all user events are lateeoi events. Note that
+lateeoi_ack_mask_dynirq() is not modified as there is no explicit call
+to xen_irq_lateeoi() expected later.
+
+Cc: stable@vger.kernel.org
+Reported-by: Julien Grall <julien@xen.org>
+Fixes: b6622798bc50b62 ("xen/events: avoid handling the same event on two cpus at the same time")
+Tested-by: Julien Grall <julien@xen.org>
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Reviewed-by: Boris Ostrovsky <boris.ostrvsky@oracle.com>
+Link: https://lore.kernel.org/r/20210623130913.9405-1-jgross@suse.com
+Signed-off-by: Juergen Gross <jgross@suse.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/xen/events/events_base.c | 23 +++++++++++++++++++----
+ 1 file changed, 19 insertions(+), 4 deletions(-)
+
+--- a/drivers/xen/events/events_base.c
++++ b/drivers/xen/events/events_base.c
+@@ -583,6 +583,9 @@ static void xen_irq_lateeoi_locked(struc
+ }
+
+ info->eoi_time = 0;
++
++ /* is_active hasn't been reset yet, do it now. */
++ smp_store_release(&info->is_active, 0);
+ do_unmask(info, EVT_MASK_REASON_EOI_PENDING);
+ }
+
+@@ -1807,10 +1810,22 @@ static void lateeoi_ack_dynirq(struct ir
+ struct irq_info *info = info_for_irq(data->irq);
+ evtchn_port_t evtchn = info ? info->evtchn : 0;
+
+- if (VALID_EVTCHN(evtchn)) {
+- do_mask(info, EVT_MASK_REASON_EOI_PENDING);
+- ack_dynirq(data);
+- }
++ if (!VALID_EVTCHN(evtchn))
++ return;
++
++ do_mask(info, EVT_MASK_REASON_EOI_PENDING);
++
++ if (unlikely(irqd_is_setaffinity_pending(data)) &&
++ likely(!irqd_irq_disabled(data))) {
++ do_mask(info, EVT_MASK_REASON_TEMPORARY);
++
++ clear_evtchn(evtchn);
++
++ irq_move_masked_irq(data);
++
++ do_unmask(info, EVT_MASK_REASON_TEMPORARY);
++ } else
++ clear_evtchn(evtchn);
+ }
+
+ static void lateeoi_mask_ack_dynirq(struct irq_data *data)