kvm-kext
kvm-kext copied to clipboard
build.sh errors
On a pristine up-to-date Mavericks with the latest Xcode from the app store and git from sourceforge I get the following error when running build.sh:
$ ./build.sh Password: Can't open CFBundle for /tmp/kvm.kext. Can't create /tmp/kvm.kext. In file included from main.cpp:4: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/proc.h:118:19: error: field has incomplete type 'struct itimerval' struct itimerval p_realtimer; /* Alarm timer. / ^ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/proc.h:118:9: note: forward declaration of 'itimerval' struct itimerval p_realtimer; / Alarm timer. */ ^ main.cpp:5:10: fatal error: 'libkern/libkern.h' file not found
include <libkern/libkern.h>
^
2 errors generated.
Should I be using Yosemite instead, or is there something else I'm missing ?
Thanks, --Gabriel
Same thing happens after I upgraded to Yosemite, so I must be missing something else :)
--Gabriel
Do you have /System/Library/Frameworks/Kernel.framework/Headers/libkern/libkern.h on your system?
I do not. There's /Applications/Xcode.app/Contents/Developer/Platform/MacOSX.platform/Developer/SDKs/MacOSX10.[9,10].sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/libkern/libkern.h, but nothing directly under /System/Library/Frameworks/...
Adding one of those paths (9 or 10, depending on OS X version) with -I just causes g++ to spit out a whole bunch more errors. What prerequisite would provide that include file ?
Not sure, but I cleaned up the include files and used the Kernel.framework headers from the SDK. Checkout and try again. Post errors.
Cool, build.sh works now. Moving on to get-qemu.sh:
wget doesn't ship on OS X by default, so I replaced it with "curl -O".
Then, after successfully patching qemu, "./configure ..." results in
ERROR: pkg-config binary 'pkg-config' not found
At this point, google tells me I probably need to install homebrew :) (http://mxcl.github.com/homebrew/)
If that's the case, maybe add a quick mention in your README ?
Thanks, --G
So, after installing homebrew, and setting it up with "brew doctor", I grabbed gcc and pkg-config:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb brew install pkg-config
Now, re-running get-qemu.sh gets me this:
ERROR: glib-2.12 gthread-2.0 is required to compile QEMU
I assume more "brew install
Thanks, --G
So these are all issues with building QEMU normally, nothing specific to my patches.
Perhaps http://mikelev.in/2012/10/qemu-mac-os-x-success/ works? If it does, I'll add it to the README
Looks like it might just be "brew install glib"
On Tue, Jan 13, 2015 at 06:15:50AM -0800, George Hotz wrote:
Perhaps http://mikelev.in/2012/10/qemu-mac-os-x-success/ works? If it does, I'll add it to the README
It helps somewhat (it says I should also "brew install glib" on top of what I already did -- apple-gcc42 and pkg-config). But that's only the beginning :)
After some trial-and-error I "brew install"-ed automake and libtool as well, and now, running get-qemu.sh actually begins compiling stuff, but crashes and burns after a while whit something like this:
...
CCLD region-translate-test CCLD region-test CCLD combiner-test CCLD pixel-test CCLD fetch-test clang: warning: clang: argument unused during compilation: '-pthread'warning: argument unused during compilation: '-pthread'clang: warning: argument unused during compilation: '-pthread' clang: warningclang: : argument unused during compilation: '-pthread'warning : argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'
clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'
clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'
clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'
clangclang: : warningwarning: : argument unused during compilation: '-pthread'argument unused during compilation: '-pthread'
clang: clangwarning: : warningargument unused during compilation: '-pthread': argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' clang: warning: argument unused during compilation: '-pthread' Undefined symbols for architecture x86_64: "_prng_state", referenced from: _main in region-test.o "_prng_state_data", referenced from: _main in region-test.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[3]: *** [region-test] Error 1 make[3]: *** Waiting for unfinished jobs.... make[2]: *** [all-recursive] Error 1 make[1]: *** [all] Error 2 make: *** [subdir-pixman] Error 2
There's no "pthread" formula to "brew install", so I'm stuck.
There are various recipes (and lists of brew formulae to install) to get various versions of qemu to build on OS X, but they all seem specific to the various respective qemu versions their authors happened to be struggling with at the time. :)
Maybe directions to get the minimal set of prerequisites specific to the one you're dealing with would be nice, after all...
So far, the "brew install" list (when starting from scratch on a clean Yosemite) includes:
https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb pkg-config glib automake libtool
I get the feeling I'm close, only missing a one or two more :)
Maybe list the output of your $(brew list) to the readme instead ?
BTW, right now mine looks like this:
$ brew list apple-gcc42 automake glib libtool autoconf gettext libffi pkg-config
Thanks, --Gabriel
I'm using macports, and my port list is 1000+ lines long. The pthread doesn't seem like it's the problem, it's missing prng_state. Perhaps try disable flags to the configure?
On Tue, Jan 13, 2015 at 06:15:50AM -0800, George Hotz wrote:
So these are all issues with building QEMU normally, nothing specific to my patches.
Perhaps http://mikelev.in/2012/10/qemu-mac-os-x-success/ works? If it does, I'll add it to the README
So, immediately after firing off the previous mail, I stumbled upon some random web page which mentioned that homebrew had its own version of qemu. Combined with RTFM-ing the homebrew man page, may I suggest adding the following to your README:
- install homebrew
- run "brew doctor"
- brew install apple-gcc42
- for i in $(brew deps qemu); do
brew install $i
done
The latter installs "whatever qemu needs", and allows get-qemu.sh to run to completion and successfully generate a qemu-system-i386 binary.
I did manage to get to the busybox prompt from there, using your bootfd.img :) Nice work!
Cheers, --G
I gave it a try on 10.8 and failed
tests-mac:kvm-kext test$ sudo ./build.sh
Password:
Can't open CFBundle for /tmp/kvm.kext.
Can't create /tmp/kvm.kext.
In file included from main.cpp:5:
/usr/include/sys/proc.h:118:19: error: field has incomplete type
'struct itimerval'
struct itimerval p_realtimer; /* Alarm timer. */
^
/usr/include/sys/proc.h:118:9: note: forward declaration of 'itimerval'
struct itimerval p_realtimer; /* Alarm timer. */
^
main.cpp:13:10: fatal error: 'IOKit/IOMemoryDescriptor.h' file not found
#include <IOKit/IOMemoryDescriptor.h>
^
2 errors generated.
tests-mac:kvm-kext test$
Any hints?
I'm running 10.12.2, and I also tried with 10.9.5. I had the same issue as above, but installed the 10.10SDK
Now I've hit a wall:
./build.sh In file included from main.cpp:59: In file included from /usr/include/signal.h:64: /usr/include/sys/_types/_pthread_t.h:30:9: error: unknown type name '__darwin_pthread_t' typedef __darwin_pthread_t pthread_t; ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: In file included from /usr/include/signal.h:64: /usr/include/sys/_types/_pthread_t.h:30:9: error: unknown type name '__darwin_pthread_t' typedef __darwin_pthread_t pthread_t; ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ls README.md build.sh helpers kvm.kext qemu.patch tests bintest get-qemu.sh include main.cpp test.sh Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: In file included from /usr/include/signal.h:64: /usr/include/sys/_types/_pthread_t.h:30:9: error: unknown type name '__darwin_pthread_t' typedef __darwin_pthread_t pthread_t; ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: /usr/include/signal.h:64:10: fatal error: 'sys/_types/_pthread_t.h' file not found #include <sys/_types/_pthread_t.h> ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: /usr/include/signal.h:64:10: fatal error: 'sys/_types/_pthread_t.h' file not found #include <sys/_types/_pthread_t.h> ^ 1 error generated.
What is the required build OS for this to work?
I can only find the _pthread_t.h in 10.9SDK, but I tried to link it with adding:
-I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Kernel.framework/Headers
To the build.sh, but now I get:
./build.sh In file included from main.cpp:59: In file included from /usr/include/signal.h:64: /usr/include/sys/_types/_pthread_t.h:30:9: error: unknown type name '__darwin_pthread_t' typedef __darwin_pthread_t pthread_t; ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: /usr/include/signal.h:64:10: fatal error: 'sys/_types/_pthread_t.h' file not found #include <sys/_types/_pthread_t.h> ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: /usr/include/signal.h:64:10: fatal error: 'sys/_types/_pthread_t.h' file not found #include <sys/_types/_pthread_t.h> ^ 1 error generated. Jams-Mac-mini:kvm-kext jam1$ ./build.sh In file included from main.cpp:59: In file included from /usr/include/signal.h:64: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Kernel.framework/Headers/sys/_types/_pthread_t.h:30:9: error: unknown type name '__darwin_pthread_t' typedef __darwin_pthread_t pthread_t; ^ 1 error generated.
Any help on how to build this .kext?
After adjusting the headers argument to what I have present in Xcode, I've got:
$ ./build.sh
Password:
Executing: /usr/bin/kmutil unload -p /tmp/kvm.kext
Error Domain=KMErrorDomain Code=71 "Could not find: No bundle was found at /tmp/kvm.kext." UserInfo={NSLocalizedDescription=Could not find: No bundle was found at /tmp/kvm.kext.}
main.cpp:988:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
copyin(msrs->self + offsetof(struct kvm_msrs, entries), vcpu->msrs, vcpu->msr_count * sizeof(struct kvm_msr_entry));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/libkern/copyio.h:60:35: note: expanded from macro 'copyin'
#define copyin(uaddr, kaddr, len) __copyin_chk(uaddr, kaddr, len, __builtin_object_size(kaddr, 0))
^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:1002:3: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
copyin(cpuid2->self + offsetof(struct kvm_cpuid2, entries), vcpu->cpuids, vcpu->cpuid_count * sizeof(struct kvm_cpuid_entry2));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/libkern/copyio.h:60:35: note: expanded from macro 'copyin'
#define copyin(uaddr, kaddr, len) __copyin_chk(uaddr, kaddr, len, __builtin_object_size(kaddr, 0))
^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
ld: warning: object file (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libkmod.a(c_start.o)) was built for newer macOS version (12.1) than being linked (11.0)
ld: warning: object file (/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libkmod.a(c_stop.o)) was built for newer macOS version (12.1) than being linked (11.0)
Executing: /usr/bin/kmutil load --bundle-path /tmp/kvm.kext
Error Domain=KMErrorDomain Code=29 "Authenticating extension failed: Kext com.geohot.virt.kvm v1.9 in executable kext bundle com.geohot.virt.kvm at /private/var/db/KernelExtensionManagement/Staging/com.geohot.virt.kvm.vmVKfo/kvm.kext:
Authenticating extension failed: Bad code signature" UserInfo={NSLocalizedDescription=Authenticating extension failed: Kext com.geohot.virt.kvm v1.9 in executable kext bundle com.geohot.virt.kvm at /private/var/db/KernelExtensionManagement/Staging/com.geohot.virt.kvm.vmVKfo/kvm.kext:
Authenticating extension failed: Bad code signature}
It seems the Kernel extension is built but can't be loaded, any tips?