OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 18, 2024 5:43 am

All times are UTC - 6 hours




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 6:11 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Quote:
The 32-bit kernel (...) doesn't pick the 32-bit version from the universal binary but uses the 64-bit version
Citation needed. Your previous link demonstrated nothing.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 6:53 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Quote:
Citation needed.

Mac OS X Internals - A systems approach, 1st Edition, Section 8.18.2.2.

Now, can you return the courtesy and give a citation as to why it is impossible to run 64-bit applications on a 32-bit kernel?

"Impossible is a word to be found only in the dictionary of fools."
Napoleon Bonaparte


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 6:55 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

Combuster wrote:
Quote:
The 32-bit kernel (...) doesn't pick the 32-bit version from the universal binary but uses the 64-bit version
Citation needed. Your previous link demonstrated nothing.


As far as I can tell; it's all smoke, mirrors and lies.

For a lot of micro-kernels; the idea is to have an "OS personality" running on top of it. For example, you might have an L4 kernel with a POSIX style personality running on top. Part of this idea is to allow several different "OS personalities" on the same machine at the same time. The Mach micro-kernel is like this too.

So, what Apple do is they take the micro-kernel, and add an "OS X personality" layer on top (mostly by taking code from FreeBSD). Then they bastardise it to run the "OS X personality" at CPL=0 so they can ram device drivers into it like a monolithic system. After that they try to pretend that the real kernel doesn't exist and that the "OS X personality" (which runs in its own address space like a normal task) is the "kernel".

Of course for a system like this, if the real kernel (the Mach micro-kernel) is 64-bit and is capable of running 32-bit tasks (including 32-bit "OS personalities"); then you get a situation were stupid people believe a whole pile of crap (e.g. that an over-privileged 32-bit task is a "32-bit kernel" and it "runs 64-bit processes", when it only actually tells the real kernel to run those 64-bit processes).


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 7:01 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
I take it you haven't read the requested citation? ;)

What seems to bother no-one is that the 32-bit OS X kernel would run on a 32-bit processor. Not bad for a 64-bit kernel. :)

"Why, sometimes I've believed as many as six impossible things before breakfast."
Lewis Carroll


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 7:58 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
Quote:
Mac OS X Internals - A systems approach, 1st Edition, Section 8.18.2.2

Quote:
(...) two architectures: ppc and ppc64

That's not x86.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 9:33 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
iansjack wrote:
What seems to bother no-one is that the 32-bit OS X kernel would run on a 32-bit processor. Not bad for a 64-bit kernel. :)


Pseudocode:

if detected processor is 64-bit capable:
initialize 64-bit parts of kernel
else:
initialize 32-bit parts only

And if we look at the actual source code to Apple's Mac OS X kernel (XNU), we find a block of code that appears to do exactly that in i386_init.c and more code that appears to selectively enable 64-bit features in pmap.c... I think it's pretty safe to say that the osfmk (Mach) layer is capable of running in either 32 or 64-bit mode, while the BSD layer seems to be either word-length independent or 32-bit only, it's hard to tell from the code. (__darwin_ptrdiff_t seems to be 32-bit if there is no compiler provided __PTRDIFF_TYPE__, but most other pointer-related types are based on "long" which switches, assuming an LP64 compiler).

_________________
Image


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 9:42 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Quote:
That's not x86.

The question was "can a 32-bit kernel run 64-bit apps". Don't limit your thinking to just one processor. There's a whole wide world out there.

But the same process applied to Intel versions of the kernel too.

Whether you think a 64-bit aware kernel cannot be a 32-bit kernel just because it runs 32-bit code is another matter. If not then, by definition, such a kernel is not 32-bit (but it's not 64-bit either, so perhaps we'll have to call it 48-bit ;)).

I'm a little surprised by some of the narrow thought processes in this thread. I've seen assertions that, for example, a 32-bit kernel couldn't understand 64-bit page tables. Goodness only knows how any 64-bit kernel ever gets itself started since it needs such a page table in the first place. I'm glad to say that I can handle 64-bit page tables with 32-bit code. It's not rocket science.

Now, I think this subject has been done to death.


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 10:15 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
iansjack wrote:
Quote:
That's not x86.

The question was "can a 32-bit kernel run 64-bit apps". Don't limit your thinking to just one processor.

iansjack wrote:
The 32-bit Intel kernel could run 64-bit Intel userspace applications
Just accepting the fact that you were wrong is also an option. A healthy one even.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 10:42 am 
Offline
Member
Member
User avatar

