Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp507767ybt; Wed, 8 Jul 2020 05:22:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcgVueKMmNWtwuDr15d2jHj531yfRvg5tUnQJXp7rl3/kLJLiS8Qjsen6rPuADWJsO1uV4 X-Received: by 2002:a05:6402:b84:: with SMTP id cf4mr41304584edb.21.1594210928744; Wed, 08 Jul 2020 05:22:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594210928; cv=none; d=google.com; s=arc-20160816; b=vsMoxEWeP90z+lvsmaLuopgpVduYA//wu/WrgFeQ0ekzrwkXBxDLDKdrtr0ZlwGkfW 78e/yn/OKWtZo85HzFVK9tLTst0DLGTg+fG9AhVzlyiUPmQAlSuJk3k5H3ab0B+hKbhV vjyrt/cu/0VZFjPb9K7l69ByYMgjFkwp9BritiGUfpOfDoUEVUXqpPfIC20yFgx8GI2J eMgvV/4xA4axUpzbum07dwCPnjjuYo4KQz+CUb8STAfU2SeiiVyXeEEbwgiTU/8buC+8 8wfqdIEDrgp316+7VMClOoQI/X9Pm+lbJWu+wAe/r2q6XDznoGGW2kLl9Xb5hzHsIkyp CKeA== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=pfwWfl8GxFTIW8SHiowZwRaPT+2jnP1mQalm1z9zESQ=; b=wysHDSZT4tsbv8WAuui9fvwA6/4n1RmQsvAmBNiPa6aal2TXPG/+dw4MhI14+3eqyd RS9tsxGGtAekxztyiHncOLRYPJG48LOpIBIKa7IbDsfBOzBwAKVM4yyCNiuoW0Asiq4N yaHnrZejLLd8xoWW0hsH7PhVxhX+tCvFooJ2YGBNh5cWy7S4CbtsgyShQSgm26p7vhY4 uB+M2/yqd2lrcw7kZ7qOuogB7UdbBqycSN38cQx4swDxcnqi0uTkRl7+vJPoXAdwllDQ fUvGkAhemu3lR8ArvnPXt67qfsfJtyC5kDPntZrFTLVG4ist4LvSKMtlUWFeqmpQv5CU SLcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ouHC65Qf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g15si16635135edm.229.2020.07.08.05.21.45; Wed, 08 Jul 2020 05:22:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ouHC65Qf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728960AbgGHMUL (ORCPT + 99 others); Wed, 8 Jul 2020 08:20:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:38408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728640AbgGHMUK (ORCPT ); Wed, 8 Jul 2020 08:20:10 -0400 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1945A20739 for ; Wed, 8 Jul 2020 12:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594210810; bh=HHc2Ezng0IQrmBx/mRY0UyImVZU/ECrgQzrZ0kvkusw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ouHC65Qf6oGeZDFUQaogvKORY/uhSXljwcU/VdOvJIa4O0lqgUIZG9Xx47EpHDGGM B6YA7iYs6UVA1fYnVozB4LVF+1udfQzxKwoTj7bs5FubrM1f6zaj8lY1W6TiOcRjH1 XaywCic+p1Ev/kEbcZz+CSaYVFKyYPgIoD0GHiys= Received: by mail-oi1-f176.google.com with SMTP id l63so36197862oih.13 for ; Wed, 08 Jul 2020 05:20:10 -0700 (PDT) X-Gm-Message-State: AOAM533RxVf5+C1mLeqgDiDZNbW296kYlLeDFDzgzlHJujrZpqfDAFdN RZCd4Y2gABencDOslzjjt6t/xqPqNiB2w7mpiQY= X-Received: by 2002:aca:f257:: with SMTP id q84mr7167150oih.174.1594210809486; Wed, 08 Jul 2020 05:20:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Wed, 8 Jul 2020 15:19:58 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64/module-plts: Consider the special case where plt_max_entries is 0 To: =?UTF-8?B?5b2t5rWpKFJpY2hhcmQp?= Cc: Will Deacon , "catalin.marinas@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 8 Jul 2020 at 13:03, =E5=BD=AD=E6=B5=A9(Richard) wrote: > > > On Tue, Jul 07, 2020 at 07:46:08AM -0400, Peng Hao wrote: > >> If plt_max_entries is 0, a warning is triggered. > >> WARNING: CPU: 200 PID: 3000 at arch/arm64/kernel/module-plts.c:97 modu= le_emit_plt_entry+0xa4/0x150 > > > > Which kernel are you seeing this with? There is a PLT-related change in > > for-next/core, and I'd like to rule if out if possible. > > > 5.6.0-rc3+ > >> Signed-off-by: Peng Hao > >> --- > >> arch/arm64/kernel/module-plts.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/modul= e-plts.c > >> index 65b08a74aec6..1868c9ac13f2 100644 > >> --- a/arch/arm64/kernel/module-plts.c > >> +++ b/arch/arm64/kernel/module-plts.c > >> @@ -79,7 +79,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_= Shdr *sechdrs, > >> int i =3D pltsec->plt_num_entries; > >> int j =3D i - 1; > >> u64 val =3D sym->st_value + rela->r_addend; > >> - > >> + if (pltsec->plt_max_entries =3D=3D 0) > >> + return 0; > > > >Hmm, but if there aren't any PLTs then how do we end up here? > > > We also returned 0 when warning was triggered. That doesn't really answer the question. Apparently, you are hitting a R_AARCH64_JUMP26 or R_AARCH64_CALL26 relocation that operates on a b or bl instruction that is more than 128 megabytes away from its target. In module_frob_arch_sections(), we count all such relocations that point to other sections, and allocate a PLT slot for each (and update plt_max_entries) accordingly. So this means that the relocation in question was disregarded, and this could happen for only two reasons: - the branch instruction and its target are both in the same section, in which case this section is *really* large, - CONFIG_RANDOMIZE_BASE is disabled, but you are still ending up in a situation where the modules are really far away from the core kernel or from other modules. Do you have a lot of [large] modules loaded when this happens?