login
Header Space

 
 

Re: [PATCH 1/2] OLPC: Add support for calling into Open Firmware

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Andres Salomon <dilinger@...>
Cc: H. Peter Anvin <hpa@...>, Yinghai Lu <yhlu.kernel@...>, Eric W. Biederman <ebiederm@...>, Ingo Molnar <mingo@...>, Andrew Morton <akpm@...>, Joseph Fannin <jfannin@...>, <linux-kernel@...>, <jordan.crouse@...>
Date: Sunday, April 20, 2008 - 2:42 pm

Andres Salomon wrote:

The x86 architecture doesn't make this problem easy.

The conventional solution is to have the BIOS operate in real mode.  
When the kernel calls into the BIOS, it has to do a grotesque dance that 
involves jumping through a chain of several segments of different 
flavors, thus gradually shutting down the multi-tiered address 
translation mechanism.  Then, if the BIOS is actually operating in 
protected mode (which is necessary if it is larger than 64K, as all 
modern BIOSes are), it has to perform the inverse process, do the 
requested work, then go back into real mode to return to the kernel.  
The net result is that a "call" into the BIOS involves:

a) Copying the arguments to a real-mode register shadow array
b) Saving all the registers - general ones and a few special ones too
c) Far call to a linear-mapped code segment with an execution address in 
the first 1M of memory
d) Switching to a different stack
e) Turning off page translation
f) Switching from protected mode to real mode (or in some cases, V86 
mode instead, which requires an additional Task State Segment dance to 
set the IO permission mask)
g) Switching to a real-mode interrupt descriptor table

h) Executing an INT instruction

I) Performing the inverse of a - g inside the BIOS

j) Doing the requested work

K) Performing a - g again to get back into real mode

l) Executing an "iret" instruction

M) Performing the inverse of a-g to return to normal operation

The machinery that you need to do all that is predictably complex - 
extra segment descriptors that are set up just-so, several little code 
fragments that must be at special addresses in the first meg, additional 
stacks, a real-mode interrupt table at a fixed address, and several data 
save arrays.  That machinery has to be in assembly language, spanning 
several different instruction set modes.

Compared to that, I think that sharing one or two page directory entries 
at the very top of the virtual address space is pretty clean and 
simple.  With that sharing, the BIOS call is just an ordinary subroutine 
call.  (The setup code copies the entire page directory, but only a 
couple of entries are actually needed.  The reason for copying the whole 
thing is because it is rather more work to determine the exact number of 
entries necessary, compared to copying everything and then letting Linux 
replace the ones it uses.)

