views:

282

answers:

1

The main motivation: to use the movntdqa assembler command to avoid stack pollution. This command only works with write combining memory (also called WS and USWC)

+1  A: 

Pass PAGE_WRITECOMBINE to VirtualAllocEx(). Sequential writes to that page will be write-combined by the MMU. Reads or nonsequential writes will induce a severe performance penalty.

Crashworks
i tried it:char *ans=(char * ) VirtualAllocEx (hProcess, 0,1024*1024*64, MEM_COMMIT, PAGE_READWRITE| PAGE_WRITECOMBINE); it always returns 0 with GetLastError=87when replaceing PAGE_WRITECOMBINE with PAGE_NOCACHE, it does work and indeed memory access is very slow. but i need write combining so that movntdqa works as advertised.
yigal
Hmm. Try creating the page and then changing its permissions after the fact with VirtualProtectEx() ?
Crashworks
does not work either, the code below still returns 87unsigned long old;err=VirtualProtectEx(hProcess,ans,size,PAGE_READWRITE|PAGE_WRITECOMBINE,
yigal
Gosh, I'm stumped. It seems like your version of the Windows kernel isn't aware of write combined memory and rejects the parameter (that error code is "invalid parameter").
Crashworks
i tested using XP Professional with SP3, and vista home edition.
yigal
tested using vista 64 bits, sp1, and it works! thanks!
yigal