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
This commit is contained in:
Bjoern A. Zeeb 2018-10-30 20:51:03 +00:00
parent c955c6cd08
commit 0f823b6497
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339931
2 changed files with 34 additions and 4 deletions

View file

@ -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,

View file

@ -368,6 +368,10 @@ link_elf_link_preload(linker_class_t cls, const char *filename,
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 *filename,
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 *filename,
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 =