Re: Building 10.6 kernel?
Re: Building 10.6 kernel?
- Subject: Re: Building 10.6 kernel?
- From: "Nix, James L (IS)" <email@hidden>
- Date: Wed, 25 Nov 2009 16:00:23 -0600
- Thread-topic: Building 10.6 kernel?
The instructions at:
http://shantonu.blogspot.com/2009/09/mac-os-x-kernel-source-xnu-has-been.html
work great. I had no problems building the kernel. The problem is that when I install the new kernel, my test machine takes approx. 10 minutes to boot. Actually boot works ok, but the machine hangs prior to login -- just after the SecurityAgent launches. It hangs for about 10 minutes and then proceeds normally. It's as if some process is timing out.
When I ssh into the machine and run top, I notice that the hidd process is "stuck". If I kill the hidd process, it restarts, and the machine immediately becomes responsive.
Any ideas? Are there some kernel dependencies that I am overlooking? By the way, this happens with all three versions of the 10.6 source available at opensource.apple.com.
Thanks,
--Jim
-----Original Message-----
From: darwin-kernel-bounces+james.nix=email@hidden on behalf of email@hidden
Sent: Wed 11/25/2009 3:03 PM
To: email@hidden
Subject: Darwin-kernel Digest, Vol 6, Issue 174
Send Darwin-kernel mailing list submissions to
email@hidden
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.apple.com/mailman/listinfo/darwin-kernel
or, via email, send a message with subject or body 'help' to
email@hidden
You can reach the person managing the list at
email@hidden
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Darwin-kernel digest..."
Today's Topics:
1. Building 10.6 kernel? (Duane Murphy)
2. Re: Building 10.6 kernel? (Duane Murphy)
3. Re: remote debugging with gdb on 10.6.2 (Brian Bechtel)
4. Re: Building 10.6 kernel? (Stacey Son)
5. Re: Building 10.6 kernel? (Chris Simpson)
6. Re: Building 10.6 kernel? (Shantonu Sen)
7. Re: Kernel stack size and kernel memory debugger (Michael Smith)
8. Re: Kernel stack size and kernel memory debugger
(Michael Crawford)
9. Re: Kernel stack size and kernel memory debugger (mogambo)
10. Re: Kernel stack size and kernel memory debugger (Andrew Myrick)
----------------------------------------------------------------------
Message: 1
Date: Tue, 24 Nov 2009 15:51:11 -0800
From: Duane Murphy <email@hidden>
Subject: Building 10.6 kernel?
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
I am correct in assuming that the 10.6 kernel cannot be built
(publicly) at this point? Seems like there are several pieces missing
or at least not obvious where to find those pieces.
References to instructions for building the 10.6 kernel would be
great. (http://developer.apple.com/mac/library/documentation/Darwin/Conceptual/KernelProgramming/build/build.html
doesn't work by the way. :-))
Thanks,
...Duane
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.10.0 (Build 500)
Charset: US-ASCII
wsBVAwUBSwxxdUrg9acQ4r2CAQjPgggApkPrHThcJMBd0xblkw672qcfTKXvzP4J
j6SdXEeUH0Nz+9DKvI1EUZ/9iYDHE83gsLVs7kLD3LfPKbIwdqrTQCf8mmmp7024
Klhkue6u1YafAV0ShuzXlIF4/tI1FIyvQTgMz6+BNI1BqvEk5R+bHjfk8M13gJ4+
UWyoSGSTgUoRYLEGIlvg27gw82243xxyTOmBacQWp9D+Yrjl4L6S9WZbf8hEoHmH
t+g9igpTzcralIQVSPx/YXxOPdqs9rD5kAZ6NxwE3mke8JD0gSIAKHkwKGtWpW/A
8m91WtOugm+pQRFi2JGWZ9NsGnsBHlvTtwmsO73ZviHC1rjFWfAf/Q==
=R5Mp
-----END PGP SIGNATURE-----
------------------------------
Message: 2
Date: Tue, 24 Nov 2009 16:04:15 -0800
From: Duane Murphy <email@hidden>
Subject: Re: Building 10.6 kernel?
To: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=US-ASCII
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
darwinbuild to the rescue. :-)
On Nov 24, 2009, at 3:51 PM, Duane Murphy wrote:
> Am I correct in assuming that the 10.6 kernel cannot be built
> (publicly) at this point? Seems like there are several pieces
> missing or at least not obvious where to find those pieces.
>
> References to instructions for building the 10.6 kernel would be
> great. (http://developer.apple.com/mac/library/documentation/Darwin/Conceptual/KernelProgramming/build/build.html
> doesn't work by the way. :-))
...Duane
-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.10.0 (Build 500)
Charset: US-ASCII
wsBVAwUBSwx0hkrg9acQ4r2CAQggXgf/ZdIS5/LulSExO3YOKoaMehW48YF3YbgV
+nfXzHtjdG0TIBRoip0e4Xb6IW4ZOQnefJjc397iF5a8/P9xWrSkEbP6xuQPcbW8
4HXFERdkiG7vv/90V7t6l3bNPDjkqweCXq6raUsu9rM8sxwH3DVMSl6dC4BLwbpD
DsyzOozBUaeHMBqwfYvuCKHhwyeij1LiaH58rt9SkjG4rLxeYJSN5/0uDB6/cjo0
FuPXOhbag48cE8uJ+moLkXREzA/z0vxCLaiHEf8fZiHRNS9c1nFkgFSlRc5xgI6D
26x/Khk50fYmI5Ho2y5FvjK7XX2erHpZw/tZl27n91jM4iepVhy0Bw==
=mPEq
-----END PGP SIGNATURE-----
------------------------------
Message: 3
Date: Tue, 24 Nov 2009 17:10:21 -0800
From: Brian Bechtel <email@hidden>
Subject: Re: remote debugging with gdb on 10.6.2
To: mogambo <email@hidden>
Cc: email@hidden
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=ISO-8859-1
On Mon, Nov 23, 2009 at 10:19 PM, mogambo <email@hidden> wrote:
> Thanks, Brian. I made some progress, but I am still having problems.
> I tried boot-args 0x144 (although with boot-args 0xd44 I did have _panicd_ip
> set as welll). The most important I was misisng was NMI the machine with
> power button. I had used remote debugging with freebsd in my previous job.
> I don't remember having to do anything special like that.
> I am debugging a file system driver, which I am able to load successfully.
> I created symbols at kextload time and copied to the debugger machine
> earlier. I used -arch x86_64 as the debugger and debugee are both running
> 64-bit 10.6. I was able to connect to the debugee in the gdb. With
> add-symbol-file, I added the kext symbols, but get warnings:
> Reading symbols from /path/to/com.company.kext.fsd.sym...
> warning: .o file "/path/to/object.o" more recent than executable timestamp
> in "/path/to/com.company.kext.fsd.sym
> warning: Could not open OSO file /path/to/object.o to scan for pubtypes for
> objfile /path/to/com.company.kext.fsd.sym
> :
> done.
> I was able to set a breakpoint in my kext and apparently hit it too as
> expected. However, I cannot single-step through the kext code - I get an
> error saying something like "no symbol information for this line was found;
> continuing to the end of the function". At the point where I hit the trap
> fault, I am unable print any arguments to the function, or locals.
> I am sure what I intend to do is not an uncommon use of remote debugging.
> What am I doing wrong?
Are you following the guidelines at
<http://developer.apple.com/mac/library/documentation/DeviceDrivers/Conceptual/WritingDeviceDriver/DebuggingDrivers/DebuggingDrivers.html>
?
In Leopard and later, kextutil was split into two parts. You want to
do the following:
{ build your kext }
cd build/Development
{ in here you would have the kext and kext.dSYM bundles }
kextutil -z -n -s . -- ./fsd.kext
{ it will prompt you for the kext load address. You can get that from
"showallkmods" in gdb }
inside gdb, use add-kext
(gdb) add-kext ./fsd.kext
This should give you source lines and locals if you compiled & linked
everything correctly.
Good luck.
------------------------------
Message: 4
Date: Tue, 24 Nov 2009 20:27:02 -0600
From: Stacey Son <email@hidden>
Subject: Re: Building 10.6 kernel?
To: Duane Murphy <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset="us-ascii"
On Nov 24, 2009, at 5:51 PM, Duane Murphy wrote:
> I am correct in assuming that the 10.6 kernel cannot be built
> (publicly) at this point? Seems like there are several pieces missing
> or at least not obvious where to find those pieces.
>
> References to instructions for building the 10.6 kernel would be
> great. (http://developer.apple.com/mac/library/documentation/Darwin/Conceptual/KernelProgramming/build/build.html
> doesn't work by the way. :-))
see http://shantonu.blogspot.com/2009/09/mac-os-x-kernel-source-xnu-has-been.html
Best Regards,
-stacey.
----
Stacey Son
email@hidden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/darwin-kernel/attachments/20091124/383974cf/attachment.html
------------------------------
Message: 5
Date: Tue, 24 Nov 2009 22:58:49 -0500
From: Chris Simpson <email@hidden>
Subject: Re: Building 10.6 kernel?
To: Stacey Son <email@hidden>
Cc: email@hidden
Message-ID:
<email@hidden>
Content-Type: text/plain; charset="iso-8859-1"
Darwinbuild works, and only just a few days ago kext_tool was updated which
yeilds a somewhat better working kernel. For some reason the build tools
are still missing linking libraries and the resulting kernels take a while
to boot.
On Tue, Nov 24, 2009 at 9:27 PM, Stacey Son <email@hidden> wrote:
>
> On Nov 24, 2009, at 5:51 PM, Duane Murphy wrote:
>
> I am correct in assuming that the 10.6 kernel cannot be built
> (publicly) at this point? Seems like there are several pieces missing
> or at least not obvious where to find those pieces.
>
> References to instructions for building the 10.6 kernel would be
> great. (
> http://developer.apple.com/mac/library/documentation/Darwin/Conceptual/KernelProgramming/build/build.html
> doesn't work by the way. :-))
>
>
> see
> http://shantonu.blogspot.com/2009/09/mac-os-x-kernel-source-xnu-has-been.html
>
> Best Regards,
>
> -stacey.
>
> ----
> Stacey Son
> email@hidden
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/darwin-kernel/attachments/20091124/c4dc6304/attachment.html
------------------------------
Message: 6
Date: Tue, 24 Nov 2009 20:04:15 -0800
From: Shantonu Sen <email@hidden>
Subject: Re: Building 10.6 kernel?
To: Chris Simpson <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset="us-ascii"
Try:
$ sudo mkdir -p /System/Library/Extensions.disabled
$ sudo mv /System/Library/Extensions/AppleProfileFamily.kext /System/Library/Extensions.disabled/
$ sudo mv /System/Library/Extensions/CHUD*.kext /System/Library/Extensions.disabled/
$ sudo touch /System/Library/Extensions
$ sudo shutdown -r now
Shantonu
Sent from my MacBook
On Nov 24, 2009, at 7:58 PM, Chris Simpson wrote:
> Darwinbuild works, and only just a few days ago kext_tool was updated which yeilds a somewhat better working kernel. For some reason the build tools are still missing linking libraries and the resulting kernels take a while to boot.
>
> On Tue, Nov 24, 2009 at 9:27 PM, Stacey Son <email@hidden> wrote:
>
> On Nov 24, 2009, at 5:51 PM, Duane Murphy wrote:
>> I am correct in assuming that the 10.6 kernel cannot be built
>> (publicly) at this point? Seems like there are several pieces missing
>> or at least not obvious where to find those pieces.
>>
>> References to instructions for building the 10.6 kernel would be
>> great. (http://developer.apple.com/mac/library/documentation/Darwin/Conceptual/KernelProgramming/build/build.html
>> doesn't work by the way. :-))
>
> see http://shantonu.blogspot.com/2009/09/mac-os-x-kernel-source-xnu-has-been.html
>
> Best Regards,
>
> -stacey.
>
> ----
> Stacey Son
> email@hidden
>
>
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/darwin-kernel/attachments/20091124/e4744273/attachment.html
------------------------------
Message: 7
Date: Wed, 25 Nov 2009 18:53:43 +1100
From: Michael Smith <email@hidden>
Subject: Re: Kernel stack size and kernel memory debugger
To: mogambo <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset=us-ascii
On Nov 24, 2009, at 6:11 PM, mogambo wrote:
> I am debugging a couple of issues with a filesystem driver kext on 64-bit 10.6. One of them looks like stack corruption. A pointer to an array of two ints on stack in fnA() is passed to a fnB(). When fnB() tries writing to it, it gets a kernel trap. Looking at the address of the passed in array in fnB() reveals that it is corrupt. If I compare the esp between frame 0 and frame 20 in the kernel coredump, the difference is about 6400 bytes. I do not think the kernel stack will be smaller than that, but in general, is there an easy way to check kernel stack size?
You've confused two things here; corrupting your stack, and running off the stack. Totally different issues.
If you run out of stack, you'll take a trap on the guard page that's below the stack. Not at all related to running off an array boundary or dereferencing a bad pointer into the stack and corrupting your array.
= Mike
------------------------------
Message: 8
Date: Wed, 25 Nov 2009 00:39:18 -0800
From: Michael Crawford <email@hidden>
Subject: Re: Kernel stack size and kernel memory debugger
To: email@hidden
Message-ID:
<email@hidden>
Content-Type: text/plain; charset=ISO-8859-1
Make sure that the AMD64 ABI Red Zone is disabled. I found that it
wasn't in my 64-bit build, even though it is documented to be set when
-mkernel is enabled.
Just try rebuilding your kext with -mno-red-zone
I filed a bug with Apple, and got a really snarky reply telling me
that Xcode was working as designed, and that there was no bug. This
gentleman closed the bug without even investigating. But in my
experience the bug persisted, and I had to use -mno-red-zone even
though I shouldn't have had to.
The AMD64 Red Zone is a 128-byte area below the stack pointer that may
not be touched by signal or interrupt handlers. It gives leaf
functions some local storage without the runtime and code size of
decrementing the stack pointer. (Yes, Really.) While a really scary
optimization, it works well provided everyone agrees to either respect
it, or not use it at all if it's not respected.
The Snow Leopard 64-bit kernel doesn't respect the Red Zone, so you
have to disable it in your build. That snarky engineer told me that
it was disabled in *my* build, but it clearly wasn't until I added
-mno-red-zone.
(The Linux kernel doesn't respect it either.)
Mike
--
Michael David Crawford
mdcrawford at gmail dot com
GoingWare's Bag of Programming Tricks
http://www.goingware.com/tips/
------------------------------
Message: 9
Date: Wed, 25 Nov 2009 09:31:22 -0800
From: mogambo <email@hidden>
Subject: Re: Kernel stack size and kernel memory debugger
To: email@hidden
Message-ID:
<email@hidden>
Content-Type: text/plain; charset="iso-8859-1"
Yes, I understand that stack overflow and corruption are different issues.
I still want to know the stack size on 64-bit 10.6 and an easy way to check
it in general. Looking at vm_param.h, it is 16KB.
On Tue, Nov 24, 2009 at 11:53 PM, Michael Smith <email@hidden> wrote:
>
> On Nov 24, 2009, at 6:11 PM, mogambo wrote:
>
> > I am debugging a couple of issues with a filesystem driver kext on 64-bit
> 10.6. One of them looks like stack corruption. A pointer to an array of
> two ints on stack in fnA() is passed to a fnB(). When fnB() tries writing
> to it, it gets a kernel trap. Looking at the address of the passed in array
> in fnB() reveals that it is corrupt. If I compare the esp between frame 0
> and frame 20 in the kernel coredump, the difference is about 6400 bytes. I
> do not think the kernel stack will be smaller than that, but in general, is
> there an easy way to check kernel stack size?
>
> You've confused two things here; corrupting your stack, and running off the
> stack. Totally different issues.
>
> If you run out of stack, you'll take a trap on the guard page that's below
> the stack. Not at all related to running off an array boundary or
> dereferencing a bad pointer into the stack and corrupting your array.
>
> = Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/darwin-kernel/attachments/20091125/27eebb7b/attachment.html
------------------------------
Message: 10
Date: Wed, 25 Nov 2009 09:55:41 -0800
From: Andrew Myrick <email@hidden>
Subject: Re: Kernel stack size and kernel memory debugger
To: mogambo <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden>
Content-Type: text/plain; charset="us-ascii"
> I am debugging a couple of issues with a filesystem driver kext on 64-bit 10.6. One of them looks like stack corruption. A pointer to an array of two ints on stack in fnA() is passed to a fnB(). When fnB() tries writing to it, it gets a kernel trap. Looking at the address of the passed in array in fnB() reveals that it is corrupt. If I compare the esp between frame 0 and frame 20 in the kernel coredump, the difference is about 6400 bytes. I do not think the kernel stack will be smaller than that, but in general, is there an easy way to check kernel stack size?
I posted this to darwin-drivers about a month ago:
> I believe it's on the order of 4 pages (16KiB). The relevant bits can be found here:
>
> http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/mach/i386/vm_param.h
> http://www.opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/kern/stack.c
>
> And sysctl confirms it:
>
> $ sysctl kern.stack_size
> kern.stack_size: 16384
>
> From the looks of that stack code, it seems you can use the boot arg "kernel_stack_pages" to change the default kernel stack size, but I have to stress that this should be used for development purposes only. The shipping driver _must_ be able to run with a default stack size.
Per Michael Crawford's reply, it may also be worth double-checking that the -mno-red-zone flag is set.
> And, while I am on the subject of corruption, is there a kernel memory debugger in Mac OS/bsd? I have seen this questions being asked on the forum, but did not find any answers.
Are you looking for something other than two-machine debugging with gdb? This is the relevant section of the (somewhat outdated) Kernel Extension Programming Topics.
-Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/darwin-kernel/attachments/20091125/3204e5e5/attachment.html
------------------------------
_______________________________________________
Darwin-kernel mailing list
email@hidden
http://lists.apple.com/mailman/listinfo/darwin-kernel
End of Darwin-kernel Digest, Vol 6, Issue 174
*********************************************
<<winmail.dat>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden