---
name: "mtrr"
section: "4"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["openbsd"]
url: "https://new.carta.tech/mtrr"
---

# mtrr(4)

driver for CPU memory range attributes

## NAME

**mtrr** – driver for CPU memory range attributes

## SYNOPSIS

**pseudo-device mtrr 1**

## DESCRIPTION

The **mtrr** device provides access to the memory range attributes supported by the MTRRs on AMD64 compatible CPUs.

### IOCTL INTERFACE

Several architectures allow attributes to be associated with ranges of physical memory. These attributes can be manipulated via **ioctl**() calls performed on */dev/mem* or */dev/xf86*. Declarations and data types are to be found in ⟨sys/memrange.h⟩.

The specific attributes, and number of programmable ranges may vary between architectures. The full set of supported attributes is:

- MDF\_UNCACHEABLE

  The region is not cached.

- MDF\_WRITECOMBINE

  Writes to the region may be combined or performed out of order.

- MDF\_WRITETHROUGH

  Writes to the region are committed synchronously.

- MDF\_WRITEBACK

  Writes to the region are committed asynchronously.

- MDF\_WRITEPROTECT

  The region cannot be written to.

Memory ranges are described by

```
struct mem_range_desc {
	u_int64_t	mr_base;	/∗ physical base address ∗/
	u_int64_t	mr_len;		/∗ physical length of region ∗/
	int		mr_flags;	/∗ attributes of region ∗/
	char		mr_owner[8];
};
```

In addition to the region attributes listed above, the following flags may also be set in the *mr\_flags* field:

- MDF\_FIXBASE

  The region's base address cannot be changed.

- MDF\_FIXLEN

  The region's length cannot be changed.

- MDF\_FIRMWARE

  The region is believed to have been established by the system firmware.

- MDF\_ACTIVE

  The region is currently active.

- MDF\_BOGUS

  We believe the region to be invalid or otherwise erroneous.

- MDF\_FIXACTIVE

  The region cannot be disabled.

Operations are performed using

```
struct mem_range_op {
	struct mem_range_desc	*mo_desc;
	int			mo_arg[2];
};
```

The *MEMRANGE\_GET* ioctl is used to retrieve current memory range attributes. If *mo\_arg\[0\]* is set to 0, it will be updated with the total number of memory range descriptors. If greater than 0, the array at *mo\_desc* will be filled with a corresponding number of descriptor structures, or the maximum, whichever is less.

The *MEMRANGE\_SET* ioctl is used to add, alter and remove memory range attributes. A range with the MDF\_FIXACTIVE flag may not be removed.

*mo\_arg\[0\]* should be set to MEMRANGE\_SET\_UPDATE to update an existing or establish a new range, or to MEMRANGE\_SET\_REMOVE to remove a range.

## ERRORS

On [ioctl(2)](/ioctl/2.md) failure, [errno(2)](/errno/2.md) will be set as follows:

- \[EOPNOTSUPP\]

  Memory range operations are not supported on this architecture.

- \[ENXIO\]

  No memory range descriptors are available (e.g., firmware has not enabled any).

- \[EINVAL\]

  The memory range supplied as an argument is invalid or overlaps another range in a fashion not supported by this architecture.

- \[EBUSY\]

  An attempt to remove or update a range failed because the range is busy.

- \[ENOSPC\]

  An attempt to create a new range failed due to a shortage of hardware resources (e.g., descriptor slots).

- \[ENOENT\]

  An attempt to remove a range failed because no range matches the descriptor base/length supplied.

- \[EPERM\]

  An attempt to remove a range failed because the range is permanently enabled.

## SEE ALSO

[ioctl(2)](/ioctl/2.md), [mem(4)](/mem/4.md), [pctr(4)](/pctr/4.md), [xf86(4)](/xf86/4.md), [memconfig(8)](/memconfig/8.md)

## HISTORY

**mtrr** support was originally included in FreeBSD 3.3.
