kaiser.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef _LINUX_KAISER_H
  2. #define _LINUX_KAISER_H
  3. #ifdef CONFIG_PAGE_TABLE_ISOLATION
  4. #include <asm/kaiser.h>
  5. static inline int kaiser_map_thread_stack(void *stack)
  6. {
  7. /*
  8. * Map that page of kernel stack on which we enter from user context.
  9. */
  10. return kaiser_add_mapping((unsigned long)stack +
  11. THREAD_SIZE - PAGE_SIZE, PAGE_SIZE, __PAGE_KERNEL);
  12. }
  13. static inline void kaiser_unmap_thread_stack(void *stack)
  14. {
  15. /*
  16. * Note: may be called even when kaiser_map_thread_stack() failed.
  17. */
  18. kaiser_remove_mapping((unsigned long)stack +
  19. THREAD_SIZE - PAGE_SIZE, PAGE_SIZE);
  20. }
  21. #else
  22. /*
  23. * These stubs are used whenever CONFIG_PAGE_TABLE_ISOLATION is off, which
  24. * includes architectures that support KAISER, but have it disabled.
  25. */
  26. static inline void kaiser_init(void)
  27. {
  28. }
  29. static inline int kaiser_add_mapping(unsigned long addr,
  30. unsigned long size, u64 flags)
  31. {
  32. return 0;
  33. }
  34. static inline void kaiser_remove_mapping(unsigned long start,
  35. unsigned long size)
  36. {
  37. }
  38. static inline int kaiser_map_thread_stack(void *stack)
  39. {
  40. return 0;
  41. }
  42. static inline void kaiser_unmap_thread_stack(void *stack)
  43. {
  44. }
  45. #endif /* !CONFIG_PAGE_TABLE_ISOLATION */
  46. #endif /* _LINUX_KAISER_H */