Go to main content

man pages section 2: System Calls

Exit Print View

Updated: Wednesday, August 8, 2018
 
 

adi (2)

Name

adi, adi_set_enabled, adi_get_enabled, adi_blksz, adi_version_max, adi_version_nbits - Application Data Integrity operations

Synopsis

#include <adi.h>

int adi_set_enabled(int arg);

int adi_get_enabled(void);

int adi_blksz(void);

int adi_version_max(void);

int adi_version_nbits(void);

Description

Applications can use the functions described in this section to disable, enable, or query the per-thread state of Application Data Integrity (ADI), and to determine the system constants used to provide the ADI feature. See the adi(3C) man page for additional information on the ADI feature.

The adi_set_enabled() function sets the state of ADI for the calling thread. The value of arg can be either ADI_DISABLE or ADI_ENABLE, to disable or enable ADI respectively.

The adi_get_enabled() function returns the current state of ADI for the calling thread.

The adi_blksz() function returns the granularity of ADI versioning supported by the platform. granularity can be used to determine the optimal alignment for the address and size arguments, when calling the adi_clr_version(3C), adi_set_version(3C), or adi_memset(3C) functions.

The adi_version_max() function returns the maximum value an application may use for an ADI version tag. This value can be used to determine the maximum value for the version argument when calling the adi_set_version(3C) or adi_memset(3C) functions.

The adi_version_nbits() function returns the number of bits used in a 64-bit virtual address to represent an ADI version tag. To create a versioned address, set the upper nbits in an address to the version. To normalize a versioned address, clear the upper nbits and sign-extend the highest non-versioned bit as shown in the "Examples" section.

Return Values

The adi_set_enabled() function returns the previous state of ADI for the calling thread. On error, this function returns -1 and sets errno.

The adi_get_enabled() function returns the current state of ADI for the calling thread. On error, this function returns -1 and sets errno.

The adi_blksz() function returns the granularity of ADI versioning supported by the platform in bytes. On error, this function returns -1 and sets errno.

The adi_version_max() function returns the maximum value an application may use for an ADI version tag. On error, this function returns -1 and sets errno.

The adi_version_nbits() function returns the number of bits used in a 64-bit virtual address to represent an ADI version tag. On error, this function returns -1 and sets errno.

Errors

All adi(2) family functions will fail if:

ENOTSUP
  • ADI is not supported by the platform.

  • ADI is not supported for 32-bit processes.

The adi_set_enabled() function will fail if:

EINVAL

The argument is invalid.

Examples

Example 1 Normalizing a Versioned Address

The following example shows how you can normalize a versioned address by clearing the upper nbits and sign-extending the highest non-versioned bit:

#include <sys/types.h>
#include <adi.h>

void adi_function(caddr_t addr, int version)
{
       int nbits = adi_version_nbits();
       int shift = 64 - nbits;
       caddr_t versioned_addr;
       caddr_t normal_addr;

       /*
        * Create a versioned address.
        */
       versioned_addr = (caddr_t) ((version << shift) |
           ((((unsigned long)addr) << nbits) >> nbits));

       /*
        * Extract the version from a versioned address.
        */
       version = ((unsigned long)versioned_addr) >> shift;

       /*
        * Remove the version and normalize an address.
        */
       normal_addr = (caddr_t) (((((long)versioned_addr) << nbits) >> nbits));
}

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Volatile
MT-Level
MT-Safe

See Also

adi(3C), attributes(7), standards(7)