Received: by 10.223.176.5 with SMTP id f5csp900855wra; Fri, 2 Feb 2018 07:58:00 -0800 (PST) X-Google-Smtp-Source: AH8x224lzmaF+ZHLNqCHJL5K2kEPcjgJh/7K7Sc/Uc4meTkgdf40klovJGSQ1XCiBtYcy3zYzZ8g X-Received: by 10.99.173.5 with SMTP id g5mr32068799pgf.391.1517587080567; Fri, 02 Feb 2018 07:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517587080; cv=none; d=google.com; s=arc-20160816; b=xSOxG2vNbaT1zMg7uzsHoLs5RzRc6iYe4qRoOkHU6FcfWHreTePqPq+GeiEJ6lKPRc cyyq0bCmC86vR8waeomtbIAgnLuFuSJuREAlICz3ivuKOI07RoS2WzI1IgjTRKhtMd1s jZcv6UsdEX9GZM+kmjZqh1GazSP/SwsVRfVdoAOQo8cVqRsJf4I40axY5GCYzGV9nnAC 3fFrPnXiPo8JxqWcH4rgN8YCEnDNJvjIxQAR676KX/cqSEuKsyMeyv0h0P9qCGnxGIpr 6jqYcaI3qabqkt5DpOl+UF/jA6oL7pECLz3h+kQy/Vx5WfqID6j23ZBQZn2krqI4xKU2 sIOQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=jAjTPNypcNENV9Gn4HhzDvFvDKpJ9F2jzzJ4sG/Xe24=; b=J+ARr5kg2coX0YBs37DzO2h6r8jnOVeT0OD7wipkqx5V6mP8ydK0iznqGaKyQscQZq ReREaTJ0DfJ3sACK1z9ylPcPgPTgxtNILz3SjyYPrmrs0aSTG28ji4sFHSeoZ+ujtmdC 447vsJaeRk3V+ALJNVS5eXLXq7AOGgJJzUsUNHsevd+m3pF1yMdvjk2Zg/HqPldAP1oD KuiScLFKOlEWO9M4OA1HjjEM1+qOXzxSJ98gzvJDP1yQGp3Y31qy/NJbidwppx3PNaBS 4UXYeTE8adxM+8A7f/48/+p3udjaFXsvbriApbCHwBE5WUn9C2OamNJj8SupFXfSXxr5 3B8A== ARC-Authentication-Results: i=1; mx.google.com; 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 u185si1623711pgc.101.2018.02.02.07.57.44; Fri, 02 Feb 2018 07:58:00 -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; 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 S1751993AbeBBPzq (ORCPT + 99 others); Fri, 2 Feb 2018 10:55:46 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:32908 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751995AbeBBPzl (ORCPT ); Fri, 2 Feb 2018 10:55:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AE92480D; Fri, 2 Feb 2018 07:55:40 -0800 (PST) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 83EB13F24D; Fri, 2 Feb 2018 07:55:38 -0800 (PST) Subject: Re: [PATCH 1/2] ARM: kvm: fix building with gcc-8 To: Arnd Bergmann , Christoffer Dall , Marc Zyngier , Russell King Cc: Andi Kleen , Nicolas Pitre , Julien Thierry , linux-kernel@vger.kernel.org, stable@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Richard Earnshaw , Tamar Christina References: <20180202150756.420422-1-arnd@arndb.de> From: Robin Murphy Message-ID: <2cff070a-357d-c5f5-9ec6-036d93112ce4@arm.com> Date: Fri, 2 Feb 2018 15:55:36 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180202150756.420422-1-arnd@arndb.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/02/18 15:07, Arnd Bergmann wrote: > In banked-sr.c, we use a top-level '__asm__(".arch_extension virt")' > statement to allow compilation of a multi-CPU kernel for ARMv6 > and older ARMv7-A that don't normally support access to the banked > registers. > > This is considered to be a programming error by the gcc developers > and will no longer work in gcc-8, where we now get a build error: > > /tmp/cc4Qy7GR.s:34: Error: Banked registers are not available with this architecture. -- `mrs r3,SP_usr' > /tmp/cc4Qy7GR.s:41: Error: Banked registers are not available with this architecture. -- `mrs r3,ELR_hyp' > /tmp/cc4Qy7GR.s:55: Error: Banked registers are not available with this architecture. -- `mrs r3,SP_svc' > /tmp/cc4Qy7GR.s:62: Error: Banked registers are not available with this architecture. -- `mrs r3,LR_svc' > /tmp/cc4Qy7GR.s:69: Error: Banked registers are not available with this architecture. -- `mrs r3,SPSR_svc' > /tmp/cc4Qy7GR.s:76: Error: Banked registers are not available with this architecture. -- `mrs r3,SP_abt' > > Passign the '-march-armv7ve' flag to gcc works, and is ok here, because > we know the functions won't ever be called on pre-ARMv7VE machines. > Unfortunately, older compiler versions (4.8 and earlier) do not understand > that flag, so we still need to keep the asm around. > > Backporting to stable kernels (4.6+) is needed to allow those to be built > with future compilers as well. Is "-Wa,arch=armv7-a+virt" (as we appear to do for a couple of files already) viable as a possibly cleaner alternative, or is GCC itself now policing the contents of inline asms? > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84129 > Fixes: 33280b4cd1dc ("ARM: KVM: Add banked registers save/restore") > Cc: stable@vger.kernel.org > Signed-off-by: Arnd Bergmann > --- > arch/arm/kvm/hyp/Makefile | 5 +++++ > arch/arm/kvm/hyp/banked-sr.c | 4 ++++ > 2 files changed, 9 insertions(+) > > diff --git a/arch/arm/kvm/hyp/Makefile b/arch/arm/kvm/hyp/Makefile > index 5638ce0c9524..63d6b404d88e 100644 > --- a/arch/arm/kvm/hyp/Makefile > +++ b/arch/arm/kvm/hyp/Makefile > @@ -7,6 +7,8 @@ ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING > > KVM=../../../../virt/kvm > > +CFLAGS_ARMV7VE :=$(call cc-option, -march=armv7ve) > + > obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v2-sr.o > obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v3-sr.o > obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/timer-sr.o > @@ -15,7 +17,10 @@ obj-$(CONFIG_KVM_ARM_HOST) += tlb.o > obj-$(CONFIG_KVM_ARM_HOST) += cp15-sr.o > obj-$(CONFIG_KVM_ARM_HOST) += vfp.o > obj-$(CONFIG_KVM_ARM_HOST) += banked-sr.o > +CFLAGS_banked-sr.o += $(CFLAGS_ARMV7VE) > + > obj-$(CONFIG_KVM_ARM_HOST) += entry.o > obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o > obj-$(CONFIG_KVM_ARM_HOST) += switch.o > +CFLAGS_switch.o += $(CFLAGS_ARMV7VE) > obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o > diff --git a/arch/arm/kvm/hyp/banked-sr.c b/arch/arm/kvm/hyp/banked-sr.c > index 111bda8cdebd..be4b8b0a40ad 100644 > --- a/arch/arm/kvm/hyp/banked-sr.c > +++ b/arch/arm/kvm/hyp/banked-sr.c > @@ -20,6 +20,10 @@ > > #include > > +/* > + * gcc before 4.9 doesn't understand -march=armv7ve, so we have to > + * trick the assembler. > + */ > __asm__(".arch_extension virt"); Would it be worth wrapping this in a preprocessor check for compilers that won't understand the command-line flag? I believe LLVM tends to choke on these global asm statements entirely, so minimising exposure might be a good thing to do in general. Robin. > > void __hyp_text __banked_save_state(struct kvm_cpu_context *ctxt) >