Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp598210rwb; Thu, 22 Sep 2022 04:08:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70i/W3mNF/dgNACjwBnpswyxGOdFtdCBUXwRmQ91dlSlbGZcdLBwn+Wa9QAKzrAS/KpZT7 X-Received: by 2002:a17:907:3f13:b0:782:1266:8c10 with SMTP id hq19-20020a1709073f1300b0078212668c10mr2289505ejc.197.1663844921369; Thu, 22 Sep 2022 04:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663844921; cv=none; d=google.com; s=arc-20160816; b=kUrD2I3+xBQ6+sUa2GA8RrAHIibvyvUsEbtJhEpudaIona+DkgQCJ8tUgX71n8an3B /MU1orsqLCRZQxSGFUBpenoI8ildZws2xFZ49aELMAnnurixftyWAQwS1mPBpf8qsIGV n6/x4wIjFEDPofyF5wXa8hncxZVb5Xrt0mEGvLsLemH6Vt3uKopfXuMeoeiLWxCBmppV HCUpNHnieA1s+8ztuN+Bzo0tISRio9FGZyExSIAZG/3V8msoqTBiAKuSEgjVFtkXBKqY CYRTl8g5wQl0PFXoKuPgVIUls073pG4KNCnQi3afY/8sjbeek7KJrag6nI7jY934Pqxg PDug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=9fIG/hPxc5wpUbQrTpZ1MCCmz+aus2+p1a7h7ePfsSA=; b=qO2KaJQdUe2Xdp9XcfCDiqRIlaDrl/LqfvQrzA1+f37tT2OZDsDdMuwAVEuJTp87q7 1+nSuW+sBSDwOQwA+bnj8c0LKR6f1nxp7fc1SpAO7ewVJBXwGtddtz3cX7DeYKsM1qcM fdb3ps4KV6LqD5zFc349UKzo9vpJTTGgtAX8qh6rKjI4TYzxlykWN5bhIlP5AxQfDmC0 fo9yz6ZsWKBBJmeeZP2hZwmfSdk3bcBGH5Eo+bgCntVuAbgixNEpWdyviLGcyn/I82ym paoZdbOYSBItu7nMZmtraou4oNvQDXD2k1ZdUcQOGR2YS6WMnYcJkuoiPQPdgL+3DXay ePHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QeHYxLtV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs35-20020a1709072d2300b007827639faffsi92119ejc.760.2022.09.22.04.08.14; Thu, 22 Sep 2022 04:08:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QeHYxLtV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbiIVKiE (ORCPT + 99 others); Thu, 22 Sep 2022 06:38:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbiIVKiC (ORCPT ); Thu, 22 Sep 2022 06:38:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7968DB5146 for ; Thu, 22 Sep 2022 03:38:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA4CE61314 for ; Thu, 22 Sep 2022 10:37:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DF09C433D6; Thu, 22 Sep 2022 10:37:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663843079; bh=xgmLw7d4PE2k0XeJU9Rnum0/i9pq4y604yrZhPEmnuk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=QeHYxLtVg98xO9Y+iSy4BPTafwdVMe0uKgoanxKK/iwKumJ+bh9zB8QDyNmQMnwJ/ otXRniCKuGbasENbzAYabZLD1/T0Wi1lf6LK5yA6e9ff4T8iA5GB6Q5Pmm8kFRtoxF VRf04HcGjyyGER3VdOSa8TjqjX8XbrCxFYj9X1NkldLFSyJrz0rDqg1dOGfW2GIc3D EGhmWg4IzA4IOo8iLID2pqd6GQgGpoyf0CNbQoNogzoiMab8cPtujyxAhA3XPey+C9 MJo5EfLEmLVYC09hOKBGHsvqGYMQIIFCdxG7BwWvZc23+z8y98PUMJNpycLOt1G5z9 n6/Lajas+8W+g== Received: from 185-176-101-241.host.sccbroadband.ie ([185.176.101.241] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1obJae-00BsHQ-W9; Thu, 22 Sep 2022 11:37:57 +0100 Date: Thu, 22 Sep 2022 11:37:55 +0100 Message-ID: <87h70zk83g.wl-maz@kernel.org> From: Marc Zyngier To: Denis Nikitin Cc: Catalin Marinas , Will Deacon , James Morse , Alexandru Elisei , Nick Desaulniers , Manoj Gupta , David Brazdil , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] KVM: arm64: nvhe: Fix build with profile optimization In-Reply-To: <20220922053145.944786-1-denik@chromium.org> References: <20220920082005.2459826-1-denik@chromium.org> <20220922053145.944786-1-denik@chromium.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.176.101.241 X-SA-Exim-Rcpt-To: denik@chromium.org, catalin.marinas@arm.com, will@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, ndesaulniers@google.com, manojgupta@google.com, dbrazdil@google.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 22 Sep 2022 06:31:45 +0100, Denis Nikitin wrote: > > Kernel build with clang and KCFLAGS=-fprofile-sample-use fails with: > > error: arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: Unexpected SHT_REL > section ".rel.llvm.call-graph-profile" > > Starting from 13.0.0 llvm can generate SHT_REL section, see > https://reviews.llvm.org/rGca3bdb57fa1ac98b711a735de048c12b5fdd8086. > gen-hyprel does not support SHT_REL relocation section. > > Remove ".llvm.call-graph-profile" SHT_REL relocation from kvm_nvhe > to fix the build. > > Signed-off-by: Denis Nikitin > --- > V1 -> V2: Remove the relocation instead of disabling the profile-use flags. > --- > arch/arm64/kvm/hyp/nvhe/Makefile | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile > index b5c5119c7396..49ec950ac57b 100644 > --- a/arch/arm64/kvm/hyp/nvhe/Makefile > +++ b/arch/arm64/kvm/hyp/nvhe/Makefile > @@ -78,8 +78,10 @@ $(obj)/kvm_nvhe.o: $(obj)/kvm_nvhe.rel.o FORCE > > # The HYPREL command calls `gen-hyprel` to generate an assembly file with > # a list of relocations targeting hyp code/data. > +# Starting from 13.0.0 llvm emits SHT_REL section '.llvm.call-graph-profile' > +# when profile optimization is applied. gen-hyprel does not support SHT_REL. > quiet_cmd_hyprel = HYPREL $@ > - cmd_hyprel = $(obj)/gen-hyprel $< > $@ > + cmd_hyprel = $(OBJCOPY) -R .llvm.call-graph-profile $<; $(obj)/gen-hyprel $< > $@ I was really hoping that you'd just drop the flags from the CFLAGS instead of removing the generated section. Something like: diff --git a/arch/arm64/kvm/hyp/nvhe/Makefile b/arch/arm64/kvm/hyp/nvhe/Makefile index b5c5119c7396..e5b2d43925b4 100644 --- a/arch/arm64/kvm/hyp/nvhe/Makefile +++ b/arch/arm64/kvm/hyp/nvhe/Makefile @@ -88,7 +88,7 @@ quiet_cmd_hypcopy = HYPCOPY $@ # Remove ftrace, Shadow Call Stack, and CFI CFLAGS. # This is equivalent to the 'notrace', '__noscs', and '__nocfi' annotations. -KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI), $(KBUILD_CFLAGS)) +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE) $(CC_FLAGS_SCS) $(CC_FLAGS_CFI) -fprofile-sample-use, $(KBUILD_CFLAGS)) # KVM nVHE code is run at a different exception code with a different map, so # compiler instrumentation that inserts callbacks or checks into the code may However, I even failed to reproduce your problem using LLVM 14 as packaged by Debian (if that matters, I'm using an arm64 build machine). I build the kernel with: $ make LLVM=1 KCFLAGS=-fprofile-sample-use -j8 vmlinux and the offending object only contains the following sections: arch/arm64/kvm/hyp/nvhe/kvm_nvhe.tmp.o: file format elf64-littleaarch64 Sections: Idx Name Size VMA LMA File off Algn 0 .hyp.idmap.text 00000ae4 0000000000000000 0000000000000000 00000800 2**11 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 1 .hyp.text 0000e988 0000000000000000 0000000000000000 00001800 2**11 CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 2 .hyp.data..ro_after_init 00000820 0000000000000000 0000000000000000 00010188 2**3 CONTENTS, ALLOC, LOAD, DATA 3 .hyp.rodata 00002e70 0000000000000000 0000000000000000 000109a8 2**3 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 4 .hyp.data..percpu 00001ee0 0000000000000000 0000000000000000 00013820 2**4 CONTENTS, ALLOC, LOAD, DATA 5 .hyp.bss 00001158 0000000000000000 0000000000000000 00015700 2**3 ALLOC 6 .comment 0000001f 0000000000000000 0000000000000000 00017830 2**0 CONTENTS, READONLY 7 .llvm_addrsig 000000b8 0000000000000000 0000000000000000 0001784f 2**0 CONTENTS, READONLY, EXCLUDE 8 .altinstructions 00001284 0000000000000000 0000000000000000 00015700 2**0 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 9 __jump_table 00000960 0000000000000000 0000000000000000 00016988 2**3 CONTENTS, ALLOC, LOAD, RELOC, DATA 10 __bug_table 0000051c 0000000000000000 0000000000000000 000172e8 2**2 CONTENTS, ALLOC, LOAD, RELOC, DATA 11 __kvm_ex_table 00000028 0000000000000000 0000000000000000 00017808 2**3 CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA 12 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00027370 2**0 CONTENTS, READONLY So what am I missing to trigger this issue? Does it rely on something like PGO, which is not upstream yet? A bit of handholding would be much appreciated. Thanks, M. -- Without deviation from the norm, progress is not possible.