Re: [PATCH v7 9/9] sparc64: Add support for ADI (Application Data Integrity)

From: Khalid Aziz
Date: Wed Sep 06 2017 - 10:13:46 EST


On 09/04/2017 10:25 AM, Pavel Machek wrote:
Hi!

ADI is a new feature supported on SPARC M7 and newer processors to allow
hardware to catch rogue accesses to memory. ADI is supported for data
fetches only and not instruction fetches. An app can enable ADI on its
data pages, set version tags on them and use versioned addresses to
access the data pages. Upper bits of the address contain the version
tag. On M7 processors, upper four bits (bits 63-60) contain the version
tag. If a rogue app attempts to access ADI enabled data pages, its
access is blocked and processor generates an exception. Please see
Documentation/sparc/adi.txt for further details.

I'm afraid I still don't understand what this is meant to prevent.

IOMMU ignores these, so this is not to prevent rogue DMA from doing
bad stuff.

Will gcc be able to compile code that uses these automatically? That
does not sound easy to me. Can libc automatically use this in malloc()
to prevent accessing freed data when buffers are overrun?

Is this for benefit of JITs?


David explained it well. Yes, preventing buffer overflow is one of the uses of ADI. Protecting critical data from wild writes caused by programming errors is another use. ADI can be used for debugging as well during development.

Thanks,
Khalid