Memory Detection for Linux

This memory detection code is now part of the baseline Linux kernels, so this page is obsolete unless you’re running a really old version of the kernel.

In days gone by, Linux would only detect up to 64mb of memory (because it only used the BIOS service int 15h, ah=088h. This didn’t use to be a problem, because no mortal could afford 64mb of memory, but that, um, changed. I was working on machines with more than 64mb fairly early on, so I was constantly patching memory sizes in. Eventually I snapped and started writing better a memory detection system for Linux (which eventually found its way into the baseline kernel.) I started putting patches into the McAfee WebShield kernels starting with Linux 1.2.13, and eventually got around to sending Linus a copy of a 2.1.x patch at around 2.1.23, with a fixed version at 2.1.46.

Unfortunately, I picked int 15h, ax=0e801h as the BIOS service to use, and the rest of the world decided to standardize on int 15h, ax=0x820h. So I had to go back to the shops and rework the patch to use that one.

This patch uses the BIOS services int 15h, ax=0e820h, int 15h, ax=0e801h, and int 15h, ah=088h to get the memory size. E820 is allegedly the memory detection scheme that Microsoft® Windows® uses to detect memory, so it should be pretty universal on modern BIOSes. E801 used to be pretty widely used, but it appears to be falling into disuse on modern BIOSes. 88 is ancient and clunky and not described very well, so vendors can return most anything they want (either 16mb or 64mb max) when the amount of memory gets too large.

Current patches

240t1ac7.diff
The 2.3.51 memory patch updated to kernel 2.4.0-test1-ac7.
2351.fancy.diff
The full-blown memory patch against kernel 2.3.51, though it works with every 2.3.x kernel up to around 2.3.99pre4 or so. It is a fairly heavy reworking of the memory patch because of suggestions from Linux Torvalds on how the patch might work better (not exactly in those words). In this patch, the whole world becomes memory regions, and on bioses that don’t support E820, or when the user specifies memory via the traditional mem=Xxx, memory regions are fabricated for the memory init routines to handle.
2214.fancy.diff
The same memory detect code, ported to 2.2.14
2028.diff
And ported to 2.0.28
new.new.mem-1.2.13
The most recent version of an older memory detection patch (which supports E820, but which does not support memory regions) for 1.2.13. Alas, time moves on and I no longer use 1.2.13 on very many systems, so it’s fairly likely this is the last patch I’ll do for this version of the Linux kernel.

Obsolete patches

mem.2315.patch

The full-blown memory patch against kernel 2.3.15; it is a fairly heavy reworking of the memory patch because of suggestions from Linux Torvalds on how the patch might work better (not exactly in those words). In this patch, the whole world becomes memory regions, and on bioses that don’t support E820, or when the user specifies memory via the traditional mem=Xxx, memory regions are fabricated for the memory init routines to handle.

And this patch has the vitally important side-effect of minimizing the additional assembly language needed by the kernel.

new.new.mem-1.2.13
The most recent version of an older memory detection patch (which supports E820, but which does not support memory regions) for 1.2.13. Alas, time moves on and I no longer use 1.2.13 on very many systems, so it’s fairly likely this is the last patch I’ll do for this version.
new.new.mem-2.0.28
The same patch as the 1.2.13 patch, but for the 2.0 kernel that ships with Mastodon Linux. A fancier patch exists for 2.0.x, but it’s not going to be published because I need to backport the 2.3.15 patch.
newmem.1213
The memory detection patch for Linux version 1.2.13. This patch does not get along very well with loadlin, but it’s perfectly happy with Lilo.
newmem.2030

A memory detection patch for Linux version 2.0.30. This is the second generation of my enhanced memory detection code, which will hopefully cooperate better with loadlin.

This patch is newmem.2027 and [newmem.2028-2] (newmem.2028-2) put together, and should also work against versions 2.0.27 through 2.0.29 (McAfee’s WebShield used this patch in its 2.0.28-based kernel.)

new.new.mem-2.2.1

The 2.2.1 version of the E820 patch.

It works on the single machine I’ve tested it on (though 2.2.1 broke enough interfaces so that nothing ELSE works on that machine with a 2.2.1 kernel in place) and I welcome feedback from other people who wish to test it.

fancy.new.2210
An experimental version of my E820 memory patch. This one properly handles memory holes, so it can be used on systems with memory-mapped accelerated video cards.
fancy.mem.2306
An earlier version of the above patch, for the early 2.3 series of kernel
mem.2313.patch
The kernel patch for 2.3.13