18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright © 2015 Intel Corporation.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Authors: David Woodhouse <David.Woodhouse@intel.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __INTEL_SVM_H__
98c2ecf20Sopenharmony_ci#define __INTEL_SVM_H__
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistruct device;
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistruct svm_dev_ops {
148c2ecf20Sopenharmony_ci	void (*fault_cb)(struct device *dev, u32 pasid, u64 address,
158c2ecf20Sopenharmony_ci			 void *private, int rwxp, int response);
168c2ecf20Sopenharmony_ci};
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci/* Values for rxwp in fault_cb callback */
198c2ecf20Sopenharmony_ci#define SVM_REQ_READ	(1<<3)
208c2ecf20Sopenharmony_ci#define SVM_REQ_WRITE	(1<<2)
218c2ecf20Sopenharmony_ci#define SVM_REQ_EXEC	(1<<1)
228c2ecf20Sopenharmony_ci#define SVM_REQ_PRIV	(1<<0)
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci/*
258c2ecf20Sopenharmony_ci * The SVM_FLAG_PRIVATE_PASID flag requests a PASID which is *not* the "main"
268c2ecf20Sopenharmony_ci * PASID for the current process. Even if a PASID already exists, a new one
278c2ecf20Sopenharmony_ci * will be allocated. And the PASID allocated with SVM_FLAG_PRIVATE_PASID
288c2ecf20Sopenharmony_ci * will not be given to subsequent callers. This facility allows a driver to
298c2ecf20Sopenharmony_ci * disambiguate between multiple device contexts which access the same MM,
308c2ecf20Sopenharmony_ci * if there is no other way to do so. It should be used sparingly, if at all.
318c2ecf20Sopenharmony_ci */
328c2ecf20Sopenharmony_ci#define SVM_FLAG_PRIVATE_PASID		(1<<0)
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/*
358c2ecf20Sopenharmony_ci * The SVM_FLAG_SUPERVISOR_MODE flag requests a PASID which can be used only
368c2ecf20Sopenharmony_ci * for access to kernel addresses. No IOTLB flushes are automatically done
378c2ecf20Sopenharmony_ci * for kernel mappings; it is valid only for access to the kernel's static
388c2ecf20Sopenharmony_ci * 1:1 mapping of physical memory — not to vmalloc or even module mappings.
398c2ecf20Sopenharmony_ci * A future API addition may permit the use of such ranges, by means of an
408c2ecf20Sopenharmony_ci * explicit IOTLB flush call (akin to the DMA API's unmap method).
418c2ecf20Sopenharmony_ci *
428c2ecf20Sopenharmony_ci * It is unlikely that we will ever hook into flush_tlb_kernel_range() to
438c2ecf20Sopenharmony_ci * do such IOTLB flushes automatically.
448c2ecf20Sopenharmony_ci */
458c2ecf20Sopenharmony_ci#define SVM_FLAG_SUPERVISOR_MODE	(1<<1)
468c2ecf20Sopenharmony_ci/*
478c2ecf20Sopenharmony_ci * The SVM_FLAG_GUEST_MODE flag is used when a PASID bind is for guest
488c2ecf20Sopenharmony_ci * processes. Compared to the host bind, the primary differences are:
498c2ecf20Sopenharmony_ci * 1. mm life cycle management
508c2ecf20Sopenharmony_ci * 2. fault reporting
518c2ecf20Sopenharmony_ci */
528c2ecf20Sopenharmony_ci#define SVM_FLAG_GUEST_MODE		(1<<2)
538c2ecf20Sopenharmony_ci/*
548c2ecf20Sopenharmony_ci * The SVM_FLAG_GUEST_PASID flag is used when a guest has its own PASID space,
558c2ecf20Sopenharmony_ci * which requires guest and host PASID translation at both directions.
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci#define SVM_FLAG_GUEST_PASID		(1<<3)
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#endif /* __INTEL_SVM_H__ */
60