linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Vaibhav Rustagi <vaibhavrustagi@google.com>,
	Andreas Smas <andreas@lonelycoder.com>,
	Steve Wahl <steve.wahl@hpe.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Borislav Petkov <bp@alien8.de>, "H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	clang-built-linux@googlegroups.com, dimitri.sivanich@hpe.com,
	mike.travis@hpe.com, russ.anderson@hpe.com,
	Ingo Molnar <mingo@kernel.org>
Subject: [PATCH 5.2 48/85] x86/purgatory: Change compiler flags from -mcmodel=kernel to -mcmodel=large to fix kexec relocation errors
Date: Wed, 18 Sep 2019 08:19:06 +0200	[thread overview]
Message-ID: <20190918061235.646618432@linuxfoundation.org> (raw)
In-Reply-To: <20190918061234.107708857@linuxfoundation.org>

From: Steve Wahl <steve.wahl@hpe.com>

commit e16c2983fba0fa6763e43ad10916be35e3d8dc05 upstream.

The last change to this Makefile caused relocation errors when loading
a kdump kernel.  Restore -mcmodel=large (not -mcmodel=kernel),
-ffreestanding, and -fno-zero-initialized-bsss, without reverting to
the former practice of resetting KBUILD_CFLAGS.

Purgatory.ro is a standalone binary that is not linked against the
rest of the kernel.  Its image is copied into an array that is linked
to the kernel, and from there kexec relocates it wherever it desires.

With the previous change to compiler flags, the error "kexec: Overflow
in relocation type 11 value 0x11fffd000" was encountered when trying
to load the crash kernel.  This is from kexec code trying to relocate
the purgatory.ro object.

>From the error message, relocation type 11 is R_X86_64_32S.  The
x86_64 ABI says:

  "The R_X86_64_32 and R_X86_64_32S relocations truncate the
   computed value to 32-bits.  The linker must verify that the
   generated value for the R_X86_64_32 (R_X86_64_32S) relocation
   zero-extends (sign-extends) to the original 64-bit value."

This type of relocation doesn't work when kexec chooses to place the
purgatory binary in memory that is not reachable with 32 bit
addresses.

The compiler flag -mcmodel=kernel allows those type of relocations to
be emitted, so revert to using -mcmodel=large as was done before.

Also restore the -ffreestanding and -fno-zero-initialized-bss flags
because they are appropriate for a stand alone piece of object code
which doesn't explicitly zero the bss, and one other report has said
undefined symbols are encountered without -ffreestanding.

These identical compiler flag changes need to happen for every object
that becomes part of the purgatory.ro object, so gather them together
first into PURGATORY_CFLAGS_REMOVE and PURGATORY_CFLAGS, and then
apply them to each of the objects that have C source.  Do not apply
any of these flags to kexec-purgatory.o, which is not part of the
standalone object but part of the kernel proper.

Tested-by: Vaibhav Rustagi <vaibhavrustagi@google.com>
Tested-by: Andreas Smas <andreas@lonelycoder.com>
Signed-off-by: Steve Wahl <steve.wahl@hpe.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: None
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: clang-built-linux@googlegroups.com
Cc: dimitri.sivanich@hpe.com
Cc: mike.travis@hpe.com
Cc: russ.anderson@hpe.com
Fixes: b059f801a937 ("x86/purgatory: Use CFLAGS_REMOVE rather than reset KBUILD_CFLAGS")
Link: https://lkml.kernel.org/r/20190905202346.GA26595@swahl-linux
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andreas Smas <andreas@lonelycoder.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/purgatory/Makefile |   35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -18,37 +18,40 @@ targets += purgatory.ro
 KASAN_SANITIZE	:= n
 KCOV_INSTRUMENT := n
 
+# These are adjustments to the compiler flags used for objects that
+# make up the standalone purgatory.ro
+
+PURGATORY_CFLAGS_REMOVE := -mcmodel=kernel
+PURGATORY_CFLAGS := -mcmodel=large -ffreestanding -fno-zero-initialized-in-bss
+
 # Default KBUILD_CFLAGS can have -pg option set when FTRACE is enabled. That
 # in turn leaves some undefined symbols like __fentry__ in purgatory and not
 # sure how to relocate those.
 ifdef CONFIG_FUNCTION_TRACER
-CFLAGS_REMOVE_sha256.o		+= $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_purgatory.o	+= $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_string.o		+= $(CC_FLAGS_FTRACE)
-CFLAGS_REMOVE_kexec-purgatory.o	+= $(CC_FLAGS_FTRACE)
+PURGATORY_CFLAGS_REMOVE		+= $(CC_FLAGS_FTRACE)
 endif
 
 ifdef CONFIG_STACKPROTECTOR
