1238438Sdteske/* SPDX-License-Identifier: GPL-2.0 */ 2238438Sdteske#ifndef _ASM_X86_IOBITMAP_H 3238438Sdteske#define _ASM_X86_IOBITMAP_H 4238438Sdteske 5238438Sdteske#include <linux/refcount.h> 6238438Sdteske#include <asm/processor.h> 7238438Sdteske 8238438Sdteskestruct io_bitmap { 9238438Sdteske u64 sequence; 10238438Sdteske refcount_t refcnt; 11238438Sdteske /* The maximum number of bytes to copy so all zero bits are covered */ 12238438Sdteske unsigned int max; 13238438Sdteske unsigned long bitmap[IO_BITMAP_LONGS]; 14238438Sdteske}; 15238438Sdteske 16238438Sdteskestruct task_struct; 17238438Sdteske 18238438Sdteske#ifdef CONFIG_X86_IOPL_IOPERM 19238438Sdteskevoid io_bitmap_share(struct task_struct *tsk); 20238438Sdteskevoid io_bitmap_exit(struct task_struct *tsk); 21238438Sdteske 22238438Sdteskestatic inline void native_tss_invalidate_io_bitmap(void) 23238438Sdteske{ 24238438Sdteske /* 25238438Sdteske * Invalidate the I/O bitmap by moving io_bitmap_base outside the 26238438Sdteske * TSS limit so any subsequent I/O access from user space will 27238438Sdteske * trigger a #GP. 28238438Sdteske * 29251906Sdteske * This is correct even when VMEXIT rewrites the TSS limit 30251906Sdteske * to 0x67 as the only requirement is that the base points 31238438Sdteske * outside the limit. 32251906Sdteske */ 33238438Sdteske this_cpu_write(cpu_tss_rw.x86_tss.io_bitmap_base, 34251906Sdteske IO_BITMAP_OFFSET_INVALID); 35251906Sdteske} 36251906Sdteske 37238438Sdteskevoid native_tss_update_io_bitmap(void); 38251906Sdteske 39238438Sdteske#ifdef CONFIG_PARAVIRT_XXL 40251906Sdteske#include <asm/paravirt.h> 41251906Sdteske#else 42251906Sdteske#define tss_update_io_bitmap native_tss_update_io_bitmap 43251906Sdteske#define tss_invalidate_io_bitmap native_tss_invalidate_io_bitmap 44251906Sdteske#endif 45251906Sdteske 46251906Sdteske#else 47251906Sdteskestatic inline void io_bitmap_share(struct task_struct *tsk) { } 48238438Sdteskestatic inline void io_bitmap_exit(struct task_struct *tsk) { } 49251906Sdteskestatic inline void tss_update_io_bitmap(void) { } 50238438Sdteske#endif 51251906Sdteske 52238438Sdteske#endif 53251906Sdteske