From: "H. Peter Anvin" <hpa@zytor.com>
To: Jonathan Campbell <jon@nerdgrounds.com>
Cc: linux-kernel@vger.kernel.org, torvalds@transmeta.com
Subject: Re: Patches for REALLY TINY 386 kernels
Date: Sun, 15 Jul 2007 16:08:04 -0700 [thread overview]
Message-ID: <469AA8D4.2070206@zytor.com> (raw)
In-Reply-To: <469A8AED.7070207@nerdgrounds.com>
Jonathan Campbell wrote:
> I wrote a set of patches out of concern that even if you compile a 386
> kernel a lot of code irrelevent to legacy machines still remains. Things
> like the Pentium TSC register, DMI information, ESCD parsing, and the
> use of CPUID do not apply to these machines, but looking at System.map
> you can see they're still there.
>
> Already with these patches I can compile a zImage kernel that is 450kb
> large (890kb decompressed) with a small initramfs payload, floppy and
> kernel module support, FPU emulation, that can successfully boot on an
> ancient 386 laptop with only 1MB of extended memory. Eventually what I'd
> like to have is the ability to compile a pure 386 kernel with all
> non-386 functions removed (and perhaps the same for 486 machines).
>
> These patches were written against the vanilla 2.6.21.1 kernel. They
> will have no effect UNLESS you make menuconfig and explicitly enable
> them there.
These should all probably depend on EMBEDDED (which is the "allow
features to be disabled which would be dangerous for most people".)
CONFIG_X86_TSC, however, would be cleaner implemented by something like:
#ifdef CONFIG_X86_TSC
int disable_tsc;
#else
#define disable_tsc 1
#endif
... then gcc will optimize out the rest of the code.
The CPUID stuff hacks up the code quite a bt which makes it hard to
read. Can you abstract any of that code so it doesn't get so ugly?
Stuff like:
+#ifndef CONFIG_X86_DONT_CPUID
if (cpu_has_fxsr) {
/*
* Verify that the FXSAVE/FXRSTOR data will be 16-byte aligned.
@@ -1177,6 +1178,7 @@
set_in_cr4(X86_CR4_OSXMMEXCPT);
printk("done.\n");
}
+#endif
... is much better handled by forcing the value of the cpu_has_* macros
to zero, in which case gcc optimizes out the if clause. The current git
HEAD has handling of constant cpu_* going the other way, but it should
be easy enough to extend.
-hpa
next prev parent reply other threads:[~2007-07-15 23:08 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-15 21:00 Patches for REALLY TINY 386 kernels Jonathan Campbell
2007-07-15 21:42 ` Nigel Cunningham
2007-07-15 22:45 ` Alan Cox
2007-07-15 23:12 ` Nigel Cunningham
2007-07-15 23:14 ` Satyam Sharma
2007-07-15 23:13 ` Arnd Bergmann
2007-07-15 23:28 ` Satyam Sharma
2007-07-15 23:05 ` Adrian Bunk
2007-07-15 23:08 ` H. Peter Anvin [this message]
2007-07-17 10:59 ` Jan Engelhardt
2007-07-17 19:30 ` Matt Mackall
2007-07-18 2:33 ` Andi Kleen
2007-07-18 15:55 ` H. Peter Anvin
2007-07-18 18:20 ` Andi Kleen
2007-07-18 18:29 ` Jan Engelhardt
2007-07-18 18:38 ` Andi Kleen
2007-07-18 18:45 ` Jan Engelhardt
2007-07-18 18:47 ` Andi Kleen
2007-07-18 20:24 ` John Stoffel
2007-07-18 18:33 ` Adrian Bunk
2007-07-18 18:42 ` Jan Engelhardt
2007-07-18 18:44 ` Andi Kleen
2007-07-18 19:00 ` H. Peter Anvin
2007-07-21 10:09 ` Oleg Verych
2007-07-18 19:41 ` Matt Mackall
2007-07-18 19:50 ` H. Peter Anvin
2007-07-18 20:10 ` Andi Kleen
2007-07-18 20:24 ` H. Peter Anvin
2007-07-18 21:04 ` Andi Kleen
2007-07-18 22:17 ` H. Peter Anvin
2007-07-30 17:59 ` Denis Vlasenko
2007-07-18 20:41 ` Matt Mackall
2007-07-20 7:27 ` Uwe Hermann
2007-07-20 7:35 ` Andi Kleen
2007-07-24 14:49 ` Helge Hafting
2007-07-24 20:50 ` Yinghai Lu
2007-07-24 22:56 ` Adrian Bunk
2007-07-25 0:55 ` Yinghai Lu
2007-07-24 22:45 ` Willy Tarreau
[not found] <8HjYY-4Jk-15@gated-at.bofh.it>
[not found] ` <8HlxM-7iT-13@gated-at.bofh.it>
[not found] ` <8HlxL-7iT-11@gated-at.bofh.it>
[not found] ` <8HlHq-7vR-17@gated-at.bofh.it>
[not found] ` <8HlHr-7vR-25@gated-at.bofh.it>
2007-07-16 13:12 ` Bodo Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=469AA8D4.2070206@zytor.com \
--to=hpa@zytor.com \
--cc=jon@nerdgrounds.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox