Commit b9873755 authored by Alexander Graf's avatar Alexander Graf Committed by Greg Kroah-Hartman

misc: Add Nitro Secure Module driver

When running Linux inside a Nitro Enclave, the hypervisor provides a
special virtio device called "Nitro Security Module" (NSM). This device
has 3 main functions:

  1) Provide attestation reports
  2) Modify PCR state
  3) Provide entropy

This patch adds a driver for NSM that exposes a /dev/nsm device node which
user space can issue an ioctl on this device with raw NSM CBOR formatted
commands to request attestation documents, influence PCR states, read
entropy and enumerate status of the device. In addition, the driver
implements a hwrng backend.
Originally-by: default avatarPetre Eftime <petre.eftime@gmail.com>
Signed-off-by: default avatarAlexander Graf <graf@amazon.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20231011213522.51781-1-graf@amazon.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 110684d5
...@@ -15291,6 +15291,15 @@ F: include/linux/nitro_enclaves.h ...@@ -15291,6 +15291,15 @@ F: include/linux/nitro_enclaves.h
F: include/uapi/linux/nitro_enclaves.h F: include/uapi/linux/nitro_enclaves.h
F: samples/nitro_enclaves/ F: samples/nitro_enclaves/
NITRO SECURE MODULE (NSM)
M: Alexander Graf <graf@amazon.com>
L: linux-kernel@vger.kernel.org
L: The AWS Nitro Enclaves Team <aws-nitro-enclaves-devel@amazon.com>
S: Supported
W: https://aws.amazon.com/ec2/nitro/nitro-enclaves/
F: drivers/misc/nsm.c
F: include/uapi/linux/nsm.h
NOHZ, DYNTICKS SUPPORT NOHZ, DYNTICKS SUPPORT
M: Frederic Weisbecker <frederic@kernel.org> M: Frederic Weisbecker <frederic@kernel.org>
M: Thomas Gleixner <tglx@linutronix.de> M: Thomas Gleixner <tglx@linutronix.de>
......
...@@ -562,6 +562,19 @@ config TPS6594_PFSM ...@@ -562,6 +562,19 @@ config TPS6594_PFSM
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called tps6594-pfsm. will be called tps6594-pfsm.
config NSM
tristate "Nitro (Enclaves) Security Module support"
depends on VIRTIO
select HW_RANDOM
select CBOR
help
This driver provides support for the Nitro Security Module
in AWS EC2 Nitro based Enclaves. The driver exposes a /dev/nsm
device user space can use to communicate with the hypervisor.
To compile this driver as a module, choose M here.
The module will be called nsm.
source "drivers/misc/c2port/Kconfig" source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig" source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig" source "drivers/misc/cb710/Kconfig"
......
...@@ -67,3 +67,4 @@ obj-$(CONFIG_TMR_MANAGER) += xilinx_tmr_manager.o ...@@ -67,3 +67,4 @@ obj-$(CONFIG_TMR_MANAGER) += xilinx_tmr_manager.o
obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o obj-$(CONFIG_TMR_INJECT) += xilinx_tmr_inject.o
obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o obj-$(CONFIG_TPS6594_ESM) += tps6594-esm.o
obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o
obj-$(CONFIG_NSM) += nsm.o
This diff is collapsed.
/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*/
#ifndef __UAPI_LINUX_NSM_H
#define __UAPI_LINUX_NSM_H
#include <linux/ioctl.h>
#include <linux/types.h>
#define NSM_MAGIC 0x0A
#define NSM_REQUEST_MAX_SIZE 0x1000
#define NSM_RESPONSE_MAX_SIZE 0x3000
struct nsm_iovec {
__u64 addr; /* Virtual address of target buffer */
__u64 len; /* Length of target buffer */
};
/* Raw NSM message. Only available with CAP_SYS_ADMIN. */
struct nsm_raw {
/* Request from user */
struct nsm_iovec request;
/* Response to user */
struct nsm_iovec response;
};
#define NSM_IOCTL_RAW _IOWR(NSM_MAGIC, 0x0, struct nsm_raw)
#endif /* __UAPI_LINUX_NSM_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment