Re: r286727 breaks geom_md.ko loading

2015-09-16 Thread Gleb Smirnoff
On Wed, Sep 16, 2015 at 08:10:05AM +0300, Konstantin Belousov wrote:
K> >   There is regression after r286727. Our dynamic kernel linker doesn't
K> > support weak symbols, so the geom_md.ko can no longer be loaded dynamically
K> > neither from loader nor at runtime. Having it statically in kernel is
K> > the only working option.
K> 
K> Perhaps, something could be fixed in the dynamic linker ?
K> 
K> I checked both i386 and amd64, and on both arches I can load geom_md.ko.
K> On the other hand, I do not use preloaded mfs images.  Can you explain
K> how to reproduce the issue, and what linker is affected ?  Note that we
K> have two kernel dynamic linkers, one is used on amd64 and mips, second one
K> is for all other architectures.

To reproduce you need just a vanilla head, a kernel that doesn't have
'device md' in it, and run kldload geom_md.ko. Does that work for you?

-- 
Totus tuus, Glebius.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r286727 breaks geom_md.ko loading

2015-09-16 Thread Konstantin Belousov
On Wed, Sep 16, 2015 at 04:15:15PM +0300, Gleb Smirnoff wrote:
> On Wed, Sep 16, 2015 at 08:10:05AM +0300, Konstantin Belousov wrote:
> K> >   There is regression after r286727. Our dynamic kernel linker doesn't
> K> > support weak symbols, so the geom_md.ko can no longer be loaded 
> dynamically
> K> > neither from loader nor at runtime. Having it statically in kernel is
> K> > the only working option.
> K> 
> K> Perhaps, something could be fixed in the dynamic linker ?
> K> 
> K> I checked both i386 and amd64, and on both arches I can load geom_md.ko.
> K> On the other hand, I do not use preloaded mfs images.  Can you explain
> K> how to reproduce the issue, and what linker is affected ?  Note that we
> K> have two kernel dynamic linkers, one is used on amd64 and mips, second one
> K> is for all other architectures.
> 
> To reproduce you need just a vanilla head, a kernel that doesn't have
> 'device md' in it, and run kldload geom_md.ko. Does that work for you?

Yes, it does, both on amd64 and i386.  You did not said which architecture
exposes your problem.  Post your kernel config.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r286727 breaks geom_md.ko loading

2015-09-16 Thread Gleb Smirnoff
On Wed, Sep 16, 2015 at 04:42:49PM +0300, Konstantin Belousov wrote:
K> On Wed, Sep 16, 2015 at 04:15:15PM +0300, Gleb Smirnoff wrote:
K> > On Wed, Sep 16, 2015 at 08:10:05AM +0300, Konstantin Belousov wrote:
K> > K> >   There is regression after r286727. Our dynamic kernel linker doesn't
K> > K> > support weak symbols, so the geom_md.ko can no longer be loaded 
dynamically
K> > K> > neither from loader nor at runtime. Having it statically in kernel is
K> > K> > the only working option.
K> > K> 
K> > K> Perhaps, something could be fixed in the dynamic linker ?
K> > K> 
K> > K> I checked both i386 and amd64, and on both arches I can load geom_md.ko.
K> > K> On the other hand, I do not use preloaded mfs images.  Can you explain
K> > K> how to reproduce the issue, and what linker is affected ?  Note that we
K> > K> have two kernel dynamic linkers, one is used on amd64 and mips, second 
one
K> > K> is for all other architectures.
K> > 
K> > To reproduce you need just a vanilla head, a kernel that doesn't have
K> > 'device md' in it, and run kldload geom_md.ko. Does that work for you?
K> 
K> Yes, it does, both on amd64 and i386.  You did not said which architecture
K> exposes your problem.  Post your kernel config.

It is amd64. Here is config.

-- 
Totus tuus, Glebius.
cpu HAMMER
ident   THINKPAD_X1

makeoptions DEBUG=-g
makeoptions WITH_CTF=1

options SCHED_ULE   # ULE scheduler
options PREEMPTION  # Enable kernel thread preemption
options INET# InterNETworking
options INET6   # IPv6 communications protocols
options SCTP# Stream Control Transmission Protocol
options FFS # Berkeley Fast Filesystem
options SOFTUPDATES # Enable FFS soft updates support
options UFS_ACL # Support for access control lists
options UFS_DIRHASH # Improve performance on big directories
options UFS_GJOURNAL# Enable gjournal-based UFS journaling
options MD_ROOT # MD is a potential root device
options NFSCL   # New Network Filesystem Client
options NFSD# New Network Filesystem Server
options NFSLOCKD# Network Lock Manager
options NFS_ROOT# NFS usable as /, requires NFSCL
options MSDOSFS # MSDOS Filesystem
options CD9660  # ISO 9660 Filesystem
options PROCFS  # Process filesystem (requires PSEUDOFS)
options PSEUDOFS# Pseudo-filesystem framework
options GEOM_PART_GPT   # GUID Partition Tables.
options GEOM_LABEL  # Provides labelization
options COMPAT_FREEBSD32# Compatible with i386 binaries
options SCSI_DELAY=5000 # Delay (in ms) before probing SCSI
options KTRACE  # ktrace(1) support
options STACK   # stack(9) support
options SYSVSHM # SYSV-style shared memory
options SYSVMSG # SYSV-style message queues
options SYSVSEM # SYSV-style semaphores
options _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time 
extensions
options PRINTF_BUFR_SIZE=128# Prevent printf output being 
interspersed.
options KBD_INSTALL_CDEV# install a CDEV entry in /dev
options HWPMC_HOOKS # Necessary kernel hooks for hwpmc(4)
options KDTRACE_FRAME   # Ensure frames are compiled in
options KDTRACE_HOOKS   # Kernel DTrace hooks
options DDB_CTF
options INCLUDE_CONFIG_FILE # Include this file in kernel

options KDB # Enable kernel debugger support.
options DDB # Support DDB.
options GDB # Support remote GDB.

# Make an SMP-capable kernel by default
options SMP # Symmetric MultiProcessor Kernel

# CPU frequency control
device  cpufreq

# Bus support.
device  acpi
options ACPI_DMAR
device  pci

# ATA controllers
device  ahci# AHCI-compatible SATA controllers
device  ata # Legacy ATA/SATA controllers
options ATA_STATIC_ID   # Static device numbering

# ATA/SCSI peripherals
device  scbus   # SCSI bus (required for ATA/SCSI)
device  da  # Direct Access (disks)
device  cd  # CD
device  pass# Passthrough device (direct ATA/SCSI access)

# atkbdc0 controls both the keyboard and the PS/2 mouse
device  atkbdc  # AT keyboard controller
device  atkbd   # AT keyboard
device  psm # PS/2 mouse
device  

Re: r286727 breaks geom_md.ko loading

2015-09-16 Thread Konstantin Belousov
On Wed, Sep 16, 2015 at 04:50:03PM +0300, Gleb Smirnoff wrote:
> On Wed, Sep 16, 2015 at 04:42:49PM +0300, Konstantin Belousov wrote:
> K> On Wed, Sep 16, 2015 at 04:15:15PM +0300, Gleb Smirnoff wrote:
> K> > On Wed, Sep 16, 2015 at 08:10:05AM +0300, Konstantin Belousov wrote:
> K> > K> >   There is regression after r286727. Our dynamic kernel linker 
> doesn't
> K> > K> > support weak symbols, so the geom_md.ko can no longer be loaded 
> dynamically
> K> > K> > neither from loader nor at runtime. Having it statically in kernel 
> is
> K> > K> > the only working option.
> K> > K> 
> K> > K> Perhaps, something could be fixed in the dynamic linker ?
> K> > K> 
> K> > K> I checked both i386 and amd64, and on both arches I can load 
> geom_md.ko.
> K> > K> On the other hand, I do not use preloaded mfs images.  Can you explain
> K> > K> how to reproduce the issue, and what linker is affected ?  Note that 
> we
> K> > K> have two kernel dynamic linkers, one is used on amd64 and mips, 
> second one
> K> > K> is for all other architectures.
> K> > 
> K> > To reproduce you need just a vanilla head, a kernel that doesn't have
> K> > 'device md' in it, and run kldload geom_md.ko. Does that work for you?
> K> 
> K> Yes, it does, both on amd64 and i386.  You did not said which architecture
> K> exposes your problem.  Post your kernel config.
> 
> It is amd64. Here is config.

> options   MD_ROOT # MD is a potential root device
It is MD_ROOT which is problematic, it seems.  I will take a look into
linker.

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r286727 breaks geom_md.ko loading

2015-09-16 Thread Gleb Smirnoff
On Wed, Sep 16, 2015 at 04:57:39PM +0300, Konstantin Belousov wrote:
K> On Wed, Sep 16, 2015 at 04:50:03PM +0300, Gleb Smirnoff wrote:
K> > On Wed, Sep 16, 2015 at 04:42:49PM +0300, Konstantin Belousov wrote:
K> > K> On Wed, Sep 16, 2015 at 04:15:15PM +0300, Gleb Smirnoff wrote:
K> > K> > On Wed, Sep 16, 2015 at 08:10:05AM +0300, Konstantin Belousov wrote:
K> > K> > K> >   There is regression after r286727. Our dynamic kernel linker 
doesn't
K> > K> > K> > support weak symbols, so the geom_md.ko can no longer be loaded 
dynamically
K> > K> > K> > neither from loader nor at runtime. Having it statically in 
kernel is
K> > K> > K> > the only working option.
K> > K> > K> 
K> > K> > K> Perhaps, something could be fixed in the dynamic linker ?
K> > K> > K> 
K> > K> > K> I checked both i386 and amd64, and on both arches I can load 
geom_md.ko.
K> > K> > K> On the other hand, I do not use preloaded mfs images.  Can you 
explain
K> > K> > K> how to reproduce the issue, and what linker is affected ?  Note 
that we
K> > K> > K> have two kernel dynamic linkers, one is used on amd64 and mips, 
second one
K> > K> > K> is for all other architectures.
K> > K> > 
K> > K> > To reproduce you need just a vanilla head, a kernel that doesn't have
K> > K> > 'device md' in it, and run kldload geom_md.ko. Does that work for you?
K> > K> 
K> > K> Yes, it does, both on amd64 and i386.  You did not said which 
architecture
K> > K> exposes your problem.  Post your kernel config.
K> > 
K> > It is amd64. Here is config.
K> 
K> > optionsMD_ROOT # MD is a potential root device
K> It is MD_ROOT which is problematic, it seems.  I will take a look into
K> linker.

Yes, sorry for not being verbose enough. Kernel must not have 'device md'
and must have 'options MD_ROOT'.

-- 
Totus tuus, Glebius.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r286727 breaks geom_md.ko loading

2015-09-16 Thread Konstantin Belousov
On Wed, Sep 16, 2015 at 05:04:11PM +0300, Gleb Smirnoff wrote:
> Yes, sorry for not being verbose enough. Kernel must not have 'device md'
> and must have 'options MD_ROOT'.

The following worked for me on i386 and amd64.  Unless some objections are
raised against the approach, I will do the pass over other architectures
later.

diff --git a/sys/amd64/amd64/elf_machdep.c b/sys/amd64/amd64/elf_machdep.c
index d1cffd9..d961f09 100644
--- a/sys/amd64/amd64/elf_machdep.c
+++ b/sys/amd64/amd64/elf_machdep.c
@@ -168,6 +168,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
Elf_Size rtype, symidx;
const Elf_Rel *rel;
const Elf_Rela *rela;
+   int error;
 
