Skip to content
代码片段 群组 项目
提交 3c9f3b69 编辑于 作者: Mathias Krause's avatar Mathias Krause 提交者: Jason A. Donenfeld
浏览文件

crypto: curve25519-x86_64: solve register constraints with reserved registers


The register constraints for the inline assembly in fsqr() and fsqr2()
are pretty tight on what the compiler may assign to the remaining three
register variables. The clobber list only allows the following to be
used: RDI, RSI, RBP and R12. With RAP reserving R12 and a kernel having
CONFIG_FRAME_POINTER=y, claiming RBP, there are only two registers left
so the compiler rightfully complains about impossible constraints.

Provide alternatives that'll allow a memory reference for 'out' to solve
the allocation constraint dilemma for this configuration.

Also make 'out' an input-only operand as it is only used as such. This
not only allows gcc to optimize its usage further, but also works around
older gcc versions, apparently failing to handle multiple alternatives
correctly, as in failing to initialize the 'out' operand with its input
value.

Signed-off-by: default avatarMathias Krause <minipli@grsecurity.net>
Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
上级 8e40dd62
No related branches found
No related tags found
无相关合并请求
...@@ -581,8 +581,8 @@ static inline void fsqr(u64 *out, const u64 *f, u64 *tmp) ...@@ -581,8 +581,8 @@ static inline void fsqr(u64 *out, const u64 *f, u64 *tmp)
" cmovc %%rdx, %%rax;" " cmovc %%rdx, %%rax;"
" add %%rax, %%r8;" " add %%rax, %%r8;"
" movq %%r8, 0(%0);" " movq %%r8, 0(%0);"
: "+&r" (tmp), "+&r" (f), "+&r" (out) : "+&r,&r" (tmp), "+&r,&r" (f)
: : "r,m" (out)
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc" : "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc"
); );
} }
...@@ -743,8 +743,8 @@ static inline void fsqr2(u64 *out, const u64 *f, u64 *tmp) ...@@ -743,8 +743,8 @@ static inline void fsqr2(u64 *out, const u64 *f, u64 *tmp)
" cmovc %%rdx, %%rax;" " cmovc %%rdx, %%rax;"
" add %%rax, %%r8;" " add %%rax, %%r8;"
" movq %%r8, 32(%0);" " movq %%r8, 32(%0);"
: "+&r" (tmp), "+&r" (f), "+&r" (out) : "+&r,&r" (tmp), "+&r,&r" (f)
: : "r,m" (out)
: "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc" : "%rax", "%rcx", "%rdx", "%r8", "%r9", "%r10", "%r11", "%rbx", "%r13", "%r14", "%r15", "memory", "cc"
); );
} }
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册