--- /dev/null
+From ec4696925da6b9baec38345184403ce9e29a2e48 Mon Sep 17 00:00:00 2001
+From: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
+Date: Mon, 9 Dec 2024 13:20:39 -0500
+Subject: efi/libstub: Bump up EFI_MMAP_NR_SLACK_SLOTS to 32
+
+From: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
+
+commit ec4696925da6b9baec38345184403ce9e29a2e48 upstream.
+
+Recent platforms require more slack slots than the current value of
+EFI_MMAP_NR_SLACK_SLOTS, otherwise they fail to boot. The current
+workaround is to append `efi=disable_early_pci_dma` to the kernel's
+cmdline. So, bump up EFI_MMAP_NR_SLACK_SLOTS to 32 to allow those
+platforms to boot with the aforementioned workaround.
+
+Signed-off-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
+Acked-by: Ard Biesheuvel <ardb@kernel.org>
+Reviewed-by: Allen Pais <apais@linux.microsoft.com>
+Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/firmware/efi/libstub/efistub.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/firmware/efi/libstub/efistub.h
++++ b/drivers/firmware/efi/libstub/efistub.h
+@@ -171,7 +171,7 @@ void efi_set_u64_split(u64 data, u32 *lo
+ * the EFI memory map. Other related structures, e.g. x86 e820ext, need
+ * to factor in this headroom requirement as well.
+ */
+-#define EFI_MMAP_NR_SLACK_SLOTS 8
++#define EFI_MMAP_NR_SLACK_SLOTS 32
+
+ typedef struct efi_generic_dev_path efi_device_path_protocol_t;
+
misc-pci_endpoint_test-fix-displaying-irq_type-after-request_irq-error.patch
misc-pci_endpoint_test-fix-irq_type-to-convey-the-correct-type.patch
fix-mmu-notifiers-for-range-based-invalidates.patch
+efi-libstub-bump-up-efi_mmap_nr_slack_slots-to-32.patch
+x86-xen-move-xen_reserve_extra_memory.patch
+x86-xen-fix-memblock_reserve-usage-on-pvh.patch
--- /dev/null
+From 4c006734898a113a64a528027274a571b04af95a Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau@citrix.com>
+Date: Thu, 25 Jul 2024 09:31:15 +0200
+Subject: x86/xen: fix memblock_reserve() usage on PVH
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Roger Pau Monne <roger.pau@citrix.com>
+
+commit 4c006734898a113a64a528027274a571b04af95a upstream.
+
+The current usage of memblock_reserve() in init_pvh_bootparams() is done before
+the .bss is zeroed, and that used to be fine when
+memblock_reserved_init_regions implicitly ended up in the .meminit.data
+section. However after commit 73db3abdca58c memblock_reserved_init_regions
+ends up in the .bss section, thus breaking it's usage before the .bss is
+cleared.
+
+Move and rename the call to xen_reserve_extra_memory() so it's done in the
+x86_init.oem.arch_setup hook, which gets executed after the .bss has been
+zeroed, but before calling e820__memory_setup().
+
+Fixes: 73db3abdca58c ("init/modpost: conditionally check section mismatch to __meminit*")
+Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
+Reviewed-by: Juergen Gross <jgross@suse.com>
+Message-ID: <20240725073116.14626-3-roger.pau@citrix.com>
+Signed-off-by: Juergen Gross <jgross@suse.com>
+[ Context fixup for hypercall_page removal ]
+Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/include/asm/xen/hypervisor.h | 5 -----
+ arch/x86/platform/pvh/enlighten.c | 3 ---
+ arch/x86/xen/enlighten_pvh.c | 15 ++++++++++++---
+ 3 files changed, 12 insertions(+), 11 deletions(-)
+
+--- a/arch/x86/include/asm/xen/hypervisor.h
++++ b/arch/x86/include/asm/xen/hypervisor.h
+@@ -62,11 +62,6 @@ void xen_arch_unregister_cpu(int num);
+ #ifdef CONFIG_PVH
+ void __init xen_pvh_init(struct boot_params *boot_params);
+ void __init mem_map_via_hcall(struct boot_params *boot_params_p);
+-#ifdef CONFIG_XEN_PVH
+-void __init xen_reserve_extra_memory(struct boot_params *bootp);
+-#else
+-static inline void xen_reserve_extra_memory(struct boot_params *bootp) { }
+-#endif
+ #endif
+
+ /* Lazy mode for batching updates / context switch */
+--- a/arch/x86/platform/pvh/enlighten.c
++++ b/arch/x86/platform/pvh/enlighten.c
+@@ -74,9 +74,6 @@ static void __init init_pvh_bootparams(b
+ } else
+ xen_raw_printk("Warning: Can fit ISA range into e820\n");
+
+- if (xen_guest)
+- xen_reserve_extra_memory(&pvh_bootparams);
+-
+ pvh_bootparams.hdr.cmd_line_ptr =
+ pvh_start_info.cmdline_paddr;
+
+--- a/arch/x86/xen/enlighten_pvh.c
++++ b/arch/x86/xen/enlighten_pvh.c
+@@ -8,6 +8,7 @@
+ #include <asm/io_apic.h>
+ #include <asm/hypervisor.h>
+ #include <asm/e820/api.h>
++#include <asm/setup.h>
+
+ #include <xen/xen.h>
+ #include <asm/xen/interface.h>
+@@ -40,8 +41,9 @@ EXPORT_SYMBOL_GPL(xen_pvh);
+ * hypervisor should notify us which memory ranges are suitable for creating
+ * foreign mappings, but that's not yet implemented.
+ */
+-void __init xen_reserve_extra_memory(struct boot_params *bootp)
++static void __init pvh_reserve_extra_memory(void)
+ {
++ struct boot_params *bootp = &boot_params;
+ unsigned int i, ram_pages = 0, extra_pages;
+
+ for (i = 0; i < bootp->e820_entries; i++) {
+@@ -93,14 +95,21 @@ void __init xen_reserve_extra_memory(str
+ }
+ }
+
++static void __init pvh_arch_setup(void)
++{
++ pvh_reserve_extra_memory();
++
++ if (xen_initial_domain())
++ xen_add_preferred_consoles();
++}
++
+ void __init xen_pvh_init(struct boot_params *boot_params)
+ {
+ xen_pvh = 1;
+ xen_domain_type = XEN_HVM_DOMAIN;
+ xen_start_flags = pvh_start_info.flags;
+
+- if (xen_initial_domain())
+- x86_init.oem.arch_setup = xen_add_preferred_consoles;
++ x86_init.oem.arch_setup = pvh_arch_setup;
+ x86_init.oem.banner = xen_banner;
+
+ xen_efi_init(boot_params);
--- /dev/null
+From fc05ea89c9ab45e70cb73e70bc0b9cdd403e0ee1 Mon Sep 17 00:00:00 2001
+From: Roger Pau Monne <roger.pau@citrix.com>
+Date: Thu, 25 Jul 2024 09:31:14 +0200
+Subject: x86/xen: move xen_reserve_extra_memory()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: Roger Pau Monne <roger.pau@citrix.com>
+
+commit fc05ea89c9ab45e70cb73e70bc0b9cdd403e0ee1 upstream.
+
+In preparation for making the function static.
+
+No functional change.
+
+Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
+Reviewed-by: Juergen Gross <jgross@suse.com>
+Message-ID: <20240725073116.14626-2-roger.pau@citrix.com>
+Signed-off-by: Juergen Gross <jgross@suse.com>
+[ Stable backport - move the code as it exists ]
+Signed-off-by: Jason Andryuk <jason.andryuk@amd.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/xen/enlighten_pvh.c | 82 +++++++++++++++++++++----------------------
+ 1 file changed, 41 insertions(+), 41 deletions(-)
+
+--- a/arch/x86/xen/enlighten_pvh.c
++++ b/arch/x86/xen/enlighten_pvh.c
+@@ -26,47 +26,6 @@
+ bool __ro_after_init xen_pvh;
+ EXPORT_SYMBOL_GPL(xen_pvh);
+
+-void __init xen_pvh_init(struct boot_params *boot_params)
+-{
+- xen_pvh = 1;
+- xen_domain_type = XEN_HVM_DOMAIN;
+- xen_start_flags = pvh_start_info.flags;
+-
+- if (xen_initial_domain())
+- x86_init.oem.arch_setup = xen_add_preferred_consoles;
+- x86_init.oem.banner = xen_banner;
+-
+- xen_efi_init(boot_params);
+-
+- if (xen_initial_domain()) {
+- struct xen_platform_op op = {
+- .cmd = XENPF_get_dom0_console,
+- };
+- int ret = HYPERVISOR_platform_op(&op);
+-
+- if (ret > 0)
+- xen_init_vga(&op.u.dom0_console,
+- min(ret * sizeof(char),
+- sizeof(op.u.dom0_console)),
+- &boot_params->screen_info);
+- }
+-}
+-
+-void __init mem_map_via_hcall(struct boot_params *boot_params_p)
+-{
+- struct xen_memory_map memmap;
+- int rc;
+-
+- memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
+- set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
+- rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
+- if (rc) {
+- xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
+- BUG();
+- }
+- boot_params_p->e820_entries = memmap.nr_entries;
+-}
+-
+ /*
+ * Reserve e820 UNUSABLE regions to inflate the memory balloon.
+ *
+@@ -133,3 +92,44 @@ void __init xen_reserve_extra_memory(str
+ xen_add_extra_mem(PFN_UP(e->addr), pages);
+ }
+ }
++
++void __init xen_pvh_init(struct boot_params *boot_params)
++{
++ xen_pvh = 1;
++ xen_domain_type = XEN_HVM_DOMAIN;
++ xen_start_flags = pvh_start_info.flags;
++
++ if (xen_initial_domain())
++ x86_init.oem.arch_setup = xen_add_preferred_consoles;
++ x86_init.oem.banner = xen_banner;
++
++ xen_efi_init(boot_params);
++
++ if (xen_initial_domain()) {
++ struct xen_platform_op op = {
++ .cmd = XENPF_get_dom0_console,
++ };
++ int ret = HYPERVISOR_platform_op(&op);
++
++ if (ret > 0)
++ xen_init_vga(&op.u.dom0_console,
++ min(ret * sizeof(char),
++ sizeof(op.u.dom0_console)),
++ &boot_params->screen_info);
++ }
++}
++
++void __init mem_map_via_hcall(struct boot_params *boot_params_p)
++{
++ struct xen_memory_map memmap;
++ int rc;
++
++ memmap.nr_entries = ARRAY_SIZE(boot_params_p->e820_table);
++ set_xen_guest_handle(memmap.buffer, boot_params_p->e820_table);
++ rc = HYPERVISOR_memory_op(XENMEM_memory_map, &memmap);
++ if (rc) {
++ xen_raw_printk("XENMEM_memory_map failed (%d)\n", rc);
++ BUG();
++ }
++ boot_params_p->e820_entries = memmap.nr_entries;
++}