Joined: Wed Aug 21, 2013 3:53 am
Posts: 449
Location: Asia, Singapore
I'm not sure if this is sane but would it be possible to use Intel-VT or AMD-V virtualisation technologies to run 64 bit applications under a 32 bit environment?

_________________
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 12:29 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Good point. You can indeed run a 64-bit guest on VirtualBox running on a 32-bit host. So, another example of a 32-bit kernel running 64-bit programs.

Of course, everyone knows that that is not possible. ;)


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 12:41 pm 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 852
This thread is silly. It is a matter of fact that the 32-bit version of the OSX kernel consists mainly of 32-bit code, which anyone can easily confirm by looking at the code instead of trying to reason away facts. There is only a tiny amount of 64-bit code having to do with 64-bit exception vectors, 64-bit syscalls, etc. If the CPU doesn't support long mode, it's simply not used. My OS does the same thing, and it's not particularly hard. There are about 20 places in the OSX kernel where it explicitly cares about whether the CPU is 64 bit.


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Wed Jun 25, 2014 9:16 pm 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

iansjack wrote:
I take it you haven't read the requested citation? ;)


I take it the citation was written by a stupid Apple fanboy that can't see past their lies.

iansjack wrote:
What seems to bother no-one is that the 32-bit OS X kernel would run on a 32-bit processor. Not bad for a 64-bit kernel. :)


What you're saying is that the "32-bit OS X personality" can run on top of a 32-bit Mach kernel or a 64-bit Mach kernel. So what? Most 64-bit kernels can run 32-bit tasks.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Thu Jun 26, 2014 12:02 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
Quote:
So what? Most 64-bit kernels can run 32-bit tasks.

On a 32-bit processor? Those Apple guys are cleverer than I thought. ;)

Gigasoft is right - this discussion is very silly. I suspect that half the contributors have never used OS X.


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Thu Jun 26, 2014 12:28 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

iansjack wrote:
Quote:
So what? Most 64-bit kernels can run 32-bit tasks.

On a 32-bit processor? Those Apple guys are cleverer than I thought. ;)


Nobody said that the 64-bit Mach kernel runs on a 32-bit CPU (you'd use the 32-bit Mach kernel for that). This is what's called a "red herring" - it indicates that you know your argument is false but aren't willing to admit it, so you pretend I said something I didn't in an attempt to hide your shame.

iansjack wrote:
Gigasoft is right - this discussion is very silly. I suspect that half the contributors have never used OS X.


There's no logical connection between using something and knowing how it works.

There's probably billions of people that drive cars that don't know how combustion engines or transmissions work, and probably billions of people that use all sorts of OSs (including OS X) that don't know how they work. In the same way it's possible for someone to know how combustion engines and transmissions work without driving a car; and possible for someone that doesn't use OS X to know you're "misguided".


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
 Post subject: Re: 32-bit kernel that runs 64-bit apps
PostPosted: Thu Jun 26, 2014 12:30 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4594
Location: Chichester, UK
milouz wrote:
Hi,

I thought that it was impossible to have a 32-bit kernel running 64-bit apps... until I read that some versions of Mac OS X kernel, despite being 32-bit, can effectively run 64-bit apps :shock:

Does anyone knows a little bit more about this ? I really can't figure out how it can be possible :?:

Let's try and make this my last word on what has turned into a very silly discussion (but very thought provoking OP).

Can 64-bit programs run on a 32-bit processor? Yes, but it would take a deal of emulation and would be pretty slow.

Can 64-bit programs run on a 32-bit OS? As Apple demonstrates, yes they can.

Is 32-bit OS X truly a 32-bit program? It will run on a 32-bit processor so, by any reasonable definition, yes it is.

On a 32-bit processor can OS X run 64-bit programs? No.

Does the 32-bit OS X kernel contain any 64-bit instructions? By definition, to be able to run 64-bit programs an OS must be 64-bit aware. This will involve some 64-bit instructions that will be called when a 64-bit user program is run.

Does that make the kernel 64-bit? No. Those instructions are just the glue that allows interaction between the 64-bit programs and the 32-bit kernel. They are, if you like, the 64-bit personality. This no more makes the kernel 64-bit than the 32-bit personality of a 64-bit kernel makes it 32-bit. The kernel functions perfectly without them but, in that case, it wouldn't be able to run 64-bit programs.

Was the mythical 32-bit OS X kernel just a marketing ploy by Apple to downplay their OS? Let's not get too silly!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 49 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 42 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group