Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Oct 2010 15:49:48 -0700
From:      mdf@FreeBSD.org
To:        freebsd-current@freebsd.org
Cc:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Subject:   kldload of compressed modules
Message-ID:  <AANLkTi=dfuU9zqbYjTUa0UepTk9GnHA7C-gR6HtUB9mF@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I'm trying to add support for kldload of compressed modules; they work
at boot time but not at runtime.

I'm having trouble uncompressing the module in the kernel to try
processing it.  The difficulty is several-fold:

1) gzip(1) doesn't seem to produce a compressed image that net/zlib.c
understands.  It gets hung up on the first byte, since it's not 0x8
indicating Z_DEFLATED.  I tried setting next_in to the input buffer +
2 since that is the Z_DEFLATED marker, but it dies one byte later with
the "incorrect header check" failure.

2) I was using inflate in kern/inflate.c wrong earlier (not skipping
the first 10 bytes + comment), but even so that code and the net/zlib
code aren't compatible, since they both define an inflate() function
that takes differing numbers of arguments, etc.  And link_elf.c
already can include net/zlib.h when DDB_CTF is set, so that would
conflict with sys/inflate.h.

It's likely that kern/inflate.c is what I want, since it's the code
the boot loader uses, but I'm annoyed that it's only available with
device gzip (I can change this, of course) and that it's incompatible
with what seems to be the somewhat standard compress/decompress code
in net/zlib.c.

All of this is on stable/7 at the moment, though if I had something
that worked I want to commit to CURRENT and MFC.

So, what's the basic problem?  Should net/zlib support this gzipped
file?  Should I have compressed with some other user-space utility?
Should I add a new link_elf_compress.c file to support compressed
images (and use sys/inflate.h instead of net/zlib.h) instead of trying
to add it to the existing link_elf_load_file() functions?

For reference, here's the beginning of the compressed module (on amd64):

# od -h mnvf.ko.gz | less
0000000      8b1f    0808    fd2a    4cbe    0300    6e6d    6676    6b2e
0000020      006f    7ded    740f    d554    f7b5    484d    f842    6613
0000040      0340    4401    182e    2820    0484    1208    3425    4ca3
0000060      d198    4409    0121    3a51    924c    1909    3249    6663
0000100      0426    1a2a    8c9a    9c65    e6c6    d6d9    fb5a    3cb4
0000120      5adb    9ffa    5fb6    0979    362d    4b58    6b42    a529
0000140      54a8    52ad    72ad    a0c7    c546    7f88    6f20    7def
0000160      99ce    73b9    4733    6b7d    7df5    adeb    7d6f    b8b3
0000200      7b9c    677e    7d9f    def6    9ce7    cf7d    9b9f    ef73
0000220      3ab6    52ca    5253    28c6    37fc    594a    a4a9    5840
0000240      8b30    4bc5    de39    79ff    f625    552b    0396    a95d
0000260      ad92    224c    74da    fe45    46fb    6265    28a8    fa66
0000300      f31f    c065    97b5    7be3    cd2b    6109    2641    97c3
0000320      2667    4be6    f9e5    6ff6    e862    4dfe    84e6    4d50
0000340      1251    9142    05dd    7d57    f912    c236    06b5    25ae
0000360      d570    b5c2    092a    b54d    9e21    d70b    7e22    628f
0000400      80cc    8eab    f3c7    bae1    df82    06df    6ad7    6cb8
0000420      2d70    6b86    5c1d    c397    45b5    abc7    7742    92bf
0000440      c287    65d4    34ba    be61    e15b    90da    4644    0f2b

Thanks,
matthew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=dfuU9zqbYjTUa0UepTk9GnHA7C-gR6HtUB9mF>