Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3635386pxb; Mon, 24 Jan 2022 14:04:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOe+FMssIcim+8ajsa4PXzG2S145KTzh0xo8hobm9Fjdj/kCHZSmd4LO9w/5SuiBAJYn7o X-Received: by 2002:a05:6a00:174f:b0:4c2:3cc8:d7c2 with SMTP id j15-20020a056a00174f00b004c23cc8d7c2mr15420892pfc.81.1643061853750; Mon, 24 Jan 2022 14:04:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061853; cv=none; d=google.com; s=arc-20160816; b=PTE5pIToDk8Mh2pOJan5xiGCEKZwZER7Fulw5F1rPEPgcpBqXD6j0xYmVNyvoS3aeT AvlwkkPMW82abG9RBYrsCzplXaixdCTfNXhwgjXfWfb8iJunBnFAYc389qQDxlJ1KlAR W3PcJf2kpRhd9662SGfpc8yb3WAXejndHnfmyI0E9JGEx2QOljMsUqvk56LZLz8nzrHG mCXU1fBKrjrhOPj/dbCV2sVwtqdspv2cE6gpKDMSneOBgM6u90N+/9mUOsnmm0diw5lA uJoi5FRE+gRAhIMwKXetnPhg/C6WzSuRnz7jL44LL8Gxpg2/BNFgNBeIILoD8IBMKQUM lt4w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iacLc3Mvd7IDv/G3fcU9wWeehxgW5cCUMS7KXvVFBjM=; b=CvWNAM3iUpi74yQtJFe2nO+bKVx+4eIIObk9C/Taa51wxQBU5blWgqxEOh4+y+wL2g GknmQySWliYkAGoir+MvInUXI7l8FJMIAxDYCyG3xjmSK9PDBg7+bxLnBjSn0N5UGzBr MEa0f1UqQ6zkNIUzGzcRZrZu7V9ychUamJdy6GVtoAtgDlPqkGBvpEdrHJyMaPS7x2m2 ndXETiDsEkSyAMUtSJbjvwohCiS97K8rsZiOpWmDOdKP3BfUxWsQo+TAj+Q6yjLYvmJG zQSQpX4RL0FOWkOetlJ1Hc+BZY+W2xNa445hMlnoDSVBzJ717aPoipe7PatcrOps7RIo yYSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nnFxNtC1; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w2si15204592pgm.464.2022.01.24.14.03.48; Mon, 24 Jan 2022 14:04:13 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=nnFxNtC1; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575316AbiAXVv0 (ORCPT + 99 others); Mon, 24 Jan 2022 16:51:26 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:39072 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346359AbiAXVQW (ORCPT ); Mon, 24 Jan 2022 16:16:22 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2757161469; Mon, 24 Jan 2022 21:16:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC54FC340E4; Mon, 24 Jan 2022 21:16:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058976; bh=uthVye0iwSuswlGwFuQRe9N7bDcMWWKiC6t7peSk9s0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nnFxNtC1kIUZa/GDiZQzsUTlVh3QRJGzEP5m8K5Oi8CvDHv03E/dOZefJDsns3yoS q1RAxssVZgMZH/tBX/ttyE2euODaFEwGytkHfL4XpBDv48Af/l5lQrsMIVw1AlsAQi 9LWC0GHRoTucc6QheYzN9dQU+5VKbQx+bK1dCOac= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Erhard Furtner , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.16 0463/1039] powerpc/modules: Dont WARN on first module allocation attempt Date: Mon, 24 Jan 2022 19:37:32 +0100 Message-Id: <20220124184140.843266216@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Leroy [ Upstream commit f1797e4de1146009c888bcf8b6bb6648d55394f1 ] module_alloc() first tries to allocate module text within 24 bits direct jump from kernel text, and tries a wider allocation if first one fails. When first allocation fails the following is observed in kernel logs: vmap allocation for size 2400256 failed: use vmalloc= to increase size systemd-udevd: vmalloc error: size 2395133, vm_struct allocation failed, mode:0xcc0(GFP_KERNEL), nodemask=(null) CPU: 0 PID: 127 Comm: systemd-udevd Tainted: G W 5.15.5-gentoo-PowerMacG4 #9 Call Trace: [e2a53a50] [c0ba0048] dump_stack_lvl+0x80/0xb0 (unreliable) [e2a53a70] [c0540128] warn_alloc+0x11c/0x2b4 [e2a53b50] [c0531be8] __vmalloc_node_range+0xd8/0x64c [e2a53c10] [c00338c0] module_alloc+0xa0/0xac [e2a53c40] [c027a368] load_module+0x2ae0/0x8148 [e2a53e30] [c027fc78] sys_finit_module+0xfc/0x130 [e2a53f30] [c0035098] ret_from_syscall+0x0/0x28 ... Add __GFP_NOWARN flag to first allocation so that no warning appears when it fails. Reported-by: Erhard Furtner Fixes: 2ec13df16704 ("powerpc/modules: Load modules closer to kernel text") Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/93c9b84d6ec76aaf7b4f03468e22433a6d308674.1638267035.git.christophe.leroy@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/module.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kernel/module.c b/arch/powerpc/kernel/module.c index ed04a3ba66fe8..40a583e9d3c70 100644 --- a/arch/powerpc/kernel/module.c +++ b/arch/powerpc/kernel/module.c @@ -90,16 +90,17 @@ int module_finalize(const Elf_Ehdr *hdr, } static __always_inline void * -__module_alloc(unsigned long size, unsigned long start, unsigned long end) +__module_alloc(unsigned long size, unsigned long start, unsigned long end, bool nowarn) { pgprot_t prot = strict_module_rwx_enabled() ? PAGE_KERNEL : PAGE_KERNEL_EXEC; + gfp_t gfp = GFP_KERNEL | (nowarn ? __GFP_NOWARN : 0); /* * Don't do huge page allocations for modules yet until more testing * is done. STRICT_MODULE_RWX may require extra work to support this * too. */ - return __vmalloc_node_range(size, 1, start, end, GFP_KERNEL, prot, + return __vmalloc_node_range(size, 1, start, end, gfp, prot, VM_FLUSH_RESET_PERMS | VM_NO_HUGE_VMAP, NUMA_NO_NODE, __builtin_return_address(0)); } @@ -114,13 +115,13 @@ void *module_alloc(unsigned long size) /* First try within 32M limit from _etext to avoid branch trampolines */ if (MODULES_VADDR < PAGE_OFFSET && MODULES_END > limit) - ptr = __module_alloc(size, limit, MODULES_END); + ptr = __module_alloc(size, limit, MODULES_END, true); if (!ptr) - ptr = __module_alloc(size, MODULES_VADDR, MODULES_END); + ptr = __module_alloc(size, MODULES_VADDR, MODULES_END, false); return ptr; #else - return __module_alloc(size, VMALLOC_START, VMALLOC_END); + return __module_alloc(size, VMALLOC_START, VMALLOC_END, false); #endif } -- 2.34.1