Skip to content

Commit

Permalink
Backport GCC12 build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarek committed Sep 16, 2022
1 parent 8f9e2b6 commit 4087b3b
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 10 deletions.
49 changes: 49 additions & 0 deletions patch-IOMMU-x86-work-around-bogus-gcc12-warning-in-hvm_gsi.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
From 80ad8db8a4d9bb24952f0aea788ce6f47566fa76 Mon Sep 17 00:00:00 2001
From: Jan Beulich <jbeulich@suse.com>
Date: Wed, 15 Jun 2022 10:19:32 +0200
Subject: [PATCH] IOMMU/x86: work around bogus gcc12 warning in hvm_gsi_eoi()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As per [1] the expansion of the pirq_dpci() macro causes a -Waddress
controlled warning (enabled implicitly in our builds, if not by default)
tying the middle part of the involved conditional expression to the
surrounding boolean context. Work around this by introducing a local
inline function in the affected source file.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102967
---
xen/drivers/passthrough/x86/hvm.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x86/hvm.c
index 0f94203af817..35b4938ab2bb 100644
--- a/xen/drivers/passthrough/io.c
+++ b/xen/drivers/passthrough/io.c
@@ -25,6 +25,18 @@
#include <asm/hvm/support.h>
#include <asm/io_apic.h>

+/*
+ * Gcc12 takes issue with pirq_dpci() being used in boolean context (see gcc
+ * bug 102967). While we can't replace the macro definition in the header by an
+ * inline function, we can do so here.
+ */
+static inline struct hvm_pirq_dpci *_pirq_dpci(struct pirq *pirq)
+{
+ return pirq_dpci(pirq);
+}
+#undef pirq_dpci
+#define pirq_dpci(pirq) _pirq_dpci(pirq)
+
static DEFINE_PER_CPU(struct list_head, dpci_list);

/*
--
2.35.3

63 changes: 63 additions & 0 deletions patch-x86-deal-with-gcc12-release-build-issues.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
From 9723507daf2120131410c91980d4e4d9b0d0aa90 Mon Sep 17 00:00:00 2001
From: Jan Beulich <jbeulich@suse.com>
Date: Tue, 19 Jul 2022 08:37:29 +0200
Subject: [PATCH] x86: deal with gcc12 release build issues

While a number of issues we previously had with pre-release gcc12 were
fixed in the final release, we continue to have one issue (with multiple
instances) when doing release builds (i.e. at higher optimization
levels): The compiler takes issue with subtracting (always 1 in our
case) from artifical labels (expressed as array) marking the end of
certain regions. This isn't an unreasonable position to take. Simply
hide the "array-ness" by casting to an integer type. To keep things
looking consistently, apply the same cast also on the respective
expressions dealing with the starting addresses. (Note how
efi_arch_memory_setup()'s l2_table_offset() invocations avoid a similar
issue by already having the necessary casts.) In is_xen_fixed_mfn()
further switch from __pa() to virt_to_maddr() to better match the left
sides of the <= operators.

Reported-by: Charles Arnold <carnold@suse.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
xen/arch/x86/efi/efi-boot.h | 6 +++---
xen/arch/x86/include/asm/mm.h | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h
index 6e65b569b0fa..836e8c2ba145 100644
--- a/xen/arch/x86/efi/efi-boot.h
+++ b/xen/arch/x86/efi/efi-boot.h
@@ -677,10 +677,10 @@ static void __init efi_arch_memory_setup(void)
* appropriate l2 slots to map.
*/
#define l2_4G_offset(a) \
- (((UINTN)(a) >> L2_PAGETABLE_SHIFT) & (4 * L2_PAGETABLE_ENTRIES - 1))
+ (((a) >> L2_PAGETABLE_SHIFT) & (4 * L2_PAGETABLE_ENTRIES - 1))

