Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2486951rdd; Fri, 12 Jan 2024 10:51:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPDzj5OvVhM0KjtLRAVoOs+MD4hzdHVepm0FIHqBLLp5f+pC+tCZsRH/BgCm5hfuxbIpPq X-Received: by 2002:a17:902:7d85:b0:1d5:8bce:3887 with SMTP id a5-20020a1709027d8500b001d58bce3887mr1379098plm.34.1705085498497; Fri, 12 Jan 2024 10:51:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705085498; cv=none; d=google.com; s=arc-20160816; b=MazbRAjp7KPd/Y3V0dkb7eMtuEwtqczQf74bUA5S0Kmd7Re7xhN9H1y8ULgVoJzTqf e7EW/PXvheJyqo8lO3NoGnCLcOV2mU0pcbH6w5Dgg3S8yVkUqhd16IEUrgdJT1XUM6yN TJ4ePLsx9imPGdSz4m5Tv8gKQeZQbaPKW9c7S7z5eujYEEEsdNbd6hLdyX/KEJt+dCq6 PKxuFUqAh/Z2R7cJkbzL8E4TNnVAoDPceS400QK70xc9cbLW9A+5qCI8p3LIrkAUrxXu DEl7WXxI8Yw9fDt2qn1cC5KWxwvXmBcUoqO3MQLat8PXnkKIP337JSglpErhOIdJbKjj 5NvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=fdK888rcSjL1sX83gJl4fL5zi1T/+pyqPXcMttJphw0=; fh=eSNJYClik7mYyzgfZBq7sf+7Bppf0bdqd0f7jOX7VDQ=; b=ZL/8kZ4aHpVonBcr4eVNnrcK+zVeG5U9jgG3v6W5hBHSmj+83I9/8VS6qxu4xfgXPu Jnbf7IKHAhYqsyQ/P7dQ/CHFZToiIkqCnwLdWzlG7I2iS36myXfykD2XMA8Jqv/WaL3o Kv2mpo4ZLKP5gAhki7cg8W7HwEUpIHhVPYa7o+eh2lNb/2bK1OhKqovP6XcPFFHP/yBr e9ptJE7VoYMQUK3pOWDzQXPFsaOr3JwvI2kThI/7sDP2Q+1if6tUAcirZPiZrBzdCDSb 7LZn2UmA2Z+0seZ7ka9LCsB21Zi7UkhJAdE/p9gvcoQWJE6L9gUq4r7I1Ty65jvvgKpX T6/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=akADFvt8; spf=pass (google.com: domain of linux-kernel+bounces-24983-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s13-20020a170902ea0d00b001d4f32b277dsi4097460plg.360.2024.01.12.10.51.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 10:51:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-24983-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=akADFvt8; spf=pass (google.com: domain of linux-kernel+bounces-24983-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-24983-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 11410285461 for ; Fri, 12 Jan 2024 18:51:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42D1E15AD0; Fri, 12 Jan 2024 18:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="akADFvt8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6BA34156CD; Fri, 12 Jan 2024 18:51:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F4CEC433C7; Fri, 12 Jan 2024 18:51:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705085490; bh=TTvtQ1O6bYOGyAq062N/HpL4Y1P60eFyaPwHfY+VEu4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=akADFvt8gXXY2XwsyOWh+FzLAlO16KTuPXmF51KI2OHRZyeGB2tApPR+VdwSk3djC emYrLUeRvqeeSUHEDxSrXwi3wLnd13XUWrsZt25/AmCpx1H/IujaxslJUiPCcjfRmu Fu6W7GIMa48md5m1/dJQG7filnocPXNlW4PLI6Ym/rgTkK3rwO2Mwn7JY6u1wdzJoa RfvUtJnrUDwZ59IedaB8AHpYjYZsRVunDJQXovH2De6WefcsUeBfw9Wz7fHqPeIVvr MeEvotyw9xtfp0O/NC3d9K9sQr928uyLG8Ort+lbY02RhT81JYgp8pZAgJR0abmRKg HdIAMC+fhP62w== Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-50e7ddd999bso7545088e87.1; Fri, 12 Jan 2024 10:51:30 -0800 (PST) X-Gm-Message-State: AOJu0YzxspiWLp1s+ONYhTJ4QMbUsA0eTsQbCQiI9mAdCehRuzNu85jf REU7ldTGHSk6Nr2bI1Zp5w22kaKBta01/h8Ovzw= X-Received: by 2002:a05:6512:21a8:b0:50e:76ca:52c6 with SMTP id c8-20020a05651221a800b0050e76ca52c6mr731172lft.52.1705085488444; Fri, 12 Jan 2024 10:51:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <42c63cb9-87d0-49db-9af8-95771b186684@siemens.com> In-Reply-To: <42c63cb9-87d0-49db-9af8-95771b186684@siemens.com> From: Ard Biesheuvel Date: Fri, 12 Jan 2024 19:51:16 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] riscv/efistub: Ensure GP-relative addressing is not used To: Jan Kiszka Cc: Palmer Dabbelt , linux-efi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Hi Jan, On Fri, 12 Jan 2024 at 19:37, Jan Kiszka wrote: > > From: Jan Kiszka > > The cflags for the RISC-V efistub were missing -mno-relax, thus were > under the risk that the compiler could use GP-relative addressing. That > happened for _edata with binutils-2.41 and kernel 6.1, causing the > relocation to fail due to an invalid kernel_size in handle_kernel_image. > It was not yet observed with newer versions, but that may just be luck. > > Signed-off-by: Jan Kiszka > --- > > Something like this should go to stable as well, but we will need > rebased patches. > > drivers/firmware/efi/libstub/Makefile | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile > index 06964a3c130f..d561d7de46a9 100644 > --- a/drivers/firmware/efi/libstub/Makefile > +++ b/drivers/firmware/efi/libstub/Makefile > @@ -28,7 +28,7 @@ cflags-$(CONFIG_ARM) += -DEFI_HAVE_STRLEN -DEFI_HAVE_STRNLEN \ > -DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \ > -DEFI_HAVE_STRCMP -fno-builtin -fpic \ > $(call cc-option,-mno-single-pic-base) > -cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE > +cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE -mno-relax Can we detect the presence of these references (via the relocation type)? We already do something similar for ordinary absolute references too. > cflags-$(CONFIG_LOONGARCH) += -fpie > > cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt > -- > 2.35.3