This is an archive of the discontinued LLVM Phabricator instance.

[HWAsan] Add hwasan_sys_page_size command option to support 4K/8K/16K/64K page size system
Needs ReviewPublic

Authored by XiaodongLoong on Apr 17 2022, 5:41 AM.

Details

Reviewers
MaskRay
benshi001
Summary

There is a few passes or other code that need to know the page size of the target system in advance.
And due to cross compilation, the page size might be different on host and target system. So we
need to specify the page size of the target system explicitly.

For example, HWAsan has a ring buffer that is a multiple of the page size. HWAsan pass doesnot know
the page size of the target system, but 4K page size is specified by default. As shown in D123910.

Diff Detail

Event Timeline

XiaodongLoong created this revision.Apr 17 2022, 5:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2022, 5:41 AM
Herald added a subscriber: mgorny. · View Herald Transcript
XiaodongLoong requested review of this revision.Apr 17 2022, 5:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 17 2022, 5:41 AM

Delete blank line

Please provide justification for this new config.

XiaodongLoong edited the summary of this revision. (Show Details)Apr 17 2022, 9:09 PM

Please provide justification for this new config.

OK,I add summary information about it. Thank you!

If this is meant to specify the value for the target system, then certainly,
this is still hardcoding some value, that will still not be always right.
I would guess the solution should be to read it from the IR metadata.

MaskRay requested changes to this revision.Apr 18 2022, 2:19 PM

Hard-coded build page size values may work for your system, but generally isn't reliable. For example, AT_PAGESZ was invented for retrieving the run-time value. I don't think the build system should know the page size.

This revision now requires changes to proceed.Apr 18 2022, 2:19 PM

If this is meant to specify the value for the target system, then certainly,
this is still hardcoding some value, that will still not be always right.
I would guess the solution should be to read it from the IR metadata.

I need to do a invetigation on IR metadata. Is there a similar example about it?
Thank you!

Hard-coded build page size values may work for your system, but generally isn't reliable. For example, AT_PAGESZ was invented for retrieving the run-time value. I don't think the build system should know the page size.

Yes, you are right. I'll change this revision.

update revision that doesn't change CMakeLists.txt

XiaodongLoong retitled this revision from Add LLVM_SYS_PAGE_SIZE option to support 4K/8K/16K/64K page size system to [HWAsan] Add hwasan_sys_page_size command option to support 4K/8K/16K/64K page size system.Apr 20 2022, 5:25 AM
XiaodongLoong added a comment.EditedApr 20 2022, 6:01 AM

If this is meant to specify the value for the target system, then certainly,
this is still hardcoding some value, that will still not be always right.

Hard-coded build page size values may work for your system, but generally isn't reliable.

Yes, you are right. It is not reliable. I have no better idea on it by now. I defined a new command option "hwasan-sys-page-size", It can be used as following:

$ clang -fsanitize=hwaddress -mllvm -hwasan-sys-page-size=8k example.c