
Darwin-xnu: The Darwin Kernel - adamnemecek
https://github.com/apple/darwin-xnu?
======
0x0
The big news here is the inclusion of arm and arm64 specific files, which used
to be excluded in source drops previously.

~~~
diminish
So is it a totally new story that iOS kernel is open sourced?

~~~
mindcrash
No, because this thing, darwin-xnu AKA the OSX/iOS microkernel, was already
opensourced through
[https://opensource.apple.com/](https://opensource.apple.com/) for both iOS
and OSX (to be precise, the source tarballs can be found here:
[https://opensource.apple.com/tarballs/xnu/](https://opensource.apple.com/tarballs/xnu/))

What is new however is that Apple is now seemingly actively using GitHub to
publish their opensource contributions.

~~~
willstrafach
> No, because this thing, darwin-xnu AKA the OSX/iOS microkernel, was already
> opensourced through
> [https://opensource.apple.com/](https://opensource.apple.com/) for both iOS
> and OSX

This is not true. iOS components were always stripped out until now.

~~~
joshumax
This, while probably seemingly unimportant to a lot of people, is extremely
great news for a project I'm a part of!

We're working on a full iPhone emulator based on QEMU, and currently, while we
are able to boot into early userspace from an unmodified iOS image, the
release of the iOS-specific code will be quite helpful in speeding up bug
elimination and the development of the virtual graphics hardware that can get
us past a basic graphical framebuffer.

~~~
FractalNerve
wow, interesting! Where can I find your project?

~~~
KGIII
Probably this:

[https://github.com/joshumax/QEMU-s5l89xx-
port](https://github.com/joshumax/QEMU-s5l89xx-port)

Or this:

[https://github.com/nvsio/qemu-ios](https://github.com/nvsio/qemu-ios)

Found sort of via this:

[https://www.reddit.com/r/jailbreak/comments/6crw5t/question_...](https://www.reddit.com/r/jailbreak/comments/6crw5t/question_nor_flash_dumps_of_various_idevices/)

I assume they won't mind my sharing. They posted it publicly with the same
username and have public Git pages.

~~~
joshumax
Actually, you saved me a post! Thanks!

Although quick note, a lot of work is being done in a private repo until it
passes the "clean room" test, after which it will be pushed to the public
repos. :)

------
beefhash
See also:
[https://news.ycombinator.com/item?id=15371102](https://news.ycombinator.com/item?id=15371102)
and
[https://news.ycombinator.com/item?id=15371111](https://news.ycombinator.com/item?id=15371111)

There seems to be some confusion on whether the iOS kernel was or was not
newly open sourced and whether it's the complete iOS kernel or not.

~~~
monocasa
I don't see why there's confusion. AArch64 support in platform export (like
hal.dll for XNU) seems to be stubbed out and unimplemented meaning that the
ARM support is at least from an ancient iOS kernel.

[https://github.com/apple/darwin-
xnu/blob/master/pexpert/arm/...](https://github.com/apple/darwin-
xnu/blob/master/pexpert/arm/pe_serial.c#L168)

------
arca_vorago
License for those interested:

[https://github.com/apple/darwin-
xnu/blob/master/LICENSE](https://github.com/apple/darwin-
xnu/blob/master/LICENSE)

~~~
smitherfield
TL;DR - GPL-ish with a Facebook-style patent clause.

------
walterbell
At the Tencent security conference in August, there was a demo of ARM iOS
booting on virtualized iPhone6 hardware on x86 Macbook. Video clip was on
Twitter but since removed.

------
sigmar
Odd that there wouldn't be a public explanation for this. Poking through
board_config I found support for the A10X (T8011), and for the three Apple
Watch chips, but not for the new A11 SoC (T8015).

------
amrrs
With a blog for Machine Learning where Apple shares some of its practices and
now open-sourcing its iOS kernel for the first time, Apple is entering a new
era of Post-Jobs where every company has started to believe the only way to
attract quality resources is to contribute back to the society - Remember how
this community scared FB to rewrite React License. It's a great way forward
for FOSS and hopefully one that can set up the right way for Post-Cook Apple.

~~~
new299
It's a start.

It would be nice to see more of iOS open sourced. Not everything, but enough
to run the GUI and maybe Safari.

I think that could be a huge win for Apple. Lower end, open source iOS
compatible phone could attack Android offering, particularly at the lower end.
They'd gain control over the market (as it would be derived from their source,
and compatible with their ecosystem) without having to do much work.

Honestly, if Apple don't do it, someone should come up with an open source iOS
compatible offering, which developers could easily re-target their apps to.

VCs reading this, I'm offering 15% for 3MUSD for the above idea. ;)

~~~
madeofpalk
I think Apple (and everyone else) is doing pretty well with their closed
source software.

Apple doesn't need others to make lower and cheaper devices. They're more than
capable of doing it themselves, they just don't want to.

~~~
comstock
No, they don’t want to. But I think it would be advantageous to them to not
have Android around.

Potentially they could convert many Android users to open source iOS. It
wouldn’t come with the branding, I think it could be to their advantage.

It’s not likely to happen, but I think an open source iOS clone/fork would be
nice and could also have potential benefits for Apple.

~~~
dmitriid
> No, they don’t want to. But I think it would be advantageous to them to not
> have Android around.

In 2016 Apple got 104% of the entire mobile industry's _profit_. Not revenue.
_Profit_ [1]

I hardly see how disappearance of Android would bring Apple any more
advantages.

This year Samsung looks like they might beat Apple on profits ... due to large
sales of components "to a major smartphone customer" [2]

[1] [http://fortune.com/2016/11/04/apple-smartphone-
profits/](http://fortune.com/2016/11/04/apple-smartphone-profits/) [2]
[http://money.cnn.com/2017/07/27/technology/samsung-profit-
ap...](http://money.cnn.com/2017/07/27/technology/samsung-profit-
apple/index.html)

~~~
comstock
Thanks, the 104% profit number doesn’t make sense to me and I couldn’t see it
explained the the article.

How do you get >100% of the profits available in a given industry?

~~~
AlphaSite
The rest of the industry operates at a loss.

~~~
jacobush
On average.

------
nextos
To someone not familiar with Darwin internals, are drivers bundled or is it
possible to get binary blobs? Does this mean we can build an open source stack
that could run on iPhone or iWatch?

~~~
new299
Without the ability to sign the kernel, even if you could build one you
wouldn't be able to run it.

~~~
thinkloop
That's big, what's their purpose for open sourcing if not to allow developers
to build on it?

~~~
comstock
It’s possible that this might help security researchers find/fix bugs.

It may help other developers understand how iOS works.

Overall, I think it’s unlikely to be hugely useful, in terms of actuallly
using it for anything.

------
gok
The new GitHub home aside, there's some cool stuff in XNU. The memory
compressor, process hibernation, activity tracing, DTrace...worth poking
through!

------
buildbot
Looks like they are working on NVRAM support :
[https://github.com/apple/darwin-
xnu/blob/master/iokit/Kernel...](https://github.com/apple/darwin-
xnu/blob/master/iokit/Kernel/IONVRAM.cpp)

~~~
abrowne
All Macs have NVRAM for settings like default boot disk, volume and display
brightness.

------
kev009
Dang, no APFS. Was hoping to gauge how portable it'd be to *BSD.

~~~
adamnemecek
You have zfs.

~~~
kev009
I love ZFS and use it as much as possible. But we make heavy use of UFS at
$work because sendfile and fail in place. I'm in the market for a flash
filesystem for this use case. I doubt APFS has that all figured out, but it
might be technically interesting enough to do so, and it might integrate move
coherently with the pager than ZFS (the ARC makes this quite difficult but not
impossible to do sendfile/mmap w/o extra copying)

~~~
GalacticDomin8r
Have you tried nandfs? I have not, so I don't know if it meets your needs.

------
waynecochran
Interesting side note, source contains 8701 goto statements -- I like it.

    
    
         $ find . -name "*.c" -exec grep goto {} \; -print | wc -l
         8701
    

Most of it to unify releasing resources on function returns to one place at
the end of the function body. This is what makes RAII in C++ so
important/convenient.

~~~
efiop
You are saying it like if 'goto' was a bad thing. This is pretty normal for
any kernel/system projects.

------
payne92
dupe:
[https://news.ycombinator.com/item?id=15371102](https://news.ycombinator.com/item?id=15371102)
and
[https://news.ycombinator.com/item?id=15371111](https://news.ycombinator.com/item?id=15371111)

------
navalsaini
This means that we should have cheap non-apple phones capable of running iOS
applications. Why would apple allow that?

~~~
AsyncAwait
It does not mean that at all. This is not iOS itself being open-sourced, only
the Darwin kernel is open-source, which is pretty much useless in isolation,
certainly for trying to develop a cheap phone to run iOS apps.

~~~
navalsaini
Oic ... the framework/middleware is not. I took parallels to Android. Thanks
for correcting me.

------
amelius
Nice, but I don't want open software as much as open hardware.

(For software, there are plenty of alternatives).

~~~
kzisme
What makes you say that?

~~~
amelius
Lack of good options to put a libre OS on phone hardware and build a libre
phone.

Why can my top-of-the-line desktop be libre but must my phone be locked down?

------
thought_alarm
Tabs instead of spaces. Tsk, tsk.

[https://i.imgur.com/VE7kEeC.png](https://i.imgur.com/VE7kEeC.png)

"debo" must have been an intern.

