Hi,
In my storport miniport driver I am requesting a WORD alignment by setting ConfigInfo->AlignmentMask = 1.
With this I am expecting that all the physical addresses I get will be WORD aligned, i.e. last bit cleared to 0.
I just happened to check for incoming addresses, and noticed I am actually getting DWORD aligned addresses all the time (last 2 bits as 00b)!
Now of course all DWORD aligned addresses are WORD aligned too, but just curious to know the reason why I am not getting only a WORD aligned address, i.e. address ending with 10b.
Regards,
Suresh
I find to be a very odd question. You’re getting what you asked for, but it hasn’t brought you joy.
Most buffers are DWORD aligned, because the Visual C++ compiler aligns structures and variables to a 4-byte boundary by default, because Intel processors are more efficient with that. You really have to go out of your way to get a non-4-byte aligned buffer. Buffers allocated from the heap are often 32-byte aligned (although it depends on the size of the allocation).
Thanks Tim! Well, I am joyful enough but also skeptical that my code has apparently never been tested with a non-DWORD aligned address being passed to my driver. What if there is a bug lurking during processing of such addresses!
(Of course an alternative would be to change the AlignmentMask to 3 to officially make it DWORD aligned and mask off that possibility.)
I was wondering if there is any way (some tool or some setting) which can give me non-DWORD aligned address.
Regards,
Suresh
You’re getting what you asked for, but it hasn’t brought you joy
Ah, the fate of the world, I’m afraid
P
my code has apparently never been tested with a non-DWORD aligned address being passed to my driver. What if there is a bug lurking during processing of such addresses!
Seriously? You’re worrying about testing a scenario that doesn’t matter. Think about it… what bug would there be in processing word-aligned but not dword-aligned addresses? If you want to make sure your hardware works with such addresses, well… fair enough… just hard-code one and test it yourself. Then you’re done.
Peter
Thanks Peter. Actually one other post here (https://community.osr.com/discussion/291727) spooked me as the OP there is reporting that he is facing an issue with AlignmentMask of WORD but the issue goes away with QWORD.
As I am also using WORD alignment I don’t want to stumble upon something similar, especially in the field.
Thanks for the tip of hard-coding the address. Will try that out.