Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1619512ybv; Fri, 21 Feb 2020 00:24:54 -0800 (PST) X-Google-Smtp-Source: APXvYqz7iINZqYR9XhxwFLvJkvdMOMMlkow8Nl+BqS4UsZjyQUzLCmSfeXT8YL+szNzaCH4Iigun X-Received: by 2002:a05:6830:110a:: with SMTP id w10mr27478999otq.300.1582273494627; Fri, 21 Feb 2020 00:24:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273494; cv=none; d=google.com; s=arc-20160816; b=JyFkS5zEVx9JMjhoovx7DDyg+EfeilEhAAL2WOz7UVg4gBjtsj6UMddQN9gMXsP1ax W4iJYuvlwaogL3scn/31lzrgrku3h8FkNdHX3/HTz0eYrdsTMrW2lGvguBqcvZXH8dMf U2aCPt+i4UJAEuywlQYmq7JdpwNbvhxS0I8NJsoRqnTY3wsrh7KhcL8AE+lpPc4lPQJq L+V6mbD0+UnE/FR8td+ap0iCID0AGosiaFCufbsg+B0Wn/BVHA0jvPIX8ARcs75fBch+ t2vg97A78NcVlWTqAdIoVrdH3Gx6dGA+LnL1GE4zkJByUUGJcvJc9lgqKskyo3Np3TFS 6cNw== 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=ciaKSjdowNaJIozR8tty9+nX79ius3iUtQ5hyIiRHU4=; b=G5/IGTgs7vbHwNkOWwBNHLcvyy1SK8oYVz6LtGBaPSYfHlSCkjVBFVMmZppPpIAZke sr383n65/u08SNfmW39zTj5VYgkt6+3dzltS7RYtfc+IFzyxe/u+gSeEDG2GKhph2GFC P8Aar8L98ZgUsoKngkrVk//uWHX4nzCWygoN7yfgAia74fhR3+vYtF4EWwV3GdTIX3/B U6dHqypACFLLj2k8/kMCwzzOlSkBXoBhmjUJ7QS0QfGqgU3kP44cA0p5pdrV/mHE4xSA 6EJ/aXCNLAGE3h9mtbpb8MjdhfhHk5HmhEh7ccI8HA6Hfv66tqy48iuT+hTtZeUHsE5t iqMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=14EL8769; 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 v25si1035233ote.90.2020.02.21.00.24.42; Fri, 21 Feb 2020 00:24:54 -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=14EL8769; 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 S2388577AbgBUIYA (ORCPT + 99 others); Fri, 21 Feb 2020 03:24:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:36220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388572AbgBUIX6 (ORCPT ); Fri, 21 Feb 2020 03:23:58 -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 1826E2467D; Fri, 21 Feb 2020 08:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273437; bh=qRbUMUoNDNhRm65zIbW/W+MIQ+kVKOlc6pAN/6NB8T8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=14EL8769x4wvVCTSC45EEZRLG+mSdPlzvxKfD48KaBuUjBXl+z0kXAW8qY9jd+TVs RW6gEhstsEC3f1bt7ENKZIVYZrzXs8ccpd9AT9plAMHlnnjkhG9yVPvdRDjt0TAeNh 9Bksl+WLx/OXu63hfx18UKksffhLYq/QHg5T2X3U= 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 4.19 134/191] arm64: fix alternatives with LLVMs integrated assembler Date: Fri, 21 Feb 2020 08:41:47 +0100 Message-Id: <20200221072306.861454640@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@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 4b650ec1d7dd1..887a8512bf10b 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