vm_protectp Kernel Service

Purpose

Sets the page protection key for a page range.

Syntax

#include <sys/types.h>
#include <sys/errno.h>
#include  <sys/vmuser.h>

int vm_protectp ( vmid,  pfirst,  npages,  key)
vmid_t  vmid;
int pfirst;
int npages;
int key;

Description

The vm_protectp kernel service is called to set the storage protect key for a given page range. The key parameter specifies the value to which the page protection key is set. The protection key is set for all pages touched by the specified page range that are resident in memory. The vm_protectp kernel service applies only to client storage.

If a page is not in memory, no state information is saved from a particular call to the vm_protectp service. If the page is later paged-in, it receives the default page protection key.

Note: The vm_protectp subroutine is not supported for use on large pages.

Parameters

Item Description
vmid Specifies the identifier for the virtual memory object for which the page protection key is to be set.
pfirst Specifies the first page number in the designated page range.
npages Specifies the number of pages in the designated page range.
key Specifies the value to be used in setting the page protection key for the designated page range.

Execution Environment

The vm_protectp kernel service can be called from the process environment only.

Return Values

Item Description
0 Indicates a successful operation.
EINVAL Indicates one of the following errors:
  • Invalid virtual memory object ID.
  • The starting page in the designated page range is negative.
  • The number of pages in the page range is negative.
  • The designated page range exceeds the size of virtual memory object.
  • The target page range does not exist.
  • One or more large pages lie in the target page range.