- for ( i = l2_4G_offset(_start);
- i <= l2_4G_offset(_end - 1); ++i )
+ for ( i = l2_4G_offset((UINTN)_start);
+ i <= l2_4G_offset((UINTN)_end - 1); ++i )
{
l2_pgentry_t pte = l2e_from_paddr(i << L2_PAGETABLE_SHIFT,
__PAGE_HYPERVISOR | _PAGE_PSE);
diff --git a/xen/arch/x86/include/asm/mm.h b/xen/arch/x86/include/asm/mm.h
index 07b59c982b39..0fc826de46d8 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -309,8 +309,8 @@ struct page_info
#define is_xen_heap_mfn(mfn) \
(mfn_valid(mfn) && is_xen_heap_page(mfn_to_page(mfn)))
#define is_xen_fixed_mfn(mfn) \
- (((mfn_to_maddr(mfn)) >= __pa(_stext)) && \
- ((mfn_to_maddr(mfn)) <= __pa(__2M_rwdata_end - 1)))
+ (((mfn_to_maddr(mfn)) >= virt_to_maddr((unsigned long)_stext)) && \
+ ((mfn_to_maddr(mfn)) <= virt_to_maddr((unsigned long)__2M_rwdata_end - 1)))

#define PRtype_info "016lx"/* should only be used for printk's */

--
2.35.3

2 changes: 2 additions & 0 deletions series-debian-vm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ patch-Define-build-dates-time-based-on-SOURCE_DATE_EPOCH.patch
patch-docs-rename-DATE-to-PANDOC_REL_DATE-and-allow-to-spe.patch
patch-docs-xen-headers-use-alphabetical-sorting-for-incont.patch
patch-Strip-build-path-directories-in-tools-xen-and-xen-ar.patch
patch-x86-deal-with-gcc12-release-build-issues.patch
patch-IOMMU-x86-work-around-bogus-gcc12-warning-in-hvm_gsi.patch
2 changes: 2 additions & 0 deletions series-vm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ patch-Define-build-dates-time-based-on-SOURCE_DATE_EPOCH.patch
patch-docs-rename-DATE-to-PANDOC_REL_DATE-and-allow-to-spe.patch
patch-docs-xen-headers-use-alphabetical-sorting-for-incont.patch
patch-Strip-build-path-directories-in-tools-xen-and-xen-ar.patch
patch-x86-deal-with-gcc12-release-build-issues.patch
patch-IOMMU-x86-work-around-bogus-gcc12-warning-in-hvm_gsi.patch
22 changes: 12 additions & 10 deletions xen.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,18 @@ Patch202: patch-0002-efi-Ensure-incorrectly-typed-runtime-services-get-ma.patch
Patch203: patch-0001-Add-xen.cfg-options-for-mapbs-and-noexitboot.patch

# Backports
Patch290: patch-0001-ns16550-do-not-override-fifo-size-if-explicitly-set.patch
Patch291: patch-0002-ns16550-specify-uart-param-for-ns_-read-write-_reg-a.patch
Patch292: patch-0003-ns16550-add-Exar-PCIe-UART-cards-support.patch
Patch293: patch-0001-x86-spec-ctrl-Skip-RSB-overwriting-when-safe-to-do-s.patch
Patch294: patch-libxl-Fix-QEMU-cmdline-for-scsi-device.patch
Patch295: patch-libxl-Replace-deprecated-QMP-command-by-query-cpus-f.patch
Patch296: patch-x86-pv-Inject-GP-for-implicit-grant-unmaps.patch
Patch297: patch-ns16550-add-support-for-Intel-LPSS-UART.patch
Patch298: patch-ns16550-add-more-device-IDs-for-Intel-LPSS-UART.patch
Patch299: patch-ns16550-use-poll-mode-if-INTERRUPT_LINE-is-0xff.patch
Patch240: patch-0001-ns16550-do-not-override-fifo-size-if-explicitly-set.patch
Patch241: patch-0002-ns16550-specify-uart-param-for-ns_-read-write-_reg-a.patch
Patch242: patch-0003-ns16550-add-Exar-PCIe-UART-cards-support.patch
Patch243: patch-0001-x86-spec-ctrl-Skip-RSB-overwriting-when-safe-to-do-s.patch
Patch244: patch-libxl-Fix-QEMU-cmdline-for-scsi-device.patch
Patch245: patch-libxl-Replace-deprecated-QMP-command-by-query-cpus-f.patch
Patch246: patch-x86-pv-Inject-GP-for-implicit-grant-unmaps.patch
Patch247: patch-ns16550-add-support-for-Intel-LPSS-UART.patch
Patch248: patch-ns16550-add-more-device-IDs-for-Intel-LPSS-UART.patch
Patch249: patch-ns16550-use-poll-mode-if-INTERRUPT_LINE-is-0xff.patch
Patch250: patch-x86-deal-with-gcc12-release-build-issues.patch
Patch251: patch-IOMMU-x86-work-around-bogus-gcc12-warning-in-hvm_gsi.patch

# Backport unified xen hypervisor patches from Xen 4.15
Patch301: patch-unified-0001-x86-setup-Ignore-early-boot-parameters-like-no-real-.patch
Expand Down

0 comments on commit 4087b3b

Please sign in to comment.