io_bitmap.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_X86_IOBITMAP_H
  3. #define _ASM_X86_IOBITMAP_H
  4. #include <linux/refcount.h>
  5. #include <asm/processor.h>
  6. struct io_bitmap {
  7. u64 sequence;
  8. refcount_t refcnt;
  9. /* The maximum number of bytes to copy so all zero bits are covered */
  10. unsigned int max;
  11. unsigned long bitmap[IO_BITMAP_LONGS];
  12. };
  13. struct task_struct;
  14. #ifdef CONFIG_X86_IOPL_IOPERM
  15. void io_bitmap_share(struct task_struct *tsk);
  16. void io_bitmap_exit(struct task_struct *tsk);
  17. static inline void native_tss_invalidate_io_bitmap(void)
  18. {
  19. /*
  20. * Invalidate the I/O bitmap by moving io_bitmap_base outside the
  21. * TSS limit so any subsequent I/O access from user space will
  22. * trigger a #GP.
  23. *
  24. * This is correct even when VMEXIT rewrites the TSS limit
  25. * to 0x67 as the only requirement is that the base points
  26. * outside the limit.
  27. */
  28. this_cpu_write(cpu_tss_rw.x86_tss.io_bitmap_base,
  29. IO_BITMAP_OFFSET_INVALID);
  30. }
  31. void native_tss_update_io_bitmap(void);
  32. #ifdef CONFIG_PARAVIRT_XXL
  33. #include <asm/paravirt.h>
  34. #else
  35. #define tss_update_io_bitmap native_tss_update_io_bitmap
  36. #define tss_invalidate_io_bitmap native_tss_invalidate_io_bitmap
  37. #endif
  38. #else
  39. static inline void io_bitmap_share(struct task_struct *tsk) { }
  40. static inline void io_bitmap_exit(struct task_struct *tsk) { }
  41. static inline void tss_update_io_bitmap(void) { }
  42. #endif
  43. #endif