Every other solution that I know of requires some sort of heroic dance, 
either from the OS or from the BIOS or (usually) both.

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.25-mm1, Andrew Morton, (Fri Apr 18, 4:47 am)
[Was: 2.6.25-mm1], Jiri Slaby, (Mon Apr 21, 4:31 am)
Re: [Was: 2.6.25-mm1], Al Viro, (Mon Apr 21, 5:06 am)
fault in __d_lookup [Was: 2.6.25-mm1], Jiri Slaby, (Mon Apr 21, 5:37 am)
Re: fault in __d_lookup [Was: 2.6.25-mm1], Al Viro, (Mon Apr 21, 5:45 am)
Re: fault in __d_lookup [Was: 2.6.25-mm1], Jiri Slaby, (Mon Apr 21, 5:59 am)
Re: fault in __d_lookup [Was: 2.6.25-mm1], Matthew Wilcox, (Mon Apr 21, 1:23 pm)
Re: fault in __d_lookup [Was: 2.6.25-mm1], Rafael J. Wysocki, (Mon Apr 21, 9:42 am)
internal compiler error: SIGSEGV [Was: 2.6.25-mm1], Jiri Slaby, (Sun Apr 20, 7:29 am)
Re: 2.6.25-mm1, Joseph Fannin, (Fri Apr 18, 11:10 pm)
Re: 2.6.25-mm1, Andrew Morton, (Fri Apr 18, 11:29 pm)
Re: 2.6.25-mm1, Arjan van de Ven, (Sat Apr 19, 2:21 pm)
Re: 2.6.25-mm1, Andres Salomon, (Sat Apr 19, 9:25 am)
Re: 2.6.25-mm1, Andrew Morton, (Sat Apr 19, 1:38 pm)
Re: 2.6.25-mm1, Andres Salomon, (Sat Apr 19, 1:50 pm)
Re: 2.6.25-mm1, Jordan Crouse, (Mon Apr 21, 10:56 am)
Re: 2.6.25-mm1, Andres Salomon, (Mon Apr 21, 11:05 am)
Re: 2.6.25-mm1, Jordan Crouse, (Mon Apr 21, 11:12 am)
[PATCH 2/2] OLPC: drop pre-OpenFirmware workarounds, Andres Salomon, (Sat Apr 19, 1:39 pm)
Re: OLPC: only check for OFW signature on VSA-less Geodes, Jordan Crouse, (Mon Apr 21, 5:17 pm)
Re: [PATCH 1/2] OLPC: Add support for calling into Open Firm..., Mitch Bradley, (Sun Apr 20, 2:42 pm)
Re: OLPC: Add support for calling into Open Firmware, Jordan Crouse, (Mon Apr 21, 11:05 am)
Re: OLPC: Add support for calling into Open Firmware, H. Peter Anvin, (Mon Apr 21, 10:58 am)
Re: 2.6.25-mm1, Joseph Fannin, (Fri Apr 18, 10:25 pm)
Re: 2.6.25-mm1, Andrew Morton, (Fri Apr 18, 11:08 pm)
Re: 2.6.25-mm1, Joseph Fannin, (Fri Apr 18, 10:13 pm)
Re: 2.6.25-mm1, Andrew Morton, (Fri Apr 18, 11:02 pm)
Re: 2.6.25-mm1, Dmitry Torokhov, (Sat Apr 19, 12:14 am)
Re: 2.6.25-mm1, Andrew Morton, (Sat Apr 19, 12:29 am)
Re: 2.6.25-mm1, Takashi Iwai, (Mon Apr 21, 10:06 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Mon Apr 21, 1:55 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Tue Apr 22, 6:13 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Tue Apr 22, 2:31 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Wed Apr 23, 4:49 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Wed Apr 23, 4:02 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Thu Apr 24, 5:40 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Thu Apr 24, 11:51 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Fri Apr 25, 2:28 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Fri Apr 25, 12:45 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Dmitry Torokhov, (Fri Apr 25, 2:09 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Fri Apr 25, 2:31 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Dmitry Torokhov, (Fri Apr 25, 2:37 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Fri Apr 25, 12:51 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Fri May 2, 12:44 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Fri May 2, 12:57 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Tue May 6, 6:20 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Tue May 6, 12:51 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Fri Apr 25, 1:25 pm)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Takashi Iwai, (Wed Apr 23, 10:18 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Dmitry Torokhov, (Tue Apr 22, 10:01 am)
Re: 2.6.25-mm1 (snd-pcsp doesn't like DEBUG_PAGEALLOC), Stas Sergeev, (Tue Apr 22, 12:42 pm)
Re: 2.6.25-mm1, Takashi Iwai, (Mon Apr 21, 7:07 am)
Re: 2.6.25-mm1, Stas Sergeev, (Mon Apr 21, 3:45 pm)
Re: 2.6.25-mm1 (snd-pcsp causes driver conflict), Stas Sergeev, (Mon Apr 21, 1:44 pm)
Re: 2.6.25-mm1 (snd-pcsp causes driver conflict), Takashi Iwai, (Tue Apr 22, 6:09 am)
Re: 2.6.25-mm1 (snd-pcsp causes driver conflict), Stas Sergeev, (Tue Apr 22, 1:54 pm)
Re: 2.6.25-mm1 (snd-pcsp causes driver conflict), Takashi Iwai, (Wed Apr 23, 4:55 am)
Re: 2.6.25-mm1 (snd-pcsp causes driver conflict), Takashi Iwai, (Wed Apr 23, 10:14 am)
Re: 2.6.25-mm1, Joseph Fannin, (Sat Apr 19, 2:33 am)
2.6.25-mm1: orphaned files after build, Alexey Dobriyan, (Fri Apr 18, 7:09 pm)
Re: 2.6.25-mm1, , (Fri Apr 18, 4:14 pm)
Re: 2.6.25-mm1 (build error: trace selftest), Randy Dunlap, (Fri Apr 18, 12:45 pm)
Re: 2.6.25-mm1 (build error: driver core), Randy Dunlap, (Fri Apr 18, 12:40 pm)
Re: 2.6.25-mm1 (build error: driver core), Greg KH, (Fri Apr 18, 12:56 pm)
Re: 2.6.25-mm1 (build error: driver core), Dan Williams, (Fri Apr 18, 2:38 pm)
StackProtector Oopses - Re: 2.6.25-mm1, Reuben Farrelly, (Fri Apr 18, 9:02 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Ingo Molnar, (Fri Apr 18, 9:36 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Reuben Farrelly, (Fri Apr 18, 10:49 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Ingo Molnar, (Mon Apr 21, 11:06 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Arjan van de Ven, (Mon Apr 21, 9:48 pm)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Ingo Molnar, (Tue Apr 22, 4:34 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Arjan van de Ven, (Tue Apr 22, 10:29 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Arjan van de Ven, (Fri Apr 18, 9:51 am)
Re: StackProtector Oopses - Re: 2.6.25-mm1, Reuben Farrelly, (Fri Apr 18, 10:41 am)
speck-geostationary