Thomas Gleixner | 2025cf9 | 2019-05-29 07:18:02 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
David Woodhouse | 2f26e0a | 2015-09-09 11:40:47 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright © 2015 Intel Corporation. |
| 4 | * |
| 5 | * Authors: David Woodhouse <David.Woodhouse@intel.com> |
David Woodhouse | 2f26e0a | 2015-09-09 11:40:47 +0100 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #ifndef __INTEL_SVM_H__ |
| 9 | #define __INTEL_SVM_H__ |
| 10 | |
David Woodhouse | 2f26e0a | 2015-09-09 11:40:47 +0100 | [diff] [blame] | 11 | struct device; |
| 12 | |
David Woodhouse | 0204a49 | 2015-10-13 17:18:10 +0100 | [diff] [blame] | 13 | struct svm_dev_ops { |
| 14 | void (*fault_cb)(struct device *dev, int pasid, u64 address, |
Jacob Pan | 5b438f4 | 2019-01-11 13:04:57 +0800 | [diff] [blame] | 15 | void *private, int rwxp, int response); |
David Woodhouse | 0204a49 | 2015-10-13 17:18:10 +0100 | [diff] [blame] | 16 | }; |
| 17 | |
| 18 | /* Values for rxwp in fault_cb callback */ |
| 19 | #define SVM_REQ_READ (1<<3) |
| 20 | #define SVM_REQ_WRITE (1<<2) |
| 21 | #define SVM_REQ_EXEC (1<<1) |
| 22 | #define SVM_REQ_PRIV (1<<0) |
| 23 | |
David Woodhouse | 569e4f7 | 2015-10-15 13:59:14 +0100 | [diff] [blame] | 24 | /* |
| 25 | * The SVM_FLAG_PRIVATE_PASID flag requests a PASID which is *not* the "main" |
| 26 | * PASID for the current process. Even if a PASID already exists, a new one |
| 27 | * will be allocated. And the PASID allocated with SVM_FLAG_PRIVATE_PASID |
| 28 | * will not be given to subsequent callers. This facility allows a driver to |
| 29 | * disambiguate between multiple device contexts which access the same MM, |
| 30 | * if there is no other way to do so. It should be used sparingly, if at all. |
| 31 | */ |
David Woodhouse | 5cec753 | 2015-10-15 15:52:15 +0100 | [diff] [blame] | 32 | #define SVM_FLAG_PRIVATE_PASID (1<<0) |
| 33 | |
| 34 | /* |
| 35 | * The SVM_FLAG_SUPERVISOR_MODE flag requests a PASID which can be used only |
| 36 | * for access to kernel addresses. No IOTLB flushes are automatically done |
| 37 | * for kernel mappings; it is valid only for access to the kernel's static |
| 38 | * 1:1 mapping of physical memory — not to vmalloc or even module mappings. |
| 39 | * A future API addition may permit the use of such ranges, by means of an |
| 40 | * explicit IOTLB flush call (akin to the DMA API's unmap method). |
| 41 | * |
| 42 | * It is unlikely that we will ever hook into flush_tlb_kernel_range() to |
| 43 | * do such IOTLB flushes automatically. |
| 44 | */ |
| 45 | #define SVM_FLAG_SUPERVISOR_MODE (1<<1) |
Jacob Pan | 56722a4 | 2020-05-16 14:20:47 +0800 | [diff] [blame] | 46 | /* |
| 47 | * The SVM_FLAG_GUEST_MODE flag is used when a PASID bind is for guest |
| 48 | * processes. Compared to the host bind, the primary differences are: |
| 49 | * 1. mm life cycle management |
| 50 | * 2. fault reporting |
| 51 | */ |
| 52 | #define SVM_FLAG_GUEST_MODE (1<<2) |
| 53 | /* |
| 54 | * The SVM_FLAG_GUEST_PASID flag is used when a guest has its own PASID space, |
| 55 | * which requires guest and host PASID translation at both directions. |
| 56 | */ |
| 57 | #define SVM_FLAG_GUEST_PASID (1<<3) |
David Woodhouse | 569e4f7 | 2015-10-15 13:59:14 +0100 | [diff] [blame] | 58 | |
David Woodhouse | 2f26e0a | 2015-09-09 11:40:47 +0100 | [diff] [blame] | 59 | #endif /* __INTEL_SVM_H__ */ |