From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7B1BC4332F for ; Wed, 9 Mar 2022 16:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=0iESTczjdAJvUZbNZzze29DQq6qj1TaDzkx2H5sWCbw=; b=eZBZ5/obKfEKxjH3y8XwfndbRP kpnB52GR2jSzDgIxeWiOXqPpnJCdE7k1JqzD8dRC643K2IfoecnljpkMyIAdz5o6uNbwrSMGJ+oiw Zu/rZPDVgaiA2q5o+sE6uKop6Fi4zr7QUkFMkiebsiJPRcOtyQ4yawjP9r0nwbuo8b+9OV6Qu2TN6 qZqMu+3Tz999HnpIz8uMak9w4GAzdzQWYQ7v7teQmj0FY2xwd1ob0DNNIqxGqMNvKok+SpTgnuij4 lzZ/A+vtqMG800AIHE6pUlQMuph7NQULYYvDrb0sHS2vY/TdAocP9BdjRFbJh6Jn490bUElkuHXJM aUwx/u8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRyt8-009HaF-Q5; Wed, 09 Mar 2022 16:10:10 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nRyt4-009HXu-D8 for linux-arm-kernel@lists.infradead.org; Wed, 09 Mar 2022 16:10:08 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C01FD168F; Wed, 9 Mar 2022 08:10:02 -0800 (PST) Received: from [10.1.196.218] (eglon.cambridge.arm.com [10.1.196.218]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F3F483F7F5; Wed, 9 Mar 2022 08:10:01 -0800 (PST) Subject: Re: [PATCH] arm64: Paper over ARM_SMCCC_ARCH_WORKAROUND_3 Clang issue To: Marc Zyngier , linux-arm-kernel@lists.infradead.org Cc: kernel-team@android.com, Nick Desaulniers , Will Deacon , Catalin Marinas References: <20220309155716.3988480-1-maz@kernel.org> From: James Morse Message-ID: <434e3ef6-47b0-f5de-1971-589874681d5c@arm.com> Date: Wed, 9 Mar 2022 16:09:57 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20220309155716.3988480-1-maz@kernel.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220309_081006_635232_7230B649 X-CRM114-Status: GOOD ( 15.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Marc, On 09/03/2022 15:57, Marc Zyngier wrote: > Compiling the arm64 kernel with the BHB workarounds and Clang+LTO > results in a bunch of: > > :4:2: error: invalid fixup for movz/movk instruction > mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 > > when compiling arch/arm64/kernel/entry.S, and makes no sense at all. > > As it turns out, moving a single include line around makes the > problem disappear. Why, you'd ask? Well, I don't have the faintest > idea, and I'm running out of patience. So make of that what you want. Thanks for this - I've been banging my head against the keyboard too. My attempt is below, maybe that helps the toolchain people pin it down. Catalin doesn't like it as he sensibly wants to keep the sequences together. Acked-by: James Morse Tested-by: James Morse Thanks, James Build incantation: make LLVM=1 -s -j 56 LD=ld.lld-11 clang --version: Debian clang version 12.0.0-++20200929085817+962a247aebb-1~exp1 Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin The 'exp' in debian's clang version spooked me, but I can also reproduce this with debian's clang-11: make LLVM=1 -s -j 56 LD=ld.lld-11 CC=clang-11 clang-11 --version Debian clang version 11.0.1-2 Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin Works, but equally inexplicable. -----%<------ diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index 6ebdc0f834a7..fd83baf1c552 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -880,20 +880,6 @@ alternative_cb_end #endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ .endm - /* Save/restores x0-x3 to the stack */ - .macro __mitigate_spectre_bhb_fw -#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY - stp x0, x1, [sp, #-16]! - stp x2, x3, [sp, #-16]! - mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 -alternative_cb smccc_patch_fw_mitigation_conduit - nop // Patched to SMC/HVC #0 -alternative_cb_end - ldp x2, x3, [sp], #16 - ldp x0, x1, [sp], #16 -#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ - .endm - .macro mitigate_spectre_bhb_clear_insn #ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY alternative_cb spectre_bhb_patch_clearbhb diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 4a3a653df07e..03fbb561dcb3 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -659,6 +659,20 @@ alternative_else_nop_endif #define BHB_MITIGATION_FW 2 #define BHB_MITIGATION_INSN 3 + /* Save/restores x0-x3 to the stack */ + .macro __mitigate_spectre_bhb_fw +#ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY + stp x0, x1, [sp, #-16]! + stp x2, x3, [sp, #-16]! + mov w0, #ARM_SMCCC_ARCH_WORKAROUND_3 +alternative_cb smccc_patch_fw_mitigation_conduit + nop // Patched to SMC/HVC #0 +alternative_cb_end + ldp x2, x3, [sp], #16 + ldp x0, x1, [sp], #16 +#endif /* CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY */ + .endm + .macro tramp_ventry, vector_start, regsize, kpti, bhb .align 7 1: -----%<------ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel