This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][hwasan] Support for Intel LAM v6 API
AcceptedPublic

Authored by glider on Aug 23 2022, 6:00 AM.

Details

Summary

Version 6 of Intel LAM kernel patches
(https://lore.kernel.org/all/20220815041803.17954-1-kirill.shutemov@linux.intel.com/)
introduces arch_prctl(ARCH_GET_MAX_TAG_BITS), which (unlike
ARCH_GET_UNTAG_MASK) can be used to determine if the kernel supports pointer tagging.

This patch also refactors InitializeOsSupport(), making it more
readable.

Diff Detail

Event Timeline

glider created this revision.Aug 23 2022, 6:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 6:00 AM
Herald added subscribers: Enna1, dberris. · View Herald Transcript
glider requested review of this revision.Aug 23 2022, 6:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 6:00 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
glider added inline comments.Aug 23 2022, 6:06 AM
compiler-rt/lib/hwasan/hwasan_linux.cpp
144

I actually don't see any point in checking for EINVAL here. Shouldn't we bail out in the case of a different error?

173

As far as I understood, previously the semantics of has_abi was "This platform does not have the tagged ABI".

194

I am not very proud of this construct. On the other hand, building a string on the fly looks excessive, and putting line 195 under #if SANITIZER_ANDROID is too hacky.

202

Do we really need to undef these constants? This is a .cpp file, after all.

vitalybuka accepted this revision.Aug 23 2022, 1:19 PM

Thanks for the patch, I was planing to do that today myself.
I've already updated https://lab.llvm.org/buildbot/#/builders/sanitizer-aarch64-linux-bootstrap-hwasan to LAM_v6 patchset, so you can land the patch without breaking it.

I would recommend to move fixes of preexisted issues and introduction of new functions into a separate patches.

compiler-rt/lib/hwasan/hwasan_linux.cpp
144

do you know why don't have x86_64 of PR_GET_TAGGED_ADDR_CTRL in kernel, seems like it more gereric than ARCH_GET_MAX_TAG_BITS?

144

I actually don't see any point in checking for EINVAL here. Shouldn't we bail out in the case of a different error?

Yes, looks weird

173

As far as I understood, previously the semantics of has_abi was "This platform does not have the tagged ABI".

yes, looks like a typo

202

i don't think so

This revision is now accepted and ready to land.Aug 23 2022, 1:19 PM
vitalybuka added inline comments.Aug 23 2022, 1:20 PM
compiler-rt/lib/hwasan/hwasan_linux.cpp
126

static

150

static

Thanks for the comments, I'll split this patch into a series then.

compiler-rt/lib/hwasan/hwasan_linux.cpp
144

do you know why don't have x86_64 of PR_GET_TAGGED_ADDR_CTRL in kernel, seems like it more gereric than ARCH_GET_MAX_TAG_BITS?

I don't remember for sure. There's some discussion in https://lore.kernel.org/lkml/20210205151631.43511-1-kirill.shutemov@linux.intel.com/T/#u, the second RFC (https://lore.kernel.org/lkml/20220511022751.65540-1-kirill.shutemov@linux.intel.com/) was already using the arch_prctl() interface. The second thread also points out that the original ARM interface wasn't generic enough (with reasons being explained).