-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add separate ASM file for XGETBV64 and CPUID64 (GH #1240)
This will allow us to define CRYPTOPP_DISABLE_ASM and completely avoid building x64dll.asm and x64masm.asm
- Loading branch information
Showing
5 changed files
with
131 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
;; https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention | ||
;; The first four integer arguments are passed in registers. | ||
;; Integer values are passed in left-to-right order in RCX, | ||
;; RDX, R8, and R9, respectively. Arguments five and higher | ||
;; are passed on the stack. | ||
|
||
;; The registers RAX, RCX, RDX, R8, R9, R10, R11, XMM0-5, | ||
;; and the upper portions of YMM0-15 and ZMM0-15 are | ||
;; considered volatile and must be considered destroyed on | ||
;; function calls. | ||
|
||
.CODE | ||
|
||
TITLE CPU features source file | ||
SUBTITLE Microsoft specific ASM code to utilize CPUID and XGETBV64 for down level Microsoft toolchains | ||
|
||
;; http://www.agner.org/optimize/vectorclass/read.php?i=65 | ||
;; word64 Xgetbv(word32 ctrl) | ||
;; ctrl = rcx | ||
|
||
ALIGN 8 | ||
XGETBV64 PROC FRAME | ||
.endprolog | ||
;; query | ||
DB 0fh, 01h, 0d0h | ||
;; xcr = (EDX << 32) | EAX | ||
and rax, 0ffffffffh | ||
shl rdx, 32 | ||
or rax, rdx | ||
ret | ||
XGETBV64 ENDP | ||
|
||
;; word64 CpuId(word32 func, word32 subfunc, word32 output[4]) | ||
;; func = rcx | ||
;; subfunc = rdx | ||
;; output = r8 | ||
|
||
ALIGN 8 | ||
CPUID64 PROC FRAME | ||
;; preserve per ABI | ||
mov [rsp+8], rbx | ||
.savereg rbx, 8 | ||
.endprolog | ||
;; eax = func | ||
mov rax, rcx | ||
;; ecx = subfunc | ||
mov rcx, rdx | ||
;; query | ||
cpuid | ||
;; save | ||
mov [r8+0], eax | ||
mov [r8+4], ebx | ||
mov [r8+8], ecx | ||
mov [r8+12], edx | ||
;; return value | ||
mov rax, 1 | ||
;; restore | ||
mov rbx, [rsp+8] | ||
ret | ||
CPUID64 ENDP | ||
|
||
_TEXT ENDS | ||
END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0432085
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good patch! But you forgot to change the files
cryptdll.vcxproj
andcryptdll.vcxproj.filters
as well.0432085
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OgreTransporter,
That should be cleared at Commit 1e20219ecddc.
The DLL project is scheduled to go away. You should start thinking about an alternative. Also see https://www.cryptopp.com/wiki/Wrapper_DLL.
0432085
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! It's no problem for me. I link the static library. Perhaps one should then delete the DLL project to avoid misunderstandings.
But wouldn't it perhaps make sense to replace the various VS project files and Makefiles with something like CMake? Then you only have to maintain one file.
0432085
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good.
Yeah, that's been marked as deprecated for several years. We want to ensure folks have plenty of time to move away from it. See FIPS DLL deprecation in https://www.cryptopp.com/release800.html and friends.
We tried to support CMake around Crypto++ 5.6.3. We had to remove the support around Crypto++ 6.0. There were too many problems with CMake, and it accounted for something like 23% of our bug reports. We did not have enough tribal knowledge or manpower to work the bugs. We consider it a failed experiment.
If CMake ever gets stable, then we may revisit it.
A CMake set of build files is available from Abdessattar Sassi (@abdes) at https://github.com/abdes/cryptopp-cmake. God bless him.