This is an archive of the discontinued LLVM Phabricator instance.

Add vendor identity check for Hygon Dhyana processor in Scudo
ClosedPublic

Authored by fanjinke on May 24 2019, 12:01 AM.

Details

Summary

The Hygon Dhyana processor supports hardware CRC32.

Related link:
https://reviews.llvm.org/D78874

Result of "make check":
Testing Time: 1364.04s

Unsupported Tests:   317
Expected Passes  : 36802
Expected Failures:   161

[100%] Built target check-llvm
[100%] Built target check

Diff Detail

Event Timeline

fanjinke created this revision.May 24 2019, 12:01 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptMay 24 2019, 12:01 AM
Herald added subscribers: llvm-commits, Restricted Project, cfe-commits. · View Herald Transcript

Regarding the Scudo side of the patch: the code has to be able to compile with gcc as well, and not necessarily the latest version.
This won't compile on systems without a signature_HYGON_*.

Hi,

Please help with the patch reveiw.

Hi cryptoad,
@cryptoad IS there anything incorrectly?

fanjinke updated this revision to Diff 250996.Mar 17 2020, 11:15 PM

Results of "make check":

Testing Time: 1153.40s
  Expected Passes    : 36042
  Expected Failures  : 163
  Unsupported Tests  : 340
[100%] Built target check-llvm
Scanning dependencies of target check
[100%] Built target check

The compiler-rt directory can be compiled using gcc.

ChangeLog:
v2:

  • Updated the scudo part of the patch, Thanks Cryptoad!
fanjinke edited reviewers, added: cryptoad; removed: 01alchemist, 4tXJ7f.EditedMar 17 2020, 11:18 PM

Hi Cryptoad,

Thanks for your reminds, and I get the points now. Then updated the scudo part of the patch.
After patch update,compiler-rt can be successfully compiled using gcc.

Thanks again!

Hi cryptoad,

Any suggestions?
fanjinke updated this revision to Diff 259150.Apr 21 2020, 7:34 PM
fanjinke edited the summary of this revision. (Show Details)

1,Update patch base on lastest commit e90fb82f0f760703c14eafbad96c08b6019a2f0f.
2,Format the patch with “git clang-format-6.0 HEAD~1“.

Hey,

clang/lib/Headers/cpuid.h would have to be in its own CL that would have to be sent separately from the Scudo one.
It would have to be reviewed by clang people and likely some tests added.

Once this is done and landed, then the Scudo part can happen.

Thanks!

Hi Cryptoad,

Thank you so much for your comment. I will divide it into two patches according to your suggestion.

Best regards.

craig.topper added inline comments.
compiler-rt/lib/scudo/scudo_utils.cpp
85

What's the rationale for the vendor check here anyway? Why isn't the bit in ecx sufficient?

fanjinke marked an inline comment as done.Apr 27 2020, 3:01 AM
fanjinke added inline comments.
compiler-rt/lib/scudo/scudo_utils.cpp
85

Using the cpuid instruction to get the vendor id will return the ASCII code of the vendor id, which is stored in the ebx,ecx,edx registers.
The ASCII code in the Hygon CPU is "HygonGenuine", the ecx = "eniu".
For better differentiation from other cpus in the future, by following AMD/Intel way, we use full ASCII code to identify Hygon CPU.

craig.topper added inline comments.Apr 27 2020, 9:05 AM
compiler-rt/lib/scudo/scudo_utils.cpp
85

Sorry, my question was about why this was restricted to Intel/AMD in the first place. Why should this code need to be updated every time a new vendor comes along? Why isn’t checking for sse4.2 regardless of vendor sufficient.

fanjinke marked an inline comment as done.Apr 28 2020, 4:31 AM
fanjinke added inline comments.
compiler-rt/lib/scudo/scudo_utils.cpp
85

For this question, original author[1] may be more appropriate to reply.
From CPU specification, Bit20 of CPUID Fn0000_0001_ecx is SSE42 on Intel, AMD, and Hygon CPUs, but we are not sure that this is true for all x86 vendors.

Cryptoad, Any comments?

[1]: https://reviews.llvm.org/D40322

fanjinke updated this revision to Diff 262529.May 6 2020, 8:17 PM
fanjinke retitled this revision from Add support for Hygon Dhyana processor to Add vendor identity check for Hygon Dhyana processor in Scudo.
fanjinke edited the summary of this revision. (Show Details)

Changelog:
v3:
Remove the changes in cpuid.h that have already been committed in [1].

[1]: https://reviews.llvm.org/D78874

A couple of style issues to address.

compiler-rt/lib/scudo/scudo_utils.cpp
66

s/the gcc/gcc/

67
compiler-rt/lib/scudo/standalone/checksum.cpp
34

s/the gcc/gcc

35
fanjinke updated this revision to Diff 262839.May 8 2020, 1:42 AM

Changelog:
v4:
Change the comments to C++ style. Thanks Cryptoad.

cryptoad accepted this revision.May 8 2020, 7:33 AM
This revision is now accepted and ready to land.May 8 2020, 7:33 AM

Hi Cryptoad,

Could you help me to commit the patch? Because I don't have access.

Thanks.

Hi Cryptoad,

Could you help me to commit the patch? Because I don't have access.

Thanks.

Done, thank you!

This revision was automatically updated to reflect the committed changes.

I noticed when I pulled this morning that this seems to have been pushed as a branch to the repo

From https://github.com/llvm/llvm-project

eb7d32e..63a4fdd  master     -> origin/master
  • [new branch] arcpatch-D62368 -> origin/arcpatch-D62368

I noticed when I pulled this morning that this seems to have been pushed as a branch to the repo

From https://github.com/llvm/llvm-project

eb7d32e..63a4fdd  master     -> origin/master
  • [new branch] arcpatch-D62368 -> origin/arcpatch-D62368

Hey Craig, I gave a try to arc land this morning as opposed to my regular git llvm push workflow.
The initial attempt failed at some point so I went back to git llvm push which succeeded (https://github.com/llvm/llvm-project/commit/9959eb918acfd37ce89d4a7082ac9957d3628f16#diff-483266ff26e7d1b17130f1b371c4e62d).
Is there something I have to clean up somewhere for that other branch?

I noticed when I pulled this morning that this seems to have been pushed as a branch to the repo

From https://github.com/llvm/llvm-project

eb7d32e..63a4fdd  master     -> origin/master
  • [new branch] arcpatch-D62368 -> origin/arcpatch-D62368

Hey Craig, I gave a try to arc land this morning as opposed to my regular git llvm push workflow.
The initial attempt failed at some point so I went back to git llvm push which succeeded (https://github.com/llvm/llvm-project/commit/9959eb918acfd37ce89d4a7082ac9957d3628f16#diff-483266ff26e7d1b17130f1b371c4e62d).
Is there something I have to clean up somewhere for that other branch?

I've deleted the branch in the github web interface. I didn't know I could do that.

I've deleted the branch in the github web interface. I didn't know I could do that.

Ok thank you!