Author: bz
Date: Fri Nov  2 14:15:52 2018
New Revision: 340054
URL: https://svnweb.freebsd.org/changeset/base/340054

Log:
  MFC r339931,r339933
  
    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.
  
  PR:           228854

Modified:
  stable/11/sys/kern/link_elf.c
  stable/11/sys/kern/link_elf_obj.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/link_elf.c
==============================================================================
--- stable/11/sys/kern/link_elf.c       Fri Nov  2 14:13:31 2018        
(r340053)
+++ stable/11/sys/kern/link_elf.c       Fri Nov  2 14:15:52 2018        
(r340054)
@@ -630,8 +630,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,
@@ -663,8 +667,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/11/sys/kern/link_elf_obj.c
==============================================================================
--- stable/11/sys/kern/link_elf_obj.c   Fri Nov  2 14:13:31 2018        
(r340053)
+++ stable/11/sys/kern/link_elf_obj.c   Fri Nov  2 14:15:52 2018        
(r340054)
@@ -366,6 +366,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;
                                }
@@ -380,6 +385,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;
                                }
@@ -840,14 +850,30 @@ 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 %#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 =
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to