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

From: David Miller
Date: Sat Mar 05 2016 - 23:07:35 EST


From: Khalid Aziz <khalid.aziz@xxxxxxxxxx>
Date: Wed, 2 Mar 2016 13:39:37 -0700

> In this
> first implementation I am enabling ADI for hugepages only
> since these pages are locked in memory and hence avoid the
> issue of saving and restoring tags.

This makes the feature almost entire useless.

Non-hugepages must be in the initial implementation.

> + PR_ENABLE_SPARC_ADI - Enable ADI checking in all pages in the address
> + range specified. The pages in the range must be already
> + locked. This operation enables the TTE.mcd bit for the
> + pages specified. arg2 is the starting address for address
> + range and must be page aligned. arg3 is the length of
> + memory address range and must be a multiple of page size.

I strongly dislike this interface, and it makes the prtctl cases look
extremely ugly and hide to the casual reader what the code is actually
doing.

This is an mprotect() operation, so add a new flag bit and implement
this via mprotect please.

Then since you are guarenteed to have a consistent ADI setting for
every single VMA region, you never "lose" the ADI state when you swap
out. It's implicit in the VMA itself, because you'll store in the VMA
that this is an ADI region.

I also want this enabled unconditionally, without any Kconfig knobs.

Thanks.