Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1595204ybv; Thu, 20 Feb 2020 23:58:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxSw8F60oodYxal0fq2YvNbfgNI1iEyUDX83eGWi6NrEK7+UChTaNPwq1sSWBy4mSty57Zn X-Received: by 2002:aca:4183:: with SMTP id o125mr902193oia.125.1582271923737; Thu, 20 Feb 2020 23:58:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582271923; cv=none; d=google.com; s=arc-20160816; b=CGuOuB7oIZWwZc3M90ZgCP5n70bxRkP6SU7uv/SO+ECnLRH6eVns32qId071Hcl4Nv C1NXtWdFhnvnZTdzWWqPDCO/1IOgo0hR2C4RBmv1AefOs6v0yrY2NuunBklg19jG4Ft2 r7YTLXbS09+yc4QiGE2JfvTHDEb3QI4J9IlNQypnWyDB2DF7d4HAYzTLzMFGeTONsDdr cVMy9gkuvOKxF+1d+oc4oPu+1k6gECrdnxqqmVOjij6CWk+/p4ZqSJL2cGxGG4anEJCl c7IVq3aAAN3Pbaq3UXnvy8QgMR4FvczcDtngf4y0YiN2ifDet9+pDG4s75LPuSuW8Jrc EDKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z1EFtZ/cIHcNokpEzEp4ziUpA7DQhT4PlDw64RV/hvg=; b=vFmYxQq4pN57/mWI66OY8o/IAOFL4aVz3iFteGv7ccIme1BKTdp1BBJT5wu30gpCGB qCzjrV2mea9geLGSy4VF0BLEI1UwwLFDwD2ZKZrVVe3KS4nnb1UFfokb+HZ4CS1yHmmT yQ1fo/TRaEWWgJG73ISp9WzVd3/XT9nHBLcQv+9Bu/uLI/qddurN4jDn/90w+3o0uwdz sBy2MRqUM41hktHSj5qHE4PD5GU8Gx1lZbNSy1m9rQDhxqjcGlj2RvBk1et5G6oqsYm3 kJRiaSf2ta0CFxCaJVrMVk5D+gNlttx8jHnV7uxbmjZVNX9Ji0wowYkGQiouVJpriiea IxVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2cUxPIRn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 8si941446ota.266.2020.02.20.23.58.31; Thu, 20 Feb 2020 23:58:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2cUxPIRn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730621AbgBUH52 (ORCPT + 99 others); Fri, 21 Feb 2020 02:57:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:56926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730270AbgBUH5Z (ORCPT ); Fri, 21 Feb 2020 02:57:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DC429222C4; Fri, 21 Feb 2020 07:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271844; bh=/eTuMA1+EKSBwjBLo0bimCwtlU8PRo/V9j/mbKbSwU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2cUxPIRnoz0sEPP/rdP4UApZCXFImpVoEobqFjkrGyrK1cPtQhkKkgqaPnd+vm7w6 2mLsyD6BwJuQk1L3dlfSp++AFLGdcun7ZpP+I4hbPgRZYcrguwTik2hT578hA6k9gd dEC4h44ps5gWmAGtWWH+6eTqDPzHhFRfMEHzv0cE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sami Tolvanen , Nick Desaulniers , Kees Cook , Will Deacon , Sasha Levin Subject: [PATCH 5.5 282/399] arm64: fix alternatives with LLVMs integrated assembler Date: Fri, 21 Feb 2020 08:40:07 +0100 Message-Id: <20200221072429.379585529@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sami Tolvanen [ Upstream commit c54f90c2627cc316d365e3073614731e17dbc631 ] LLVM's integrated assembler fails with the following error when building KVM: :12:6: error: expected absolute expression .if kvm_update_va_mask == 0 ^ :21:6: error: expected absolute expression .if kvm_update_va_mask == 0 ^ :24:2: error: unrecognized instruction mnemonic NOT_AN_INSTRUCTION ^ LLVM ERROR: Error parsing inline asm These errors come from ALTERNATIVE_CB and __ALTERNATIVE_CFG, which test for the existence of the callback parameter in inline assembly using the following expression: " .if " __stringify(cb) " == 0\n" This works with GNU as, but isn't supported by LLVM. This change splits __ALTERNATIVE_CFG and ALTINSTR_ENTRY into separate macros to fix the LLVM build. Link: https://github.com/ClangBuiltLinux/linux/issues/472 Signed-off-by: Sami Tolvanen Tested-by: Nick Desaulniers Reviewed-by: Kees Cook Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/include/asm/alternative.h | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/alternative.h b/arch/arm64/include/asm/alternative.h index b9f8d787eea9f..324e7d5ab37ed 100644 --- a/arch/arm64/include/asm/alternative.h +++ b/arch/arm64/include/asm/alternative.h @@ -35,13 +35,16 @@ void apply_alternatives_module(void *start, size_t length); static inline void apply_alternatives_module(void *start, size_t length) { } #endif -#define ALTINSTR_ENTRY(feature,cb) \ +#define ALTINSTR_ENTRY(feature) \ " .word 661b - .\n" /* label */ \ - " .if " __stringify(cb) " == 0\n" \ " .word 663f - .\n" /* new instruction */ \ - " .else\n" \ + " .hword " __stringify(feature) "\n" /* feature bit */ \ + " .byte 662b-661b\n" /* source len */ \ + " .byte 664f-663f\n" /* replacement len */ + +#define ALTINSTR_ENTRY_CB(feature, cb) \ + " .word 661b - .\n" /* label */ \ " .word " __stringify(cb) "- .\n" /* callback */ \ - " .endif\n" \ " .hword " __stringify(feature) "\n" /* feature bit */ \ " .byte 662b-661b\n" /* source len */ \ " .byte 664f-663f\n" /* replacement len */ @@ -62,15 +65,14 @@ static inline void apply_alternatives_module(void *start, size_t length) { } * * Alternatives with callbacks do not generate replacement instructions. */ -#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled, cb) \ +#define __ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg_enabled) \ ".if "__stringify(cfg_enabled)" == 1\n" \ "661:\n\t" \ oldinstr "\n" \ "662:\n" \ ".pushsection .altinstructions,\"a\"\n" \ - ALTINSTR_ENTRY(feature,cb) \ + ALTINSTR_ENTRY(feature) \ ".popsection\n" \ - " .if " __stringify(cb) " == 0\n" \ ".pushsection .altinstr_replacement, \"a\"\n" \ "663:\n\t" \ newinstr "\n" \ @@ -78,17 +80,25 @@ static inline void apply_alternatives_module(void *start, size_t length) { } ".popsection\n\t" \ ".org . - (664b-663b) + (662b-661b)\n\t" \ ".org . - (662b-661b) + (664b-663b)\n" \ - ".else\n\t" \ + ".endif\n" + +#define __ALTERNATIVE_CFG_CB(oldinstr, feature, cfg_enabled, cb) \ + ".if "__stringify(cfg_enabled)" == 1\n" \ + "661:\n\t" \ + oldinstr "\n" \ + "662:\n" \ + ".pushsection .altinstructions,\"a\"\n" \ + ALTINSTR_ENTRY_CB(feature, cb) \ + ".popsection\n" \ "663:\n\t" \ "664:\n\t" \ - ".endif\n" \ ".endif\n" #define _ALTERNATIVE_CFG(oldinstr, newinstr, feature, cfg, ...) \ - __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg), 0) + __ALTERNATIVE_CFG(oldinstr, newinstr, feature, IS_ENABLED(cfg)) #define ALTERNATIVE_CB(oldinstr, cb) \ - __ALTERNATIVE_CFG(oldinstr, "NOT_AN_INSTRUCTION", ARM64_CB_PATCH, 1, cb) + __ALTERNATIVE_CFG_CB(oldinstr, ARM64_CB_PATCH, 1, cb) #else #include -- 2.20.1