linux/drivers/misc/open-dice.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2021 - Google LLC
 * Author: David Brazdil <[email protected]>
 *
 * Driver for Open Profile for DICE.
 *
 * This driver takes ownership of a reserved memory region containing data
 * generated by the Open Profile for DICE measured boot protocol. The memory
 * contents are not interpreted by the kernel but can be mapped into a userspace
 * process via a misc device. Userspace can also request a wipe of the memory.
 *
 * Userspace can access the data with (w/o error handling):
 *
 *     fd = open("/dev/open-dice0", O_RDWR);
 *     read(fd, &size, sizeof(unsigned long));
 *     data = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
 *     write(fd, NULL, 0); // wipe
 *     close(fd);
 */

#include <linux/io.h>
#include <linux/miscdevice.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>

#define DRIVER_NAME

struct open_dice_drvdata {};

static inline struct open_dice_drvdata *to_open_dice_drvdata(struct file *filp)
{}

static int open_dice_wipe(struct open_dice_drvdata *drvdata)
{}

/*
 * Copies the size of the reserved memory region to the user-provided buffer.
 */
static ssize_t open_dice_read(struct file *filp, char __user *ptr, size_t len,
			      loff_t *off)
{}

/*
 * Triggers a wipe of the reserved memory region. The user-provided pointer
 * is never dereferenced.
 */
static ssize_t open_dice_write(struct file *filp, const char __user *ptr,
			       size_t len, loff_t *off)
{}

/*
 * Creates a mapping of the reserved memory region in user address space.
 */
static int open_dice_mmap(struct file *filp, struct vm_area_struct *vma)
{}

static const struct file_operations open_dice_fops =;

static int __init open_dice_probe(struct platform_device *pdev)
{}

static void open_dice_remove(struct platform_device *pdev)
{}

static const struct of_device_id open_dice_of_match[] =;

static struct platform_driver open_dice_driver =;

static int __init open_dice_init(void)
{}

static void __exit open_dice_exit(void)
{}

module_init();
module_exit(open_dice_exit);

MODULE_DESCRIPTION();
MODULE_LICENSE();
MODULE_AUTHOR();