intel-svm.h 2.0 KB

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