switch (type) {
case ELF_RELOC_REL:
@@ -203,29 +204,29 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
break;
 
case R_X86_64_64:   /* S + A */
-   addr = lookup(lf, symidx, 1);
+   error = lookup(lf, symidx, 1, );
val = addr + addend;
-   if (addr == 0)
+   if (error != 0)
return -1;
if (*where != val)
*where = val;
break;
 
case R_X86_64_PC32: /* S + A - P */
-   addr = lookup(lf, symidx, 1);
+   error = lookup(lf, symidx, 1, );
where32 = (Elf32_Addr *)where;
val32 = (Elf32_Addr)(addr + addend - (Elf_Addr)where);
-   if (addr == 0)
+   if (error != 0)
return -1;
if (*where32 != val32)
*where32 = val32;
break;
 
case R_X86_64_32S:  /* S + A sign extend */
-   addr = lookup(lf, symidx, 1);
+   error = lookup(lf, symidx, 1, );
val32 = (Elf32_Addr)(addr + addend);
where32 = (Elf32_Addr *)where;
-   if (addr == 0)
+   if (error != 0)
return -1;
if (*where32 != val32)
*where32 = val32;
@@ -242,8 +243,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
 
case R_X86_64_GLOB_DAT: /* S */
case R_X86_64_JMP_SLOT: /* XXX need addend + offset */
-   addr = lookup(lf, symidx, 1);
-   if (addr == 0)
+   error = lookup(lf, symidx, 1, );
+   if (error != 0)
return -1;
if (*where != addr)
*where = addr;
diff --git a/sys/i386/i386/elf_machdep.c b/sys/i386/i386/elf_machdep.c
index 03ab10f..81d6e35 100644
--- a/sys/i386/i386/elf_machdep.c
+++ b/sys/i386/i386/elf_machdep.c
@@ -178,6 +178,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
Elf_Word rtype, symidx;
const Elf_Rel *rel;
const Elf_Rela *rela;
+   int error;
 
switch (type) {
case ELF_RELOC_REL:
@@ -213,8 +214,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
break;
 
case R_386_32:  /* S + A */
-   addr = lookup(lf, symidx, 1);
-   if (addr == 0)
+   error = lookup(lf, symidx, 1, );
+   if (error != 0)
return -1;
addr += addend;
if (*where != addr)
@@ -222,8 +223,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
break;
 
case R_386_PC32:/* S + A - P */
-   addr = lookup(lf, symidx, 1);
-   if (addr == 0)
+   error = lookup(lf, symidx, 1, );
+   if (error != 0)
return -1;
addr += addend - (Elf_Addr)where;
if (*where != addr)
@@ -240,8 +241,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, 
const void *data,
break;
 
case R_386_GLOB_DAT:/* S */
-   addr = lookup(lf, symidx, 1);
-   if (addr == 0)
+   error = lookup(lf, symidx, 1, );
+   if (error != 0)
return -1;
if (*where != addr)
*where = addr;
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index 3b741cc..c931ae9 100644
--- 

Re: r286727 breaks geom_md.ko loading

2015-09-15 Thread Konstantin Belousov
On Wed, Sep 16, 2015 at 03:00:19AM +0300, Gleb Smirnoff wrote:
>   Hi!
> 
>   There is regression after r286727. Our dynamic kernel linker doesn't
> support weak symbols, so the geom_md.ko can no longer be loaded dynamically
> neither from loader nor at runtime. Having it statically in kernel is
> the only working option.

Perhaps, something could be fixed in the dynamic linker ?

I checked both i386 and amd64, and on both arches I can load geom_md.ko.
On the other hand, I do not use preloaded mfs images.  Can you explain
how to reproduce the issue, and what linker is affected ?  Note that we
have two kernel dynamic linkers, one is used on amd64 and mips, second one
is for all other architectures.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


r286727 breaks geom_md.ko loading

2015-09-15 Thread Gleb Smirnoff
  Hi!

  There is regression after r286727. Our dynamic kernel linker doesn't
support weak symbols, so the geom_md.ko can no longer be loaded dynamically
neither from loader nor at runtime. Having it statically in kernel is
the only working option.

-- 
Totus tuus, Glebius.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: r286727 breaks geom_md.ko loading

2015-09-15 Thread Steve Kiernan
On Wed, 16 Sep 2015 03:00:19 +0300
Gleb Smirnoff  wrote:

>   Hi!
> 
>   There is regression after r286727. Our dynamic kernel linker doesn't
> support weak symbols, so the geom_md.ko can no longer be loaded dynamically
> neither from loader nor at runtime. Having it statically in kernel is
> the only working option.

The question in that case would be does it make sense to allow MD_ROOT when
building md as a kernel module?

-Steve
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"