Skip to content

Commit

Permalink
Apply TBI to virtual addresses on aarch64.
Browse files Browse the repository at this point in the history
In tag-based KASAN modes, TCR_EL1.TBI1 is enabled, which causes the
top 8 bits of virtual addresses to be ignored for address translation
purposes. Do the same in the page table iterator. There is no harm in
doing so unconditionally, as the architecture does not support >56 bit
VA sizes.
  • Loading branch information
pcc committed Jun 27, 2023
1 parent 73e451d commit 6a20370
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libdrgn/arch_aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ static void linux_kernel_pgtable_iterator_init_aarch64(struct drgn_program *prog
{
struct pgtable_iterator_aarch64 *it =
container_of(_it, struct pgtable_iterator_aarch64, it);

/* Apply TBI. */
if (it->it.virt_addr & (1ULL << 55))
it->it.virt_addr |= 0xFFULL << 56;
else
it->it.virt_addr &= ~(0xFFULL << 56);

if (it->it.pgtable == prog->vmcoreinfo.swapper_pg_dir) {
it->va_range_min = UINT64_MAX << prog->vmcoreinfo.va_bits;
it->va_range_max = UINT64_MAX;
Expand Down

0 comments on commit 6a20370

Please sign in to comment.