-CFLAGS_REMOVE_sha256.o		+= -fstack-protector
-CFLAGS_REMOVE_purgatory.o	+= -fstack-protector
-CFLAGS_REMOVE_string.o		+= -fstack-protector
-CFLAGS_REMOVE_kexec-purgatory.o	+= -fstack-protector
+PURGATORY_CFLAGS_REMOVE		+= -fstack-protector
 endif
 
 ifdef CONFIG_STACKPROTECTOR_STRONG
-CFLAGS_REMOVE_sha256.o		+= -fstack-protector-strong
-CFLAGS_REMOVE_purgatory.o	+= -fstack-protector-strong
-CFLAGS_REMOVE_string.o		+= -fstack-protector-strong
-CFLAGS_REMOVE_kexec-purgatory.o	+= -fstack-protector-strong
+PURGATORY_CFLAGS_REMOVE		+= -fstack-protector-strong
 endif
 
 ifdef CONFIG_RETPOLINE
-CFLAGS_REMOVE_sha256.o		+= $(RETPOLINE_CFLAGS)
-CFLAGS_REMOVE_purgatory.o	+= $(RETPOLINE_CFLAGS)
-CFLAGS_REMOVE_string.o		+= $(RETPOLINE_CFLAGS)
-CFLAGS_REMOVE_kexec-purgatory.o	+= $(RETPOLINE_CFLAGS)
+PURGATORY_CFLAGS_REMOVE		+= $(RETPOLINE_CFLAGS)
 endif
 
+CFLAGS_REMOVE_purgatory.o	+= $(PURGATORY_CFLAGS_REMOVE)
+CFLAGS_purgatory.o		+= $(PURGATORY_CFLAGS)
+
+CFLAGS_REMOVE_sha256.o		+= $(PURGATORY_CFLAGS_REMOVE)
+CFLAGS_sha256.o			+= $(PURGATORY_CFLAGS)
+
+CFLAGS_REMOVE_string.o		+= $(PURGATORY_CFLAGS_REMOVE)
+CFLAGS_string.o			+= $(PURGATORY_CFLAGS)
+
 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
 		$(call if_changed,ld)
 



  parent reply	other threads:[~2019-09-18  6:29 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18  6:18 [PATCH 5.2 00/85] 5.2.16-stable review Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 01/85] bridge/mdb: remove wrong use of NLM_F_MULTI Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 02/85] cdc_ether: fix rndis support for Mediatek based smartphones Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 03/85] ipv6: Fix the link time qualifier of ping_v6_proc_exit_net() Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 04/85] isdn/capi: check message length in capi_write() Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 05/85] ixgbe: Fix secpath usage for IPsec TX offload Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 06/85] ixgbevf: Fix secpath usage for IPsec Tx offload Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 07/85] net: Fix null de-reference of device refcount Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 08/85] net: gso: Fix skb_segment splat when splitting gso_size mangled skb having linear-headed frag_list Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 09/85] net: phylink: Fix flow control resolution Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 10/85] net: sched: fix reordering issues Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 11/85] sch_hhf: ensure quantum and hhf_non_hh_weight are non-zero Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 12/85] sctp: Fix the link time qualifier of sctp_ctrlsock_exit() Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 13/85] sctp: use transport pf_retrans in sctp_do_8_2_transport_strike Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 14/85] tcp: fix tcp_ecn_withdraw_cwr() to clear TCP_ECN_QUEUE_CWR Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 15/85] tipc: add NULL pointer check before calling kfree_rcu Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 16/85] tun: fix use-after-free when register netdev failed Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 17/85] net-ipv6: fix excessive RTF_ADDRCONF flag on ::1/128 local route (and others) Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 18/85] ipv6: addrconf_f6i_alloc - fix non-null pointer check to !IS_ERR() Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 19/85] net: fixed_phy: Add forward declaration for struct gpio_desc; Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 20/85] sctp: fix the missing put_user when dumping transport thresholds Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 21/85] net: sock_map, fix missing ulp check in sock hash case Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 22/85] gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 23/85] gpio: mockup: add missing single_release() Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 24/85] gpio: fix line flag validation in linehandle_create Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 25/85] gpio: fix line flag validation in lineevent_create Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 26/85] Btrfs: fix assertion failure during fsync and use of stale transaction Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 27/85] cgroup: freezer: fix frozen state inheritance Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 28/85] Revert "mmc: bcm2835: Terminate timeout work synchronously" Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 29/85] Revert "mmc: sdhci: Remove unneeded quirk2 flag of O2 SD host controller" Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 30/85] mmc: tmio: Fixup runtime PM management during probe Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 31/85] mmc: tmio: Fixup runtime PM management during remove Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 32/85] drm/lima: fix lima_gem_wait() return value Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 33/85] drm/i915: Limit MST to <= 8bpc once again Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 34/85] drm/i915: Restore relaxed padding (OCL_OOB_SUPPRES_ENABLE) for skl+ Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 35/85] ipc: fix semtimedop for generic 32-bit architectures Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 36/85] ipc: fix sparc64 ipc() wrapper Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 37/85] ixgbe: fix double clean of Tx descriptors with xdp Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 38/85] ixgbe: Prevent u8 wrapping of ITR value to something less than 10us Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 39/85] Revert "rt2800: enable TX_PIN_CFG_LNA_PE_ bits per band" Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 40/85] mt76: mt76x0e: disable 5GHz band for MT7630E Greg Kroah-Hartman
