This is in the context of current 64-bit processors and current linux kernels (I'm using 4.6.4.)

Is it possible for me to write a program that during boot can examine base memory, 640k and under, without it being a kernel module?

I'm trying to remote boot a volume over an InfiniBand network using the InfiniBand protocol SRP. It's a lot like iSCSI booting, but it seems like there's nothing public to actually do this.

I'm using iPXE (network boot firmware.) It's able to connect using the SRP protocol to the remote volume, and successfully load the kernel and initramfs. But, when execution is passed over to the kernel, the kernel hasn't connected to the remote volume, so it doesn't know anything about it or see it.

iPXE leaves the information about who to connect to and how in base (< 640k) memory in a structure called a sBFT, which is a type of ACPI table.

iSCSI does something very similar, with the boot loader leaving that information in an ACPI table, called an iBFT, but there's a kernel module iscsi_ibft which gives a sysfs interface to the iBFT structure. I don't see an equivalent yet for an InfiniBand sBFT, such as an ib_sbft kernel module.

So, I'm wondering if I want this to work, if someone (maybe me) needs to write the non-existant ib_sbft kernel module.

Or, is there a way for me to have a program be able to access base (< 640k) memory without a memory violation, and before it's (presumably) overwritten by something else?

I'm using Arch Linux, which uses mkinitcpio to make the initial ramdisk and run programs during the early boot process, but I'm thinking by that point it's already too late and running in protected mode. (Unless it's changed, real mode runs in 16-bit, and I'm not seeing anything about initial ramdisk programs needing to be compiled in 16-bit, leading me to believe it's too late.)

  • You can always take a look in /sys/firmware/acpi/tables/both sBFT and iBFT should be available via the ACPIinterface, and that is what the iscsi_ibft module is using (but via kernel calls to the ACPI module, but the same data is available via sysfs as mentioned above) – NiKiZe Dec 27 '17 at 19:54

The initramfs filesystem is, to all intents and purposes, just another filesystem that's loaded at /, and programs that run in it are run from user space under the running kernel. This means they have the same limitations as any other program.

You might find the data you want via /dev/mem but you probably shouldn't rely on specific iPXE implementations; different vendors and different PXEboot processes could easily change things.

Typically the information you should be passed as part of the kernel calling command and so made visible in /proc/cmdline where userspace programs can parse it and do whatever is necessary.

| improve this answer | |

Programs run from the initramfs are perfectly ordinary programs. They run like any other Linux process.

Switching from real mode (the boot-time legacy mode of 32-bit x86 processors) to protected mode (the normal working mode of 32-bit x86 processors since the 286 generation) happens very early in the Linux kernel boot process. Even drivers have not started at that point.

If your peripheral stores something at a particular physical address then you can access it through the device /dev/mem. You'll need to tell the kernel not to use that range of physical addresses, I don't know how to do that (IIRC there's a kernel command line option for that but I can't find it right now).

What you need may already exist as part of a generic ACPI feature however, giving you access to the raw ACPI data but not to the parsed data like iscsi_bft.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.