From owner-svn-src-all@freebsd.org Wed Oct 31 14:03:49 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5485E10DA152; Wed, 31 Oct 2018 14:03:49 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 09F4F76409; Wed, 31 Oct 2018 14:03:49 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C3BE357C7; Wed, 31 Oct 2018 14:03:48 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w9VE3mFn017575; Wed, 31 Oct 2018 14:03:48 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w9VE3m9S017572; Wed, 31 Oct 2018 14:03:48 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201810311403.w9VE3m9S017572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Wed, 31 Oct 2018 14:03:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r339953 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: bz X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 339953 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Oct 2018 14:03:49 -0000 Author: bz Date: Wed Oct 31 14:03:48 2018 New Revision: 339953 URL: https://svnweb.freebsd.org/changeset/base/339953 Log: MFC r339931,r339933: As a follow-up to r339930 (r339951 in stable/12) and various reports implement logging in case we fail during module load because the pcpu or vnet module sections are full. We did return a proper error but not leaving any indication to the user as to what the actual problem was. Even worse, on 12/13 currently we are seeing an unrelated error (ENOSYS instead of ENOSPC, which gets skipped over in kern_linker.c) to be printed which made problem diagnostics even harder. PR: 228854 Approved by: re (kib) Modified: stable/12/sys/kern/link_elf.c stable/12/sys/kern/link_elf_obj.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/link_elf.c ============================================================================== --- stable/12/sys/kern/link_elf.c Wed Oct 31 12:53:58 2018 (r339952) +++ stable/12/sys/kern/link_elf.c Wed Oct 31 14:03:48 2018 (r339953) @@ -637,8 +637,12 @@ parse_dpcpu(elf_file_t ef) * all per-cpu storage from that. */ ef->pcpu_base = (Elf_Addr)(uintptr_t)dpcpu_alloc(size); - if (ef->pcpu_base == 0) + if (ef->pcpu_base == 0) { + printf("%s: pcpu module space is out of space; " + "cannot allocate %d for %s\n", + __func__, size, ef->lf.pathname); return (ENOSPC); + } memcpy((void *)ef->pcpu_base, (void *)ef->pcpu_start, size); dpcpu_copy((void *)ef->pcpu_base, size); elf_set_add(&set_pcpu_list, ef->pcpu_start, ef->pcpu_stop, @@ -670,8 +674,12 @@ parse_vnet(elf_file_t ef) * all per-vnet storage from that. */ ef->vnet_base = (Elf_Addr)(uintptr_t)vnet_data_alloc(size); - if (ef->vnet_base == 0) + if (ef->vnet_base == 0) { + printf("%s: vnet module space is out of space; " + "cannot allocate %d for %s\n", + __func__, size, ef->lf.pathname); return (ENOSPC); + } memcpy((void *)ef->vnet_base, (void *)ef->vnet_start, size); vnet_data_copy((void *)ef->vnet_base, size); elf_set_add(&set_vnet_list, ef->vnet_start, ef->vnet_stop, Modified: stable/12/sys/kern/link_elf_obj.c ============================================================================== --- stable/12/sys/kern/link_elf_obj.c Wed Oct 31 12:53:58 2018 (r339952) +++ stable/12/sys/kern/link_elf_obj.c Wed Oct 31 14:03:48 2018 (r339953) @@ -368,6 +368,11 @@ link_elf_link_preload(linker_class_t cls, const char * dpcpu = dpcpu_alloc(shdr[i].sh_size); if (dpcpu == NULL) { + printf("%s: pcpu module space is out " + "of space; cannot allocate %#jx " + "for %s\n", __func__, + (uintmax_t)shdr[i].sh_size, + filename); error = ENOSPC; goto out; } @@ -382,6 +387,11 @@ link_elf_link_preload(linker_class_t cls, const char * vnet_data = vnet_data_alloc(shdr[i].sh_size); if (vnet_data == NULL) { + printf("%s: vnet module space is out " + "of space; cannot allocate %#jx " + "for %s\n", __func__, + (uintmax_t)shdr[i].sh_size, + filename); error = ENOSPC; goto out; } @@ -847,14 +857,30 @@ link_elf_load_file(linker_class_t cls, const char *fil else ef->progtab[pb].name = "<>"; if (ef->progtab[pb].name != NULL && - !strcmp(ef->progtab[pb].name, DPCPU_SETNAME)) + !strcmp(ef->progtab[pb].name, DPCPU_SETNAME)) { ef->progtab[pb].addr = dpcpu_alloc(shdr[i].sh_size); + if (ef->progtab[pb].addr == NULL) { + printf("%s: pcpu module space is out " + "of space; cannot allocate %#jx " + "for %s\n", __func__, + (uintmax_t)shdr[i].sh_size, + filename); + } + } #ifdef VIMAGE else if (ef->progtab[pb].name != NULL && - !strcmp(ef->progtab[pb].name, VNET_SETNAME)) + !strcmp(ef->progtab[pb].name, VNET_SETNAME)) { ef->progtab[pb].addr = vnet_data_alloc(shdr[i].sh_size); + if (ef->progtab[pb].addr == NULL) { + printf("%s: vnet module space is out " + "of space; cannot allocate %#jx " + "for %s\n", __func__, + (uintmax_t)shdr[i].sh_size, + filename); + } + } #endif else ef->progtab[pb].addr =