2019-09-18  6:18 ` [PATCH 5.2 41/85] genirq: Prevent NULL pointer dereference in resend_irqs() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 42/85] regulator: twl: voltage lists for vdd1/2 on twl4030 Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 43/85] KVM: s390: kvm_s390_vm_start_migration: check dirty_bitmap before using it as target for memset() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 44/85] KVM: s390: Do not leak kernel stack data in the KVM_S390_INTERRUPT ioctl Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 45/85] KVM: x86: work around leak of uninitialized stack contents Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 46/85] KVM: x86/mmu: Reintroduce fast invalidate/zap for flushing memslot Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 47/85] KVM: nVMX: handle page fault in vmread Greg Kroah-Hartman
2019-09-18  6:19 ` Greg Kroah-Hartman [this message]
2019-09-18  6:19 ` [PATCH 5.2 49/85] powerpc: Add barrier_nospec to raw_copy_in_user() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 50/85] kernel/module: Fix mem leak in module_add_modinfo_attrs Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 51/85] x86/boot: Use efi_setup_data for searching RSDP on kexec-ed kernels Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 52/85] x86/ima: check EFI SetupMode too Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 53/85] drm/meson: Add support for XBGR8888 & ABGR8888 formats Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 54/85] clk: Fix debugfs clk_possible_parents for clks without parent string names Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 55/85] clk: Simplify debugfs printing and add a newline Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 56/85] mt76: Fix a signedness bug in mt7615_add_interface() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 57/85] mt76: mt7615: Use after free in mt7615_mcu_set_bcn() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 58/85] clk: rockchip: Dont yell about bad mmc phases when getting Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 59/85] mtd: rawnand: mtk: Fix wrongly assigned OOB buffer pointer issue Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 60/85] PCI: Always allow probing with driver_override Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 61/85] ubifs: Correctly use tnc_next() in search_dh_cookie() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 62/85] driver core: Fix use-after-free and double free on glue directory Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 63/85] crypto: talitos - check AES key size Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 64/85] crypto: talitos - fix CTR alg blocksize Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 65/85] crypto: talitos - check data blocksize in ablkcipher Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 66/85] crypto: talitos - fix ECB algs ivsize Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 67/85] crypto: talitos - Do not modify req->cryptlen on decryption Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 68/85] crypto: talitos - HMAC SNOOP NO AFEU mode requires SW icv checking Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 69/85] firmware: ti_sci: Always request response from firmware Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 70/85] drm: panel-orientation-quirks: Add extra quirk table entry for GPD MicroPC Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 71/85] drm/mediatek: mtk_drm_drv.c: Add of_node_put() before goto Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 72/85] mm/z3fold.c: remove z3fold_migration trylock Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 73/85] mm/z3fold.c: fix lock/unlock imbalance in z3fold_page_isolate Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 74/85] Revert "Bluetooth: btusb: driver to enable the usb-wakeup feature" Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 75/85] iio: adc: stm32-dfsdm: fix output resolution Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 76/85] iio: adc: stm32-dfsdm: fix data type Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 77/85] modules: fix BUG when load module with rodata=n Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 78/85] modules: fix compile error if dont have strict module rwx Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 79/85] modules: always page-align module section allocations Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 80/85] kvm: nVMX: Remove unnecessary sync_roots from handle_invept Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 81/85] KVM: SVM: Fix detection of AMD Errata 1096 Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 82/85] platform/x86: pmc_atom: Add CB4063 Beckhoff Automation board to critclk_systems DMI table Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 83/85] platform/x86: pcengines-apuv2: use KEY_RESTART for front button Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 84/85] rsi: fix a double free bug in rsi_91x_deinit() Greg Kroah-Hartman
2019-09-18  6:19 ` [PATCH 5.2 85/85] x86/build: Add -Wnoaddress-of-packed-member to REALMODE_CFLAGS, to silence GCC9 build warning Greg Kroah-Hartman
2019-09-18 11:59 ` [PATCH 5.2 00/85] 5.2.16-stable review kernelci.org bot
2019-09-18 15:17 ` Naresh Kamboju
2019-09-19  6:37   ` Greg Kroah-Hartman
2019-09-18 16:28 ` Jon Hunter
2019-09-19  6:37   ` Greg Kroah-Hartman
2019-09-18 19:38 ` Guenter Roeck
2019-09-19  1:22 ` shuah
2019-09-19  6:36   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190918061235.646618432@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=andreas@lonelycoder.com \
    --cc=bp@alien8.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dimitri.sivanich@hpe.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.travis@hpe.com \
    --cc=mingo@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=peterz@infradead.org \
    --cc=russ.anderson@hpe.com \
    --cc=stable@vger.kernel.org \
    --cc=steve.wahl@hpe.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=vaibhavrustagi@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).