Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1170768ybt; Wed, 8 Jul 2020 23:58:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+FFyopEf3Hlrpk/+wfDW/Tkhv2AWtYG1SXj19Ah3YPHYkQqXrVY+gsIiTTI/hH8rH3DU6 X-Received: by 2002:a50:bc03:: with SMTP id j3mr72022431edh.234.1594277914871; Wed, 08 Jul 2020 23:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594277914; cv=none; d=google.com; s=arc-20160816; b=p9SJYfFfzjv4DYUbNShviFM7VPV1wlC1KB/I/QKvO3g5AJ/797sPMUzP4C9SfkGYcq kRKWAtngSSiswHXBk8y/yqFaoNJLCcUXrVGHImY5RDOI3F3GNCXPKBnCINmgn2nR4IXc uPz/NiWxeao3aLtxTA6/Vg7+ansxjMJghWakKq/fdYlrbmO1lRMKP+GOeDjyMdCUDSRo AH77qpygLJryde2O8dTN7E4CUyRjbIMZny9eYm7PyKarP2W98RgUXOkwGuQsSFKxPV65 /HuWp8uJRWKW/j55XdXeOvNQwMokBMsUG+vyBpAB/1lJAzuyJKufTpUwXMnPhTTBLa3o Davw== 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=oPwTUyZDWAuuBxgN36P+2nQm7huaH8y2Sa+Y48zUCjc=; b=muUWjEG2wdbGqpS+57JM3wqZd6L3PACjEOi9u+4OfbIyxBtpR9KenFPAeWNkOyev3x b8Dkt+ktY2dB4ch9XYNkHwbNzgoWYtcw3qhgJ1iPl1+U/V/FepCycdL2BNg1OZcmPPGz 1/z69l/9Gnl5PSaAxZJzbpxupvYpeIym3kKS4JgnEyRjOB+pC9J/oLyPdlwFFPzUbtWs Rulw6W4yEtsBVyGjzVf0rBeJcgQMMDlCzLF+gJN5TJoXbLAnVnP1toFt8961z5O5+86T Sc4ySg3rwNzu7l2/NHyLBXtrESvCIzAoJ3crhEMGm+qLkkasVHEa3jAxRiquy6BXJZpj Yk9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="0BJ/s2ur"; 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 do15si1732433ejc.430.2020.07.08.23.58.12; Wed, 08 Jul 2020 23:58:34 -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="0BJ/s2ur"; 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 S1726245AbgGIGzt (ORCPT + 99 others); Thu, 9 Jul 2020 02:55:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:53420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726006AbgGIGzs (ORCPT ); Thu, 9 Jul 2020 02:55:48 -0400 Received: from mail-ot1-f51.google.com (mail-ot1-f51.google.com [209.85.210.51]) (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 7ED172065D for ; Thu, 9 Jul 2020 06:55:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594277747; bh=0qnpvvOZ2ouMPWabm2r0fZNRG344s4R3ra9at+9Szr4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=0BJ/s2ur1C0tGBHUScgrUPTUDAedxmw1oV9wtOfbUB/oDtFRYPEGvBBjWBt41aSI7 niuJtyLcD4TPlc74Rr8vHUtgkSP7mNH1k7tSjrabgkUfat5SUVj1cfc8SKcM+wVnpk idhHXaWZuGfYv5yWJbyKVK6cMenGhMXovW+39H0Q= Received: by mail-ot1-f51.google.com with SMTP id e90so1003349ote.1 for ; Wed, 08 Jul 2020 23:55:47 -0700 (PDT) X-Gm-Message-State: AOAM533feXPQJ9kcUo6+3XLlNK+Fgf7+dkAL/lOw4xSSUc7HohdIvviJ ePbC664EpnDzJch8GAHJoiUnun/Pg2gHNjxQs/w= X-Received: by 2002:a9d:6e85:: with SMTP id a5mr11940861otr.90.1594277746780; Wed, 08 Jul 2020 23:55:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ard Biesheuvel Date: Thu, 9 Jul 2020 09:55:35 +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 Thu, 9 Jul 2020 at 09:50, =E5=BD=AD=E6=B5=A9(Richard) wrote: > > 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 m= odule_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/mo= dule-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, Elf= 64_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. > > > My understanding is that a module that calls functions that are not part = of the module will use PLT. > Plt_max_entries =3D0 May occur if a module does not depend on other modul= e functions. > A PLT slot is allocated for each b or bl instruction that refers to a symbol that lives in a different section, either of the same module (e.g., bl in .init calling into .text), of another module, or of the core kernel. I don't see how you end up with plt_max_entries in this case, though. Are you sure you have CONFIG_RANDOMIZE_BASE enabled? > >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? > I don=E2=80=99t think I have [large] modules. I'll trace which module ca= used this warning. Yes please.