Author: bz
Date: Tue Oct 30 20:51:03 2018
New Revision: 339931
URL: https://svnweb.freebsd.org/changeset/base/339931

Log:
  As a follow-up to r339930 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
  MFC after:    3 days

Modified:
  head/sys/kern/link_elf.c
  head/sys/kern/link_elf_obj.c

Modified: head/sys/kern/link_elf.c
==============================================================================
--- head/sys/kern/link_elf.c    Tue Oct 30 20:45:15 2018        (r339930)
+++ head/sys/kern/link_elf.c    Tue Oct 30 20:51:03 2018        (r339931)
@@ -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: head/sys/kern/link_elf_obj.c
==============================================================================
--- head/sys/kern/link_elf_obj.c        Tue Oct 30 20:45:15 2018        
(r339930)
+++ head/sys/kern/link_elf_obj.c        Tue Oct 30 20:51:03 2018        
(r339931)
@@ -368,6 +368,10 @@ 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 %ld for "
+                                           "%s\n", __func__, shdr[i].sh_size,
+                                           filename);
                                        error = ENOSPC;
                                        goto out;
                                }
@@ -382,6 +386,10 @@ 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 %ld for "
+                                           "%s\n", __func__, shdr[i].sh_size,
+                                           filename);
                                        error = ENOSPC;
                                        goto out;
                                }
@@ -847,14 +855,28 @@ link_elf_load_file(linker_class_t cls, const char *fil
                        else
                                ef->progtab[pb].name = "<<NOBITS>>";
                        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 %ld for "
+                                           "%s\n", __func__, 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 %ld for "
+                                           "%s\n", __func__, shdr[i].sh_size,
+                                           filename);
+                               }
+                       }
 #endif
                        else
                                ef->progtab[pb].addr =
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to