From patchwork Thu Jun 15 17:37:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9789459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3A81460325 for ; Thu, 15 Jun 2017 17:43:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DEE42863A for ; Thu, 15 Jun 2017 17:43:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2240228662; Thu, 15 Jun 2017 17:43:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DAA02863A for ; Thu, 15 Jun 2017 17:43:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbdFORmy (ORCPT ); Thu, 15 Jun 2017 13:42:54 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:34695 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750801AbdFORmw (ORCPT ); Thu, 15 Jun 2017 13:42:52 -0400 Received: by mail-pf0-f171.google.com with SMTP id s66so10574640pfs.1 for ; Thu, 15 Jun 2017 10:42:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gsiTwI2KU7ny8E9TX1Pu9xgQHVqgMxj6tGuJjrm83mI=; b=cC5yl463teHmjWPsSJABPY6QVOq+29EHNDDp4pacfFQUFKypffYA61mPPDh1ToE6JC CfMAI/igSifMGAiO2Rqk+egSEC4Xf9Guxtc0UkchLh2LEahZNjtn01Os/D281NYTh3Wd KByglhdEL8zCSJdKDSm78roexezNMRbkE5b90ks6lzWRR+3oWj4UsvBEpuOBjhOJbIDa ppazQUtolZb24F1a/UASrd8gktcfRPfAMVYyRJb1AABJ0DOWfc/oDkrBawir4rBtHxyF WknUZGaCQha9AcFqBd2we7SMzSBia3P2OSz0TuMI6QNjgCCE7saxzCjTvX6azgiL2Ao1 QRXg== X-Gm-Message-State: AKS2vOwoVEy4KeSE3CrAwm1qskD+WZQuQORmtiT5ml6zsP2aiB80/D7A vVC3adpISJVPBE6P X-Received: by 10.99.109.7 with SMTP id i7mr6514953pgc.143.1497548571980; Thu, 15 Jun 2017 10:42:51 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.64.162]) by smtp.gmail.com with ESMTPSA id t2sm1320974pfi.76.2017.06.15.10.42.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Jun 2017 10:42:51 -0700 (PDT) From: Matthias Kaehlcke To: Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , "H . J . Lu" , David Woodhouse , Masahiro Yamada , Michal Marek Cc: x86@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Davidson , Greg Hackmann , Nick Desaulniers , Stephen Hines , Kees Cook , Arnd Bergmann , Bernhard.Rosenkranzer@linaro.org, Peter Foley , Behan Webster , Douglas Anderson , Matthias Kaehlcke Subject: [PATCH v3 2/3] x86/build: Use __cc-option for boot code compiler options Date: Thu, 15 Jun 2017 10:37:14 -0700 Message-Id: <20170615173715.40882-3-mka@chromium.org> X-Mailer: git-send-email 2.13.1.518.g3df882009-goog In-Reply-To: <20170615173715.40882-1-mka@chromium.org> References: <20170615173715.40882-1-mka@chromium.org> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP cc-option is used to enable compiler options for the boot code if they are available. The macro uses KBUILD_CFLAGS and KBUILD_CPPFLAGS for the check, however these flags aren't used to build the boot code, in consequence cc-option can yield wrong results. For example -mpreferred-stack-boundary=2 is never set with a 64-bit compiler, since the setting is only valid for 16 and 32-bit binaries. This is also the case for 32-bit kernel builds, because the option -m32 is added to KBUILD_CFLAGS after the assignment of REALMODE_CFLAGS. Use __cc-option instead of cc-option for the boot mode options. The macro receives the compiler options as parameter instead of using KBUILD_C*FLAGS, for the boot code we pass REALMODE_CFLAGS. Also use separate statements for the __cc-option checks instead of performing them in the initial assignment of REALMODE_CFLAGS since the variable is an input of the macro. Signed-off-by: Matthias Kaehlcke --- Changes in v3: - Use __cc-option instead of cc-option-raw - Updated commit message arch/x86/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index bf240b920473..b2dae639f778 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -24,10 +24,11 @@ REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -D__KERNEL__ \ -DDISABLE_BRANCH_PROFILING \ -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ - -mno-mmx -mno-sse \ - $(call cc-option, -ffreestanding) \ - $(call cc-option, -fno-stack-protector) \ - $(call cc-option, -mpreferred-stack-boundary=2) + -mno-mmx -mno-sse + +REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding) +REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector) +REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -mpreferred-stack-boundary=2) export REALMODE_CFLAGS # BITS is used as extension for files which are available in a 32 bit