Re: [PATCH] Intel Restricted Access Region Handler

From: Randy Dunlap
Date: Mon Mar 15 2010 - 13:24:59 EST


On 03/14/10 01:14, Ossama Othman wrote:
> The Intel Restricted Access Region Handler provides a buffer allocation
> mechanism to RAR users. Since the intended usage model is to lock out
> CPU access to RAR (the CPU will not be able to access RAR memory), this
> driver does not access RAR memory, and merely keeps track of what areas
> of RAR memory are in use. It has it's own simple allocator that does
> not rely on existing kernel allocators (SLAB, etc) since those
> allocators are too tightly coupled with the paging mechanism, which isn't
> needed for the intended RAR use cases.
>
> An mmap() implementation is provided for debugging purposes to simplify
> RAR memory access from the user space. However, it will effectively be
> a no-op when RAR access control is enabled since the CPU will not be
> able to access RAR.
>
> This driver should not be confused with the rar_register driver. That
> driver exposes an interface to access RAR registers on the Moorestown
> platform. The RAR handler driver relies on the rar_register driver for
> low level RAR register reads and writes.
>
> Signed-off-by: Ossama Othman <ossama.othman@xxxxxxxxx>
> ---
> drivers/staging/Kconfig | 2 +
> drivers/staging/Makefile | 1 +
> drivers/staging/memrar/Kconfig | 15 +
> drivers/staging/memrar/Makefile | 2 +
> drivers/staging/memrar/memrar.h | 160 +++++
> drivers/staging/memrar/memrar_allocator.c | 432 +++++++++++++
> drivers/staging/memrar/memrar_allocator.h | 141 +++++
> drivers/staging/memrar/memrar_handler.c | 948 +++++++++++++++++++++++++++++
> 8 files changed, 1701 insertions(+), 0 deletions(-)
> create mode 100644 drivers/staging/memrar/Kconfig
> create mode 100644 drivers/staging/memrar/Makefile
> create mode 100644 drivers/staging/memrar/memrar.h
> create mode 100644 drivers/staging/memrar/memrar_allocator.c
> create mode 100644 drivers/staging/memrar/memrar_allocator.h
> create mode 100644 drivers/staging/memrar/memrar_handler.c
>
> diff --git a/drivers/staging/memrar/Makefile b/drivers/staging/memrar/Makefile
> new file mode 100644
> index 0000000..a3336c0
> --- /dev/null
> +++ b/drivers/staging/memrar/Makefile
> @@ -0,0 +1,2 @@
> +obj-$(CONFIG_MRST_RAR_HANDLER) += memrar.o
> +memrar-y := memrar_allocator.o memrar_handler.o
> diff --git a/drivers/staging/memrar/memrar.h b/drivers/staging/memrar/memrar.h
> new file mode 100644
> index 0000000..7a09e7d
> --- /dev/null
> +++ b/drivers/staging/memrar/memrar.h
> @@ -0,0 +1,160 @@
> +/*
> + * RAR Handler (/dev/memrar) internal driver API.
> + * Copyright (C) 2009 Intel Corporation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of version 2 of the GNU General
> + * Public License as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be
> + * useful, but WITHOUT ANY WARRANTY; without even the implied
> + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
> + * PURPOSE. See the GNU General Public License for more details.
> + * You should have received a copy of the GNU General Public
> + * License along with this program; if not, write to the Free
> + * Software Foundation, Inc., 59 Temple Place - Suite 330,
> + * Boston, MA 02111-1307, USA.
> + * The full GNU General Public License is included in this
> + * distribution in the file called COPYING.
> + */
> +
> +
> +#ifndef _MEMRAR_H
> +#define _MEMRAR_H
> +
> +#include <linux/ioctl.h>
> +#include <linux/types.h>
> +
> +
> +/*
> + * @struct RAR_stat
> + *
> + * @brief This structure is used for @c RAR_HANDLER_STAT ioctl and for
> + * @c RAR_get_stat() user space wrapper function.
> + */

Don't use doxygen or whatever that is in the Linux kernel.
Use kernel-doc notation as described in Documentation/kernel-doc-nano-HOWTO.txt.

In many places/multiple files.


> +struct RAR_stat {
> + /* Type of RAR memory (e.g., audio vs. video) */
> + __u32 type;
> +
> + /*
> + * Total size of RAR memory region.
> + */
> + __u32 capacity;
> +
> + /* Size of the largest reservable block. */
> + __u32 largest_block_size;
> +};


Thanks.

--
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/