include/linux/pci-tsm.h

Source file repositories/reference/linux-study-clean/include/linux/pci-tsm.h

File Facts

System
Linux kernel
Corpus path
include/linux/pci-tsm.h
Extension
.h
Size
8470 bytes
Lines
244
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pci_tsm_ops {
	/*
	 * struct pci_tsm_link_ops - Manage physical link and the TSM/DSM session
	 * @probe: establish context with the TSM (allocate / wrap 'struct
	 *	   pci_tsm') for follow-on link operations
	 * @remove: destroy link operations context
	 * @connect: establish / validate a secure connection (e.g. IDE)
	 *	     with the device
	 * @disconnect: teardown the secure link
	 * @bind: bind a TDI in preparation for it to be accepted by a TVM
	 * @unbind: remove a TDI from secure operation with a TVM
	 * @guest_req: marshal TVM information and state change requests
	 *
	 * Context: @probe, @remove, @connect, and @disconnect run under
	 * pci_tsm_rwsem held for write to sync with TSM unregistration and
	 * mutual exclusion of @connect and @disconnect. @connect and
	 * @disconnect additionally run under the DSM lock (struct
	 * pci_tsm_pf0::lock) as well as @probe and @remove of the subfunctions.
	 * @bind, @unbind, and @guest_req run under pci_tsm_rwsem held for read
	 * and the DSM lock.
	 */
	struct_group_tagged(pci_tsm_link_ops, link_ops,
		struct pci_tsm *(*probe)(struct tsm_dev *tsm_dev,
					 struct pci_dev *pdev);
		void (*remove)(struct pci_tsm *tsm);
		int (*connect)(struct pci_dev *pdev);
		void (*disconnect)(struct pci_dev *pdev);
		struct pci_tdi *(*bind)(struct pci_dev *pdev,
					struct kvm *kvm, u32 tdi_id);
		void (*unbind)(struct pci_tdi *tdi);
		ssize_t (*guest_req)(struct pci_tdi *tdi,
				     enum pci_tsm_req_scope scope,
				     sockptr_t req_in, size_t in_len,
				     sockptr_t req_out, size_t out_len,
				     u64 *tsm_code);
	);

	/*
	 * struct pci_tsm_devsec_ops - Manage the security state of the function
	 * @lock: establish context with the TSM (allocate / wrap 'struct
	 *	  pci_tsm') for follow-on security state transitions from the
	 *	  LOCKED state
	 * @unlock: destroy TSM context and return device to UNLOCKED state
	 *
	 * Context: @lock and @unlock run under pci_tsm_rwsem held for write to
	 * sync with TSM unregistration and each other
	 */
	struct_group_tagged(pci_tsm_devsec_ops, devsec_ops,
		struct pci_tsm *(*lock)(struct tsm_dev *tsm_dev,
					struct pci_dev *pdev);
		void (*unlock)(struct pci_tsm *tsm);
	);
};

/**
 * struct pci_tdi - Core TEE I/O Device Interface (TDI) context
 * @pdev: host side representation of guest-side TDI
 * @kvm: TEE VM context of bound TDI
 * @tdi_id: Identifier (virtual BDF) for the TDI as referenced by the TSM and DSM
 */
struct pci_tdi {
	struct pci_dev *pdev;
	struct kvm *kvm;
	u32 tdi_id;
};

/**
 * struct pci_tsm - Core TSM context for a given PCIe endpoint
 * @pdev: Back ref to device function, distinguishes type of pci_tsm context
 * @dsm_dev: PCI Device Security Manager for link operations on @pdev
 * @tsm_dev: PCI TEE Security Manager device for Link Confidentiality or Device
 *	     Function Security operations
 * @tdi: TDI context established by the @bind link operation
 *
 * This structure is wrapped by low level TSM driver data and returned by
 * probe()/lock(), it is freed by the corresponding remove()/unlock().
 *
 * For link operations it serves to cache the association between a Device
 * Security Manager (DSM) and the functions that manager can assign to a TVM.
 * That can be "self", for assigning function0 of a TEE I/O device, a
 * sub-function (SR-IOV virtual function, or non-function0
 * multifunction-device), or a downstream endpoint (PCIe upstream switch-port as
 * DSM).
 */
struct pci_tsm {
	struct pci_dev *pdev;
	struct pci_dev *dsm_dev;
	struct tsm_dev *tsm_dev;
	struct pci_tdi *tdi;
};

Annotation

Implementation Notes