Kernels > 1M

Riley Williams (rhw@MemAlpha.CX)
Sat, 7 Aug 1999 23:50:34 +0100 (GMT)


This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.

--1421910094-445988011-934063993=:24414
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.LNX.4.10.9908072314541.24414@ps.cus.umist.ac.uk>

Hi Peter.

I've now analysed the code, and the enclosed patch does a large part
of what is necessary for the kernel loaders to support kernels over
1023k in size, but it doesn't do all of it. I'd like your comments on
the patch so far, and also on what's left to do.

First, whilst the patch to build.c that you suggested will allow the
kernel to compile ok with `make bzImage`, the resulting kernel will be
unstable and most probably will not work at all.

The reason for this is that the current kernel loader uses the value
of a 16-bit unsigned int in the boot sector as the number of 16-byte
paragraphs of kernel source to load, thus only supporting kernels of
not more than 0xFFFF0 (1,048,560) bytes in size. Worse still, the
value stored in this word is the lower 16 bits of the calculated
value, so if the kernel was, say, 0x107630 (1,078,832) bytes ( in
size, the stored value would be 0x00763 paragraphs, or about 30k !!!

The first hunk of the enclosed patch defines a new 32-bit size field
using four of the previously unused bytes in the boot sector, and
defines this to store the actual kernel size, still measured in 16
byte paragraphs. This field can therefore handle kernels up to 64
Terabytes in size, and it should be a few days before we can produce
kernels that big 8-)))

The second hunk implements all the tweaks to build.c that are needed
for it to correctly fill in this field. As defined, it will record the
correct value in the old field for kernels that are small enough, and
will record 65,535 paragraphs in the old field for kernels that are
too large to be recorded therein.

Note that it IS safe to apply these two hunks to the current kernel,
as the ONLY result will be to actually define the extra field as
mentioned above, and to fill it in when compiling. The resulting
patched kernel will not actually use that field, and the current
1,023k limit will still apply.

The work still to be done is to the actual assembly code in the helper
routine in setup.S along with a small tweak to the code in bootsect.S
but I haven't yet had time to work that part of it out, and I would
definately appreciate your comments thereon. Here's my thoughts,
assuming the above patches have been applied:

1. I would start by applying the following patch to bootsect.S:

Q> @@ -273,8 +273,8 @@
Q> #else
Q> mov ax,es
Q> sub ax,#SYSSEG
Q> -#endif
Q> cmp ax,syssize ! have we loaded all yet?
Q> +#endif
Q> jbe ok1_read
Q> ret
Q> ok1_read:

This has the effect of changing the return value of the helper
function in setup.S such that instead of returning the amount
transferred in AX, it returns with the flags set according to
the results of the relevant comparison, and lets the helper
routine decide exactly how to do the comparison with the actual
kernel size.

To ensure that the rest of the outside routine still works, it
will return with AX holding the smaller of the total number of
paragraphs to go and 65535, ie, it will only hold a value smaller
than 65535 when there are less than 65535 paragraphs still to go.

2. Once this change is finished, the kernel will make absolutely no
use of the old size field, but will depend entirely on the new
size field. This will prevent any problems that might be caused
by code that tweaks the old size field for any reason.

Comments?

Best wishes from Riley.

+----------------------------------------------------------------------+
| There is something frustrating about the quality and speed of Linux |
| development, ie., the quality is too high and the speed is too high, |
| in other words, I can implement this XXXX feature, but I bet someone |
| else has already done so and is just about to release their patch. |
+----------------------------------------------------------------------+
* ftp://ftp.MemAlpha.cx/pub/rhw/Linux
* http://www.MemAlpha.cx/kernel.versions.html

--1421910094-445988011-934063993=:24414
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII; NAME="big-bz.diff"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.LNX.4.10.9908072313130.24414@ps.cus.umist.ac.uk>
Content-Description:
Content-Disposition: ATTACHMENT; FILENAME="big-bz.diff"

LS0tIGxpbnV4LTIuMi4xMC9hcmNoL2kzODYvYm9vdC9ib290c2VjdC5TfglX
ZWQgSnVuIDI0IDIyOjMwOjA4IDE5OTgNCisrKyBsaW51eC0yLjIuMTAvYXJj
aC9pMzg2L2Jvb3QvYm9vdHNlY3QuUwlTYXQgQXVnICA3IDIyOjMyOjAwIDE5
OTkNCkBAIC00NDQsOSArNDQ0LDEyIEBADQogbXNnMToNCiAJLmJ5dGUgMTMs
MTANCiAJLmFzY2lpICJMb2FkaW5nIg0KIA0KLS5vcmcgNDk3DQorLm9yZyA0
OTMNCitrZXJuZWxfc2l6ZToNCisJLndvcmQgMA0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cgaXMgT0sgKi8NCisJ
cmV0dXJuIDA7DQogfQ0K
--1421910094-445988011-934063993=:24414--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/