KMDF calling LoadResource?

All,

I previous posted an issue about not getting resources assigned to a UMDF 2.0 driver. Converting to KMDF fixed this problem. But it created a new one.

The driver I am writing needs to download firmware to a device. This is on Windows 8.1 (obviously, since I am trying to use UMDF 2.0). I was originally hoping to write a UMDF 2.0 driver and use FindResource/LoadResource/LockResource/SizeofResource to load and obtain the size of the firmware, and then download it over I2C.

I searched online for this, and ran into this link: http://www.osronline.com/ShowThread.cfm?link=239932.

The question have is, from the thread discussion, there was strong pushback for embedding firmware into the driver. Arguments for embedded are: reduction of attack surface, and preference to update the driver with new firmware each time the firmware needs to be updated. This is obviously quite easy with UMDF 2.0, but there is that resources issue I am running into.

Whether I can go the UMDF 2.0 route or not later (I am told I should be able to, but I have yet to learn of the technical reason why the usermode version of the driver isn’t receiving resources), I think I should go the ZwOpenFile/ZwReadFile/ZwCloseFile route for now, just to get going.

But long term, if I cannot go to UMDF 2.0 for whatever reason, should I keep using the ZwXxx API or is there another solution that has come around since the posting of that other thread?

Thanks in advance,
ck

Well, const static initialized arrays exist for a reason.

Yes, but I am receiving the firmware as a .bin file, not something I can simply cut and paste. I could write a tool to process this for me, but I was looking for alternatives.

>I could write a tool to process this for me, but I was looking for alternatives.

Writing such a tool is pretty much a one hour exercise. Much simpler than reading a resource from kernel.

> Well, const static initialized arrays exist for a reason.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

The problem is that this binds the .bin code fairly tightly to the
executable binary. It means installing a replacement driver each time the
firmware is updated, at a perceived higher complexity in the build
process, whereas resources are “naturally supported” by the build process,
which may form the basis of the desire to use them. But they are really
only an app-level concept. I would choose to install the .bin file as a
separate file, and just use ZwCreateFile & friends to read the bits. One
nice feature: you can add an IOCTL which provides the name of the file (in
Unicode), making it possible to easily reload firmware during development.
Default, on driver startup sequence, is that once the device is located,
it calls the load function with a default path name. Note that it can’t
use names like C:, which are session specific, and leads to the question
of how to locate %system32%\drivers from the kernel (I don’t know the
answer).
joe

If the bin file is a part of the driver package (ie copied by the inf), you invalidate the signing of the package anytime you update the bin file. So, if touching the FW requires resigning either way, pick the simplest path. If you are going to embed it, consider putting it into a named section and then tell Mm to toss out the section after FW download

d

Bent from my phone


From: xxxxx@flounder.commailto:xxxxx
Sent: ?12/?10/?2013 6:45 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] KMDF calling LoadResource?

> Well, const static initialized arrays exist for a reason.
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
The problem is that this binds the .bin code fairly tightly to the
executable binary. It means installing a replacement driver each time the
firmware is updated, at a perceived higher complexity in the build
process, whereas resources are “naturally supported” by the build process,
which may form the basis of the desire to use them. But they are really
only an app-level concept. I would choose to install the .bin file as a
separate file, and just use ZwCreateFile & friends to read the bits. One
nice feature: you can add an IOCTL which provides the name of the file (in
Unicode), making it possible to easily reload firmware during development.
Default, on driver startup sequence, is that once the device is located,
it calls the load function with a default path name. Note that it can’t
use names like C:, which are session specific, and leads to the question
of how to locate %system32%\drivers from the kernel (I don’t know the
answer).
joe


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

>consider putting it into a named section and then tell Mm to toss out the section after FW download

Just put it in paged data. No need to tell Mm anything. The array could be used later to reload the firmware after hibernation, or for a second instance.

Note that it can’t use names like C:, which are session specific, and leads to the question
of how to locate %system32%\drivers from the kernel (I don’t know the
answer).

??\C: is a global link. The kernel drivers use \SystemRoot, though.

If you need the fw after a low power transition (that wasn’t a clear requirement) so not put it into a pageable section. You want to avoid paging io as much as possible because it will increase your power up time exponentially

d

Bent from my phone


From: xxxxx@broadcom.commailto:xxxxx
Sent: ?12/?10/?2013 7:32 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] KMDF calling LoadResource?

>consider putting it into a named section and then tell Mm to toss out the section after FW download

Just put it in paged data. No need to tell Mm anything. The array could be used later to reload the firmware after hibernation, or for a second instance.

> Note that it can’t use names like C:, which are session specific, and leads to the question
of how to locate %system32%\drivers from the kernel (I don’t know the
answer).

??\C: is a global link. The kernel drivers use \SystemRoot, though.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

>You want to avoid paging io as much as possible because it will increase your power up time exponentially

The OP is uploading the firmware through I2C, which is “exponentially” slower than paging I/O.

Not compared to paging io off of the SD card

d

Bent from my phone


From: xxxxx@broadcom.commailto:xxxxx
Sent: ?12/?10/?2013 8:10 PM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: RE:[ntdev] KMDF calling LoadResource?

>You want to avoid paging io as much as possible because it will increase your power up time exponentially

The OP is uploading the firmware through I2C, which is “exponentially” slower than paging I/O.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

The driver signing issue which was raised is something that emerged after
I stopped working on drivers. What it basically says is that there is no
advantage to using resources over embedding the code in the driver.

However, a UMDF driver would need to retain an open instance handle to the
executable to use FindResource/LoadResource sequences. But AFAIK, drivers
do not get instance handles, so there is no built-in way to simply request
the resources in the same way you ask for app resources. What you would
have to do is LoadLibrary on the .sys file that constitutes your driver,
using the flag that causes it to only load the resources without trying to
load code or resolve pending imports required. The module is not callable
because it has unresolved external links, but the instance handle you get
can be used to access the resources. I do not know enough about the UMDF
operating environment to know if GetModuleName(NULL, …) will actually
return the name of the .sys file, but that is certainly what I would try
first to see if it produces a valid value. Once you have that, your UMDF
driver might well be able to use the familiar app-level
LoadLibrary/Freelibrary to get or free an instance handle that can be used
to access the executable image’s resources. However, you may be skirting
on the thin edge between “unsupported” and “disaster”. And there would be
no good KMDF equivalents; you would probably be deep into Undocumented
Territory with all that implies if you went after resources from within a
kernel driver.

So, because of the new requirements for signing, particularly on x64,
there does not seem to be any advantage to putting the bits in the
resource segment, since new firmware bits are going to require a new
signed driver anyway. It was not clear to me from the message if the .bin
file is managed in the signature-authentication computation during driver
load; if so, then there is no advantage of using it, because, while the
signing eliminates the attack surface, it only adds gratuitous complexity
to the installer without any significant payback.

The comment about “exponentially slower” does not seem to fit; unless the
page faults go up as a power of the size of the firmware, you can’t have
exponential growth. You can have a massive /linear/ growth; note that
O(n) really means t.setup + C * n + t.teardown, and if C is large (the
“constant of proportionality”) then n can hurt badly. But if your
firmware occupies n pages, and you suffer one page fault for each, you may
never notice any slowdown at boot time/dehibernate time/wakeup time
because the C in the I2C is fairly large, and could easily dominate the C
required to page a new page in every 4096 bytes (and if this is causing
massive slowdowns at boot/etc. time, the problems may be deeper than you
can address, and nothing you can do will make any difference anyway.) I
won’t believe “exponentially slower” unless I am given some data to show
that, for example, the slowdown is O(x^n), for x some constant > 1, and n
is the number of page faults to be processed.

