Re: kernel panic on readBytes
Re: kernel panic on readBytes
- Subject: Re: kernel panic on readBytes
- From: "Timur Alperovich" <email@hidden>
- Date: Thu, 10 Apr 2008 11:00:02 -0400
> 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 (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden