Re: kernel panic on readBytes
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=yxodzYbF4J5A3TzU4Kh8F+e5kUR5Z4xqvsI+qrQa5GM=; b=dZhvsKTIV1+1yuaN1diHpuqBFrn3Qz1D7Fn8Q/O3XpKrsj4TmugUgI7gLXsT5uEd/EOu2Q50EPb/iW8D3kDHdptCEoInAAeYLZwYD7s8uC/6UA42msh7Kgk1p7JeHzwWDu1lbST2yuk/W71ugvxOIU49f+CRGjSonO8uKBa2uUI= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=XU9Dxj/wpLGJIAao/SiifHW3UJiDuinSUQsCRsEhvS8fMih3UjlTh98mPX/UeKZKZYgxOOA2zhgKcf8C51wRkZ4ryEqZDmVSq6L/V9l9EKCc8iIwH6hDLdtKMjDHQtJxLQ8XQuf4qbVJhM0q6GgcSPacz6GHbfNPK5rOLmPz0GE=
Hey Timur,
Where does the physical address in inStruct->offset come from? getPhysicalSegment()?
The address is passed in from userspace. I wrote a little daemon that simply goes from 0x0 to the highest possible address (I figure that out by getting the maximum amount of ram on the machine through a sysctl call) and pass it to the kernel extension. The kernel then returns a 32-bit hash value for each page. I thought that should work ok, but is it a problem? Timur
Dan
The problem is that kMemoryTypePhysical != kIOMemoryTypePhysical64. The former is a 32-bit I/O physical address. The later is a 64-bit CPU
physical
address.
Right, makes sense. I tried doing what you described and ended up with: Unresolved kernel trap(cpu 1): 0x300 - Data access DAR=0x6572436D00001000 PC=0x00000000000B3E40 Latest crash info for cpu 1: Exception state (sv=0x26c76500) PC=0x000B3E40; MSR=0x00009030; DAR=0x00001000; DSISR=0x00200000; LR=0x000B26A8; R1=0x268F2A20; XCP=0x0000000C (0x300 - Data access) Backtrace: 0x000B2618 0x003622DC 0x26C95310 0x26C949AC 0x0037AA38 0x00377CB8 0x00093E0C 0x0002C1B4 0x00024C88 0x000B2C4C 0x00000000 backtrace terminated - frame not mapped or invalid: 0xBFFFE260
I hate to be the guy who posts code and asks for help, but I'm pretty stuck at this point, as the documentation I could find on this was scarce at best. Anyway, here is what I tried running:
IOOptionBits opt = kIOMemoryTypePhysical64 | kIODirectionOut; struct IOPhysicalRange* range = (IOPhysicalRange*)IOMalloc(sizeof(struct IOPhysicalRange)); range->address = inStruct->offset; range->length = MEM_READ_CHUNK; task_t task; IOLog("calling withoptions\n"); IOSleep(2000); IOMemoryDescriptor* d = IOMemoryDescriptor::withOptions(range, 1, 0, task, opt); IOLog("withoptions ran\n"); IOSleep(5000);
IOFree(range, sizeof(IOPhysicalRange)); if (d == NULL) { IOLog("IO-Init failed on the page %u\n", inStruct->offset); goto End; }
ret = d->prepare(); if (ret != kIOReturnSuccess) { IOLog("IO-Prepare failed on the page %u\n", inStruct->offset); goto End; } char* buf = (char*) IOMalloc(MEM_READ_CHUNK); int copied; IOLog("printing: %d %d %d\n", (int)buf, MEM_READ_CHUNK, inStruct->offset); copied = d->readBytes(0, buf, MEM_READ_CHUNK);
It prints out "calling with options" in the system log but not "withoptions ran". Did I screw up that call as well?
Thank you, Timur
Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
Timur Alperovich