[PATCH] D97606: [Clang interpreter] Avoid storing pointers at unaligned locations

Jessica Clarke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 26 19:27:13 PST 2021


jrtc27 created this revision.
jrtc27 added reviewers: nand, jfb, Bigcheese, rsmith, dexonsmith.
Herald added subscribers: kristof.beyls, arichardson.
jrtc27 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The Clang interpreter's bytecode uses a packed stream of bytes
representation, but also wants to have some opcodes take pointers as
arguments, which are currently embedded in the bytecode directly.

However, CHERI, and thus Arm's upcoming experimental Morello prototype,
provide spatial memory safety for C/C++ by implementing language-level
(and sub-language-level) pointers as capabilities, which track bounds,
permissions and validity in hardware. This uses tagged memory with a
single tag bit at every capability-aligned address, and so storing
pointers to unaligned addresses results in the tag being stripped,
leading to a tag fault when the pointer is ultimately dereferenced at a
later point.

In order to support a stricter C/C++ implementation like CHERI, we no
longer store pointers directly in the bytecode, instead storing them in
a table and embedding the index in the bytecode.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97606

Files:
  clang/lib/AST/Interp/ByteCodeEmitter.cpp
  clang/lib/AST/Interp/Disasm.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Program.cpp
  clang/lib/AST/Interp/Program.h
  clang/lib/AST/Interp/Source.h
  clang/utils/TableGen/ClangOpcodesEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97606.326871.patch
Type: text/x-patch
Size: 8854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210227/d0125cd5/attachment.bin>


More information about the cfe-commits mailing list