MOVDQU instruction + page boundary

后端 未结 2 1761
臣服心动
臣服心动 2021-01-17 16:48

I have a simple test program that loads an xmm register with the movdqu instruction accessing data across a page boundary (OS = Linux).

If the following page is mapp

2条回答
  •  醉梦人生
    2021-01-17 17:00

    Facing a similar problem with a library I was writing, I got some information from a very helpful contributor.

    The core of the idea is to align the 16-byte reads to the end of the string, then handle the leftover bytes at the beginning. This works because the end of the string must live in an accessible page, and you are guaranteed that the 16-byte truncated starting address must also live in an accessible page.

    Since we never read past the string we cannot potentially stray into a protected page.

    To handle the initial set of bytes, I chose to use the PCMPxSTRM functions, which return the bitmask of matching bytes. Then it's simply a matter of shifting the result to ignore any mask bits that occur before the true beginning of the string.

提交回复
热议问题