Messages in this thread | | | Date | Fri, 6 Oct 2023 16:58:27 -0700 | Subject | Re: [PATCH v2 0/6] x86: Clean up fast syscall return validation | From | "H. Peter Anvin" <> |
| |
On 10/6/23 11:59, H. Peter Anvin wrote: > > Incidentally, it is possible to save one instruction and use only *one* > alternative immediate: > > leaq (%rax,%rax),%rdx > xorq %rax,%rdx > shrq $(63 - LA),%rdx # Yes, 63, not 64 > # ZF=1 if canonical > > This works because if bit [x] is set in the output, then bit [x] and > [x-1] in the input are different (bit [-1] considered to be zero); and > by definition a bit is canonical if and only if all the bits [63:LA] are > identical, thus bits [63:LA+1] in the output must all be zero. >
Yes, I'm a doofus. Bits [63:LA-1] must be identical, so 64 is correct :$)
-hpa
| |