Live data from Hacker News

Hacking the OS X Kernel for Fun and Profiles

research.swtch.com

31–38 of 38 posts

Re: Hacking the OS X Kernel for Fun and Profiles

#31
post #17

It's articles like this that keep me reading HN. Kernel bugs, POSIX thread details, code disassembly, binary patching, and I get to learn about a new signal. What's not to love?

The paper on KSplice attached at the end is also really neat if you're into this stuff. It describes the design and implementation of a tool for applying binary patches based on normal source code diffs.

Re: Hacking the OS X Kernel for Fun and Profiles

#32

So you can't boot OS X by taking stock Darwin/XNU and recompile? If so that is kind of disappointing. I understand they have private code that they don't want to open up but it would be nice if you could still boot with a self-compiled kernel.

You can. See http://shantonu.blogspot.com/2012/07/building-xnu-for-os-x-1...

Re: Hacking the OS X Kernel for Fun and Profiles

#34
post #32

So you can't boot OS X by taking stock Darwin/XNU and recompile? If so that is kind of disappointing. I understand they have private code that they don't want to open up but it would be nice if you could still boot with a self-compiled kernel.

You can. See http://shantonu.blogspot.com/2012/07/building-xnu-for-os-x-1...

Glad to hear. It was suspect. "I can't be bothered to figure out how to build so I guess we'll patch the binary."

I guess Apple doesn't exactly shout from the rooftops how to do this but I see now that this is the top Google hit for "building xnu". So it's not too hidden.

Re: Hacking the OS X Kernel for Fun and Profiles

#35
post #9

Can someone explain what this patch actually does? I have an old Macbook Air with a malfunctioning sensor that cause the CPU to always run in powersaving mode (capped at 800 mhz), so it's basically unusable under OS X. I have walked around this issue by installing Linux which allows me to tune the CPU governor manually, and it uncaps the artificial limit that the malfunctioning sensor puts. Would this patch allow me…

You could also try this out... https://github.com/hholtmann/smcFanControl/tree/master/smc-c...

Re: Hacking the OS X Kernel for Fun and Profiles

#36
post #16

Earlier quoted context omitted.

Last time I checked on this, there was no safe way (i.e. using only async-signal-safe calls) to list the contents of /dev/fd post-fork. Did I miss something?

It's interesting that starting a new process in a signal handler is something you want to do. (I just searched and yes I understand fork() and exec() are spec'd by POSIX to be safe.) It seems like writing safe signal handlers is hard enough, making them multiprocess seems like a "now you have two problems" kind of thing. I suppose if I am not mistaken you could go the pre-readdir() route and open a directory with ope…

I don't think it's so much that starting a new process in a signal handler is an intended use case, but rather than the post-fork environment is very similar to the signal handler environment, and so calls that work in one will work in the other.

(In both cases, you can't count on currently acquired locks ever being released. In a signal handler, this is because it could be acquired on the current thread, and post-fork, this is because all other threads have been killed from the perspective of the child process. As such, no lock-based code can safely be called.)

Re: Hacking the OS X Kernel for Fun and Profiles

#37
post #9

Can someone explain what this patch actually does? I have an old Macbook Air with a malfunctioning sensor that cause the CPU to always run in powersaving mode (capped at 800 mhz), so it's basically unusable under OS X. I have walked around this issue by installing Linux which allows me to tune the CPU governor manually, and it uncaps the artificial limit that the malfunctioning sensor puts. Would this patch allow me…

You could try NullCPUPowerManagement.kext. It's used in the OS X x86 community to disable the built in Power management. If you don't mind getting your hands dirty you might be able to get it (or another related kext) to turn off frequency switching. [1] http://www.osx86.net/downloads.php?do=file&id=16

I don't mind getting my hands dirty at all. I'll see if I can find any more info about this kext, thanks :)

Re: Hacking the OS X Kernel for Fun and Profiles

#38
post #9

Can someone explain what this patch actually does? I have an old Macbook Air with a malfunctioning sensor that cause the CPU to always run in powersaving mode (capped at 800 mhz), so it's basically unusable under OS X. I have walked around this issue by installing Linux which allows me to tune the CPU governor manually, and it uncaps the artificial limit that the malfunctioning sensor puts. Would this patch allow me…

You could also try this out... https://github.com/hholtmann/smcFanControl/tree/master/smc-c...

Will this also allow me to scale the cpu? I was already able to change the fan's speed .... thanks
Post reply on HN