Note that if the .bin file does not have its contents checked against the
digital signature, using the separate file definitely increases the attack
surface to the point where it becomes arguable if security actually exists
at all; if it is included in the signature checking, then it has no
advantage over embedding it in the .sys file as a massively large
pre-initialized data segment declaration in the source code (how large
this is depends on how you expand it; for example, if you expand four
bytes of binary into

…, 0xFF, 0xFE, 0x00, 0x02, …

that is, six source characters per byte, you will have a minimum of 6:1
expansion, but there are more efficient ways to write this
0xfeff, 0x0200.

in a pre-initialized WORD array, which, if I’ve counted correctly,
requires a 4:1 expansion, or as
…, 0x0200feff, …
in a pre-initialized DWORD array, which (IICC) requires a 3:1 expansion.
Some idea of the scale of your firmware might help suggest tradeoffs. Is
it 4KB, 4MB or 4GB, for example?
joe

joe

All,

I previous posted an issue about not getting resources assigned to a UMDF
2.0 driver. Converting to KMDF fixed this problem. But it created a new
one.

The driver I am writing needs to download firmware to a device. This is
on Windows 8.1 (obviously, since I am trying to use UMDF 2.0). I was
originally hoping to write a UMDF 2.0 driver and use
FindResource/LoadResource/LockResource/SizeofResource to load and obtain
the size of the firmware, and then download it over I2C.

I searched online for this, and ran into this link:
http://www.osronline.com/ShowThread.cfm?link=239932.

The question have is, from the thread discussion, there was strong
pushback for embedding firmware into the driver. Arguments for embedded
are: reduction of attack surface, and preference to update the driver with
new firmware each time the firmware needs to be updated. This is
obviously quite easy with UMDF 2.0, but there is that resources issue I am
running into.

Whether I can go the UMDF 2.0 route or not later (I am told I should be
able to, but I have yet to learn of the technical reason why the usermode
version of the driver isn’t receiving resources), I think I should go the
ZwOpenFile/ZwReadFile/ZwCloseFile route for now, just to get going.

But long term, if I cannot go to UMDF 2.0 for whatever reason, should I
keep using the ZwXxx API or is there another solution that has come around
since the posting of that other thread?

Thanks in advance,
ck


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

>Not compared to paging io off of the SD card

I suppose you need somehow to get it to memory, to restart the device. If it’s in a pageable section, there is a chance some pages will still be present (unless pre-hibernation culls all non-dirty unlocked pages, which could makes some sense). If it’s in a file, you will need to read it from that SD, anyway.

> ??\C: is a global link. The kernel drivers use \SystemRoot, though.

Yes, \SystemRoot\system32\drivers will do the job.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

> The problem is that this binds the .bin code fairly tightly to the

executable binary. It means installing a replacement driver each time the
firmware is updated

This is normal. Usually, firmware+driver “go in pair”.

, at a perceived higher complexity in the build process

1 more trivial Python script?

, whereas resources are “naturally supported” by the build process,

They do not naturally supported by the Windows kernel though.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

A umdf driver is a normal dll. As such, DllMain is called and you can capture your HINSTANCE there. There is also a windows API to get you module handle at any time

d

Bent from my phone


From: xxxxx@flounder.commailto:xxxxx
Sent: ?12/?11/?2013 1:20 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: Re: [ntdev] KMDF calling LoadResource?

The driver signing issue which was raised is something that emerged after
I stopped working on drivers. What it basically says is that there is no
advantage to using resources over embedding the code in the driver.

However, a UMDF driver would need to retain an open instance handle to the
executable to use FindResource/LoadResource sequences. But AFAIK, drivers
do not get instance handles, so there is no built-in way to simply request
the resources in the same way you ask for app resources. What you would
have to do is LoadLibrary on the .sys file that constitutes your driver,
using the flag that causes it to only load the resources without trying to
load code or resolve pending imports required. The module is not callable
because it has unresolved external links, but the instance handle you get
can be used to access the resources. I do not know enough about the UMDF
operating environment to know if GetModuleName(NULL, …) will actually
return the name of the .sys file, but that is certainly what I would try
first to see if it produces a valid value. Once you have that, your UMDF
driver might well be able to use the familiar app-level
LoadLibrary/Freelibrary to get or free an instance handle that can be used
to access the executable image’s resources. However, you may be skirting
on the thin edge between “unsupported” and “disaster”. And there would be
no good KMDF equivalents; you would probably be deep into Undocumented
Territory with all that implies if you went after resources from within a
kernel driver.

So, because of the new requirements for signing, particularly on x64,
there does not seem to be any advantage to putting the bits in the
resource segment, since new firmware bits are going to require a new
signed driver anyway. It was not clear to me from the message if the .bin
file is managed in the signature-authentication computation during driver
load; if so, then there is no advantage of using it, because, while the
signing eliminates the attack surface, it only adds gratuitous complexity
to the installer without any significant payback.

The comment about “exponentially slower” does not seem to fit; unless the
page faults go up as a power of the size of the firmware, you can’t have
exponential growth. You can have a massive /linear/ growth; note that
O(n) really means t.setup + C * n + t.teardown, and if C is large (the
“constant of proportionality”) then n can hurt badly. But if your
firmware occupies n pages, and you suffer one page fault for each, you may
never notice any slowdown at boot time/dehibernate time/wakeup time
because the C in the I2C is fairly large, and could easily dominate the C
required to page a new page in every 4096 bytes (and if this is causing
massive slowdowns at boot/etc. time, the problems may be deeper than you
can address, and nothing you can do will make any difference anyway.) I
won’t believe “exponentially slower” unless I am given some data to show
that, for example, the slowdown is O(x^n), for x some constant > 1, and n
is the number of page faults to be processed.

Note that if the .bin file does not have its contents checked against the
digital signature, using the separate file definitely increases the attack
surface to the point where it becomes arguable if security actually exists
at all; if it is included in the signature checking, then it has no
advantage over embedding it in the .sys file as a massively large
pre-initialized data segment declaration in the source code (how large
this is depends on how you expand it; for example, if you expand four
bytes of binary into

…, 0xFF, 0xFE, 0x00, 0x02, …

that is, six source characters per byte, you will have a minimum of 6:1
expansion, but there are more efficient ways to write this
0xfeff, 0x0200.

in a pre-initialized WORD array, which, if I’ve counted correctly,
requires a 4:1 expansion, or as
…, 0x0200feff, …
in a pre-initialized DWORD array, which (IICC) requires a 3:1 expansion.
Some idea of the scale of your firmware might help suggest tradeoffs. Is
it 4KB, 4MB or 4GB, for example?
joe

joe

> All,
>
> I previous posted an issue about not getting resources assigned to a UMDF
> 2.0 driver. Converting to KMDF fixed this problem. But it created a new
> one.
>
> The driver I am writing needs to download firmware to a device. This is
> on Windows 8.1 (obviously, since I am trying to use UMDF 2.0). I was
> originally hoping to write a UMDF 2.0 driver and use
> FindResource/LoadResource/LockResource/SizeofResource to load and obtain
> the size of the firmware, and then download it over I2C.
>
> I searched online for this, and ran into this link:
> http://www.osronline.com/ShowThread.cfm?link=239932.
>
> The question have is, from the thread discussion, there was strong
> pushback for embedding firmware into the driver. Arguments for embedded
> are: reduction of attack surface, and preference to update the driver with
> new firmware each time the firmware needs to be updated. This is
> obviously quite easy with UMDF 2.0, but there is that resources issue I am
> running into.
>
> Whether I can go the UMDF 2.0 route or not later (I am told I should be
> able to, but I have yet to learn of the technical reason why the usermode
> version of the driver isn’t receiving resources), I think I should go the
> ZwOpenFile/ZwReadFile/ZwCloseFile route for now, just to get going.
>
> But long term, if I cannot go to UMDF 2.0 for whatever reason, should I
> keep using the ZwXxx API or is there another solution that has come around
> since the posting of that other thread?
>
> Thanks in advance,
> ck
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx>

On 11-Dec-2013 05:31, xxxxx@broadcom.com wrote:

Just put it in paged data. No need to tell Mm anything. The array could be used later to reload the firmware after hibernation, or for a second instance.

You may need to lock the firmware in memory if the update runs at
dispatch or the device pulls it via DMA. So a separate section can be handy.
Otherwise, embedding firmware into kernel drivers and file i/o is not
banned for us, as in the other OS.
– pa

Or one could simply use the __ImageBase linker-defined symbolhttp:.

- S

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Wednesday, December 11, 2013 8:52 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF calling LoadResource?

A umdf driver is a normal dll. As such, DllMain is called and you can capture your HINSTANCE there. There is also a windows API to get you module handle at any time

d

Bent from my phone
________________________________
From: xxxxx@flounder.commailto:xxxxx
Sent: ?12/?11/?2013 1:20 AM
To: Windows System Software Devs Interest Listmailto:xxxxx
Subject: Re: [ntdev] KMDF calling LoadResource?

The driver signing issue which was raised is something that emerged after
I stopped working on drivers. What it basically says is that there is no
advantage to using resources over embedding the code in the driver.

However, a UMDF driver would need to retain an open instance handle to the
executable to use FindResource/LoadResource sequences. But AFAIK, drivers
do not get instance handles, so there is no built-in way to simply request
the resources in the same way you ask for app resources. What you would
have to do is LoadLibrary on the .sys file that constitutes your driver,
using the flag that causes it to only load the resources without trying to
load code or resolve pending imports required. The module is not callable
because it has unresolved external links, but the instance handle you get
can be used to access the resources. I do not know enough about the UMDF
operating environment to know if GetModuleName(NULL, …) will actually
return the name of the .sys file, but that is certainly what I would try
first to see if it produces a valid value. Once you have that, your UMDF
driver might well be able to use the familiar app-level
LoadLibrary/Freelibrary to get or free an instance handle that can be used
to access the executable image’s resources. However, you may be skirting
on the thin edge between “unsupported” and “disaster”. And there would be
no good KMDF equivalents; you would probably be deep into Undocumented
Territory with all that implies if you went after resources from within a
kernel driver.

So, because of the new requirements for signing, particularly on x64,
there does not seem to be any advantage to putting the bits in the
resource segment, since new firmware bits are going to require a new
signed driver anyway. It was not clear to me from the message if the .bin
file is managed in the signature-authentication computation during driver
load; if so, then there is no advantage of using it, because, while the
signing eliminates the attack surface, it only adds gratuitous complexity
to the installer without any significant payback.

The comment about “exponentially slower” does not seem to fit; unless the
page faults go up as a power of the size of the firmware, you can’t have
exponential growth. You can have a massive /linear/ growth; note that
O(n) really means t.setup + C * n + t.teardown, and if C is large (the
“constant of proportionality”) then n can hurt badly. But if your
firmware occupies n pages, and you suffer one page fault for each, you may
never notice any slowdown at boot time/dehibernate time/wakeup time
because the C in the I2C is fairly large, and could easily dominate the C
required to page a new page in every 4096 bytes (and if this is causing
massive slowdowns at boot/etc. time, the problems may be deeper than you
can address, and nothing you can do will make any difference anyway.) I
won’t believe “exponentially slower” unless I am given some data to show
that, for example, the slowdown is O(x^n), for x some constant > 1, and n
is the number of page faults to be processed.

Note that if the .bin file does not have its contents checked against the
digital signature, using the separate file definitely increases the attack
surface to the point where it becomes arguable if security actually exists
at all; if it is included in the signature checking, then it has no
advantage over embedding it in the .sys file as a massively large
pre-initialized data segment declaration in the source code (how large
this is depends on how you expand it; for example, if you expand four
bytes of binary into

…, 0xFF, 0xFE, 0x00, 0x02, …

that is, six source characters per byte, you will have a minimum of 6:1
expansion, but there are more efficient ways to write this
0xfeff, 0x0200.

in a pre-initialized WORD array, which, if I’ve counted correctly,
requires a 4:1 expansion, or as
…, 0x0200feff, …
in a pre-initialized DWORD array, which (IICC) requires a 3:1 expansion.
Some idea of the scale of your firmware might help suggest tradeoffs. Is
it 4KB, 4MB or 4GB, for example?
joe

joe

> All,
>
> I previous posted an issue about not getting resources assigned to a UMDF
> 2.0 driver. Converting to KMDF fixed this problem. But it created a new
> one.
>
> The driver I am writing needs to download firmware to a device. This is
> on Windows 8.1 (obviously, since I am trying to use UMDF 2.0). I was
> originally hoping to write a UMDF 2.0 driver and use
> FindResource/LoadResource/LockResource/SizeofResource to load and obtain
> the size of the firmware, and then download it over I2C.
>
> I searched online for this, and ran into this link:
> http://www.osronline.com/ShowThread.cfm?link=239932.
>
> The question have is, from the thread discussion, there was strong
> pushback for embedding firmware into the driver. Arguments for embedded
> are: reduction of attack surface, and preference to update the driver with
> new firmware each time the firmware needs to be updated. This is
> obviously quite easy with UMDF 2.0, but there is that resources issue I am
> running into.
>
> Whether I can go the UMDF 2.0 route or not later (I am told I should be
> able to, but I have yet to learn of the technical reason why the usermode
> version of the driver isn’t receiving resources), I think I should go the
> ZwOpenFile/ZwReadFile/ZwCloseFile route for now, just to get going.
>
> But long term, if I cannot go to UMDF 2.0 for whatever reason, should I
> keep using the ZwXxx API or is there another solution that has come around
> since the posting of that other thread?
>
> Thanks in advance,
> ck
>
>
>
> —
> NTDEV is sponsored by OSR
>
> Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev
>
> OSR is HIRING!! See http://www.osr.com/careers
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</mailto:xxxxx></mailto:xxxxx></http:>

Which emphasizes that there are two issues here

(a) making the bits available
(b) using the bits once you have them

Then there is a third issue in modern systems:
(c) guaranteeing the bits are the Right Bits (signed driver issues)

There are many potential solutions in this space, and the consensus seem
to be saying that using resources is going to have problems in achieving
(a), which makes (b) a secondary problem.

Putting the bits in the executable image seems to make (a) trivial, and as
a side effect also solves (c). Fine points, such as putting it in a named
segment, making that segment constant and shared, etc. are fine points
whose solution depends on what is being optimized, such as nonpaged
footprint, page faults, costs of wakeup, dehibernation, and others do
exist, but a large set of solutions that solve (a) and (b) do exist, each
one of which has engineering tradeoffs. But using resources does not seem
to be in the set of visble options.
joe

On 11-Dec-2013 05:31, xxxxx@broadcom.com wrote:
>
> Just put it in paged data. No need to tell Mm anything. The array could
> be used later to reload the firmware after hibernation, or for a second
> instance.

You may need to lock the firmware in memory if the update runs at
dispatch or the device pulls it via DMA. So a separate section can be
handy.
Otherwise, embedding firmware into kernel drivers and file i/o is not
banned for us, as in the other OS.
– pa


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

We seem to be discussing a fine point of optimization here. What does it
matter? A LoadResource is going to take a couple accesses of the device
on which the resource is stored; it has to read the resource segment in,
search the segment for the correct resource, and make it available. I
would be very surprised if this were somehow faster than a page-in
operation. Resources remain on secondary storage until found, loaded, and
locked. So ignoring the fact that there is no kernel support for this, we
seem to be concerned only about pageable vs. nonpageable, a decision which
has to be based on a lot of performance parameters unstated by the OP,
such as the number of bytes, the memory footprint in nonpaged pool, the
total amount of physical memory on the system, the overall paging behavior
of the system, the impact of pageable vs. nonpageable memory on the
overall system performance, just to name a few highlights. So until the
impact of the page-in cost vs. the nonpaged cost is assessed in the
context of the running system, it is probably going to be hard to make
specific implementation tradeoffs. For example, compared to the overall
unhibernation cost, is one or even a small integer number of page-in
operations even going to matter? Given the device has been turned off for
some lengthy period of time, how many milliseconds delay is going to
matter on an unhibernation?

It’s all about the numbers. And WE have none of the numbers required to
make a sound decision, or even a recommendation.
joe

>Not compared to paging io off of the SD card

I suppose you need somehow to get it to memory, to restart the device. If
it’s in a pageable section, there is a chance some pages will still be
present (unless pre-hibernation culls all non-dirty unlocked pages, which
could makes some sense). If it’s in a file, you will need to read it from
that SD, anyway.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer