Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6905755rwd; Mon, 19 Jun 2023 14:40:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6MCxSyCOiruMgm0DNxmQ5KEUbTZP5wfWkQgoWe1W4A46ZdSwUOI+VjCRwBhkeGHjbuvbLS X-Received: by 2002:a9d:6945:0:b0:6b4:6955:453e with SMTP id p5-20020a9d6945000000b006b46955453emr6371597oto.25.1687210808215; Mon, 19 Jun 2023 14:40:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687210808; cv=none; d=google.com; s=arc-20160816; b=uBbIDtl9XgknfUs3NKD15I0rSZBxhXwr5NqWTZwdm+qtpvpJprXZbkuwJrX/CHFTne w2dvrx/+zNspft93CUZAt1vuJ2jRkYXA7Hj506xiWK+n7PgaAIhHmjMmR0911Ec2aL7y aJhfG2RF0raoHob6za+Gpc3YKbQzSdXmUXKA2Ol8KiNlLjiYQvJ4wqfAoicDmGCjowsr hVw83ulNTRoTeVVB2vR709tqciQ6Oy92GpVEDxCBKF/XCyPx6Wh179eTZGdhywOp73re eJq1PlcWfpIZGf2ZFYrKlufyHP77v6pfMYI7bygV3a78KloacSgVG7QPTbCzIkB73rGx Gjzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=0F/HmPYrX2+2YXjhicna2U9ZXZVghOWwV5+8A0s6ZuM=; b=K9jvJPbRkWIsmW/6xbLmG47PuFAyRbbGkubbKZ3Zm28IgYCe6j6tfXl29xmrmgrZoI 7k3uwvGJE/PuAzGnzm/uC5jciAxldC6UdjpemFAfCgif7gDfuIG9zbxzroeCtj61GBc/ 0n0j2FCwbDxPu94xeyFNbO9yKrY3PJFH1RQyj4T1x/gUvjeLu2LxhSzqlU6MJ6kzyXoJ mAWYi2lq81timKWx8gHfgpoPCsjyO91IMvCQga0GAWs24WW079ifXoNZTIkeDiZxauHK BQHsJQfz51sdE6A1GY8RKK5q1TYHpyK0TlYj+kNAFNt5rXgHeWF6VBJRDL1vWE4CJw1+ KoIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=oXWJFMrL; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r143-20020a632b95000000b0053fee209655si268525pgr.664.2023.06.19.14.39.53; Mon, 19 Jun 2023 14:40:08 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=oXWJFMrL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229538AbjFSV01 (ORCPT + 99 others); Mon, 19 Jun 2023 17:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbjFSV01 (ORCPT ); Mon, 19 Jun 2023 17:26:27 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90915E5 for ; Mon, 19 Jun 2023 14:26:25 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1b4fef08cfdso18826085ad.1 for ; Mon, 19 Jun 2023 14:26:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1687209985; x=1689801985; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=0F/HmPYrX2+2YXjhicna2U9ZXZVghOWwV5+8A0s6ZuM=; b=oXWJFMrLryRiRcluWQ0ExLJUaukON7mv7BNPPv/Xp426GKqT2t0kdEK8NR1TMrvMd1 Pdiw//+MthS3dl2hx07aMzM9qbrsXkjS5gniypxOlxjnaje9uV8YC5bRxYLmABgVDv0k /la8eBBD6jHW2nVJgcb1qxDxjfUPiHodRKYoCnxG/3SH9vl+Nc7L2zroggSi1qt8A5zy P6uKY5IQcRFRMI6sST8vyr4FZMlrjkKWabNYdVPIP4mCQ2fn+JB+bjIi6lx1feSJ1lqs x6yPK+WAe8/ia4B5ZDJg3/0TA5yoHsxRmA4cDswU/0GpKrJ2sQTXWM9InZeJOYw+N40A QF5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687209985; x=1689801985; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=0F/HmPYrX2+2YXjhicna2U9ZXZVghOWwV5+8A0s6ZuM=; b=OiygRFCeGEHlY3kzM6y+ZtbJLwCSU6vs8ySD6dJN9thBbl590eVj2pp6Fnqq31unze c21jFdmigFjdymVIkaJ8y+Xk+fxoBhnLWq5I6wR1J3l83zR+CZblgb19tddfEd1Z/a+6 68oVqQUHEaqny23nPMcklqH9/GkJtU0z3JCFXiHlMNseZ4KaReN37FQ8MXcKo1XqQ7W2 4YeCuagSzbpKJToMgz9h6VWToQb0JrbcABcQaOZ514CpRSZD/9x1czV0TEGaEGRjm6qT nW95q4fxkBk5BAgbNrEtv9MO9LciPNMwvm5I44WY1EG05TCXik/h/v7sXBXwrfOLXrsD T3RA== X-Gm-Message-State: AC+VfDwa3Sqk3eVsWum77hyPvcpKJ+0asynX9MaqKcxIRaqKFPs12MYh yWcumInQsVwokFco0cUDl7QzlKSc6oXWEkKN7ZE= X-Received: by 2002:a17:902:f688:b0:1b4:5699:aab8 with SMTP id l8-20020a170902f68800b001b45699aab8mr6984381plg.29.1687209984924; Mon, 19 Jun 2023 14:26:24 -0700 (PDT) Received: from localhost ([135.180.227.0]) by smtp.gmail.com with ESMTPSA id z8-20020a1709027e8800b001b5620c2c59sm266765pla.159.2023.06.19.14.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 14:26:24 -0700 (PDT) Date: Mon, 19 Jun 2023 14:26:24 -0700 (PDT) X-Google-Original-Date: Mon, 19 Jun 2023 14:26:19 PDT (-0700) Subject: Re: ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol 'misaligned_access_speed'; recompile with -fPIC In-Reply-To: CC: alexghiti@rivosinc.com, lkp@intel.com, llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: ndesaulniers@google.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Wed, 14 Jun 2023 09:40:28 PDT (-0700), ndesaulniers@google.com wrote: > On Tue, Jun 13, 2023 at 4:17 AM Alexandre Ghiti wrote: >> >> On Sun, Jun 11, 2023 at 2:11 AM kernel test robot wrote: >> > >> > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >> > head: 022ce8862dff83c859089cd14bc4dca0733e2f90 >> > commit: 8dc2a7e8027fbeca0c7df81d4c82e735a59b5741 riscv: Fix relocatable kernels with early alternatives using -fno-pie >> > date: 10 days ago >> > config: riscv-randconfig-r022-20230611 (https://download.01.org/0day-ci/archive/20230611/202306110855.7TlBCIzI-lkp@intel.com/config) >> > compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) >> > reproduce (this is a W=1 build): >> > mkdir -p ~/bin >> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross >> > chmod +x ~/bin/make.cross >> > # install riscv cross compiling tool for clang build >> > # apt-get install binutils-riscv64-linux-gnu >> > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8dc2a7e8027fbeca0c7df81d4c82e735a59b5741 >> > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git >> > git fetch --no-tags linus master >> > git checkout 8dc2a7e8027fbeca0c7df81d4c82e735a59b5741 >> > # save the config file >> > mkdir build_dir && cp config build_dir/.config >> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=riscv olddefconfig >> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash >> > >> > If you fix the issue in a separate patch/commit (i.e. not just a new version of >> > the same patch/commit), kindly add following tags >> > | Reported-by: kernel test robot >> > | Closes: https://lore.kernel.org/oe-kbuild-all/202306110855.7TlBCIzI-lkp@intel.com/ >> > >> > All errors (new ones prefixed by >>): >> > >> > >> ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol 'misaligned_access_speed'; recompile with -fPIC >> > >>> defined in vmlinux.a(arch/riscv/kernel/cpufeature.o) >> > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) >> > >>> arch/riscv/errata/thead/errata.o:(thead_feature_probe_func) in archive vmlinux.a >> > -- >> > >> ld.lld: error: relocation R_RISCV_LO12_I cannot be used against symbol 'misaligned_access_speed'; recompile with -fPIC >> > >>> defined in vmlinux.a(arch/riscv/kernel/cpufeature.o) >> > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) >> > >>> arch/riscv/errata/thead/errata.o:(thead_feature_probe_func) in archive vmlinux.a >> > -- >> > >> ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol 'riscv_cbom_block_size'; recompile with -fPIC >> > >>> defined in vmlinux.a(arch/riscv/mm/cacheflush.o) >> > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) >> > >>> arch/riscv/errata/thead/errata.o:(thead_errata_patch_func) in archive vmlinux.a >> > -- >> > >> ld.lld: error: relocation R_RISCV_LO12_S cannot be used against symbol 'riscv_cbom_block_size'; recompile with -fPIC >> > >>> defined in vmlinux.a(arch/riscv/mm/cacheflush.o) >> > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) >> > >>> arch/riscv/errata/thead/errata.o:(thead_errata_patch_func) in archive vmlinux.a >> > -- >> > >> ld.lld: error: relocation R_RISCV_HI20 cannot be used against symbol '__per_cpu_offset'; recompile with -fPIC >> > >>> defined in vmlinux.a(mm/percpu.o) >> > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) >> > >>> arch/riscv/errata/thead/errata.o:(thead_feature_probe_func) in archive vmlinux.a >> > -- >> > >> ld.lld: error: relocation R_RISCV_LO12_I cannot be used against symbol '__per_cpu_offset'; recompile with -fPIC >> > >>> defined in vmlinux.a(mm/percpu.o) >> > >>> referenced by errata.c:42 (arch/riscv/errata/thead/errata.c:42) >> > >>> arch/riscv/errata/thead/errata.o:(thead_feature_probe_func) in archive vmlinux.a >> > >> >> So I looked into those errors, the config is basically = RELOCATABLE + >> MEDLOW - EARLY_ALTERNATIVES. Then errata/thead is not compiled as > > Thanks for taking a look. Shouldn't CONFIG_RELOCATABLE be setting > -fPIC? If so, why is LLD complaining about -fPIC not being used? > > arch/riscv/Makefile sets -fPIE if CONFIG_RELOCATABLE == y. > > Is it possible that -fpie was dropped for these object files, or > -fno-pic or -fno-pie was added to the cflags for these object files > somehow? > > I've filed > https://github.com/ClangBuiltLinux/linux/issues/1872 > to track this. Using R_RISCV_{HI20,LO12_I,LO12_S} to refer to non-absolute symbols in a PIE shouldn't be allowed, it's not going to produce the right answer at runtime. We've got a lot of complicated bits in the build scripts so it's worth checking to make sure that `-fPIE` actually manifests in the link step. If it is and GNU LD isn't complaining then I think we've likely got a linker bug. >> medany, which makes sense since we only need this code to be medany >> when EARLY_ALTERNATIVES is enabled (because the code would be executed >> with mmu off, which is not the case here). >> >> I can fix those errors by adding the medany flag, but I'm not sure >> actually we want to do that since we do not need it and gcc does not >> complain: any idea? >> >> Alex >> >> >> >> > -- >> > 0-DAY CI Kernel Test Service >> > https://github.com/intel/lkp-tests/wiki >> > > > -- > Thanks, > ~Nick Desaulniers