AArch64 backend incorrectly maps __builtin_cheri_[gs]et_flags to [GS]CFLGS
As discussed on Slack a couple of times, the aforementioned builtin is being used by Morello for what it calls the flags field, which differs from what CHERI ISAv7/8 define as the flags field (CHERI defines it to be a set of architectural hardware-interpreted bits and CHERI-RISC-V uses this for its mode bit, rather than the LSB of the address like Morello, whereas Morello defines it to be the top byte of the address and has no other architectural meaning).
Thus, the Morello-extended CHERI-LLVM should instead map __builtin_cheri_get_flags
to the constant 0 and __builtin_cheri_set_flags
to a no-op (or perhaps not provide the builtin at all; unclear what's best). If intrinsics to access the Morello user flags are deemed useful they can be added as __builtin_morello_*
, with suitable bike-shedding for an acceptable name (things involving "user", "software" and "top byte" may make useful disambiguation qualifiers).
Note that this difference between CHERI-MIPS/CHERI-RISC-V and Morello broke generic CHERI code in CheriBSD's printf, which was consulting the result of __builtin_cheri_get_flags
and relied on it being as defined by CHERI ISAv7/8 (specifically, checking if it was zero in the context of null-derived capabilities).