[7/11] patch series to port HWASAN for riscv64
Depends On D131343
Differential D132994
[RISC-V][HWASAN] Don't explicitly load GOT entry to call hwasan mismatch routine smd on Aug 30 2022, 11:18 PM. Authored by
Details
Diff Detail
Event TimelineComment Actions Sorry, could you please explain why this required a manually written check? It's not obvious to me. Comment Actions I tried to figure out how to use update_llc_test_checks.py properly, but unfortunately I was not able to make it expand @llvm.hwasan.check.memaccess.shortgranules, so I had to add those checks manually. Btw this patch and previous one obviously should be merged and pushed together.' Thanks! Comment Actions I looked at this more carefully. I think the CHECKs for the .section were already not being updated automatically (not sure if that was the case when they were originally added), so you didn't change that (when I originally skimmed the patch I thought that was new). I'm not sure the two UTC_ARGS are actually needed. The changes to the test itself seem fine, please do merge with the previous patch, as you indicated. Comment Actions As far as I can tell from looking at the relevant psABI discussions and GNU patches, this overall approach is OK. Thinking about the specifics of the patch, what happens if you separately compile and assemble this? Does it lose the STO_RISCV_VARIANT_CC? Comment Actions Hi Luis, Sorry for the delayed reply. clang -fsanitize=hwaddress -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions global.c -c -o /tmp/globals.o ... llvm-readobj -a /tmp/globals.o ... Symbol { Name: __hwasan_tag_mismatch_v2 (650) Value: 0x0 Size: 0 Binding: Global (0x1) Type: None (0x0) Other [ (0x80) STO_RISCV_VARIANT_CC (0x80) ] Section: Undefined (0x0) } And I expect it's also supported by the linkers by quickly looking into existing patches. Comment Actions It seems we're missing a emitDirectiveVariantCC equivalent to AArch64's emitDirectiveVariantPCS, which is what should be used here I believe otherwise Luis is right, the assembly doesn't mark the symbol as a variant CC one, so round-tripping through assembly loses the flag. What you showed is still compiling directly from C to an object file with the integrated assembler; you'd need to either use -no-integrated-as or use -S and then assemble the .s file. Comment Actions Indeed asm file lacks .variant_cc annotation. Comment Actions I think one of possible solutions for the problem mentioned above might be the following:
Supposedly (2) should be implemented/committed as a separate patch before this one. It looks like it's being done as part of https://reviews.llvm.org/D103435 @jrtc27 @luismarques what do you think of that? Comment Actions It looks like it D103435 has started picking up activity again. You can always publish your patch with a description that references D103435, and possibly point out the ways in which the patches are different. For instance, sometimes if it's just a subset of another patch that can help that subset be merged earlier, without being blocked on other issues. In any case, perhaps now D103435 will move faster. I suggest rebasing this patch on an implementation of (2), either D103435 or your alternative, as that seems like the proper solution. If those patches were to continue being blocked for a while I don't have a problem with (1), but I imagine other people might disagree. Comment Actions Hi Luis, I think all 3 of those steps might be necessary: it's impossible to do (1) without having changes from (2). Other possible solution I see is to push this patch as is and later fix the issues you've raised after .variant_cc patch is commited. Comment Actions With D139414 being pushed to upstream, .variant_cc symbol is now properly emitted by hwasan code: clang -fsanitize=hwaddress -mllvm -hwasan-globals -mllvm -hwasan-use-short-granules -mllvm -hwasan-instrument-landing-pads=0 -mllvm -hwasan-instrument-personality-functions src/llvm-project/compiler-rt/test/hwasan/TestCases/global.c -S -c -o /tmp/globals.s | grep variant_cc /tmp/globals.s .variant_cc __hwasan_tag_mismatch_v2 |
Nit: missing period.