Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3548120pxj; Mon, 24 May 2021 09:07:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9jT9OTzV7/c36D5cAcgAxXbKRDbqJdxCCPZuPZdOsyqXQciCkWALhwZCDlGe0xQw+Hkri X-Received: by 2002:a02:5b0a:: with SMTP id g10mr20393655jab.2.1621872461585; Mon, 24 May 2021 09:07:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872461; cv=none; d=google.com; s=arc-20160816; b=vypz2SmvduUJnLS0KGhyXG+cplXS5RR92F0J6/zmc9/KVIvLkPov9RLBUFBE3gFNpY NSPelr1cmKuPQFyaBbyJq6eVLrzfCIuJwSfNagitKbh5j3eiJLyfEvm1zOD319MZ0w4R Qt/PJ/45LI6TSbuFWjlmM4q9R/kLfDybF7+jo1ur3mOzi5f/FuJwGUC95LUzBOHcSvY8 WY17GtxTM/zw73InNyfr8t0Odot3whzm5wHL+WDQJgvZ63Wh9TRUTjf9QNkWrYa3w0ze NsWwmYjib1uRRkzFOeuhHgav6+4AjH1eTYD1UqldYc4xjYZb1SC0HBo9oxTan3Om4bLc ziYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YFxejIW4ysNAoBauX41CwPmynSnLN7hxQieJ3LdjpoQ=; b=wfERuW49Zws21+c/Lq+r7zgE8KHtYwNb06IkBaoHc4nx4LXFdhzkvYUyfjspK5f5M4 s5SM29o/dTJPAVDGMDz+srjwPjApn4N1ruS+PiHKtiTsc4vfmRksEMFiiVquDucXJtmV Q1/yTtb9cAleI2+ezFh7jonKLaBSNBr9uOiCCsnpEzOwQB7pFK/PVGevo8c6+Y32wriM btmTeekV+vVswrKig9UowhZ2HqbAVIxXX2wr/oo7QhkKTVT5Yz7OjtTvOf7EmCSNjkP6 jIoennxhPKKOuKWTVL++WoGd7u1w8nr6HVrOEPZZ1UA33AA/9n4gwSJcIUbCK0ylqIxF x5NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PLpGbIFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o1si15470179jat.48.2021.05.24.09.07.29; Mon, 24 May 2021 09:07:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PLpGbIFy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235825AbhEXQI1 (ORCPT + 99 others); Mon, 24 May 2021 12:08:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:46884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235263AbhEXQAQ (ORCPT ); Mon, 24 May 2021 12:00:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8953A61985; Mon, 24 May 2021 15:46:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871164; bh=aQU06NP4TbAS94hxCLLE0B5GUPZTGRoMn+HDYln3HX0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLpGbIFyrq4dVLbBPN57qL2vnTTPWCl4BnxiXAhLaQ7cnlUkKPfNDTEsYmqkpGu08 zzRHKwy+09po29kqBpJhnoq17AsUVBA6B1tXunIgIKIhbQvwQF2PRCNUdwIsGJrwx/ KcyKDz6OA1QZtchzP9LY7rAMbGTY4m+G3e25u+ZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anthony Ruhier , Nathan Chancellor , Ingo Molnar Subject: [PATCH 5.12 068/127] x86/build: Fix location of -plugin-opt= flags Date: Mon, 24 May 2021 17:26:25 +0200 Message-Id: <20210524152337.153392028@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor commit 0024430e920f2900654ad83cd081cf52e02a3ef5 upstream. Commit b33fff07e3e3 ("x86, build: allow LTO to be selected") added a couple of '-plugin-opt=' flags to KBUILD_LDFLAGS because the code model and stack alignment are not stored in LLVM bitcode. However, these flags were added to KBUILD_LDFLAGS prior to the emulation flag assignment, which uses ':=', so they were overwritten and never added to $(LD) invocations. The absence of these flags caused misalignment issues in the AMDGPU driver when compiling with CONFIG_LTO_CLANG, resulting in general protection faults. Shuffle the assignment below the initial one so that the flags are properly passed along and all of the linker flags stay together. At the same time, avoid any future issues with clobbering flags by changing the emulation flag assignment to '+=' since KBUILD_LDFLAGS is already defined with ':=' in the main Makefile before being exported for modification here as a result of commit: ce99d0bf312d ("kbuild: clear LDFLAGS in the top Makefile") Fixes: b33fff07e3e3 ("x86, build: allow LTO to be selected") Reported-by: Anthony Ruhier Signed-off-by: Nathan Chancellor Signed-off-by: Ingo Molnar Tested-by: Anthony Ruhier Cc: stable@vger.kernel.org Link: https://github.com/ClangBuiltLinux/linux/issues/1374 Link: https://lore.kernel.org/r/20210518190106.60935-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/x86/Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -170,11 +170,6 @@ ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1) KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,) endif -ifdef CONFIG_LTO_CLANG -KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \ - -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) -endif - # Workaround for a gcc prelease that unfortunately was shipped in a suse release KBUILD_CFLAGS += -Wno-sign-compare # @@ -194,7 +189,12 @@ ifdef CONFIG_RETPOLINE endif endif -KBUILD_LDFLAGS := -m elf_$(UTS_MACHINE) +KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE) + +ifdef CONFIG_LTO_CLANG +KBUILD_LDFLAGS += -plugin-opt=-code-model=kernel \ + -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) +endif ifdef CONFIG_X86_NEED_RELOCS LDFLAGS_vmlinux := --emit-relocs --discard-none