Re: [RFC PATCH v3] sparc64: Add support for Application Data Integrity (ADI)

From: Dave Hansen
Date: Wed Jan 04 2017 - 18:27:50 EST


On 01/04/2017 02:46 PM, Khalid Aziz wrote:
> This patch extends mprotect to enable ADI (TSTATE.mcde), enable/disable
> MCD (Memory Corruption Detection) on selected memory ranges, enable
> TTE.mcd in PTEs, return ADI parameters to userspace and save/restore ADI
> version tags on page swap out/in.

I'm a bit confused why we need all the mechanics with set_swp_pte_at().
For pkeys, for instance, all of the PTEs under a given VMA share a pkey.
When swapping something in, we just get the pkey out of the VMA and
populate the PTE.

ADI doesn't seem to have a similar restriction. The feature is turned
on or off at a VMA granularity, but we do not (or can enforce that all
pages under a given VMA must share a tag.

But this leads to an interesting question: is the tag associated with
the (populated?) pte, or the virtual address? Can you have tags
associated with non-present addresses? What's the mechanism that clears
the tags at munmap() or MADV_FREE time?

Is the tag storage a precious resource? Can it be exhausted?