From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9C986CDB474 for ; Mon, 23 Oct 2023 09:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MasJuxErUXHTDqnYPkiX56pGAnCPxprAuH8mqALIf54=; b=Bm8V3x/CMX5xZe F7hr+XzYMwoPhVSJwhGkeuu6xK0e132yFOsZzuAQegnkQWYMqGoRu2Zhil6ymegUv5CVPxCKUTGbC 1s7TaWNvKHF7aIaiDEKxxKNspa9DDpvjYlbTpDYA6hXTeMZ6ECzxv3WwvauvGsD0e8Qe5Fl4XnyE8 1CPP9bqGjeQFdmsyhj9gO8g6vF5sN+pd/GT7QcCs96g8fqtYpBjx+CM700tM21PcJWnnHRdrLHjie GC6NqUre/kvMUr1KY6sm6VlicsspwBvu1UfkyUV58ktnyB9OKgsuDVooHj3Hh8uTx1YwZcpTDJjeY ImUhaKELLbxiqH/6atJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quqpj-006qNh-29; Mon, 23 Oct 2023 09:02:47 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1quqph-006qMh-0a for linux-arm-kernel@lists.infradead.org; Mon, 23 Oct 2023 09:02:46 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6C2812F4; Mon, 23 Oct 2023 02:03:22 -0700 (PDT) Received: from FVFF77S0Q05N (unknown [10.57.70.183]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F1B703F64C; Mon, 23 Oct 2023 02:02:39 -0700 (PDT) Date: Mon, 23 Oct 2023 10:02:37 +0100 From: Mark Rutland To: Arnd Bergmann Cc: Maria Yu , Catalin Marinas , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@quicinc.com, linux-arm-msm@vger.kernel.org, Ard Biesheuvel Subject: Re: [PATCH] arm64: module: PLT allowed even !RANDOM_BASE Message-ID: References: <20231023075714.21672-1-quic_aiquny@quicinc.com> <56c2d30b-2f25-4613-aab1-00fccbd2fa05@app.fastmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56c2d30b-2f25-4613-aab1-00fccbd2fa05@app.fastmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231023_020245_285726_38778C99 X-CRM114-Status: GOOD ( 25.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 23, 2023 at 10:08:33AM +0200, Arnd Bergmann wrote: > On Mon, Oct 23, 2023, at 09:57, Maria Yu wrote: > > Module PLT feature can be enabled even when RANDOM_BASE is disabled. > > Break BLT entry counts of relocation types will make module plt entry > > allocation fail and finally exec format error for even correct and plt > > allocation available modules. Has an actual problem been seen in practice, or was this found by looking at the code? > > > > Signed-off-by: Maria Yu > > Adding Ard Biesheuvel to Cc, as he added the check in commit > a257e02579e42 ("arm64/kernel: don't ban ADRP to work around > Cortex-A53 erratum #843419") I think that the actual mistake is in commit: 3e35d303ab7d22c4 ("arm64: module: rework module VA range selection") Prior to that commit, when CONFIG_RANDOMIZE_BASE=n all modules and code had to be within 128M of each other, and so there were no PLTs necessary for B/BL. After that commit we can have a 2G module range regardless of CONFIG_RANDOMIZE_BASE, and PLTs may be necessary for B/BL. We should have removed the check for !CONFIG_RANDOMIZE_BASE as part of that. > > arch/arm64/kernel/module-plts.c | 3 --- > > 1 file changed, 3 deletions(-) > > > > diff --git a/arch/arm64/kernel/module-plts.c > > b/arch/arm64/kernel/module-plts.c > > index bd69a4e7cd60..21a67d52d7a0 100644 > > --- a/arch/arm64/kernel/module-plts.c > > +++ b/arch/arm64/kernel/module-plts.c > > @@ -167,9 +167,6 @@ static unsigned int count_plts(Elf64_Sym *syms, > > Elf64_Rela *rela, int num, > > switch (ELF64_R_TYPE(rela[i].r_info)) { > > case R_AARCH64_JUMP26: > > case R_AARCH64_CALL26: > > - if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE)) > > - break; > > - > > /* > > * We only have to consider branch targets that resolve > > * to symbols that are defined in a different section. > > I see there are two such checks (in partition_branch_plt_relas() > and in count_plts()), can you explain in more detail how you > concluded that one of them is correct but the other one is not? I believe that the one in partition_branch_plt_relas() needs to go too; that's just a minor optimization for the case where there shouldn't be any PLTs for B/BL, and it no longer holds after the module VA range rework. That was introduced in commit: d4e0340919fb9190 ("arm64/module: Optimize module load time by optimizing PLT counting") Thanks, Mark. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel