From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752625AbcFVOYv (ORCPT ); Wed, 22 Jun 2016 10:24:51 -0400 Received: from verein.lst.de ([213.95.11.211]:52273 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752259AbcFVOYs (ORCPT ); Wed, 22 Jun 2016 10:24:48 -0400 Date: Wed, 22 Jun 2016 16:24:41 +0200 From: Torsten Duwe To: Jiri Kosina Cc: matz@suse.de, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] Disable non-ABI-compliant optimisations for live patching Message-ID: <20160622142441.GA31609@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Live patching, as we use it, deliberately disrupts the fabric of compile units; thus all assumptions a compiler can make about the control flow may be invalid. As an example, it could analyse that a callee does not touch a caller-saved register at all, so why waste memory bandwidth saving it? The register allocations for the live patch replacement function may however be quite different. Starting with this example, disable all compiler optimisations that do not strictly comply with the established calling conventions. Signed-off-by: Torsten Duwe --- Working on the arm64 ftrace-with-regs/livepatch, it struck me that this is a general problem: with live patching, certain optimisations must be switched off for all architectures, the new(?) IPA register allocator in gcc6 is only one example. We should tackle this well before it bites us. Torsten --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Makefile b/Makefile index b409076..424d2e6 100644 --- a/Makefile +++ b/Makefile @@ -743,6 +743,13 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ $(call cc-option,-fno-var-tracking) endif +ifdef CONFIG_LIVEPATCH +# The compiler might generate ABI "shortcuts" to speed up the code, +# making assumptions which are no longer valid when live patching +# is enabled. Disable all of them. +KBUILD_CFLAGS += $(call cc-option,-fno-ipa-ra) +endif + ifdef CONFIG_FUNCTION_TRACER ifndef CC_FLAGS_FTRACE CC_FLAGS_FTRACE := -pg -- 2.6.6