Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1256073

[PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization

From Luis Henriques <luis.henriques@canonical.com>
Newsgroups linux.kernel
Subject [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization
Date 2015-10-26 15:30 +0100
Message-ID <qnQWE-Ui-59@gated-at.bofh.it> (permalink)
References <qnQjT-qq-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


3.16.7-ckt19 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ard Biesheuvel <ard.biesheuvel@linaro.org>

commit a077224fd35b2f7fbc93f14cf67074fc792fbac2 upstream.

While working on the 32-bit ARM port of UEFI, I noticed a strange
corruption in the kernel log. The following snprintf() statement
(in drivers/firmware/efi/efi.c:efi_md_typeattr_format())

	snprintf(pos, size, "|%3s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]",

was producing the following output in the log:

	|    |   |   |   |    |WB|WT|WC|UC]
	|    |   |   |   |    |WB|WT|WC|UC]
	|    |   |   |   |    |WB|WT|WC|UC]
	|RUN|   |   |   |    |WB|WT|WC|UC]*
	|RUN|   |   |   |    |WB|WT|WC|UC]*
	|    |   |   |   |    |WB|WT|WC|UC]
	|RUN|   |   |   |    |WB|WT|WC|UC]*
	|    |   |   |   |    |WB|WT|WC|UC]
	|RUN|   |   |   |    |   |   |   |UC]
	|RUN|   |   |   |    |   |   |   |UC]

As it turns out, this is caused by incorrect code being emitted for
the string() function in lib/vsprintf.c. The following code

	if (!(spec.flags & LEFT)) {
		while (len < spec.field_width--) {
			if (buf < end)
				*buf = ' ';
			++buf;
		}
	}
	for (i = 0; i < len; ++i) {
		if (buf < end)
			*buf = *s;
		++buf; ++s;
	}
	while (len < spec.field_width--) {
		if (buf < end)
			*buf = ' ';
		++buf;
	}

when called with len == 0, triggers an issue in the GCC SRA optimization
pass (Scalar Replacement of Aggregates), which handles promotion of signed
struct members incorrectly. This is a known but as yet unresolved issue.
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932). In this particular
case, it is causing the second while loop to be executed erroneously a
single time, causing the additional space characters to be printed.

So disable the optimization by passing -fno-ipa-sra.

Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
[ luis: backported to 3.16: adjusted context ]
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
---
 arch/arm/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 6721fab13734..2c359d52f4b4 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -52,6 +52,14 @@ endif
 
 comma = ,
 
+#
+# The Scalar Replacement of Aggregates (SRA) optimization pass in GCC 4.9 and
+# later may result in code being generated that handles signed short and signed
+# char struct members incorrectly. So disable it.
+# (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65932)
+#
+KBUILD_CFLAGS	+= $(call cc-option,-fno-ipa-sra)
+
 # This selects which instruction set is used.
 # Note that GCC does not numerically define an architecture version
 # macro, but instead defines a whole series of macros which makes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 005/104] arm64: head.S: initialise mdcr_el2 in el2_setup Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 038/104] usb: xhci: Clear XHCI_STATE_DYING on start Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 006/104] kvm: don't try to register to KVM_FAST_MMIO_BUS for non mmio eventfd Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 027/104] drm/vmwgfx: Fix up user_dmabuf refcounting Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 001/104] ARM: 8429/1: disable GCC SRA optimization Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 015/104] arm64: errata: add module build workaround for erratum #843419 Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 029/104] Btrfs: fix read corruption of compressed and shared extents Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 15:30 +0100
  [PATCH 3.16.y-ckt 105/107] KEYS: Fix race between key destruction and finding a keyring by name Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 20:10 +0100
  [PATCH 3.16.y-ckt 107/107] KEYS: Don't permit request_key() to construct a new keyring Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 20:10 +0100
  Re: [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 20:10 +0100
    Re: [3.16.y-ckt stable] Linux 3.16.7-ckt19 stable review Luis Henriques <luis.henriques@canonical.com> - 2015-10-28 18:00 +0100
  [PATCH 3.16.y-ckt 106/107] KEYS: Fix crash when attempt to garbage collect an uninstantiated keyring Luis Henriques <luis.henriques@canonical.com> - 2015-10-26 20:10 +0100
  [PATCH 3.16.y-ckt 108/108] Btrfs: update fix for read corruption of compressed and shared extents Luis Henriques <luis.henriques@canonical.com> - 2015-10-28 18:00 +0100

csiph-web