Page MenuHomeFreeBSD

aarch64: enable tagged pointers (TBI — Top Byte Ignored)
Needs ReviewPublic

Authored by val_packett.cool on Jul 2 2019, 1:19 PM.
Tags
Referenced Files
F156665792: D20835.id65763.diff
Fri, May 15, 1:09 PM
F156655926: D20835.id59313.diff
Fri, May 15, 11:04 AM
Unknown Object (File)
Fri, May 15, 6:54 AM
Unknown Object (File)
Fri, May 15, 6:05 AM
Unknown Object (File)
Thu, May 14, 6:41 PM
Unknown Object (File)
Wed, May 13, 2:55 PM
Unknown Object (File)
Mon, May 11, 7:57 PM
Unknown Object (File)
Fri, May 8, 12:33 AM

Details

Reviewers
manu
andrew
Group Reviewers
arm64
Contributor Reviews (src)
Summary

TBI is a very useful feature of ARMv8 that allows the top byte of pointers to be used as a tag. This is useful for various JIT compilers, HWASAN etc. This has been enabled on Linux since 2013, but not on FreeBSD yet. (upd: also on Linux it's per-process toggleable via procctl or something now?)

Linux clears the bits on EL0 data abort, so I've done the same (??) here — not sure about that actually.

Test Plan

This example

#include <stdio.h>
#include <stdint.h>

static inline char *tag(char *ptr) {
        return (char*)(((uintptr_t)ptr & 0xffffffffffff) | (69L << 56));
}

int main() {
        char v = 'x';
        printf("ptr %p val %c\n", &v, *(&v));
        printf("ptr %p\n", tag(&v));
        printf("val %c\n", *tag(&v));
        return 0;
}

no longer segfaults on the last dereference.

UPD: also, I got HWASAN working :) my current llvm80 patches are here (I'll try to keep the link here up to date)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped